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));
......
This diff is collapsed.
This diff is collapsed.
......@@ -32,6 +32,7 @@ const Firmware Firmware::v2_0c("2.0c");
const Firmware Firmware::v2_1b("2.1b");
const Firmware Firmware::v3_0i("3.0i");
const Firmware Firmware::v3_1c("3.1c");
const Firmware Firmware::v4_1("4.1");
Firmware::Firmware()
{
......@@ -180,12 +181,29 @@ void Model::getComplexSerialNb(int& complex_ser_nb)
DEB_RETURN() << DEB_VAR1(DEB_HEX(complex_ser_nb));
}
void Model::setCamChar(int cam_char)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(DEB_HEX(cam_char));
m_cam_char = cam_char;
update();
}
void Model::getCamChar(int& cam_char)
{
DEB_MEMBER_FUNCT();
cam_char = m_cam_char;
DEB_RETURN() << DEB_VAR1(DEB_HEX(cam_char));
}
void Model::reset()
{
DEB_MEMBER_FUNCT();
m_firmware.reset();
m_complex_ser_nb = 0;
m_cam_char = 0;
update();
}
......@@ -198,27 +216,49 @@ void Model::update()
if (!m_valid)
return;
bool is_spb2 = isSPB2();
if (is_spb2)
m_chip_type = ChipType(getSerialNbParam(SPB2Type) >> 12);
else
m_spb_type = SPBType(getSerialNbParam(SPBTypeMask) >> 8);
m_feature[SPB1] = (m_spb_type == SPBType1);
m_feature[SPB2] = (m_spb_type == SPBType2);
m_feature[SPB8] = (m_spb_type == SPBType8);
m_feature[Taper] = bool(getSerialNbParam(TaperFlag));
bool is_spb1 = has(SPB1);
if (!is_spb1) {
int raw = getSerialNbParam(ChipTypeMask) >> 11;
m_chip_type = ChipType(((raw & 1) << 3) | (raw >> 1));
} else {
m_chip_type = bool(getSerialNbParam(SPB1Kodak)) ? Kodak : Atmel;
m_is_hama = (m_chip_type == Hama);
}
m_feature[HamaChip] = (m_chip_type == Hama);
bool firm_v2_0c = (is_spb2 && (m_firmware >= Firmware::v2_0c));
m_htd_cmd = firm_v2_0c;
bool firm_v2_0c = (!is_spb1 && (m_firmware >= Firmware::v2_0c));
m_feature[HTDCmd] = firm_v2_0c;
bool firm_v2_1b = (is_spb2 && (m_firmware >= Firmware::v2_1b));
m_modes_avail = m_time_calc = firm_v2_1b;
bool firm_v2_1b = (!is_spb1 && (m_firmware >= Firmware::v2_1b));
m_feature[ModesAvail] = firm_v2_1b;