Commit 8cefd248 authored by Alejandro Homs Puron's avatar Alejandro Homs Puron
Browse files

Auto-detect Camera::APIGeneration based on Simplon API version

parent 28406b63
Pipeline #21574 failed with stages
in 3 minutes and 16 seconds
......@@ -73,7 +73,7 @@ class LIBEIGER Camera : public HwMaxImageSizeCallbackGen, public EventCallbackGe
enum Status { Initializing, Ready, Armed, Exposure, Fault };
enum CompressionType {NoCompression,LZ4,BSLZ4};
Camera(const std::string& detector_ip, ApiGeneration api = Eiger1);
Camera(const std::string& detector_ip);
~Camera();
void initialize();
......
......@@ -194,6 +194,8 @@ namespace eigerapi
Requests(const std::string& address);
~Requests();
std::string get_api_version();
CommandReq get_command(COMMAND_NAME);
ParamReq get_param(PARAM_NAME);
ParamReq get_param(PARAM_NAME,bool&);
......@@ -223,10 +225,11 @@ namespace eigerapi
typedef std::map<int,std::string> CACHE_TYPE;
CurlLoop m_loop;
std::string m_address;
std::string m_api_version;
CACHE_TYPE m_cmd_cache_url;
CACHE_TYPE m_param_cache_url;
std::string m_address;
CurlLoop m_loop;
};
}
......
......@@ -201,10 +201,10 @@ Requests::Requests(const std::string& address) :
m_loop.add_request(version_request);
Requests::Param::Value value = version_request->get();
std::string& api_version = value.string_val;
m_api_version = value.string_val;
std::ostringstream api;
api << '/' << CSTR_EIGERAPI << '/' << api_version << '/';
api << '/' << CSTR_EIGERAPI << '/' << m_api_version << '/';
// COMMANDS URL CACHE
int nb_cmd = sizeof(CommandsDescription) / sizeof(CommandIndex);
......@@ -226,6 +226,11 @@ Requests::~Requests()
{
}
std::string Requests::get_api_version()
{
return m_api_version;
}
CommandReq Requests::get_command(Requests::COMMAND_NAME cmd_name)
{
CACHE_TYPE::iterator cmd_url = m_cmd_cache_url.find(cmd_name);
......
......@@ -32,8 +32,7 @@ namespace Eiger
enum Status { Initializing, Ready, Armed, Exposure, Fault };
enum CompressionType {NoCompression,LZ4,BSLZ4};
Camera(const std::string& detector_ip,
Eiger::Camera::ApiGeneration api = Eiger::Camera::Eiger1);
Camera(const std::string& detector_ip);
~Camera();
void initialize();
......
......@@ -101,10 +101,8 @@ private:
//-----------------------------------------------------------------------------
/// Ctor
//-----------------------------------------------------------------------------
Camera::Camera(const std::string& detector_ip, ///< [in] Ip address of the detector server
ApiGeneration api)
: m_api(api),
m_frames_triggered(0),
Camera::Camera(const std::string& detector_ip) ///< [in] Ip address of the detector server
: m_frames_triggered(0),
m_frames_acquired(0),
m_latency_time(0.),
m_detectorImageType(Bpp16),
......@@ -118,6 +116,18 @@ Camera::Camera(const std::string& detector_ip, ///< [in] Ip address of the dete
{
DEB_CONSTRUCTOR();
DEB_PARAM() << DEB_VAR1(detector_ip);
// Detect EigerAPI version
std::string api_version = m_requests->get_api_version();
DEB_TRACE() << DEB_VAR1(api_version);
if (api_version == "1.6.0")
m_api = Eiger1;
else if (api_version == "1.8.0")
m_api = Eiger2;
else
THROW_HW_ERROR(Error) << "Unknown " << DEB_VAR1(api_version);
DEB_TRACE() << DEB_VAR1(m_api);
// Init EigerAPI
try {
std::string status = getCamStatus();
......
......@@ -197,9 +197,6 @@ class EigerClass(PyTango.DeviceClass):
'detector_ip_address':
[PyTango.DevString,
"Detector ip address",[]],
'api_generation':
[PyTango.DevString,
"Detector API generation: Eiger1, Eiger2",[]],
}
......@@ -308,12 +305,11 @@ from Lima import Eiger as EigerAcq
_EigerInterface = None
_EigerCamera = None
def get_control(detector_ip_address = "0", api_generation = "", **keys) :
def get_control(detector_ip_address = "0", **keys) :
global _EigerInterface
global _EigerCamera
if _EigerInterface is None:
args = [getattr(EigerAcq.Camera, api_generation)] if api_generation else []
_EigerCamera = EigerAcq.Camera(detector_ip_address, *args)
_EigerCamera = EigerAcq.Camera(detector_ip_address)
_EigerInterface = EigerAcq.Interface(_EigerCamera)
return Core.CtControl(_EigerInterface)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment