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

Port to slsDetectorPackage v4.0.1

parent e791b727
......@@ -105,9 +105,9 @@ set(SLS_DETECTOR_DIR ${CMAKE_CURRENT_SOURCE_DIR}/slsDetectorPackage)
set(SLS_DETECTOR_SW ${SLS_DETECTOR_DIR}/slsDetectorSoftware)
set(SLS_DETECTOR_RECV ${SLS_DETECTOR_DIR}/slsReceiverSoftware)
option (USE_TEXTCLIENT "Text Client" ON)
option (USE_RECEIVER "Receiver" ON)
option (USE_GUI "GUI" OFF)
set(SLS_USE_TEXTCLIENT ON CACHE BOOL "Text Client")
set(SLS_USE_RECEIVER ON CACHE BOOL "Receiver")
set(SLS_USE_GUI OFF CACHE BOOL "GUI")
add_subdirectory(${SLS_DETECTOR_DIR})
......@@ -156,7 +156,7 @@ message("NUMA_LIBRARY=" ${NUMA_LIBRARY})
target_link_libraries(slsdetector
PUBLIC limacore
PUBLIC slsDetectorShared slsReceiverShared zmq
PUBLIC slsDetectorShared slsReceiverShared
PUBLIC ${NUMA_LIBRARY}
)
......
......@@ -53,7 +53,7 @@ public:
typedef Defs::DetStatus DetStatus;
typedef Defs::NetworkParameter NetworkParameter;
Camera(std::string config_fname);
Camera(std::string config_fname, int det_id = 0);
Camera(const Camera& o) = delete;
virtual ~Camera();
......@@ -163,7 +163,7 @@ public:
GlobalCPUAffinityMgr::ProcessingFinishedEvent *
getProcessingFinishedEvent();
void reportException(Exception& e, string name);
void reportException(Exception& e, std::string name);
private:
typedef std::map<int, int> RecvPortMap;
......@@ -284,6 +284,7 @@ private:
void setFlowControl10G(bool enabled);
void resetFramesCaught();
int m_det_id;
Model *m_model;
Cond m_cond;
AutoPtr<AppInputData> m_input_data;
......
......@@ -41,6 +41,9 @@ class Receiver
DEB_CLASS_NAMESPC(DebModCamera, "Receiver", "SlsDetector");
public:
typedef slsReceiverDefs::sls_detector_header sls_detector_header;
typedef slsReceiverDefs::sls_receiver_header sls_receiver_header;
Receiver(Camera *cam, int idx, int rx_port);
~Receiver();
......@@ -94,19 +97,7 @@ private:
static int fileStartCallback(char *fpath, char *fname,
FrameType fidx, uint32_t dsize,
void *priv);
static void portCallback(FrameType frame,
uint32_t exp_len,
uint32_t recv_packets,
uint64_t bunch_id,
uint64_t timestamp,
uint16_t mod_id,
uint16_t x, uint16_t y, uint16_t z,
uint32_t debug,
uint16_t rr_nb,
uint8_t det_type,
uint8_t cb_version,
char *dptr,
uint32_t dsize,
static void portCallback(char *header, char *dptr, uint32_t dsize,
void *priv);
int fileStartCallback(char *fpath, char *fname, uint64_t fidx,
......
......@@ -30,7 +30,7 @@ namespace SlsDetector
class Camera : public HwMaxImageSizeCallbackGen, public EventCallbackGen
{
public:
Camera(std::string config_fname);
Camera(std::string config_fname, int det_id = 0);
virtual ~Camera();
SlsDetector::Type getType();
......
Subproject commit 2b43e1e7d428a235fef19da590728d39a9fcd5aa
Subproject commit 1e49ad7dbf2157db333187e0cc04f7d719c67ea0
......@@ -296,8 +296,9 @@ Camera::AcqThread::Status Camera::AcqThread::newFrameReady(FrameType frame)
return Status(cont_acq, acq_end);
}
Camera::Camera(string config_fname)
: m_model(NULL),
Camera::Camera(string config_fname, int det_id)
: m_det_id(det_id),
m_model(NULL),
m_frame_map(this),
m_recv_fifo_depth(1000),
m_lima_nb_frames(1),
......@@ -326,12 +327,14 @@ Camera::Camera(string config_fname)
createReceivers();
DEB_TRACE() << "Creating the slsDetectorUsers object";
m_det = new slsDetectorUsers(0);
int ret;
m_det = new slsDetectorUsers(ret, m_det_id);
DEB_TRACE() << "Reading configuration file";
const char *fname = m_input_data->config_file_name.c_str();
m_det->readConfigurationFile(fname);
m_det->setReceiverSilentMode(1);
m_det->setReceiverFramesDiscardPolicy("discardpartial");
setReceiverFifoDepth(m_recv_fifo_depth);
m_pixel_depth = PixelDepth(m_det->setBitDepth(-1));
......@@ -365,7 +368,7 @@ Camera::~Camera()
Type Camera::getType()
{
DEB_MEMBER_FUNCT();
string type_resp = getCmd("type");
string type_resp = m_det->getDetectorType();
ostringstream os;
os << "(([^+]+)\\+){" << getNbDetModules() << "}";
DEB_TRACE() << DEB_VAR1(os.str());
......
......@@ -106,7 +106,6 @@ Receiver::Receiver(Camera *cam, int idx, int rx_port)
m_recv->registerCallBackStartAcquisition(fileStartCallback, this);
m_recv->registerCallBackRawDataReady(portCallback, this);
m_recv->setFrameEventPolicy(slsReceiverUsers::SkipMissingFrames);
}
Receiver::~Receiver()
......@@ -332,26 +331,20 @@ int Receiver::fileStartCallback(char *fpath, char *fname, uint64_t fidx,
return recv->fileStartCallback(fpath, fname, fidx, dsize);
}
void Receiver::portCallback(FrameType frame,
uint32_t exp_len,
uint32_t recv_packets,
uint64_t bunch_id,
uint64_t timestamp,
uint16_t mod_id,
uint16_t x, uint16_t y, uint16_t z,
uint32_t debug,
uint16_t rr_nb,
uint8_t det_type,
uint8_t cb_version,
char *dptr,
uint32_t dsize,
void Receiver::portCallback(char *header, char *dptr, uint32_t dsize,
void *priv)
{
DEB_STATIC_FUNCT();
Receiver *recv = static_cast<Receiver *>(priv);
int port = (x % 2);
sls_receiver_header *recv_header = (sls_receiver_header *) header;
sls_detector_header *det_header = &recv_header->detHeader;
DEB_TRACE() << DEB_VAR3(det_header->frameNumber,
det_header->row, det_header->column);
const FrameType& frame = det_header->frameNumber;
const uint16_t& col = det_header->column;
int port = (col % 2);
FrameType det_frame = frame - 1;
DEB_PARAM() << DEB_VAR2(frame, det_frame);
DEB_TRACE() << DEB_VAR4(frame, det_frame, recv->m_idx, port);
int nb_ports = recv->m_port_list.size();
if ((port >= nb_ports) || (recv->m_cam->getState() == Stopping))
......
......@@ -63,7 +63,8 @@ class TestApp
class ArgOptBase
{
public:
ArgOptBase(string sopt, string lopt, string extra = "")
ArgOptBase(std::string sopt, std::string lopt,
std::string extra = "")
: m_sopt(sopt), m_lopt(lopt), m_extra(extra)
{}
virtual ~ArgOptBase()
......@@ -75,36 +76,39 @@ class TestApp
{ return !m_extra.empty(); }
protected:
string m_sopt;
string m_lopt;
string m_extra;
std::string m_sopt;
std::string m_lopt;
std::string m_extra;
};
template <class T>
class ArgOpt : public ArgOptBase
{
public:
ArgOpt(T& var, string sopt, string lopt, string extra = "")
ArgOpt(T& var, std::string sopt, std::string lopt,
std::string extra = "")
: ArgOptBase(sopt, lopt, extra), m_var(var)
{
if (!hasExtra()) {
istringstream is("0");
std::istringstream is("0");
is >> m_var;
}
}
virtual bool check(Args& args)
{
string s = args[0];
std::string s = args[0];
if ((s != m_sopt) && (s != m_lopt))
return false;
args.pop_front();
if (hasExtra() && !args) {
cerr << "Missing " << m_extra << endl;
std::cerr << "Missing " << m_extra
<< std::endl;
exit(1);
}
s = hasExtra() ? args.pop_front() : string("1");
istringstream is(s);
s = (hasExtra() ? args.pop_front() :
std::string("1"));
std::istringstream is(s);
is >> m_var;
return true;
}
......@@ -124,11 +128,12 @@ class TestApp
class EdfHeaderKey
{
public:
EdfHeaderKey(const string& key) : m_key(key)
EdfHeaderKey(const std::string& key) : m_key(key)
{}
private:
friend ostream& operator <<(ostream& os, const EdfHeaderKey& h);
string m_key;
friend std::ostream& operator <<(std::ostream& os,
const EdfHeaderKey& h);
std::string m_key;
};
TestApp(int argc, char *argv[]);
......@@ -153,7 +158,7 @@ class TestApp
void save_raw_data(int start_frame, int nb_frames);
void save_edf_data(int start_frame, int nb_frames);
void save_edf_frame(ofstream& of, int acq_idx, int edf_idx);
void save_edf_frame(std::ofstream& of, int acq_idx, int edf_idx);
Pars m_pars;
AutoPtr<NumaSoftBufferCtrlObj> m_buffer_ctrl_obj;
......@@ -164,8 +169,9 @@ class TestApp
Timestamp m_last_msg_timestamp;
};
ostream& operator <<(ostream& os, const TestApp::EdfHeaderKey& h)
std::ostream& operator <<(std::ostream& os, const TestApp::EdfHeaderKey& h)
{
using namespace std;
return os << setiosflags(ios::left) << resetiosflags(ios::right)
<< setw(14) << setfill(' ') << h.m_key << " = ";
}
......
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