Commit 2fde05e4 authored by Laurent Claustre's avatar Laurent Claustre
Browse files

Merge branch 'frelon' into 'master'

Frelon16: increase serial timeout for slow commands:

See merge request !18
parents 266c8641 bcd8e9f1
Pipeline #70960 passed with stages
in 11 minutes and 45 seconds
......@@ -14,9 +14,9 @@ stages:
build-linux:
<<: *build-conda
script:
- conda build ./conda/camera --prefix-length=80 --output-folder=dist/ --channel=http://bcu-ci.esrf.fr/stable
- conda build ./conda/camera --prefix-length=80 --output-folder=dist/ -c conda-forge --channel=http://bcu-ci.esrf.fr/stable
tags:
- linux
- cos7
build-noarch:
<<: *build-conda
......@@ -26,7 +26,7 @@ build-noarch:
dependencies:
- build-linux
tags:
- linux
- cos7
deploy-devel:
stage: deploy
......@@ -41,7 +41,7 @@ deploy-devel:
- conda index /conda-devel/
tags:
- conda
- linux
- cos7
only:
- branches
except:
......@@ -61,6 +61,6 @@ deploy-stable:
- conda index /conda/
tags:
- conda
- linux
- cos7
only:
- tags
......@@ -23,6 +23,7 @@ requirements:
- lima-common-espia
build:
- cmake
- make
- {{ compiler('cxx') }}
run:
- python
......
......@@ -19,6 +19,7 @@ build:
requirements:
build:
- cmake
- make
- git
- lima-core
run:
......
......@@ -39,6 +39,7 @@ enum Reg {
ChanMode, TimeUnit, RoiEnable, RoiFast,
AntiBloom, BinVert, BinHorz, ConfigHD,
RoiKinetic, ShutEnable, HardTrigDisable,
NbLinesXfer, ShutElecSelect,
PixelFreq, LineFreq, FlipMode, IntCalib,
DisplayImage, AdcFloatDiode, AdcSignal,
DarkPixelCalib, DarkPixelMode, ChanControl, Mire,
......@@ -47,11 +48,17 @@ enum Reg {
Version, CompSerNb, Warn, LastWarn,
LineClockPer, PixelClockPer, FirstPHIVLen, PHIHSetupLen,
SingleVertXfer, SingleHorzXfer, AllVertXfer, AllHorzXfer,
ReadoutTime, TransferTime, CcdModesAvail, StatusSeqA,
ReadoutTime, TransferTime, CcdModesAvail,
StatusSeqA, StatusSeqB,
StatusAMTA, StatusAMTB, StatusAMTC, StatusAMTD,
StatusAMTE,
LookUpTable, ImagesPerEOF, WeightValDFl, WeightValSig,
SeqClockFreq, CamChar,
SeqTimRdOutH, SeqTimRdOutL,
SeqTimTransferH, SeqTimTransferL,
SeqTimEShutH, SeqTimEShutL,
SeqTimExposureH, SeqTimExposureL,
SeqTimFramePeriodH, SeqTimFramePeriodL,
};
typedef std::map<Reg, std::string> RegStrMapType;
......@@ -64,6 +71,7 @@ extern RegListType SignedRegList;
typedef std::map<Reg, double> RegDoubleMapType;
extern RegDoubleMapType RegSleepMap;
extern RegDoubleMapType RegTimeoutMap;
extern const int MaxRegVal;
......@@ -163,7 +171,6 @@ enum SPBConType {
enum GeomType {
SPB12_4_Quad,
Hamamatsu,
SPB2_F16,
SPB8_F16_Single,
SPB8_F16_Dual,
};
......@@ -179,10 +186,26 @@ enum {
KodakModesAvail = 0x0100,
};
enum {
MaxBinX = 8,
MaxBinY = 1024,
};
typedef std::vector<int> BinList;
typedef BinList BinTable[2];
extern BinTable Frelon2kBinTable;
extern BinTable Frelon16BinTable;
inline int GetLargestDivFromList(int x, const BinList l)
{
BinList::const_reverse_iterator it, end = l.rend();
for (it = l.rbegin(); it != end; ++it) {
if ((x % *it) == 0)
return *it;
}
throw LIMA_EXC(Hardware, Error, "Invalid div list");
}
inline Bin GetLargestBin(Bin bin, const BinTable& table)
{
return Bin(GetLargestDivFromList(bin.getX(), table[0]),
GetLargestDivFromList(bin.getY(), table[1]));
}
enum ExtSync {
ExtSyncNone = 0,
......@@ -272,6 +295,16 @@ enum SPB2Config {
typedef std::map<SPB2Config, std::string> SPB2ConfigStrMapType;
extern SPB2ConfigStrMapType SPB2ConfigNameMap;
struct SeqTimValues {
double readout_time;
double transfer_time;
double electronic_shutter_time;
double exposure_time;
double frame_period;
};
std::ostream& operator <<(std::ostream& os, const SeqTimValues& tm);
} // namespace Frelon
} // namespace lima
......
......@@ -39,6 +39,31 @@ class Camera
DEB_CLASS_NAMESPC(DebModCamera, "Camera", "Frelon");
public:
class TempRegVal
{
public:
TempRegVal(Camera& cam, Reg r, int val);
~TempRegVal();
void restore();
private:
Camera& m_cam;
Reg m_reg;
int m_orig_val;
bool m_changed;
};
class AcqSeq
{
public:
AcqSeq(Camera& cam);
~AcqSeq();
bool wait(double timeout,
bool use_ser_line=false, bool read_spb=false);
void stop();
private:
Camera& m_cam;
};
Camera(Espia::SerialLine& espia_ser_line);
~Camera();
......@@ -48,13 +73,13 @@ class Camera
void readRegister (Reg reg, int& val);
void readFloatRegister(Reg reg, double& val);
TempRegVal getTempRegVal(Reg reg, int val);
void hardReset();
void getVersionStr(std::string& ver);
void getComplexSerialNb(int& complex_ser_nb);
Model& getModel();
TimingCtrl& getTimingCtrl();
bool getDefInputChan(FrameTransferMode ftm, InputChan& input_chan);
void setInputChan(InputChan input_chan);
void getInputChan(InputChan& input_chan);
......@@ -125,11 +150,21 @@ class Camera
bool use_ser_line=false, bool read_spb=false);
void getImageCount(unsigned int& img_count, bool only_lsw=false);
void getMissingExtStartPulses(int& missing_pulses);
void prepare();
void start();
void stop();
bool isRunning();
AcqSeq startAcqSeq();
bool needSeqTimMeasure();
void latchSeqTimValues(SeqTimValues& st);
void measureSeqTimValues(SeqTimValues& st, double timeout = -1);
void setAutoSeqTimMeasure(bool auto_measure);
void getAutoSeqTimMeasure(bool& auto_measure);
void registerDeadTimeChangedCallback(DeadTimeChangedCallback& cb);
void unregisterDeadTimeChangedCallback(DeadTimeChangedCallback& cb);
......@@ -137,12 +172,15 @@ class Camera
void unregisterMaxImageSizeCallback(HwMaxImageSizeCallback& cb);
private:
friend class TimingCtrl;
static const double ResetLinkWaitTime;
static const double UpdateCcdStatusTime;
static const double MaxIdleWaitTime;
static const double MaxBusyRetryTime;
Espia::Dev& getEspiaDev();
Geometry& getGeometry();
void sync();
void syncRegs();
......@@ -165,7 +203,8 @@ class Camera
SerialLine m_ser_line;
Model m_model;
TimingCtrl m_timing_ctrl;
bool m_auto_seq_tim_measure;
AutoPtr<TimingCtrl> m_timing_ctrl;
AutoPtr<Geometry> m_geom;
TrigMode m_trig_mode;
int m_nb_frames;
......@@ -186,6 +225,15 @@ inline bool Camera::waitIdleStatus(Status& status, bool use_ser_line,
use_ser_line, read_spb);
}
inline Camera::TempRegVal Camera::getTempRegVal(Reg reg, int val)
{
return TempRegVal(*this, reg, val);
}
inline Camera::AcqSeq Camera::startAcqSeq()
{
return AcqSeq(*this);
}
} // namespace Frelon
......
......@@ -56,7 +56,7 @@ class Geometry : public HwMaxImageSizeCallbackGen
public:
Geometry(Camera& cam);
~Geometry();
virtual ~Geometry();
void sync();
......@@ -99,15 +99,16 @@ class Geometry : public HwMaxImageSizeCallbackGen
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);
Flip getMirror();
Point getNbChan();
Size getCcdSize();
Size getChanSize();
protected:
virtual void setMaxImageSizeCallbackActive(bool cb_active);
......@@ -115,7 +116,6 @@ class Geometry : public HwMaxImageSizeCallbackGen
void writeRegister(Reg reg, int val);
void readRegister (Reg reg, int& val);
void readFloatRegister(Reg reg, double& val);
int getModesAvail();
......@@ -131,11 +131,7 @@ class Geometry : public HwMaxImageSizeCallbackGen
void setFlipMode(int flip_mode);
void getFlipMode(int& flip_mode);
Flip getMirror();
Point getNbChan();
Size getCcdSize();
Size getChanSize();
Flip getRoiInsideMirror();
Flip getRoiInsideMirror();
void writeChanRoi(const Roi& chan_roi);
void readChanRoi(Roi& chan_roi);
......@@ -154,7 +150,7 @@ class Geometry : public HwMaxImageSizeCallbackGen
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;
......@@ -171,7 +167,7 @@ inline bool Geometry::isChanActive(InputChan curr, InputChan chan)
inline bool Geometry::isFrelon16()
{
return (m_model.getChipType() == Andanta_CcdFT2k);
return m_model.isFrelon16();
}
......
......@@ -225,7 +225,7 @@ class BinCtrlObj : public HwBinCtrlObj
DEB_CLASS_NAMESPC(DebModCamera, "BinCtrlObj", "Frelon");
public:
BinCtrlObj(Camera& cam);
BinCtrlObj(Espia::Acq& acq, Camera& cam);
virtual ~BinCtrlObj();
virtual void setBin(const Bin& bin);
......@@ -236,6 +236,7 @@ class BinCtrlObj : public HwBinCtrlObj
void unregisterBinChangedCallback(BinChangedCallback& bin_chg_cb);
private:
Espia::Acq& m_acq;
Camera& m_cam;
BinChangedCallback *m_bin_chg_cb;
};
......@@ -300,7 +301,7 @@ class FlipCtrlObj : public HwFlipCtrlObj
DEB_CLASS_NAMESPC(DebModCamera, "FlipCtrlObj", "Frelon");
public:
FlipCtrlObj(Camera& cam);
FlipCtrlObj(Espia::Acq& acq, Camera& cam);
virtual ~FlipCtrlObj();
virtual void setFlip(const Flip& flip);
......@@ -308,6 +309,7 @@ class FlipCtrlObj : public HwFlipCtrlObj
virtual void checkFlip(Flip& flip);
private:
Espia::Acq& m_acq;
Camera& m_cam;
};
......
......@@ -113,6 +113,7 @@ class Model
Taper, HamaChip,
ModesAvail, TimeCalc, HTDCmd, GoodHTD, ImagesPerEOF, CamChar,
SPB1, SPB2, SPB8,
SeqTim,
};
Model();
......@@ -139,6 +140,8 @@ class Model
ChipType getChipType();
SPBConType getSPBConType();
GeomType getGeomType();
bool isFrelon16();
bool isFrelon16Dual();
bool has(Feature feature);
double getPixelSize();
......
......@@ -49,6 +49,7 @@ class SerialLine : public HwSerialLine
};
typedef std::map<MsgPart, std::string> MsgPartStrMapType;
typedef std::vector<std::string> StrList;
static const double TimeoutSingle, TimeoutNormal, TimeoutMultiLine,
TimeoutReset;
......@@ -98,6 +99,8 @@ class SerialLine : public HwSerialLine
void setCacheActive(bool cache_act);
void getCacheActive(bool& cache_act);
void getResetTraceLog(StrList& reset_trace_log);
private:
enum RegOp {
None, DoCmd, ReadReg, WriteReg, DoReset, MultiRead
......@@ -153,9 +156,11 @@ class SerialLine : public HwSerialLine
bool m_cache_act;
RegOp m_curr_op;
Reg m_curr_reg;
Cmd m_curr_cmd;
bool m_curr_cache;
std::string m_curr_resp;
std::string m_curr_fmt_resp;
StrList m_reset_trace_log;
};
inline void SerialLine::readRegister(Reg reg, int& val)
......
......@@ -23,7 +23,6 @@
#define FRELONTIMINGCTRL_H
#include "FrelonModel.h"
#include "FrelonSerialLine.h"
namespace lima
{
......@@ -31,19 +30,67 @@ namespace lima
namespace Frelon
{
class Camera;
class TimingCtrl
{
DEB_CLASS_NAMESPC(DebModCamera, "TimingCtrl", "Frelon");
public:
TimingCtrl(Model& model, SerialLine& ser_line);
~TimingCtrl();
struct SeqTim {
typedef std::pair<Reg, Reg> RegPair;
typedef std::vector<RegPair> RegPairList;
typedef std::pair<int, int> ValPair;
typedef std::vector<ValPair> ValPairList;
static RegPairList RegList;
static const double ClockPeriod;
static SeqTimValues calcValues(const ValPairList& l);
static double calcSeqTim(const ValPair& v)
{
unsigned long v_first = v.first;
return ((v_first << 16) + v.second) * ClockPeriod;
}
};
struct Config {
int config_hd;
int bin_vert;
int chan_mode;
int nb_lines_xfer;
int roi_enable, roi_fast, roi_kinetic;
int roi_line_begin, roi_line_width;
int shut_elec_select;
};
typedef std::map<Config, SeqTimValues> ConfigTimingMeasureMap;
TimingCtrl(Camera& cam);
virtual ~TimingCtrl();
void getReadoutTime(double& readout_time);
void getTransferTime(double& xfer_time);
void getDeadTime(double& dead_time);
private:
bool needSeqTimMeasure();
void latchSeqTimValues(SeqTimValues& st);
void measureSeqTimValues(SeqTimValues& st, double timeout = -1);
protected:
void writeRegister(Reg reg, int val);
void readRegister (Reg reg, int& val);
void readFloatRegister(Reg reg, double& val);
Config getConfig();
Camera& m_cam;
Model& m_model;
SerialLine& m_ser_line;
ConfigTimingMeasureMap m_timing_measure_cache;
};
std::ostream& operator <<(std::ostream& os, const TimingCtrl::Config& config);
bool operator <(const TimingCtrl::Config& a, const TimingCtrl::Config& b);
} // namespace Frelon
......
......@@ -25,6 +25,8 @@ from Lima import Espia
from limafrelon import *
from processlib import Tasks
EspiaDevNbInvalid = 256
class FrelonAcq:
DEB_CLASS(DebModApplication, 'FrelonAcq')
......@@ -123,6 +125,12 @@ class FrelonAcq:
espia_dev_nb2 = kws.get('espia_dev_nb2', None)
if len(args) > 0:
espia_dev_nb2 = args[0]
req_lib_dbg_lvl = kws.get('espia_lib_debug_level', -1)
if len(args) > 1:
req_lib_dbg_lvl = args[1]
req_drv_dbg_lvl = kws.get('espia_drv_debug_level', -1)
if len(args) > 2:
req_drv_dbg_lvl = args[2]
self.m_cam_inited = False
......@@ -134,6 +142,13 @@ class FrelonAcq:
self.m_bpm_task = Tasks.BpmTask(self.m_bpm_mgr)
self.m_ser_edev = Espia.Dev(espia_dev_nb)
lib_dbg_lvl, drv_dbg_lvl = self.m_ser_edev.getDebugLevels()
if req_lib_dbg_lvl >= 0:
lib_dbg_lvl = req_lib_dbg_lvl
if req_drv_dbg_lvl >= 0:
drv_dbg_lvl = req_drv_dbg_lvl
self.m_ser_edev.setDebugLevels(lib_dbg_lvl, drv_dbg_lvl)
self.m_eserline = Espia.SerialLine(self.m_ser_edev)
self.m_cam = Frelon.Camera(self.m_eserline)
......@@ -141,7 +156,7 @@ class FrelonAcq:
model = self.m_cam.getModel()
f16 = (model.getChipType() == Frelon.Andanta_CcdFT2k)
if f16:
if espia_dev_nb2 is not None:
if espia_dev_nb2 not in [None, EspiaDevNbInvalid]:
self.m_acq_edev = Espia.Meta([espia_dev_nb, espia_dev_nb2])
else:
model.setF16ForceSingle(True);
......
......@@ -38,6 +38,7 @@ enum Reg {
ChanMode, TimeUnit, RoiEnable, RoiFast,
AntiBloom, BinVert, BinHorz, ConfigHD,
RoiKinetic, ShutEnable, HardTrigDisable,
NbLinesXfer, ShutElecSelect,
PixelFreq, LineFreq, FlipMode, IntCalib,
DisplayImage, AdcFloatDiode, AdcSignal,
DarkPixelCalib, DarkPixelMode, ChanControl, Mire,
......@@ -46,11 +47,17 @@ enum Reg {
Version, CompSerNb, Warn, LastWarn,
LineClockPer, PixelClockPer, FirstPHIVLen, PHIHSetupLen,
SingleVertXfer, SingleHorzXfer, AllVertXfer, AllHorzXfer,
ReadoutTime, TransferTime, CcdModesAvail, StatusSeqA,
ReadoutTime, TransferTime, CcdModesAvail,
StatusSeqA, StatusSeqB,
StatusAMTA, StatusAMTB, StatusAMTC, StatusAMTD,
StatusAMTE,
LookUpTable, ImagesPerEOF, WeightValDFl, WeightValSig,
SeqClockFreq, CamChar,
SeqTimRdOutH, SeqTimRdOutL,
SeqTimTransferH, SeqTimTransferL,
SeqTimEShutH, SeqTimEShutL,
SeqTimExposureH, SeqTimExposureL,
SeqTimFramePeriodH, SeqTimFramePeriodL,
};
/*
typedef std::map<Reg, std::string> RegStrMapType;
......@@ -75,6 +82,7 @@ extern RegListType SignedRegList;
typedef std::map<Reg, double> RegDoubleMapType;
extern RegDoubleMapType RegSleepMap;
extern RegDoubleMapType RegTimeoutMap;
*/
const int MaxRegVal;
......@@ -170,7 +178,6 @@ enum SPBConType {
enum GeomType {
SPB12_4_Quad,
Hamamatsu,
SPB2_F16,
SPB8_F16_Single,
SPB8_F16_Dual,
};
......@@ -187,11 +194,6 @@ enum {
KodakModesAvail = 0x0100,
};
enum {
MaxBinX = 8,
MaxBinY = 1024,
};
enum ExtSync {
ExtSyncNone = 0,
ExtSyncStart = 1,
......@@ -277,4 +279,12 @@ enum SPB2Config {
SPB2Precision, SPB2Speed,
};
struct SeqTimValues {
double readout_time;
double transfer_time;
double electronic_shutter_time;
double exposure_time;
double frame_period;
};
}; // namespace Frelon
......@@ -45,8 +45,6 @@ class Camera
void getComplexSerialNb(int& complex_ser_nb /Out/);
Frelon::Model& getModel();
Frelon::TimingCtrl& getTimingCtrl();
bool getDefInputChan(Frelon::FrameTransferMode ftm,
Frelon::InputChan& input_chan /Out/);
void setInputChan(Frelon::InputChan input_chan);
......@@ -119,11 +117,19 @@ class Camera
bool read_spb2=false);
void getImageCount(unsigned int& img_count /Out/, bool only_lsw=false);
void getMissingExtStartPulses(int& missing_pulses /Out/);
void prepare();
void start();
void stop();
bool isRunning();
bool needSeqTimMeasure();
void latchSeqTimValues(Frelon::SeqTimValues& st /Out/);
void measureSeqTimValues(Frelon::SeqTimValues& st /Out/, double timeout = -1);
void setAutoSeqTimMeasure(bool auto_measure);
void getAutoSeqTimMeasure(bool& auto_measure /Out/);
void registerDeadTimeChangedCallback(Frelon::DeadTimeChangedCallback& cb);
void unregisterDeadTimeChangedCallback(Frelon::DeadTimeChangedCallback& cb);
void registerMaxImageSizeCallback(HwMaxImageSizeCallback& cb);
......
......@@ -182,7 +182,7 @@ class BinCtrlObj : HwBinCtrlObj
%End
public:
BinCtrlObj(Frelon::Camera& cam);
BinCtrlObj(Espia::Acq& acq, Frelon::Camera& cam);
virtual ~BinCtrlObj();
virtual void setBin(const Bin& bin);
......@@ -241,7 +241,7 @@ class FlipCtrlObj : HwFlipCtrlObj
%End
public:
FlipCtrlObj(Frelon::Camera& cam);
FlipCtrlObj(Espia::Acq& acq, Frelon::Camera& cam);