Commit 238cf1bb authored by Alejandro Homs Puron's avatar Alejandro Homs Puron Committed by Laurent Claustre
Browse files

Add support for Frelon16 binning modes:

* Improve checkBin algorithm for both Frelon2k and Frelon16:
  get largest divisor from an explicit BinList
parent 8b8ad8c4
......@@ -186,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,
......
......@@ -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;
};
......
......@@ -190,11 +190,6 @@ enum {
KodakModesAvail = 0x0100,
};
enum {
MaxBinX = 8,
MaxBinY = 1024,
};
enum ExtSync {
ExtSyncNone = 0,
ExtSyncStart = 1,
......
......@@ -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);
......
......@@ -270,6 +270,21 @@ static const ChipSizePair ChipPixelSizeCList[] = {
ChipPixelSizeMapType
lima::Frelon::ChipPixelSizeMap(C_LIST_ITERS(ChipPixelSizeCList));
static const int Frelon2kBinXCList[] = {1, 2, 4, 8};
static const int Frelon2kBinYCList[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512,
1024};
BinTable lima::Frelon::Frelon2kBinTable = {
{C_LIST_ITERS(Frelon2kBinXCList)},
{C_LIST_ITERS(Frelon2kBinYCList)},
};
static const int Frelon16BinXCList[] = {1, 2, 3, 5};
static const int Frelon16BinYCList[] = {1, 2, 3, 4, 5};
BinTable lima::Frelon::Frelon16BinTable = {
{C_LIST_ITERS(Frelon16BinXCList)},
{C_LIST_ITERS(Frelon16BinYCList)},
};
typedef pair<SPB2Config, string> SPB2ConfigStrPair;
static const SPB2ConfigStrPair SPB2ConfigNameCList[] = {
SPB2ConfigStrPair(SPB2Precision, "Precision"),
......
......@@ -389,13 +389,8 @@ void Geometry::checkBin(Bin& bin)
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(bin);
bool frelon16 = (isFrelon16());
int max_bin_x = frelon16 ? 1 : int(MaxBinX);
int max_bin_y = frelon16 ? 1 : int(MaxBinY);
int bin_x = min(bin.getX(), max_bin_x);
int bin_y = min(bin.getY(), max_bin_y);
bin = Bin(bin_x, bin_y);
BinTable& table = isFrelon16() ? Frelon16BinTable : Frelon2kBinTable;
bin = GetLargestBin(bin, table);
DEB_RETURN() << DEB_VAR1(bin);
}
......@@ -403,11 +398,13 @@ void Geometry::setBin(const Bin& bin)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(bin);
if ((bin.getX() > MaxBinX) || (bin.getY() > MaxBinY))
Bin check = bin;
checkBin(check);
if (check != bin)
THROW_HW_ERROR(InvalidValue) << "Invalid " << DEB_VAR1(bin)
<< ". Max. HW binning is "
<< Bin(MaxBinX, MaxBinY);
<< ". Max. HW binning is "
<< check;
Bin curr_bin;
getBin(curr_bin);
......
......@@ -422,8 +422,8 @@ BinChangedCallback::~BinChangedCallback()
m_bin_ctrl_obj->unregisterBinChangedCallback(*this);
}
BinCtrlObj::BinCtrlObj(Camera& cam)
: m_cam(cam), m_bin_chg_cb(NULL)
BinCtrlObj::BinCtrlObj(Espia::Acq& acq, Camera& cam)
: m_acq(acq), m_cam(cam), m_bin_chg_cb(NULL)
{
DEB_CONSTRUCTOR();
}
......@@ -440,6 +440,17 @@ void BinCtrlObj::setBin(const Bin& bin)
DEB_MEMBER_FUNCT();
m_cam.setBin(bin);
Espia::SGImgConfig img_config;
Size prev_size;
m_acq.getSGImgConfig(img_config, prev_size);
FrameDim det_frame_dim;
m_cam.getFrameDim(det_frame_dim);
Size new_size = det_frame_dim.getSize() / bin;
if (new_size != prev_size) {
m_acq.bufferFree();
m_acq.setSGImgConfig(img_config, new_size);
}
if (m_bin_chg_cb) {
DEB_TRACE() << "Firing change callback";
Bin hw_bin;
......@@ -806,7 +817,7 @@ Interface::Interface(Espia::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), m_roi(acq, cam), m_flip(cam), m_shutter(cam),
m_bin(acq, cam), m_roi(acq, cam), m_flip(cam), m_shutter(cam),
m_acq_end_cb(cam), m_event_cb(m_event)
{
DEB_CONSTRUCTOR();
......
Supports Markdown
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