Commit b9dae547 authored by Alejandro Homs Puron's avatar Alejandro Homs Puron

* Updated Frelon::DetInfoCtrlObj support for rectangular pixel sizes

* Implemented Frelon EventCtrlObj, redirecting EventCallbacks from Espia::Acq
* Using TimeUnit (Z) register to properly handle ShutterCloseTime and
  LatencyTime, which before were (mistakenly) assumed to be in Milliseconds
* Verify camera model before issuing SPB2-specific commands (ConfigHD, HTD)
* Using DEB_HEX() when displaying available modes (CMA)
parent 2f8a47a2
......@@ -181,6 +181,7 @@ class Camera : public HwMaxImageSizeCallbackGen
void setTimeUnitFactor(TimeUnitFactor time_unit_factor);
void getTimeUnitFactor(TimeUnitFactor& time_unit_factor);
int calcTimeUnits(double time_sec, TimeUnitFactor time_unit_factor);
double getMaxIdleWaitTime();
bool waitIdleStatus(Status& status, bool use_ser_line=false,
......
......@@ -55,6 +55,27 @@ class AcqEndCallback : public Espia::AcqEndCallback
};
/*******************************************************************
* \class EventCallback
* \brief Bridge class transfering events from Acq -> HwEventCtrlObj
*******************************************************************/
class EventCallback : public lima::EventCallback
{
DEB_CLASS_NAMESPC(DebModCamera, "EventCallback", "Frelon");
public:
EventCallback(HwEventCtrlObj& ctrl_obj);
virtual ~EventCallback();
protected:
virtual void processEvent(Event *event);
private:
HwEventCtrlObj& m_ctrl_obj;
};
/*******************************************************************
* \class DetInfoCtrlObj
* \brief Control object providing Frelon detector info interface
......@@ -75,7 +96,7 @@ class DetInfoCtrlObj : public HwDetInfoCtrlObj
virtual void getCurrImageType(ImageType& curr_image_type);
virtual void setCurrImageType(ImageType curr_image_type);
virtual void getPixelSize(double& pixel_size);
virtual void getPixelSize(double& x_size, double& y_size);
virtual void getDetectorType(std::string& det_type);
virtual void getDetectorModel(std::string& det_model);
......@@ -307,6 +328,20 @@ public:
Camera& m_cam;
};
/*******************************************************************
* \class EventCtrlObj
* \brief Control object providing Frelon event interface
*******************************************************************/
class EventCtrlObj : public HwEventCtrlObj
{
DEB_CLASS(DebModCamera, "EventCtrlObj");
public:
EventCtrlObj();
virtual ~EventCtrlObj();
};
/*******************************************************************
* \class Interface
* \brief Frelon hardware interface
......@@ -334,8 +369,6 @@ class Interface : public HwInterface
BufferCtrlMgr& m_buffer_mgr;
Camera& m_cam;
Frelon::AcqEndCallback m_acq_end_cb;
CapList m_cap_list;
DetInfoCtrlObj m_det_info;
BufferCtrlObj m_buffer;
......@@ -344,6 +377,10 @@ class Interface : public HwInterface
RoiCtrlObj m_roi;
FlipCtrlObj m_flip;
ShutterCtrlObj m_shutter;
EventCtrlObj m_event;
Frelon::AcqEndCallback m_acq_end_cb;
Frelon::EventCallback m_event_cb;
};
......
......@@ -44,6 +44,23 @@ class AcqEndCallback : Espia::AcqEndCallback
};
class EventCallback : EventCallback
{
%TypeHeaderCode
#include "FrelonInterface.h"
#include <algorithm>
%End
public:
EventCallback(HwEventCtrlObj& ctrl_obj);
virtual ~EventCallback();
protected:
virtual void processEvent(Event *event);
};
class DetInfoCtrlObj : HwDetInfoCtrlObj
{
......@@ -63,7 +80,7 @@ class DetInfoCtrlObj : HwDetInfoCtrlObj
virtual void getCurrImageType(ImageType& curr_image_type /Out/);
virtual void setCurrImageType(ImageType curr_image_type);
virtual void getPixelSize(double& pixel_size /Out/);
virtual void getPixelSize(double& x_size /Out/, double& y_size /Out/);
virtual void getDetectorType(std::string& det_type /Out/);
virtual void getDetectorModel(std::string& det_model /Out/);
......@@ -261,6 +278,20 @@ public:
};
class EventCtrlObj : HwEventCtrlObj
{
%TypeHeaderCode
#include "FrelonInterface.h"
#include <algorithm>
%End
public:
EventCtrlObj();
virtual ~EventCtrlObj();
};
class Interface : HwInterface
{
......
......@@ -320,7 +320,7 @@ int Camera::getModesAvail()
else
modes_avail = AtmelModesAvail;
DEB_RETURN() << DEB_VAR1(modes_avail);
DEB_RETURN() << DEB_VAR1(DEB_HEX(modes_avail));
return modes_avail;
}
......@@ -447,7 +447,8 @@ void Camera::getDefInputChan(FrameTransferMode ftm, InputChan& input_chan)
if (!valid_mode)
THROW_HW_ERROR(Error) << "Could not find valid " << ftm
<< "mode: " << DEB_VAR1(modes_avail);
<< "mode: "
<< DEB_VAR1(DEB_HEX(modes_avail));
DEB_RETURN() << DEB_VAR1(DEB_HEX(input_chan))
<< " [" << getInputChanModeName(ftm, input_chan) << "]";
......@@ -1162,6 +1163,11 @@ void Camera::getTimeUnitFactor(TimeUnitFactor& time_unit_factor)
DEB_RETURN() << DEB_VAR1(time_unit_factor);
}
int Camera::calcTimeUnits(double time_sec, TimeUnitFactor time_unit_factor)
{
return int(time_sec / TimeUnitFactorMap[time_unit_factor] + 0.1);
}
void Camera::setExpTime(double exp_time)
{
DEB_MEMBER_FUNCT();
......@@ -1187,8 +1193,8 @@ void Camera::setExpTime(double exp_time)
exp_time = MinExp;
}
int exp_us = int(exp_time / TimeUnitFactorMap[Microseconds] + 0.1);
int exp_ms = int(exp_time / TimeUnitFactorMap[Milliseconds] + 0.1);
int exp_us = calcTimeUnits(exp_time, Microseconds);
int exp_ms = calcTimeUnits(exp_time, Milliseconds);
int exp_val;
TimeUnitFactor time_unit;
......@@ -1236,7 +1242,9 @@ void Camera::setShutCloseTime(double shut_time)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(shut_time);
int shut_val = int(shut_time / TimeUnitFactorMap[Milliseconds] + 0.1);
TimeUnitFactor time_unit_factor;
getTimeUnitFactor(time_unit_factor);
int shut_val = calcTimeUnits(shut_time, time_unit_factor);
if (shut_val > MaxRegVal)
THROW_HW_ERROR(InvalidValue) << "Shutter close time too high: "
<< DEB_VAR1(shut_time);
......@@ -1246,9 +1254,11 @@ void Camera::setShutCloseTime(double shut_time)
void Camera::getShutCloseTime(double& shut_time)
{
DEB_MEMBER_FUNCT();
TimeUnitFactor time_unit_factor;
getTimeUnitFactor(time_unit_factor);
int shut_val;
readRegister(ShutCloseTime, shut_val);
shut_time = shut_val * TimeUnitFactorMap[Milliseconds];
shut_time = shut_val * TimeUnitFactorMap[time_unit_factor];
DEB_RETURN() << DEB_VAR1(shut_time);
}
......@@ -1256,16 +1266,20 @@ void Camera::setLatTime(double lat_time)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(lat_time);
int lat_val = int(lat_time / TimeUnitFactorMap[Milliseconds] + 0.1);
TimeUnitFactor time_unit_factor;
getTimeUnitFactor(time_unit_factor);
int lat_val = calcTimeUnits(lat_time, time_unit_factor);
writeRegister(LatencyTime, lat_val);
}
void Camera::getLatTime(double& lat_time)
{
DEB_MEMBER_FUNCT();
TimeUnitFactor time_unit_factor;
getTimeUnitFactor(time_unit_factor);
int lat_val;
readRegister(LatencyTime, lat_val);
lat_time = lat_val * TimeUnitFactorMap[Milliseconds];
lat_time = lat_val * TimeUnitFactorMap[time_unit_factor];
DEB_RETURN() << DEB_VAR1(lat_time);
}
......@@ -1292,6 +1306,9 @@ void Camera::getNbFrames(int& nb_frames)
void Camera::setSPB2Config(SPB2Config spb2_config)
{
DEB_MEMBER_FUNCT();
if (m_model.isSPB1())
THROW_HW_ERROR(NotSupported) << "Camera is SPB1: SPB2 config "
<< "not supported by hardware!";
DEB_PARAM() << DEB_VAR1(spb2_config)
<< " [" << getSPB2ConfigName(spb2_config) << "]";
writeRegister(ConfigHD, int(spb2_config));
......@@ -1300,6 +1317,9 @@ void Camera::setSPB2Config(SPB2Config spb2_config)
void Camera::getSPB2Config(SPB2Config& spb2_config)
{
DEB_MEMBER_FUNCT();
if (m_model.isSPB1())
THROW_HW_ERROR(NotSupported) << "Camera is SPB1: SPB2 config "
<< "not supported by hardware!";
int config_hd;
readRegister(ConfigHD, config_hd);
spb2_config = SPB2Config(config_hd);
......@@ -1323,6 +1343,9 @@ string Camera::getSPB2ConfigName(SPB2Config spb2_config)
void Camera::setExtSyncEnable(ExtSync ext_sync_ena)
{
DEB_MEMBER_FUNCT();
if (!m_model.hasHTDCmd())
THROW_HW_ERROR(NotSupported) << "Camera does not have "
<< "HTD cmd: upgrade firmware";
DEB_PARAM() << DEB_VAR1(ext_sync_ena);
int hard_trig_dis = int(~ext_sync_ena) & ExtSyncBoth;
writeRegister(HardTrigDisable, hard_trig_dis);
......@@ -1331,6 +1354,9 @@ void Camera::setExtSyncEnable(ExtSync ext_sync_ena)
void Camera::getExtSyncEnable(ExtSync& ext_sync_ena)
{
DEB_MEMBER_FUNCT();
if (!m_model.hasHTDCmd())
THROW_HW_ERROR(NotSupported) << "Camera does not have "
<< "HTD cmd: upgrade firmware";
int hard_trig_dis;
readRegister(HardTrigDisable, hard_trig_dis);
ext_sync_ena = ExtSync(~hard_trig_dis & ExtSyncBoth);
......
......@@ -49,6 +49,28 @@ void Frelon::AcqEndCallback::acqFinished(const HwFrameInfoType& /*finfo*/)
}
/*******************************************************************
* \brief EventCallback constructor
*******************************************************************/
Frelon::EventCallback::EventCallback(HwEventCtrlObj& ctrl_obj)
: m_ctrl_obj(ctrl_obj)
{
DEB_CONSTRUCTOR();
}
Frelon::EventCallback::~EventCallback()
{
DEB_DESTRUCTOR();
}
void Frelon::EventCallback::processEvent(Event *event)
{
DEB_MEMBER_FUNCT();
m_ctrl_obj.reportEvent(event);
}
/*******************************************************************
* \brief DetInfoCtrlObj constructor
*******************************************************************/
......@@ -106,12 +128,12 @@ void DetInfoCtrlObj::setCurrImageType(ImageType curr_image_type)
<< "Only " << DEB_VAR1(unique_image_type) << "allowed";
}
void DetInfoCtrlObj::getPixelSize(double& pixel_size)
void DetInfoCtrlObj::getPixelSize(double& x_size, double& y_size)
{
DEB_MEMBER_FUNCT();
Model& model = m_cam.getModel();
pixel_size = model.getPixelSize();
DEB_RETURN() << DEB_VAR1(pixel_size);
x_size = y_size = model.getPixelSize();
DEB_RETURN() << DEB_VAR2(x_size, y_size);
}
void DetInfoCtrlObj::getDetectorType(std::string& det_type)
......@@ -737,19 +759,36 @@ void ShutterCtrlObj::getCloseTime(double& shut_close_time) const
}
/*******************************************************************
* \brief ShutterCtrlObj constructor
*******************************************************************/
EventCtrlObj::EventCtrlObj()
{
DEB_CONSTRUCTOR();
}
EventCtrlObj::~EventCtrlObj()
{
DEB_DESTRUCTOR();
}
/*******************************************************************
* \brief Hw Interface constructor
*******************************************************************/
Interface::Interface(Espia::Acq& acq, BufferCtrlMgr& buffer_mgr,
Camera& cam)
: m_acq(acq), m_buffer_mgr(buffer_mgr), m_cam(cam), m_acq_end_cb(cam),
: m_acq(acq), m_buffer_mgr(buffer_mgr), m_cam(cam),
m_det_info(cam), m_buffer(buffer_mgr), m_sync(acq, cam),
m_bin(cam), m_roi(acq, cam), m_flip(cam), m_shutter(cam)
m_bin(cam), m_roi(acq, cam), m_flip(cam), m_shutter(cam),
m_acq_end_cb(cam), m_event_cb(m_event)
{
DEB_CONSTRUCTOR();
m_acq.registerAcqEndCallback(m_acq_end_cb);
m_acq.registerEventCallback(m_event_cb);
HwDetInfoCtrlObj *det_info = &m_det_info;
m_cap_list.push_back(HwCap(det_info));
......@@ -772,6 +811,9 @@ Interface::Interface(Espia::Acq& acq, BufferCtrlMgr& buffer_mgr,
HwShutterCtrlObj *shutter = &m_shutter;
m_cap_list.push_back(HwCap(shutter));
HwEventCtrlObj *event = &m_event;
m_cap_list.push_back(HwCap(event));
reset(SoftReset);
}
......
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