Commit 38e95089 authored by Alejandro Homs Puron's avatar Alejandro Homs Puron Committed by operator for beamline

Frelon16: Start integration of Frelon16 chip and SPB8:

* Add SPBType, SPBConType and GeomType to Frelon::Model
* Add generic Model::has(Feature)
* Move SPB1/2 code to Frelon::Geometry
parent 70940493
......@@ -101,6 +101,7 @@ add_library(frelon SHARED
src/Frelon.cpp
src/FrelonSerialLine.cpp
src/FrelonModel.cpp
src/FrelonGeometry.cpp
src/FrelonCamera.cpp
src/FrelonTimingCtrl.cpp
src/FrelonInterface.cpp
......
......@@ -50,6 +50,7 @@ enum Reg {
ReadoutTime, TransferTime, CcdModesAvail, StatusSeqA,
StatusAMTA, StatusAMTB, StatusAMTC, StatusAMTD,
LookUpTable, ImagesPerEOF, WeightValDFl, WeightValSig,
SeqClockFreq, CamChar,
};
typedef std::map<Reg, std::string> RegStrMapType;
......@@ -115,12 +116,12 @@ extern InputChanList DefInputChanList;
enum SerNbParam {
SerNb = 0x00ff,
SPB1Kodak = 0x2000,
SPB1Adc16 = 0x4000,
SPB2Sign = 0x0100,
SPB2Type = 0x7000,
Taper = 0x8000,
SerNb = 0x00ff,
SPB1Kodak = 0x2000,
SPB1Adc16 = 0x4000,
SPBTypeMask = 0x0300,
ChipTypeMask = 0x7800,
TaperFlag = 0x8000,
};
enum RoiMode {
......@@ -135,6 +136,10 @@ typedef std::map<TimeUnitFactor, double> TimeUnitFactorMapType;
extern TimeUnitFactorMapType TimeUnitFactorMap;
enum SPBType {
SPBType1, SPBType2, SPBType8,
};
enum ChipType {
Atmel,
Kodak,
......@@ -143,6 +148,19 @@ enum ChipType {
E2V_4k,
E2V_4kNotMPP,
Hama,
Andanta_CcdFT2k = 8,
};
enum SPBConType {
SPBConNone, SPBConX, SPBConY, SPBConXY,
};
enum GeomType {
SPB12_4_Quad,
Hamamatsu,
SPB2_F16,
SPB8_F16_Half,
SPB8_F16_Dual,
};
typedef std::map<ChipType, FrameDim> ChipMaxFrameDimMapType;
......
......@@ -24,6 +24,7 @@
#include "FrelonSerialLine.h"
#include "FrelonModel.h"
#include "FrelonGeometry.h"
#include "FrelonTimingCtrl.h"
#include "lima/HwMaxImageSizeCallback.h"
......@@ -33,26 +34,11 @@ namespace lima
namespace Frelon
{
class Camera : public HwMaxImageSizeCallbackGen
class Camera
{
DEB_CLASS_NAMESPC(DebModCamera, "Camera", "Frelon");
public:
class DeadTimeChangedCallback {
DEB_CLASS_NAMESPC(DebModCamera, "DeadTimeChangedCallback",
"Frelon::Camera");
public:
DeadTimeChangedCallback();
virtual ~DeadTimeChangedCallback();
protected:
virtual void deadTimeChanged(double dead_time) = 0;
private:
friend class Camera;
Camera *m_cam;
};
Camera(Espia::SerialLine& espia_ser_line);
~Camera();
......@@ -76,8 +62,8 @@ class Camera : public HwMaxImageSizeCallbackGen
void setFrameTransferMode(FrameTransferMode ftm);
void getFrameTransferMode(FrameTransferMode& ftm);
static std::string getInputChanModeName(FrameTransferMode ftm,
InputChan input_chan);
std::string getInputChanModeName(FrameTransferMode ftm,
InputChan input_chan);
void getMaxFrameDim(FrameDim& max_frame_dim);
void getFrameDim(FrameDim& frame_dim);
......@@ -128,7 +114,7 @@ class Camera : public HwMaxImageSizeCallbackGen
void setSPB2Config(SPB2Config spb2_config);
void getSPB2Config(SPB2Config& spb2_config);
static std::string getSPB2ConfigName(SPB2Config spb2_config);
std::string getSPB2ConfigName(SPB2Config spb2_config);
void setExtSyncEnable(ExtSync ext_sync_ena);
void getExtSyncEnable(ExtSync& ext_sync_ena);
......@@ -147,8 +133,8 @@ class Camera : public HwMaxImageSizeCallbackGen
void registerDeadTimeChangedCallback(DeadTimeChangedCallback& cb);
void unregisterDeadTimeChangedCallback(DeadTimeChangedCallback& cb);
protected:
virtual void setMaxImageSizeCallbackActive(bool cb_active);
void registerMaxImageSizeCallback(HwMaxImageSizeCallback& cb);
void unregisterMaxImageSizeCallback(HwMaxImageSizeCallback& cb);
private:
static const double ResetLinkWaitTime;
......@@ -165,44 +151,6 @@ class Camera : public HwMaxImageSizeCallbackGen
void sendCmd(Cmd cmd);
int getModesAvail();
void setChanMode(int chan_mode);
void getChanMode(int& chan_mode);
void calcBaseChanMode(FrameTransferMode ftm, int& base_chan_mode);
void calcChanMode(FrameTransferMode ftm, InputChan input_chan,
int& chan_mode);
void calcFTMInputChan(int chan_mode, FrameTransferMode& ftm,
InputChan& input_chan);
void setFlipMode(int flip_mode);
void getFlipMode(int& flip_mode);
Flip getMirror();
Point getNbChan();
Size getCcdSize();
Size getChanSize();
Flip getRoiInsideMirror();
void writeChanRoi(const Roi& chan_roi);
void readChanRoi(Roi& chan_roi);
void xformChanCoords(const Point& point, Point& chan_point,
Corner& ref_corner);
void calcImageRoi(const Roi& chan_roi, const Flip& roi_inside_mirror,
Roi& image_roi, Point& roi_bin_offset);
void calcFinalRoi(const Roi& image_roi, const Point& roi_offset,
Roi& final_roi);
void calcChanRoi(const Roi& image_roi, Roi& chan_roi,
Flip& roi_inside_mirror);
void calcChanRoiOffset(const Roi& req_roi, const Roi& image_roi,
Point& roi_offset);
void checkRoiMode(const Roi& roi);
void processSetRoi(const Roi& req_roi, Roi& hw_roi, Roi& chan_roi,
Point& roi_offset);
void resetRoiBinOffset();
void setTimeUnitFactor(TimeUnitFactor time_unit_factor);
void getTimeUnitFactor(TimeUnitFactor& time_unit_factor);
int calcTimeUnits(double time_sec, TimeUnitFactor time_unit_factor);
......@@ -211,27 +159,16 @@ class Camera : public HwMaxImageSizeCallbackGen
bool waitIdleStatus(Status& status, bool use_ser_line=false,
bool read_spb2=false);
void deadTimeChanged();
AutoMutex lock();
SerialLine m_ser_line;
Model m_model;
TimingCtrl m_timing_ctrl;
Point m_chan_roi_offset;
Point m_roi_bin_offset;
AutoPtr<Geometry> m_geom;
TrigMode m_trig_mode;
int m_nb_frames;
bool m_mis_cb_act;
Mutex m_lock;
bool m_started;
double m_dead_time;
DeadTimeChangedCallback *m_dead_time_cb;
};
inline bool Camera::isChanActive(InputChan curr, InputChan chan)
{
return (curr & chan) == chan;
};
inline AutoMutex Camera::lock()
......
//###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2011
// European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//###########################################################################
#ifndef FRELONGEOMETRY_H
#define FRELONGEOMETRY_H
#include "Frelon.h"
#include "lima/HwMaxImageSizeCallback.h"
namespace lima
{
namespace Frelon
{
class Model;
class Geometry;
class Camera;
class DeadTimeChangedCallback
{
DEB_CLASS_NAMESPC(DebModCamera, "DeadTimeChangedCallback", "Frelon");
public:
DeadTimeChangedCallback();
virtual ~DeadTimeChangedCallback();
protected:
virtual void deadTimeChanged(double dead_time) = 0;
private:
friend class Geometry;
Geometry *m_geom;
};
class Geometry : public HwMaxImageSizeCallbackGen
{
DEB_CLASS_NAMESPC(DebModCamera, "Geometry", "Frelon");
public:
Geometry(Camera& cam);
~Geometry();
void sync();
bool getDefInputChan(FrameTransferMode ftm,
InputChan& input_chan);
void setInputChan(InputChan input_chan);
void getInputChan(InputChan& input_chan);
void setFrameTransferMode(FrameTransferMode ftm);
void getFrameTransferMode(FrameTransferMode& ftm);
std::string getInputChanModeName(FrameTransferMode ftm,
InputChan input_chan);
void getMaxFrameDim(FrameDim& max_frame_dim);
void getFrameDim(FrameDim& frame_dim);
bool isChanActive(InputChan curr, InputChan chan);
void checkFlip(Flip& flip);
void setFlip(const Flip& flip);
void getFlip(Flip& flip);
void checkBin(Bin& bin);
void setBin(const Bin& bin);
void getBin(Bin& bin);
void setRoiMode(RoiMode roi_mode);
void getRoiMode(RoiMode& roi_mode);
void checkRoi(const Roi& set_roi, Roi& hw_roi);
void setRoi(const Roi& set_roi);
void getRoi(Roi& hw_roi);
void setRoiBinOffset(const Point& roi_bin_offset);
void getRoiBinOffset(Point& roi_bin_offset);
void setSPB2Config(SPB2Config spb2_config);
void getSPB2Config(SPB2Config& spb2_config);
std::string getSPB2ConfigName(SPB2Config spb2_config);
void getReadoutTime(double& readout_time);
void getTransferTime(double& xfer_time);
void getDeadTime(double& dead_time);
void deadTimeChanged();
void registerDeadTimeChangedCallback(DeadTimeChangedCallback& cb);
void unregisterDeadTimeChangedCallback(DeadTimeChangedCallback& cb);
protected:
virtual void setMaxImageSizeCallbackActive(bool cb_active);
void writeRegister(Reg reg, int val);
void readRegister (Reg reg, int& val);
void readFloatRegister(Reg reg, double& val);
int getModesAvail();
void setChanMode(int chan_mode);
void getChanMode(int& chan_mode);
void calcBaseChanMode(FrameTransferMode ftm, int& base_chan_mode);
void calcChanMode(FrameTransferMode ftm, InputChan input_chan,
int& chan_mode);
void calcFTMInputChan(int chan_mode, FrameTransferMode& ftm,
InputChan& input_chan);
void setFlipMode(int flip_mode);
void getFlipMode(int& flip_mode);
Flip getMirror();
Point getNbChan();
Size getCcdSize();
Size getChanSize();
Flip getRoiInsideMirror();
void writeChanRoi(const Roi& chan_roi);
void readChanRoi(Roi& chan_roi);
void xformChanCoords(const Point& point, Point& chan_point,
Corner& ref_corner);
void calcImageRoi(const Roi& chan_roi, const Flip& roi_inside_mirror,
Roi& image_roi, Point& roi_bin_offset);
void calcFinalRoi(const Roi& image_roi, const Point& roi_offset,
Roi& final_roi);
void calcChanRoi(const Roi& image_roi, Roi& chan_roi,
Flip& roi_inside_mirror);
void calcChanRoiOffset(const Roi& req_roi, const Roi& image_roi,
Point& roi_offset);
void checkRoiMode(const Roi& roi);
void processSetRoi(const Roi& req_roi, Roi& hw_roi, Roi& chan_roi,
Point& roi_offset);
void resetRoiBinOffset();
Camera& m_cam;
Model& m_model;
Point m_chan_roi_offset;
Point m_roi_bin_offset;
bool m_mis_cb_act;
double m_dead_time;
DeadTimeChangedCallback *m_dead_time_cb;
};
inline bool Geometry::isChanActive(InputChan curr, InputChan chan)
{
return (curr & chan) == chan;
};
} // namespace Frelon
} // namespace lima
#endif // FRELONGEOMETRY_H
......@@ -177,7 +177,7 @@ class SyncCtrlObj : public HwSyncCtrlObj
virtual void getValidRanges(ValidRangesType& valid_ranges);
private:
class DeadTimeChangedCallback : public Camera::DeadTimeChangedCallback
class DeadTimeChangedCallback : public Frelon::DeadTimeChangedCallback
{
DEB_CLASS_NAMESPC(DebModCamera, "DeadTimeChangedCallback",
"Frelon::SynCtrlObj");
......
......@@ -53,6 +53,7 @@ class Firmware
static const Firmware v2_1b;
static const Firmware v3_0i;
static const Firmware v3_1c;
static const Firmware v4_1;
private:
void checkValid();
......@@ -108,6 +109,12 @@ class Model
DEB_CLASS_NAMESPC(DebModCamera, "Model", "Frelon");
public:
enum Feature {
Taper, HamaChip,
ModesAvail, TimeCalc, HTDCmd, GoodHTD, ImagesPerEOF, CamChar,
SPB1, SPB2, SPB8,
};
Model();
~Model();
......@@ -117,42 +124,39 @@ class Model
void setComplexSerialNb(int complex_ser_nb);
void getComplexSerialNb(int& complex_ser_nb);
void setCamChar(int cam_char);
void getCamChar(int& cam_char);
void reset();
bool isValid();
int getSerialNb();
bool isSPB1();
bool isSPB2();
SPBType getSPBType();
int getAdcBits();
ChipType getChipType();
bool isHama();
bool hasTaper();
bool hasModesAvail();
bool hasTimeCalc();
bool hasHTDCmd();
bool hasGoodHTD();
bool hasImagesPerEOF();
SPBConType getSPBConType();
GeomType getGeomType();
bool has(Feature feature);
double getPixelSize();
std::string getName();
private:
typedef std::map<Feature, bool> FeatureMap;
void update();
void checkValid();
int getSerialNbParam(SerNbParam param);
Firmware m_firmware;
int m_complex_ser_nb;
int m_cam_char;
bool m_valid;
ChipType m_chip_type;
bool m_is_hama;
bool m_modes_avail;
bool m_time_calc;
bool m_htd_cmd;
bool m_good_htd;
bool m_images_per_eof;
bool m_valid;
SPBType m_spb_type;
ChipType m_chip_type;
SPBConType m_spb_con_type;
FeatureMap m_feature;
};
......
......@@ -48,7 +48,8 @@ enum Reg {
SingleVertXfer, SingleHorzXfer, AllVertXfer, AllHorzXfer,
ReadoutTime, TransferTime, CcdModesAvail, StatusSeqA,
StatusAMTA, StatusAMTB, StatusAMTC, StatusAMTD,
LookUpTable, ImagesPerEOF,
LookUpTable, ImagesPerEOF, WeightValDFl, WeightValSig,
SeqClockFreq, CamChar,
};
/*
typedef std::map<Reg, std::string> RegStrMapType;
......@@ -125,12 +126,12 @@ extern FTMInputChanListMapType FTMInputChanListMap;
*/
enum SerNbParam {
SerNb = 0x00ff,
SPB1Kodak = 0x2000,
SPB1Adc16 = 0x4000,
SPB2Sign = 0x0100,
SPB2Type = 0x7000,
Taper = 0x8000,
SerNb = 0x00ff,
SPB1Kodak = 0x2000,
SPB1Adc16 = 0x4000,
SPBTypeMask = 0x0300,
ChipTypeMask = 0x7800,
TaperFlag = 0x8000,
};
enum RoiMode {
......@@ -154,7 +155,21 @@ enum ChipType {
E2V_4k,
E2V_4kNotMPP,
Hama,
Andanta_CcdFT2k = 8,
};
enum SPBConType {
SPBConNone, SPBConX, SPBConY, SPBConXY,
};
enum GeomType {
SPB12_4_Quad,
Hamamatsu,
SPB2_F16,
SPB8_F16_Half,
SPB8_F16_Dual,
};
/*
typedef std::map<ChipType, FrameDim> ChipMaxFrameDimMapType;
extern ChipMaxFrameDimMapType ChipMaxFrameDimMap;
......
......@@ -23,7 +23,6 @@
namespace Frelon
{
class Camera
{
......@@ -32,15 +31,6 @@ class Camera
%End
public:
class DeadTimeChangedCallback {
public:
DeadTimeChangedCallback();
virtual ~DeadTimeChangedCallback();
protected:
virtual void deadTimeChanged(double dead_time) = 0;
};
Camera(Espia::SerialLine& espia_ser_line);
~Camera();
......@@ -65,8 +55,8 @@ class Camera
void setFrameTransferMode(Frelon::FrameTransferMode ftm);
void getFrameTransferMode(Frelon::FrameTransferMode& ftm /Out/);
static std::string getInputChanModeName(Frelon::FrameTransferMode ftm,
Frelon::InputChan input_chan);
std::string getInputChanModeName(Frelon::FrameTransferMode ftm,
Frelon::InputChan input_chan);
void getMaxFrameDim(FrameDim& max_frame_dim /Out/);
void getFrameDim(FrameDim& frame_dim /Out/);
......@@ -117,7 +107,7 @@ class Camera
void setSPB2Config(Frelon::SPB2Config spb2_config);
void getSPB2Config(Frelon::SPB2Config& spb2_config /Out/);
static std::string getSPB2ConfigName(Frelon::SPB2Config spb2_config);
std::string getSPB2ConfigName(Frelon::SPB2Config spb2_config);
void setExtSyncEnable(Frelon::ExtSync ext_sync_ena);
void getExtSyncEnable(Frelon::ExtSync& ext_sync_ena /Out/);
......@@ -134,12 +124,10 @@ class Camera
void stop();
bool isRunning();
void registerDeadTimeChangedCallback(Frelon::Camera::DeadTimeChangedCallback& cb);
void unregisterDeadTimeChangedCallback(Frelon::Camera::DeadTimeChangedCallback& cb);
protected:
virtual void setMaxImageSizeCallbackActive(bool cb_active);
void registerDeadTimeChangedCallback(Frelon::DeadTimeChangedCallback& cb);
void unregisterDeadTimeChangedCallback(Frelon::DeadTimeChangedCallback& cb);
void registerMaxImageSizeCallback(HwMaxImageSizeCallback& cb);
void unregisterMaxImageSizeCallback(HwMaxImageSizeCallback& cb);
};
......
//###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2011
// European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//###########################################################################
namespace Frelon
{
class DeadTimeChangedCallback
{
%TypeHeaderCode
#include "FrelonGeometry.h"
%End
public:
DeadTimeChangedCallback();
virtual ~DeadTimeChangedCallback();
protected:
virtual void deadTimeChanged(double dead_time) = 0;
};
}; // namespace Frelon
......@@ -48,6 +48,7 @@ class Firmware
static const Frelon::Firmware v2_1b;
static const Frelon::Firmware v3_0i;
static const Frelon::Firmware v3_1c;
static const Frelon::Firmware v4_1;
};
......@@ -59,6 +60,12 @@ class Model
%End
public:
enum Feature {
Taper, HamaChip,
ModesAvail, TimeCalc, HTDCmd, GoodHTD, ImagesPerEOF, CamChar,
SPB1, SPB2, SPB8,
};
Model();
~Model();
......@@ -68,22 +75,18 @@ class Model
void setComplexSerialNb(int complex_ser_nb);
void getComplexSerialNb(int& complex_ser_nb /Out/);
void setCamChar(int cam_char);
void getCamChar(int& cam_char /Out/);
void reset();
bool isValid();
int getSerialNb();
bool isSPB1();
bool isSPB2();
int getAdcBits();
int getChipType();
bool isHama();
bool hasTaper();
bool hasModesAvail();
bool hasTimeCalc();
bool hasHTDCmd();
bool hasGoodHTD();
bool hasImagesPerEOF();
Frelon::ChipType getChipType();
Frelon::SPBConType getSPBConType();
Frelon::GeomType getGeomType();
bool has(Model::Feature feature);
double getPixelSize();
std::string getName();
......
......@@ -97,6 +97,9 @@ static const RegPair RegStrCList[] = {
RegPair(ImagesPerEOF, "NEF"),
RegPair(WeightValDFl, "WVD"),
RegPair(WeightValSig, "WVS"),
RegPair(SeqClockFreq, "FSC"),
RegPair(CamChar, "CCH"),
};
RegStrMapType lima::Frelon::RegStrMap(C_LIST_ITERS(RegStrCList));
......
......@@ -20,8 +20,6 @@
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//###########################################################################
#include "FrelonCamera.h"
#include "lima/MiscUtils.h"
#include <sstream>
using namespace lima;
using namespace lima::Frelon;
......@@ -32,24 +30,9 @@ const double Camera::UpdateCcdStatusTime = 0.1;
const double Camera::MaxIdleWaitTime = 2.5;
const double Camera::MaxBusyRetryTime = 0.2; // 16 Mpixel image Aurora Xfer
Camera::DeadTimeChangedCallback::DeadTimeChangedCallback()
: m_cam(NULL)
{
DEB_CONSTRUCTOR();
}
Camera::DeadTimeChangedCallback::~DeadTimeChangedCallback()
{
DEB_DESTRUCTOR();
if (m_cam)
m_cam->unregisterDeadTimeChangedCallback(*this);
}
Camera::Camera(Espia::SerialLine& espia_ser_line)
: m_ser_line(espia_ser_line), m_timing_ctrl(m_model, m_ser_line),
m_mis_cb_act(false), m_dead_time(0), m_dead_time_cb(NULL)
m_geom(NULL)
{
DEB_CONSTRUCTOR();
......@@ -60,8 +43,7 @@ Camera::~Camera()
{
DEB_DESTRUCTOR();
if (m_dead_time_cb)
unregisterDeadTimeChangedCallback(*m_dead_time_cb);
stop();
}
void Camera::sync()
......@@ -82,7 +64,6 @@ void Camera::sync()
DEB_TRACE() << "Synchronizing with the camera";
m_model.reset();
m_chan_roi_offset = 0;
m_started = false;
try {
......@@ -118,13 +99,31 @@ void Camera::syncRegs()
int complex_ser_nb;
getComplexSerialNb(complex_ser_nb);
m_model.setComplexSerialNb(complex_ser_nb);
if (m_model.has(Model::CamChar)) {
int cam_char;
readRegister(CamChar, cam_char);
m_model.setCamChar(cam_char);
}
if (m_geom == NULL) {
GeomType geom_type = m_model.getGeomType();
switch (geom_type) {
case SPB12_4_Quad:
case Hamamatsu:
m_geom = new Geometry(*this);
break;
case SPB2_F16:
case SPB8_F16_Half:
case SPB8_F16_Dual:
THROW_HW_ERROR(NotSupported) << DEB_VAR1(geom_type);
}
}
if (m_model.hasGoodHTD())
if (m_model.has(Model::GoodHTD))
syncRegsGoodHTD();