Commit ccc2db10 authored by Alejandro Homs Puron's avatar Alejandro Homs Puron Committed by operator for beamline
Browse files

Add Model::RecvPort, rename Eiger::RecvPortGeometry to Eiger::RecvPort

* Implements & closes #8
parent c0d612e3
......@@ -72,14 +72,14 @@ public:
{ return m_det->getNMods(); }
int getTotNbPorts()
{ return m_recv_list.size() * m_recv_nb_ports; }
{ return m_recv_list.size() * m_nb_recv_ports; }
int getPortIndex(int recv_idx, int port)
{ return recv_idx * m_recv_nb_ports + port; }
{ return recv_idx * m_nb_recv_ports + port; }
std::pair<int, int> splitPortIndex(int port_idx)
{ return std::pair<int, int>(port_idx / m_recv_nb_ports,
port_idx % m_recv_nb_ports); }
{ return std::pair<int, int>(port_idx / m_nb_recv_ports,
port_idx % m_nb_recv_ports); }
void setBufferCtrlObj(NumaSoftBufferCtrlObj *buffer_ctrl_obj)
{ m_buffer_ctrl_obj = buffer_ctrl_obj; }
......@@ -287,7 +287,7 @@ private:
AutoPtr<AppInputData> m_input_data;
AutoPtr<slsDetectorUsers> m_det;
FrameMap m_frame_map;
int m_recv_nb_ports;
int m_nb_recv_ports;
RecvList m_recv_list;
int m_recv_fifo_depth;
TrigMode m_trig_mode;
......
......@@ -111,28 +111,26 @@ class Eiger : public Model
virtual bool checkSettings(Settings settings);
virtual int getRecvPorts();
virtual int getNbRecvPorts();
virtual Model::RecvPort *getRecvPort(int port_idx);
virtual void prepareAcq();
virtual void processRecvFileStart(int port_idx, uint32_t dsize);
virtual void processRecvPort(int port_idx, FrameType frame, char *dptr,
uint32_t dsize, char *bptr);
private:
friend class Correction;
friend class CorrBase;
class RecvPortGeometry
class RecvPort : public Model::RecvPort
{
DEB_CLASS_NAMESPC(DebModCamera, "Eiger::RecvPortGeometry",
DEB_CLASS_NAMESPC(DebModCamera, "Eiger::RecvPort",
"SlsDetector");
public:
RecvPortGeometry(Eiger *eiger, int recv_idx, int port);
RecvPort(Eiger *eiger, int recv_idx, int port);
void prepareAcq();
void processRecvFileStart(uint32_t dsize);
void processRecvPort(FrameType frame, char *dptr, char *bptr);
virtual void processRecvFileStart(uint32_t dsize);
virtual void processRecvPort(FrameType frame, char *dptr,
uint32_t dsize, char *bptr);
void expandPixelDepth4(FrameType frame, char *ptr);
private:
......@@ -149,7 +147,7 @@ class Eiger : public Model
int m_pchips;
};
typedef std::vector<AutoPtr<RecvPortGeometry> > PortGeometryList;
typedef std::vector<AutoPtr<RecvPort> > RecvPortList;
class CorrBase
{
......@@ -209,7 +207,7 @@ class Eiger : public Model
virtual void correctFrame(FrameType frame, void *ptr);
protected:
PortGeometryList& m_port_geom_list;
RecvPortList& m_recv_port_list;
};
class InterModGapCorr : public CorrBase
......@@ -361,7 +359,7 @@ class Eiger : public Model
static const int ChipSize;
static const int ChipGap;
static const int HalfModuleChips;
static const int RecvPorts;
static const int NbRecvPorts;
struct LinScale {
double factor, offset;
......@@ -381,7 +379,7 @@ class Eiger : public Model
FrameDim m_recv_frame_dim;
CorrList m_corr_list;
PortGeometryList m_port_geom_list;
RecvPortList m_recv_port_list;
bool m_fixed_clock_div;
ClockDiv m_clock_div;
};
......
......@@ -42,6 +42,19 @@ class Model
{
DEB_CLASS_NAMESPC(DebModCamera, "Model", "SlsDetector");
public:
class RecvPort
{
DEB_CLASS_NAMESPC(DebModCamera, "Model::RecvPort",
"SlsDetector");
public:
virtual ~RecvPort();
virtual void processRecvFileStart(uint32_t dsize) = 0;
// TODO: add file finished callback
virtual void processRecvPort(FrameType frame, char *dptr,
uint32_t dsize, char *bptr) = 0;
};
typedef Defs::Settings Settings;
Model(Camera *cam, Type type);
......@@ -83,13 +96,10 @@ class Model
virtual bool checkSettings(Settings settings) = 0;
virtual int getRecvPorts() = 0;
virtual int getNbRecvPorts() = 0;
virtual RecvPort *getRecvPort(int port_idx) = 0;
virtual void prepareAcq() = 0;
virtual void processRecvFileStart(int port_idx, uint32_t dsize) = 0;
// TODO: add file finished callback
virtual void processRecvPort(int port_idx, FrameType frame, char *dptr,
uint32_t dsize, char *bptr) = 0;
private:
friend class Camera;
......
......@@ -95,12 +95,10 @@ class Eiger : public SlsDetector::Model
virtual bool checkSettings(SlsDetector::Defs::Settings settings);
virtual int getRecvPorts();
virtual int getNbRecvPorts();
virtual SlsDetector::Model::RecvPort *getRecvPort(int port_idx);
virtual void prepareAcq();
virtual void processRecvFileStart(int port_idx, unsigned int dsize);
virtual void processRecvPort(int port_idx, unsigned long frame,
char *dptr, unsigned int dsize, char *bptr);
};
}; // namespace SlsDetector
......@@ -31,6 +31,16 @@ class Model
{
public:
class RecvPort
{
public:
virtual ~RecvPort();
virtual void processRecvFileStart(unsigned int dsize) = 0;
virtual void processRecvPort(unsigned long frame, char *dptr,
unsigned int dsize, char *bptr) = 0;
};
Model(SlsDetector::Camera *cam, SlsDetector::Type type);
virtual ~Model();
......@@ -66,13 +76,10 @@ protected:
virtual
bool checkSettings(SlsDetector::Defs::Settings settings) = 0;
virtual int getRecvPorts() = 0;
virtual int getNbRecvPorts() = 0;
virtual SlsDetector::Model::RecvPort *getRecvPort(int port_idx) = 0;
virtual void prepareAcq() = 0;
virtual void processRecvFileStart(int port_idx, unsigned int dsize) = 0;
virtual void processRecvPort(int port_idx, unsigned long frame,
char *dptr, unsigned int dsize,
char *bptr) = 0;
};
......
......@@ -300,7 +300,7 @@ Camera::Camera(string config_fname)
m_skip_frame_freq(0),
m_last_skipped_frame_timeout(0.5),
m_lat_time(0),
m_recv_nb_ports(0),
m_nb_recv_ports(0),
m_pixel_depth(PixelDepth16),
m_image_type(Bpp16),
m_raw_mode(false),
......@@ -397,13 +397,13 @@ void Camera::setModel(Model *model)
if (!m_model)
return;
m_recv_nb_ports = m_model->getRecvPorts();
m_nb_recv_ports = m_model->getNbRecvPorts();
int nb_ports = getTotNbPorts();
m_frame_map.setNbItems(nb_ports);
RecvList::iterator it, end = m_recv_list.end();
for (it = m_recv_list.begin(); it != end; ++it)
(*it)->setNbPorts(m_recv_nb_ports);
(*it)->setNbPorts(m_nb_recv_ports);
setPixelDepth(m_pixel_depth);
setSettings(m_settings);
......
......@@ -31,7 +31,7 @@ using namespace lima::SlsDetector::Defs;
const int Eiger::ChipSize = 256;
const int Eiger::ChipGap = 2;
const int Eiger::HalfModuleChips = 4;
const int Eiger::RecvPorts = 2;
const int Eiger::NbRecvPorts = 2;
const int Eiger::BitsPerXfer = 4;
const int Eiger::SuperColNbCols = 8;
......@@ -114,8 +114,10 @@ void Eiger::BadRecvFrameCorr::correctFrame(FrameType frame, void *ptr)
m_cam->getBadFrameList(i, last_idx, bad_frames, bfl);
}
IntList::iterator end = bfl.end();
if (find(bfl.begin(), end, frame) != end)
m_eiger->processRecvPort(i, frame, NULL, 0, bptr);
if (find(bfl.begin(), end, frame) != end) {
Model::RecvPort *port = m_eiger->getRecvPort(i);
port->processRecvPort(frame, NULL, 0, bptr);
}
if (*(end - 1) > int(frame))
continue;
last_idx += bfl.size();
......@@ -124,7 +126,7 @@ void Eiger::BadRecvFrameCorr::correctFrame(FrameType frame, void *ptr)
}
Eiger::PixelDepth4Corr::PixelDepth4Corr(Eiger *eiger)
: CorrBase(eiger), m_port_geom_list(eiger->m_port_geom_list)
: CorrBase(eiger), m_recv_port_list(eiger->m_recv_port_list)
{
DEB_CONSTRUCTOR();
}
......@@ -133,8 +135,8 @@ void Eiger::PixelDepth4Corr::correctFrame(FrameType frame, void *ptr)
{
DEB_MEMBER_FUNCT();
PortGeometryList::iterator it, end = m_port_geom_list.end();
for (it = m_port_geom_list.begin(); it != end; ++it)
RecvPortList::iterator it, end = m_recv_port_list.end();
for (it = m_recv_port_list.begin(); it != end; ++it)
(*it)->expandPixelDepth4(frame, (char *) ptr);
}
......@@ -209,7 +211,7 @@ Data Eiger::Correction::process(Data& data)
return ret;
}
Eiger::RecvPortGeometry::RecvPortGeometry(Eiger *eiger, int recv_idx, int port)
Eiger::RecvPort::RecvPort(Eiger *eiger, int recv_idx, int port)
: m_eiger(eiger), m_port(port), m_recv_idx(recv_idx)
{
DEB_CONSTRUCTOR();
......@@ -217,7 +219,7 @@ Eiger::RecvPortGeometry::RecvPortGeometry(Eiger *eiger, int recv_idx, int port)
m_top_half_recv = (m_recv_idx % 2 == 0);
}
void Eiger::RecvPortGeometry::prepareAcq()
void Eiger::RecvPort::prepareAcq()
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(m_recv_idx);
......@@ -229,7 +231,7 @@ void Eiger::RecvPortGeometry::prepareAcq()
int recv_size = frame_dim.getMemSize();
m_port_offset = recv_size * m_recv_idx;
m_pchips = HalfModuleChips / RecvPorts;
m_pchips = HalfModuleChips / NbRecvPorts;
m_scw = ChipSize * depth;
m_dcw = m_scw;
if (m_eiger->isPixelDepth4())
......@@ -261,14 +263,14 @@ void Eiger::RecvPortGeometry::prepareAcq()
}
}
void Eiger::RecvPortGeometry::processRecvFileStart(uint32_t dsize)
void Eiger::RecvPort::processRecvFileStart(uint32_t dsize)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR2(m_recv_idx, dsize);
}
void Eiger::RecvPortGeometry::processRecvPort(FrameType frame, char *dptr,
char *bptr)
void Eiger::RecvPort::processRecvPort(FrameType frame, char *dptr,
uint32_t dsize, char *bptr)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR3(frame, m_recv_idx, m_port);
......@@ -286,7 +288,7 @@ void Eiger::RecvPortGeometry::processRecvPort(FrameType frame, char *dptr,
}
}
void Eiger::RecvPortGeometry::expandPixelDepth4(FrameType frame, char *ptr)
void Eiger::RecvPort::expandPixelDepth4(FrameType frame, char *ptr)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR3(frame, m_recv_idx, m_port);
......@@ -315,9 +317,9 @@ Eiger::Eiger(Camera *cam)
DEB_TRACE() << "Using Eiger detector, " << DEB_VAR1(nb_det_modules);
for (int i = 0; i < nb_det_modules; ++i) {
for (int j = 0; j < RecvPorts; ++j) {
RecvPortGeometry *g = new RecvPortGeometry(this, i, j);
m_port_geom_list.push_back(g);
for (int j = 0; j < NbRecvPorts; ++j) {
RecvPort *g = new RecvPort(this, i, j);
m_recv_port_list.push_back(g);
}
}
......@@ -353,8 +355,8 @@ void Eiger::getRecvFrameDim(FrameDim& frame_dim, bool raw, bool geom)
frame_dim.setImageType(getCamera()->getImageType());
Size size(ChipSize * HalfModuleChips, ChipSize);
if (raw) {
size /= Point(RecvPorts, 1);
size *= Point(1, RecvPorts);
size /= Point(NbRecvPorts, 1);
size *= Point(1, NbRecvPorts);
} else if (geom) {
size += Point(ChipGap, ChipGap) * Point(3, 1) / Point(1, 2);
}
......@@ -758,11 +760,17 @@ void Eiger::getThresholdEnergy(int& thres)
DEB_RETURN() << DEB_VAR1(thres);
}
int Eiger::getRecvPorts()
int Eiger::getNbRecvPorts()
{
DEB_MEMBER_FUNCT();
DEB_RETURN() << DEB_VAR1(RecvPorts);
return RecvPorts;
DEB_RETURN() << DEB_VAR1(NbRecvPorts);
return NbRecvPorts;
}
Model::RecvPort *Eiger::getRecvPort(int port_idx)
{
DEB_MEMBER_FUNCT();
return m_recv_port_list[port_idx];
}
void Eiger::prepareAcq()
......@@ -775,8 +783,8 @@ void Eiger::prepareAcq()
DEB_TRACE() << DEB_VAR2(raw, m_recv_frame_dim);
PortGeometryList::iterator git, gend = m_port_geom_list.end();
for (git = m_port_geom_list.begin(); git != gend; ++git)
RecvPortList::iterator git, gend = m_recv_port_list.end();
for (git = m_recv_port_list.begin(); git != gend; ++git)
(*git)->prepareAcq();
CorrList::iterator cit, cend = m_corr_list.end();
......@@ -784,21 +792,6 @@ void Eiger::prepareAcq()
(*cit)->prepareAcq();
}
void Eiger::processRecvFileStart(int port_idx, uint32_t dsize)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR2(port_idx, dsize);
m_port_geom_list[port_idx]->processRecvFileStart(dsize);
}
void Eiger::processRecvPort(int port_idx, FrameType frame, char *dptr,
uint32_t dsize, char *bptr)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR3(port_idx, frame, dsize);
m_port_geom_list[port_idx]->processRecvPort(frame, dptr, bptr);
}
Eiger::Correction *Eiger::createCorrectionTask()
{
DEB_MEMBER_FUNCT();
......
......@@ -27,6 +27,11 @@ using namespace lima;
using namespace lima::SlsDetector;
Model::RecvPort::~RecvPort()
{
DEB_DESTRUCTOR();
}
Model::Model(Camera *cam, Type type)
: m_cam(cam), m_type(type), m_det(m_cam->m_det)
{
......
......@@ -94,7 +94,8 @@ void Receiver::Port::prepareAcq()
void Receiver::Port::processFileStart(uint32_t dsize)
{
DEB_MEMBER_FUNCT();
m_model->processRecvFileStart(m_port_idx, dsize);
Model::RecvPort *port = m_model->getRecvPort(m_port_idx);
port->processRecvFileStart(dsize);
}
void Receiver::Port::processFrame(FrameType frame, char *dptr, uint32_t dsize)
......@@ -105,7 +106,8 @@ void Receiver::Port::processFrame(FrameType frame, char *dptr, uint32_t dsize)
bool valid = (dptr != NULL);
if (valid) {
char *bptr = m_cam->getFrameBufferPtr(frame);
m_model->processRecvPort(m_port_idx, frame, dptr, dsize, bptr);
Model::RecvPort *port = m_model->getRecvPort(m_port_idx);
port->processRecvPort(frame, dptr, dsize, bptr);
}
Timestamp t0 = Timestamp::now();
m_frame_map_item->frameFinished(frame, true, valid);
......
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