Commit 908d8846 authored by ahoms's avatar ahoms
Browse files

* added Espia::Dev getCcdStatus and resetLink (with 0.5 sec sleep)

* added Frelon::Camera get/waitStatus; stop will wait for Wait status
* added Frelon::Interface getStatus and reset (miss add in last commit)



git-svn-id: https://scm.blissgarden.org/svn/lima/trunk@83 45c4679d-1946-429d-baad-37912b19538b
parent eeb76891
......@@ -106,6 +106,17 @@ enum {
MaxBinY = 1024,
};
enum Status {
Wait = 0x80,
Transfer = 0x40,
Exposure = 0x20,
Shutter = 0x10,
Readout = 0x08,
Latency = 0x04,
ExtStart = 0x02,
ExtStop = 0x01,
};
} // namespace Frelon
......
......@@ -63,11 +63,17 @@ class Camera
void setNbFrames(int nb_frames);
void getNbFrames(int& nb_frames);
void getStatus(Status& status);
bool waitStatus(Status& status, double timeout = 0);
void start();
void stop();
private:
static const double HorzBinSleepTime;
static const double HorzBinChangeTime;
static const double MaxReadoutTime;
Espia::Dev& getEspiaDev();
void sendCmd(Cmd cmd);
......
#ifndef FRELONINTERFACE_H
#define FRELONINTERFACE_H
#include "HwInterface.h"
#include "EspiaBufferMgr.h"
#include "FrelonCamera.h"
namespace lima
{
namespace Frelon
{
class Interface;
/*******************************************************************
* \class DetInfoCtrlObj
* \brief Control object providing Frelon detector info interface
*******************************************************************/
class DetInfoCtrlObj : public HwDetInfoCtrlObj
{
public:
DetInfoCtrlObj(Camera& cam);
virtual ~DetInfoCtrlObj();
virtual void getMaxImageSize(Size& max_image_size);
virtual void getDetectorImageSize(Size& det_image_size);
virtual void getDefImageType(ImageType& def_image_type);
virtual void getCurrImageType(ImageType& curr_image_type);
virtual void setCurrImageType(ImageType curr_image_type);
virtual void getPixelSize(double& pixel_size);
virtual void getDetectorType(std::string& det_type);
virtual void getDetectorModel(std::string& det_model);
protected:
virtual void setMaxImageSizeCallbackActive(bool cb_active);
private:
Camera& m_cam;
bool m_iscb_act;
};
/*******************************************************************
* \class BufferCtrlObj
* \brief Control object providing Frelon buffering interface
*******************************************************************/
class BufferCtrlObj : public HwBufferCtrlObj
{
public:
BufferCtrlObj(BufferCtrlMgr& buffer_mgr);
virtual ~BufferCtrlObj();
virtual void setFrameDim(const FrameDim& frame_dim);
virtual void getFramedim( FrameDim& frame_dim);
virtual void setNbBuffers(int nb_buffers);
virtual void getNbBuffers(int& nb_buffers);
virtual void setNbConcatFrames(int nb_concat_frames);
virtual void getNbConcatFrames(int& nb_concat_frames);
virtual void setNbAccFrames(int nb_acc_frames);
virtual void getNbAccFrames(int& nb_acc_frames);
virtual void getMaxNbBuffers(int& max_nb_buffers);
virtual void *getBufferPtr(int buffer_nb, int concat_frame_nb = 0);
virtual void *getFramePtr(int acq_frame_nb);
virtual void getStartTimestamp(Timestamp& start_ts);
virtual void getFrameInfo(int acq_frame_nb, HwFrameInfoType& info);
virtual void registerFrameCallback(HwFrameCallback& frame_cb);
virtual void unregisterFrameCallback(HwFrameCallback& frame_cb);
private:
BufferCtrlMgr& m_buffer_mgr;
};
/*******************************************************************
* \class SyncCtrlObj
* \brief Control object providing Frelon synchronization interface
*******************************************************************/
class SyncCtrlObj : public HwSyncCtrlObj
{
public:
SyncCtrlObj(Espia::Acq& acq, Camera& cam);
virtual ~SyncCtrlObj();
virtual void setTrigMode(TrigMode trig_mode);
virtual void getTrigMode(TrigMode& trig_mode);
virtual void setExpTime(double exp_time);
virtual void getExpTime(double& exp_time);
virtual void setLatTime(double lat_time);
virtual void getLatTime(double& lat_time);
virtual void setNbFrames(int nb_frames);
virtual void getNbFrames(int& nb_frames);
virtual void getValidRanges(ValidRangesType& valid_ranges);
private:
Espia::Acq& m_acq;
Camera& m_cam;
};
/*******************************************************************
* \class BinCtrlObj
* \brief Control object providing simulator binning interface
*******************************************************************/
class BinCtrlObj : public HwBinCtrlObj
{
public:
BinCtrlObj(Camera& cam);
virtual ~BinCtrlObj();
virtual void setBin(const Bin& bin);
virtual void getBin(Bin& bin);
virtual void checkBin(Bin& bin);
private:
Camera& m_cam;
};
/*******************************************************************
* \class Interface
* \brief Frelon hardware interface
*******************************************************************/
class Interface : public HwInterface
{
public:
Interface(Espia::Acq& acq, BufferCtrlMgr& buffer_mgr, Camera& cam);
virtual ~Interface();
virtual const CapList& getCapList() const;
virtual void reset(ResetLevel reset_level);
virtual void prepareAcq();
virtual void startAcq();
virtual void stopAcq();
virtual void getStatus(StatusType& status);
virtual int getNbAcquiredFrames();
private:
Espia::Acq& m_acq;
BufferCtrlMgr& m_buffer_mgr;
Camera& m_cam;
CapList m_cap_list;
DetInfoCtrlObj m_det_info;
BufferCtrlObj m_buffer;
SyncCtrlObj m_sync;
BinCtrlObj m_bin;
};
} // namespace Frelon
} // namespace lima
#endif // FRELONINTERFACE_H
......@@ -31,6 +31,8 @@ class SerialLine : public HwSerialLine
SerialLine(Espia::SerialLine& espia_ser_line);
Espia::SerialLine& getEspiaSerialLine();
virtual void write(const std::string& buffer,
bool no_wait = false);
virtual void read(std::string& buffer,
......
......@@ -3,10 +3,13 @@
#include "MiscUtils.h"
#include <sstream>
using namespace lima;
using namespace lima::Frelon;
using namespace std;
const double Camera::HorzBinSleepTime = 2;
const double Camera::HorzBinChangeTime = 2.0;
const double Camera::MaxReadoutTime = 0.7;
Camera::Camera(Espia::SerialLine& espia_ser_line)
: m_ser_line(espia_ser_line)
......@@ -20,6 +23,13 @@ SerialLine& Camera::getSerialLine()
return m_ser_line;
}
Espia::Dev& Camera::getEspiaDev()
{
Espia::SerialLine ser_line = m_ser_line.getEspiaSerialLine();
Espia::Dev& dev = ser_line.getDev();
return dev;
}
void Camera::sendCmd(Cmd cmd)
{
string resp;
......@@ -44,6 +54,9 @@ void Camera::readRegister(Reg reg, int& val)
void Camera::hardReset()
{
Espia::Dev& dev = getEspiaDev();
dev.resetLink();
sendCmd(Reset);
}
......@@ -209,7 +222,7 @@ void Camera::setBin(const Bin& bin)
setRoi(roi);
writeRegister(BinHorz, bin.getX());
Sleep(HorzBinSleepTime);
Sleep(HorzBinChangeTime);
writeRegister(BinVert, bin.getY());
}
......@@ -456,6 +469,7 @@ void Camera::getRoi(Roi& hw_roi)
void Camera::setTrigMode(TrigMode trig_mode)
{
m_trig_mode = trig_mode;
setNbFrames(m_nb_frames);
}
void Camera::getTrigMode(TrigMode& trig_mode)
......@@ -535,6 +549,31 @@ void Camera::getNbFrames(int& nb_frames)
nb_frames = m_nb_frames;
}
void Camera::getStatus(Status& status)
{
Espia::Dev& dev = getEspiaDev();
int ccd_status;
dev.getCcdStatus(ccd_status);
status = Status(ccd_status);
}
bool Camera::waitStatus(Status& status, double timeout)
{
Timestamp end;
if (timeout > 0)
end = Timestamp::now() + Timestamp(timeout);
bool good_status = false;
Status curr_status;
while (!good_status && !end.isSet() || (Timestamp::now() < end)) {
getStatus(curr_status);
good_status = ((curr_status & status) == status);
}
status = curr_status;
return good_status;
}
void Camera::start()
{
TrigMode trig_mode;
......@@ -549,5 +588,13 @@ void Camera::stop()
getTrigMode(trig_mode);
if (trig_mode != ExtGate)
sendCmd(Stop);
Status status = Wait;
waitStatus(status);
FrameTransferMode ftm;
getFrameTransferMode(ftm);
if (ftm == FTM)
Sleep(MaxReadoutTime);
}
#include "FrelonInterface.h"
#include <algorithm>
using namespace lima;
using namespace lima::Espia;
using namespace lima::Frelon;
using namespace std;
/*******************************************************************
* \brief DetInfoCtrlObj constructor
*******************************************************************/
DetInfoCtrlObj::DetInfoCtrlObj(Camera& cam)
: m_cam(cam)
{
}
DetInfoCtrlObj::~DetInfoCtrlObj()
{
}
void DetInfoCtrlObj::getMaxImageSize(Size& max_image_size)
{
FrameDim max_frame_dim;
m_cam.getFrameDim(max_frame_dim);
max_image_size = max_frame_dim.getSize();
}
void DetInfoCtrlObj::getDetectorImageSize(Size& det_image_size)
{
det_image_size = MaxFrameDim.getSize();
}
void DetInfoCtrlObj::getDefImageType(ImageType& def_image_type)
{
def_image_type = MaxFrameDim.getImageType();
}
void DetInfoCtrlObj::getCurrImageType(ImageType& curr_image_type)
{
FrameDim max_frame_dim;
m_cam.getFrameDim(max_frame_dim);
curr_image_type = max_frame_dim.getImageType();
}
void DetInfoCtrlObj::setCurrImageType(ImageType curr_image_type)
{
ImageType unique_image_type;
getCurrImageType(unique_image_type);
if (curr_image_type != unique_image_type)
throw LIMA_HW_EXC(InvalidValue, "Only one image type allowed");
}
void DetInfoCtrlObj::getPixelSize(double& pixel_size)
{
bool is_frelon_4m;
m_cam.isFrelon4M(is_frelon_4m);
ChipType chip_type = is_frelon_4m ? Kodak : Atmel;
pixel_size = ChipPixelSizeMap[chip_type];
}
void DetInfoCtrlObj::getDetectorType(std::string& det_type)
{
det_type = "Frelon";
}
void DetInfoCtrlObj::getDetectorModel(std::string& det_model)
{
bool is_frelon_4m;
m_cam.isFrelon4M(is_frelon_4m);
det_model = is_frelon_4m ? "4M" : "2k";
if (!is_frelon_4m) {
bool is_frelon_2k16;
m_cam.isFrelon2k16(is_frelon_2k16);
det_model += is_frelon_2k16 ? "16" : "14";
}
bool has_taper;
m_cam.hasTaper(has_taper);
if (has_taper)
det_model += "T";
}
void DetInfoCtrlObj::setMaxImageSizeCallbackActive(bool cb_active)
{
}
/*******************************************************************
* \brief BufferCtrlObj constructor
*******************************************************************/
BufferCtrlObj::BufferCtrlObj(BufferCtrlMgr& buffer_mgr)
: m_buffer_mgr(buffer_mgr)
{
}
BufferCtrlObj::~BufferCtrlObj()
{
}
void BufferCtrlObj::setFrameDim(const FrameDim& frame_dim)
{
m_buffer_mgr.setFrameDim(frame_dim);
}
void BufferCtrlObj::getFramedim(FrameDim& frame_dim)
{
m_buffer_mgr.getFrameDim(frame_dim);
}
void BufferCtrlObj::setNbBuffers(int nb_buffers)
{
m_buffer_mgr.setNbBuffers(nb_buffers);
}
void BufferCtrlObj::getNbBuffers(int& nb_buffers)
{
m_buffer_mgr.getNbBuffers(nb_buffers);
}
void BufferCtrlObj::setNbConcatFrames(int nb_concat_frames)
{
m_buffer_mgr.setNbConcatFrames(nb_concat_frames);
}
void BufferCtrlObj::getNbConcatFrames(int& nb_concat_frames)
{
m_buffer_mgr.getNbConcatFrames(nb_concat_frames);
}
void BufferCtrlObj::setNbAccFrames(int nb_acc_frames)
{
m_buffer_mgr.setNbAccFrames(nb_acc_frames);
}
void BufferCtrlObj::getNbAccFrames(int& nb_acc_frames)
{
m_buffer_mgr.getNbAccFrames(nb_acc_frames);
}
void BufferCtrlObj::getMaxNbBuffers(int& max_nb_buffers)
{
m_buffer_mgr.getMaxNbBuffers(max_nb_buffers);
}
void *BufferCtrlObj::getBufferPtr(int buffer_nb, int concat_frame_nb)
{
return m_buffer_mgr.getBufferPtr(buffer_nb, concat_frame_nb);
}
void *BufferCtrlObj::getFramePtr(int acq_frame_nb)
{
return m_buffer_mgr.getFramePtr(acq_frame_nb);
}
void BufferCtrlObj::getStartTimestamp(Timestamp& start_ts)
{
m_buffer_mgr.getStartTimestamp(start_ts);
}
void BufferCtrlObj::getFrameInfo(int acq_frame_nb, HwFrameInfoType& info)
{
m_buffer_mgr.getFrameInfo(acq_frame_nb, info);
}
void BufferCtrlObj::registerFrameCallback(HwFrameCallback& frame_cb)
{
m_buffer_mgr.registerFrameCallback(frame_cb);
}
void BufferCtrlObj::unregisterFrameCallback(HwFrameCallback& frame_cb)
{
m_buffer_mgr.unregisterFrameCallback(frame_cb);
}
/*******************************************************************
* \brief SyncCtrlObj constructor
*******************************************************************/
SyncCtrlObj::SyncCtrlObj(Acq& acq, Camera& cam)
: m_acq(acq), m_cam(cam)
{
}
SyncCtrlObj::~SyncCtrlObj()
{
}
void SyncCtrlObj::setTrigMode(TrigMode trig_mode)
{
m_cam.setTrigMode(trig_mode);
}
void SyncCtrlObj::getTrigMode(TrigMode& trig_mode)
{
m_cam.getTrigMode(trig_mode);
}
void SyncCtrlObj::setExpTime(double exp_time)
{
m_cam.setExpTime(exp_time);
}
void SyncCtrlObj::getExpTime(double& exp_time)
{
m_cam.getExpTime(exp_time);
}
void SyncCtrlObj::setLatTime(double lat_time)
{
m_cam.setLatTime(lat_time);
}
void SyncCtrlObj::getLatTime(double& lat_time)
{
m_cam.getLatTime(lat_time);
}
void SyncCtrlObj::setNbFrames(int nb_frames)
{
m_acq.setNbFrames(nb_frames);
m_cam.setNbFrames(nb_frames);
}
void SyncCtrlObj::getNbFrames(int& nb_frames)
{
m_acq.getNbFrames(nb_frames);
}
void SyncCtrlObj::getValidRanges(ValidRangesType& valid_ranges)
{
}
/*******************************************************************
* \brief BinCtrlObj constructor
*******************************************************************/
BinCtrlObj::BinCtrlObj(Camera& cam)
: m_cam(cam)
{
}
BinCtrlObj::~BinCtrlObj()
{
}
void BinCtrlObj::setBin(const Bin& bin)
{
m_cam.setBin(bin);
}
void BinCtrlObj::getBin(Bin& bin)
{
m_cam.getBin(bin);
}
void BinCtrlObj::checkBin(Bin& bin)
{
int bin_x = min(bin.getX(), int(MaxBinX));
int bin_y = min(bin.getY(), int(MaxBinY));
bin = Bin(bin_x, bin_y);
}
/*******************************************************************
* \brief Hw Interface constructor
*******************************************************************/
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_bin(cam)
{
HwDetInfoCtrlObj *det_info = &m_det_info;
m_cap_list.push_back(HwCap(det_info));
HwBufferCtrlObj *buffer = &m_buffer;
m_cap_list.push_back(HwCap(buffer));
HwSyncCtrlObj *sync = &m_sync;
m_cap_list.push_back(HwCap(sync));
HwBinCtrlObj *bin = &m_bin;
m_cap_list.push_back(HwCap(bin));
reset(SoftReset);
}
Interface::~Interface()
{
}
const HwInterface::CapList& Interface::getCapList() const
{
return m_cap_list;
}
void Interface::reset(ResetLevel reset_level)
{