Commit 44d632f6 authored by Samuel Debionne's avatar Samuel Debionne

Merge branch 'add_espia_meta_img_config' into 'master'

Add Meta device class and SGImgConfig

See merge request !3
parents 98b967cc 61abefd7
Pipeline #8288 passed with stages
in 7 minutes and 50 seconds
......@@ -54,6 +54,16 @@ enum Register {
RegPixelCount = 0x28, // 10 * 4
};
enum SGImgConfig {
SGImgNorm,
SGImgFlipVert1,
SGImgFlipVert2,
SGImgConcatVert2,
SGImgConcatVertInv2,
};
std::ostream& operator <<(std::ostream& os, SGImgConfig img_config);
inline unsigned long Sec2USec(double sec)
{
if (sec > 0)
......
......@@ -97,6 +97,11 @@ class Acq : public HwFrameCallbackGen, public EventCallbackGen
void registerAcqEndCallback(AcqEndCallback& acq_end_cb);
void unregisterAcqEndCallback(AcqEndCallback& acq_end_cb);
void setSGImgConfig(SGImgConfig sg_img_config,
const Size& det_frame_size);
void getSGImgConfig(SGImgConfig& sg_img_config,
Size& det_frame_size);
void setSGRoi(const Size& det_frame_size, const Roi& roi);
void getSGRoi(Size& det_frame_size, Roi& roi);
......@@ -122,7 +127,9 @@ class Acq : public HwFrameCallbackGen, public EventCallbackGen
AutoMutex acqLock();
void setupSGRoi(const Size& det_frame_size, const Roi& sg_roi);
bool isSGRoiValid(const Size& det_frame_size, const Roi& sg_roi);
bool isSGRoiActive(const Size& det_frame_size, const Roi& sg_roi);
void setupSG();
Dev& m_dev;
......@@ -132,6 +139,7 @@ class Acq : public HwFrameCallbackGen, public EventCallbackGen
int m_real_frame_factor;
int m_real_frame_size;
Size m_det_frame_size;
SGImgConfig m_sg_img_config;
Roi m_sg_roi;
int m_nb_frames;
......@@ -180,6 +188,19 @@ inline AutoMutex Acq::acqLock()
return m_dev.acqLock();
}
inline bool Acq::isSGRoiValid(const Size& det_frame_size, const Roi& sg_roi)
{
return sg_roi.isEmpty() || isSGRoiActive(det_frame_size, sg_roi);
}
inline bool Acq::isSGRoiActive(const Size& det_frame_size, const Roi& sg_roi)
{
int roi_area = Point(sg_roi.getSize()).getArea();
int det_area = Point(det_frame_size).getArea();
bool dest_size_match = (sg_roi.getSize() == m_frame_dim.getSize());
return !sg_roi.isEmpty() && (roi_area < det_area) && dest_size_match;
}
} // namespace Espia
std::ostream& operator <<(std::ostream& os,
......
......@@ -52,7 +52,7 @@ class Dev
public:
Dev(int dev_nb);
~Dev();
virtual ~Dev();
operator espia_t();
......@@ -62,7 +62,7 @@ class Dev
void registerCallback(struct espia_cb_data& cb_data, int& cb_nr);
void unregisterCallback(int& cb_nr);
void resetLink();
virtual void resetLink();
void getCcdStatus(int& ccd_status);
AutoMutex acqLock();
......@@ -118,6 +118,36 @@ inline AutoMutex Dev::acqLock()
}
class Meta : public Dev
{
DEB_CLASS_NAMESPC(DebModEspia, "Meta", "Espia");
public:
typedef std::vector<int> DevNbList;
Meta(DevNbList dev_nb_list);
virtual void resetLink();
int getNbDevs();
Dev& getDev(int dev_idx);
private:
typedef std::vector<AutoPtr<Dev> > DevList;
DevList m_dev_list;
};
inline int Meta::getNbDevs()
{
return m_dev_list.size();
}
inline Dev& Meta::getDev(int dev_idx)
{
return *m_dev_list.at(dev_idx);
}
} // namespace Espia
} // namespace lima
......
......@@ -45,6 +45,14 @@ enum Register {
RegPixelCount = 0x28, // 10 * 4
};
enum SGImgConfig {
SGImgNorm,
SGImgFlipVert1,
SGImgFlipVert2,
SGImgConcatVert2,
SGImgConcatVertInv2,
};
unsigned long Sec2USec(double sec);
double USec2Sec(unsigned long usec);
std::string StrError(int ret);
......
......@@ -92,6 +92,11 @@ using namespace lima;
void registerAcqEndCallback(Espia::AcqEndCallback& acq_end_cb);
void unregisterAcqEndCallback(Espia::AcqEndCallback& acq_end_cb);
void setSGImgConfig(Espia::SGImgConfig sg_img_config,
const Size& det_frame_size);
void getSGImgConfig(Espia::SGImgConfig& sg_img_config /Out/,
Size& det_frame_size /Out/);
void setSGRoi(const Size& det_frame_size, const Roi& roi);
void getSGRoi(Size& det_frame_size /Out/, Roi& roi /Out/);
......
......@@ -31,12 +31,12 @@ using namespace lima;
%End
public:
Dev(int dev_nb);
~Dev();
virtual ~Dev();
int getDevNb();
bool isMeta();
void resetLink();
virtual void resetLink();
void getCcdStatus(int& ccd_status);
void setDebugLevels(int lib_deb_lvl, int drv_deb_lvl);
......@@ -55,5 +55,20 @@ using namespace lima;
void getChanUpLed(int &chan_up_led /Out/);
};
class Meta : public Espia::Dev
{
%TypeHeaderCode
#include <EspiaDev.h>
using namespace lima;
%End
public:
Meta(std::vector<int> dev_nb_list);
virtual void resetLink();
int getNbDevs();
Espia::Dev& getDev(int dev_idx);
};
}; // namespace Espia
......@@ -22,9 +22,23 @@
#include "Espia.h"
using namespace lima;
using namespace lima::Espia;
using namespace std;
std::ostream& lima::Espia::operator <<(std::ostream& os, SGImgConfig img_config)
{
const char *name = "Unknown";
switch (img_config) {
case SGImgNorm: name = "SGImgNorm"; break;
case SGImgFlipVert1: name = "SGImgFlipVert1"; break;
case SGImgFlipVert2: name = "SGImgFlipVert2"; break;
case SGImgConcatVert2: name = "SGImgConcatVert2"; break;
case SGImgConcatVertInv2: name = "SGImgConcatVertInv2"; break;
}
return os << name;
}
string lima::Espia::StrError(int ret)
{
return espia_strerror(ret);
......
......@@ -81,6 +81,7 @@ Acq::Acq(Dev& dev)
os << "Acq#" << dev.getDevNb();
DEB_SET_OBJ_NAME(os.str());
m_sg_img_config = SGImgNorm;
m_nb_buffers = m_nb_buffer_frames = 0;
m_real_frame_factor = m_real_frame_size = 0;
......@@ -320,8 +321,7 @@ void Acq::bufferAlloc(int& nb_buffers, int nb_buffer_frames,
m_real_frame_factor = frame_factor;
m_real_frame_size = real_frame_size;
if (!m_sg_roi.isEmpty())
setupSGRoi(m_det_frame_size, m_sg_roi);
setupSG();
DEB_RETURN() << DEB_VAR1(nb_buffers);
}
......@@ -545,16 +545,46 @@ void Acq::unregisterAcqEndCallback(AcqEndCallback& acq_end_cb)
acq_end_cb.setAcq(NULL);
}
void Acq::setSGRoi(const Size& det_frame_size, const Roi& sg_roi)
void Acq::setSGImgConfig(SGImgConfig sg_img_config,
const Size& det_frame_size)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR2(det_frame_size, sg_roi);
DEB_PARAM() << DEB_VAR4(sg_img_config, det_frame_size,
m_det_frame_size, m_sg_roi);
bool roi_active = isSGRoiActive(m_det_frame_size, m_sg_roi);
if (roi_active && (sg_img_config != SGImgNorm))
THROW_HW_ERROR(NotSupported)
<< "SGRoi is active: only available with SGImgNorm";
m_sg_img_config = sg_img_config;
m_det_frame_size = det_frame_size;
setupSG();
}
void Acq::getSGImgConfig(SGImgConfig& sg_img_config,
Size& det_frame_size)
{
DEB_MEMBER_FUNCT();
sg_img_config = m_sg_img_config;
det_frame_size = m_det_frame_size;
DEB_RETURN() << DEB_VAR2(sg_img_config, det_frame_size);
}
void Acq::setSGRoi(const Size& det_frame_size, const Roi& sg_roi)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR3(m_sg_img_config, det_frame_size, sg_roi);
bool roi_active = isSGRoiActive(det_frame_size, sg_roi);
if (roi_active && (m_sg_img_config != SGImgNorm))
THROW_HW_ERROR(NotSupported)
<< "SGRoi only available with SGImgNorm";
if (roi_active)
m_det_frame_size = det_frame_size;
m_sg_roi = sg_roi;
bool size_match = (sg_roi.getSize() == m_frame_dim.getSize());
if ((m_nb_buffers > 0) && (sg_roi.isEmpty() || size_match))
setupSGRoi(det_frame_size, m_sg_roi);
setupSG();
}
void Acq::getSGRoi(Size& det_frame_size, Roi& sg_roi)
......@@ -565,39 +595,40 @@ void Acq::getSGRoi(Size& det_frame_size, Roi& sg_roi)
DEB_RETURN() << DEB_VAR2(det_frame_size, sg_roi);
}
void Acq::setupSGRoi(const Size& det_frame_size, const Roi& sg_roi)
void Acq::setupSG()
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR3(det_frame_size, sg_roi, m_frame_dim);
DEB_PARAM() << DEB_VAR4(m_sg_img_config, m_det_frame_size, m_sg_roi,
m_frame_dim);
if ((m_nb_buffers == 0) || !isSGRoiValid(m_det_frame_size, m_sg_roi))
return;
struct scdxipci_sg_table *sg_list;
struct espia_frame_dim eframe_dim;
struct espia_roi eroi, *eroi_ptr;
eframe_dim.width = det_frame_size.getWidth();
eframe_dim.height = det_frame_size.getHeight();
eframe_dim.width = m_det_frame_size.getWidth();
eframe_dim.height = m_det_frame_size.getHeight();
eframe_dim.depth = m_frame_dim.getDepth();
if (sg_roi.isEmpty()) {
eroi_ptr = NULL;
} else {
Size roi_size = sg_roi.getSize();
eroi.left = sg_roi.getTopLeft().x;
eroi.top = sg_roi.getTopLeft().y;
if (isSGRoiActive(m_det_frame_size, m_sg_roi)) {
Size roi_size = m_sg_roi.getSize();
eroi.left = m_sg_roi.getTopLeft().x;
eroi.top = m_sg_roi.getTopLeft().y;
eroi.width = roi_size.getWidth();
eroi.height = roi_size.getHeight();
eroi_ptr = &eroi;
} else {
eroi_ptr = NULL;
}
int nr_dev;
CHECK_CALL(espia_create_sg(m_dev, ESPIA_SG_NORM, &eframe_dim, eroi_ptr,
&sg_list, &nr_dev));
CHECK_CALL(espia_create_sg(m_dev, m_sg_img_config, &eframe_dim,
eroi_ptr, &sg_list, &nr_dev));
try {
if (nr_dev > 1)
THROW_HW_ERROR(Error) << "espia_create_sg retured "
<< DEB_VAR1(nr_dev);
CHECK_CALL(espia_set_sg(m_dev, 0, &sg_list[0]));
for (int i = 0; i < nr_dev; ++i)
CHECK_CALL(espia_set_sg(m_dev, i, &sg_list[i]));
} catch (...) {
espia_release_sg(m_dev, sg_list, nr_dev);
throw;
......
......@@ -336,3 +336,23 @@ void Dev::getChanUpLed(int& chan_up_led)
}
Meta::Meta(DevNbList dev_nb_list)
: Dev(MetaDev)
{
DEB_CONSTRUCTOR();
DevNbList::const_iterator it, end = dev_nb_list.end();
for (it = dev_nb_list.begin(); it != end; ++it)
m_dev_list.push_back(new Dev(*it));
CHECK_CALL(espia_set_dev(*this, &dev_nb_list[0], dev_nb_list.size()));
}
void Meta::resetLink()
{
DEB_MEMBER_FUNCT();
DevList::const_iterator it, end = m_dev_list.end();
for (it = m_dev_list.begin(); it != end; ++it)
(*it)->resetLink();
}
Markdown is supported
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