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

* Added HwSyncCtrlObj::checkTrigMode to properly verify available modes;

  updated Simulator, Focla, Frelon and Maxipix
* Added HwShutterCtrlObj::checkMode
* Implemented Frelon::ShutterCtrlObj using Camera::set/getShutMode
parent 48f37f7f
......@@ -139,6 +139,10 @@ enum Status {
StatusMask = 0xff,
};
enum ShutMode {
Off, AutoFrame,
};
} // namespace Frelon
......
......@@ -70,6 +70,9 @@ class Camera : public HwMaxImageSizeCallbackGen
void setExpTime(double exp_time);
void getExpTime(double& exp_time);
void setShutMode(ShutMode shut_mode);
void getShutMode(ShutMode& shut_mode);
void setShutCloseTime(double shut_time);
void getShutCloseTime(double& shut_time);
......
......@@ -101,6 +101,7 @@ class SyncCtrlObj : public HwSyncCtrlObj
SyncCtrlObj(Espia::Acq& acq, Camera& cam, BufferCtrlObj& buffer_ctrl);
virtual ~SyncCtrlObj();
virtual bool checkTrigMode(TrigMode trig_mode);
virtual void setTrigMode(TrigMode trig_mode);
virtual void getTrigMode(TrigMode& trig_mode);
......@@ -203,6 +204,35 @@ class FlipCtrlObj : public HwFlipCtrlObj
};
/*******************************************************************
* \class ShutterCtrlObj
* \brief Control object providing Frelon shutter interface
*******************************************************************/
class ShutterCtrlObj : public HwShutterCtrlObj
{
DEB_CLASS(DebModCamera, "ShutterCtrlObj");
public:
ShutterCtrlObj(Camera& cam);
virtual ~ShutterCtrlObj();
virtual bool checkMode(Mode mode);
virtual void setMode(Mode mode);
virtual void getMode(Mode& mode);
virtual void setState(bool open);
virtual void getState(bool& open);
virtual void setOpenTime (double shut_open_time);
virtual void getOpenTime (double& shut_open_time);
virtual void setCloseTime(double shut_close_time);
virtual void getCloseTime(double& shut_close_time);
private:
Camera& m_cam;
};
/*******************************************************************
* \class Interface
* \brief Frelon hardware interface
......@@ -237,6 +267,7 @@ class Interface : public HwInterface
BinCtrlObj m_bin;
RoiCtrlObj m_roi;
FlipCtrlObj m_flip;
ShutterCtrlObj m_shutter;
};
......
......@@ -124,5 +124,9 @@ enum Status {
StatusMask = 0xff,
};
enum ShutMode {
Off, AutoFrame,
};
}; // namespace Frelon
......@@ -41,11 +41,11 @@ class Camera
bool isChanActive(Frelon::InputChan curr, Frelon::InputChan chan);
void checkFlip(Flip& flip /InOut/);
void checkFlip(Flip& flip /In,Out/);
void setFlip(const Flip& flip);
void getFlip(Flip& flip /Out/);
void checkBin(Bin& bin /InOut/);
void checkBin(Bin& bin /In,Out/);
void setBin(const Bin& bin);
void getBin(Bin& bin /Out/);
......@@ -65,6 +65,9 @@ class Camera
void setExpTime(double exp_time);
void getExpTime(double& exp_time /Out/);
void setShutMode(Frelon::ShutMode shut_mode);
void getShutMode(Frelon::ShutMode& shut_mode /Out/);
void setShutCloseTime(double shut_time);
void getShutCloseTime(double& shut_time /Out/);
......@@ -75,7 +78,7 @@ class Camera
void getNbFrames(int& nb_frames /Out/);
void getStatus(Frelon::Status& status /Out/);
bool waitStatus(Frelon::Status& status /InOut/, Frelon::Status mask,
bool waitStatus(Frelon::Status& status /In,Out/, Frelon::Status mask,
double timeout);
void start();
......
......@@ -87,6 +87,7 @@ class SyncCtrlObj : HwSyncCtrlObj
Frelon::BufferCtrlObj& buffer_ctrl);
virtual ~SyncCtrlObj();
virtual bool checkTrigMode(TrigMode trig_mode);
virtual void setTrigMode(TrigMode trig_mode);
virtual void getTrigMode(TrigMode& trig_mode /Out/);
......@@ -118,7 +119,7 @@ class BinCtrlObj : HwBinCtrlObj
virtual void setBin(const Bin& bin);
virtual void getBin(Bin& bin /Out/);
virtual void checkBin(Bin& bin /InOut/);
virtual void checkBin(Bin& bin /In,Out/);
};
......@@ -153,8 +154,34 @@ class FlipCtrlObj : HwFlipCtrlObj
virtual ~FlipCtrlObj();
virtual void setFlip(const Flip& flip);
virtual void getFlip(Flip& flip);
virtual void checkFlip(Flip& flip);
virtual void getFlip(Flip& flip /Out/);
virtual void checkFlip(Flip& flip /In,Out/);
};
class ShutterCtrlObj : HwShutterCtrlObj
{
%TypeHeaderCode
#include "FrelonInterface.h"
#include <algorithm>
%End
public:
ShutterCtrlObj(Frelon::Camera& cam);
virtual ~ShutterCtrlObj();
virtual bool checkMode(Mode mode);
virtual void setMode(Mode mode);
virtual void getMode(Mode& mode /Out/);
virtual void setState(bool open);
virtual void getState(bool& open /Out/);
virtual void setOpenTime (double shut_open_time);
virtual void getOpenTime (double& shut_open_time /Out/);
virtual void setCloseTime(double shut_close_time);
virtual void getCloseTime(double& shut_close_time /Out/);
};
......
......@@ -991,6 +991,23 @@ void Camera::getExpTime(double& exp_time)
DEB_RETURN() << DEB_VAR1(exp_time);
}
void Camera::setShutMode(ShutMode shut_mode)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(shut_mode);
int cam_shut_mode = (shut_mode == Frelon::AutoFrame) ? 1 : 0;
writeRegister(ShutEnable, cam_shut_mode);
}
void Camera::getShutMode(ShutMode& shut_mode)
{
DEB_MEMBER_FUNCT();
int cam_shut_mode;
readRegister(ShutEnable, cam_shut_mode);
shut_mode = (cam_shut_mode == 1) ? Frelon::AutoFrame : Frelon::Off;
DEB_RETURN() << DEB_VAR1(shut_mode);
}
void Camera::setShutCloseTime(double shut_time)
{
DEB_MEMBER_FUNCT();
......
......@@ -219,9 +219,35 @@ SyncCtrlObj::~SyncCtrlObj()
DEB_DESTRUCTOR();
}
bool SyncCtrlObj::checkTrigMode(TrigMode trig_mode)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(trig_mode);
bool valid_mode;
switch (trig_mode) {
case IntTrig:
case ExtTrigSingle:
case ExtTrigMult:
case ExtGate:
valid_mode = true;
break;
default:
valid_mode = false;
}
DEB_RETURN() << DEB_VAR1(valid_mode);
return valid_mode;
}
void SyncCtrlObj::setTrigMode(TrigMode trig_mode)
{
DEB_MEMBER_FUNCT();
if (!checkTrigMode(trig_mode))
THROW_HW_ERROR(InvalidValue) << "Invalid "
<< DEB_VAR1(trig_mode);
m_cam.setTrigMode(trig_mode);
}
......@@ -425,6 +451,120 @@ void FlipCtrlObj::checkFlip(Flip& flip)
}
/*******************************************************************
* \brief ShutterCtrlObj constructor
*******************************************************************/
ShutterCtrlObj::ShutterCtrlObj(Camera& cam)
: m_cam(cam)
{
DEB_CONSTRUCTOR();
}
ShutterCtrlObj::~ShutterCtrlObj()
{
DEB_DESTRUCTOR();
}
bool ShutterCtrlObj::checkMode(Mode mode)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(mode);
bool valid_mode;
switch (mode) {
case Manual:
case AutoFrame:
valid_mode = true;
break;
default:
valid_mode = false;
}
DEB_RETURN() << DEB_VAR1(valid_mode);
return valid_mode;
}
void ShutterCtrlObj::setMode(Mode mode)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(mode);
if (!checkMode(mode))
THROW_HW_ERROR(InvalidValue) << "Invalid " << DEB_VAR1(mode);
ShutMode cam_mode;
cam_mode = (mode == AutoFrame) ? Frelon::AutoFrame : Frelon::Off;
m_cam.setShutMode(cam_mode);
}
void ShutterCtrlObj::getMode(Mode& mode)
{
DEB_MEMBER_FUNCT();
ShutMode cam_mode;
m_cam.getShutMode(cam_mode);
mode = (cam_mode == Frelon::AutoFrame) ? AutoFrame : Manual;
DEB_RETURN() << DEB_VAR1(mode);
}
void ShutterCtrlObj::setState(bool open)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(open);
Mode mode;
getMode(mode);
if (mode != Manual)
THROW_HW_ERROR(NotSupported) << "Not in manual mode";
else if (open)
THROW_HW_ERROR(NotSupported) << "Manual shutter open "
"not supported";
}
void ShutterCtrlObj::getState(bool& open)
{
DEB_MEMBER_FUNCT();
Mode mode;
getMode(mode);
if (mode != Manual)
THROW_HW_ERROR(NotSupported) << "Not in manual mode";
open = false;
DEB_RETURN() << DEB_VAR1(open);
}
void ShutterCtrlObj::setOpenTime(double shut_open_time)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(shut_open_time);
if (shut_open_time != 0)
THROW_HW_ERROR(NotSupported) << "Invalid "
<< DEB_VAR1(shut_open_time);
}
void ShutterCtrlObj::getOpenTime(double& shut_open_time)
{
DEB_MEMBER_FUNCT();
shut_open_time = 0;
DEB_RETURN() << DEB_VAR1(shut_open_time);
}
void ShutterCtrlObj::setCloseTime(double shut_close_time)
{
DEB_MEMBER_FUNCT();
m_cam.setShutCloseTime(shut_close_time);
}
void ShutterCtrlObj::getCloseTime(double& shut_close_time)
{
DEB_MEMBER_FUNCT();
m_cam.getShutCloseTime(shut_close_time);
}
/*******************************************************************
* \brief Hw Interface constructor
*******************************************************************/
......@@ -433,7 +573,7 @@ Interface::Interface(Acq& acq, BufferCtrlMgr& buffer_mgr,
Camera& 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_buffer),
m_bin(cam), m_roi(cam), m_flip(cam)
m_bin(cam), m_roi(cam), m_flip(cam), m_shutter(cam)
{
DEB_CONSTRUCTOR();
......@@ -455,6 +595,9 @@ Interface::Interface(Acq& acq, BufferCtrlMgr& buffer_mgr,
HwFlipCtrlObj *flip = &m_flip;
m_cap_list.push_back(HwCap(flip));
HwShutterCtrlObj *shutter = &m_shutter;
m_cap_list.push_back(HwCap(shutter));
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