mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-25 07:40:03 +02:00
merge conflict resolved
This commit is contained in:
commit
70a1b87603
2
.clang-format
Normal file
2
.clang-format
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
BasedOnStyle: LLVM
|
||||||
|
IndentWidth: 4
|
@ -14,8 +14,8 @@ else ()
|
|||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 ")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 ")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
|
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=thread")
|
||||||
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
|
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=thread")
|
||||||
|
|
||||||
find_package(Qt4)
|
find_package(Qt4)
|
||||||
find_package(Qwt 6)
|
find_package(Qwt 6)
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -400,7 +400,7 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
|
|||||||
thisDetector->nTrimEn = 0;
|
thisDetector->nTrimEn = 0;
|
||||||
for(int i = 0; i < MAX_TRIMEN; ++i)
|
for(int i = 0; i < MAX_TRIMEN; ++i)
|
||||||
thisDetector->trimEnergies[i] = 0;
|
thisDetector->trimEnergies[i] = 0;
|
||||||
thisDetector->threadedProcessing = 1;
|
// thisDetector->threadedProcessing = 1;
|
||||||
thisDetector->nROI = 0;
|
thisDetector->nROI = 0;
|
||||||
memset(thisDetector->roiLimits, 0, MAX_ROIS * sizeof(ROI));
|
memset(thisDetector->roiLimits, 0, MAX_ROIS * sizeof(ROI));
|
||||||
thisDetector->roFlags = NORMAL_READOUT;
|
thisDetector->roFlags = NORMAL_READOUT;
|
||||||
|
@ -120,7 +120,7 @@ private:
|
|||||||
|
|
||||||
/** threaded processing flag
|
/** threaded processing flag
|
||||||
* (i.e. if data are processed in a separate thread) */
|
* (i.e. if data are processed in a separate thread) */
|
||||||
int threadedProcessing;
|
// int threadedProcessing;
|
||||||
|
|
||||||
/** number of rois defined */
|
/** number of rois defined */
|
||||||
int nROI;
|
int nROI;
|
||||||
|
@ -819,12 +819,12 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
|||||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdRateCorr;
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdRateCorr;
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
/*! \page data
|
// /*! \page data
|
||||||
- <b>threaded [i]</b> Sets/gets the data processing threaded flag. 1 is threaded, 0 unthreaded.
|
// - <b>threaded [i]</b> Sets/gets the data processing threaded flag. 1 is threaded, 0 unthreaded.
|
||||||
*/
|
// */
|
||||||
descrToFuncMap[i].m_pFuncName="threaded"; //
|
// descrToFuncMap[i].m_pFuncName="threaded"; //
|
||||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdThreaded;
|
// descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdThreaded;
|
||||||
++i;
|
// ++i;
|
||||||
|
|
||||||
/*! \page data
|
/*! \page data
|
||||||
- <b>darkimage fn</b> Loads the dark image to the detector from file fn (pedestal image). Cannot get. For Gotthard only.
|
- <b>darkimage fn</b> Loads the dark image to the detector from file fn (pedestal image). Cannot get. For Gotthard only.
|
||||||
@ -2154,21 +2154,21 @@ string slsDetectorCommand::cmdData(int narg, char *args[], int action, int detPo
|
|||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n");
|
cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n");
|
||||||
#endif
|
#endif
|
||||||
int b;
|
//int b;
|
||||||
if (action==PUT_ACTION) {
|
if (action==PUT_ACTION) {
|
||||||
return string("cannot set");
|
return string("cannot set");
|
||||||
} else if (action==HELP_ACTION) {
|
} else if (action==HELP_ACTION) {
|
||||||
return helpData(HELP_ACTION);
|
return helpData(HELP_ACTION);
|
||||||
} else {
|
} else {
|
||||||
b=myDet->setThreadedProcessing(-1);
|
// b=myDet->setThreadedProcessing(-1);
|
||||||
myDet->setThreadedProcessing(0);
|
// myDet->setThreadedProcessing(0);
|
||||||
myDet->setOnline(ONLINE_FLAG, detPos);
|
// myDet->setOnline(ONLINE_FLAG, detPos);
|
||||||
myDet->setReceiverOnline(ONLINE_FLAG, detPos);
|
// myDet->setReceiverOnline(ONLINE_FLAG, detPos);
|
||||||
myDet->readAll(detPos);
|
// myDet->readAll(detPos);
|
||||||
//processdata in receiver is useful only for gui purposes
|
// //processdata in receiver is useful only for gui purposes
|
||||||
if(myDet->setReceiverOnline(detPos)==OFFLINE_FLAG)
|
// if(myDet->setReceiverOnline(detPos)==OFFLINE_FLAG)
|
||||||
myDet->processData();
|
// myDet->processData();
|
||||||
myDet->setThreadedProcessing(b);
|
// myDet->setThreadedProcessing(b);
|
||||||
return string("");
|
return string("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2743,21 +2743,21 @@ string slsDetectorCommand::helpRateCorr(int action){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
string slsDetectorCommand::cmdThreaded(int narg, char *args[], int action, int detPos){
|
// string slsDetectorCommand::cmdThreaded(int narg, char *args[], int action, int detPos){
|
||||||
int ival;
|
// int ival;
|
||||||
char answer[1000];
|
// char answer[1000];
|
||||||
|
|
||||||
if (action==HELP_ACTION)
|
// if (action==HELP_ACTION)
|
||||||
return helpThreaded(action);
|
// return helpThreaded(action);
|
||||||
|
|
||||||
if (action==PUT_ACTION) {
|
// if (action==PUT_ACTION) {
|
||||||
if (sscanf(args[1],"%d",&ival))
|
// if (sscanf(args[1],"%d",&ival))
|
||||||
myDet->setThreadedProcessing(ival);
|
// myDet->setThreadedProcessing(ival);
|
||||||
}
|
// }
|
||||||
sprintf(answer,"%d",myDet->setThreadedProcessing());
|
// sprintf(answer,"%d",myDet->setThreadedProcessing());
|
||||||
return string(answer);
|
// return string(answer);
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
string slsDetectorCommand::helpThreaded(int action){
|
string slsDetectorCommand::helpThreaded(int action){
|
||||||
|
@ -113,7 +113,7 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
|
|||||||
std::string cmdFileName(int narg, char *args[], int action, int detPos = -1);
|
std::string cmdFileName(int narg, char *args[], int action, int detPos = -1);
|
||||||
std::string cmdFileIndex(int narg, char *args[], int action, int detPos = -1);
|
std::string cmdFileIndex(int narg, char *args[], int action, int detPos = -1);
|
||||||
std::string cmdRateCorr(int narg, char *args[], int action, int detPos = -1);
|
std::string cmdRateCorr(int narg, char *args[], int action, int detPos = -1);
|
||||||
std::string cmdThreaded(int narg, char *args[], int action, int detPos = -1);
|
// std::string cmdThreaded(int narg, char *args[], int action, int detPos = -1);
|
||||||
std::string cmdNetworkParameter(int narg, char *args[], int action, int detPos = -1);
|
std::string cmdNetworkParameter(int narg, char *args[], int action, int detPos = -1);
|
||||||
std::string cmdPort(int narg, char *args[], int action, int detPos = -1);
|
std::string cmdPort(int narg, char *args[], int action, int detPos = -1);
|
||||||
std::string cmdLock(int narg, char *args[], int action, int detPos = -1);
|
std::string cmdLock(int narg, char *args[], int action, int detPos = -1);
|
||||||
|
@ -42,7 +42,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
* @param dataModifyReadycb pointer to data ready call back function with modified
|
* @param dataModifyReadycb pointer to data ready call back function with modified
|
||||||
* @param pDataReadycb pointer to arguments of data ready call back function. To write/stream a smaller size of processed data, change this value (only smaller value is allowed).
|
* @param pDataReadycb pointer to arguments of data ready call back function. To write/stream a smaller size of processed data, change this value (only smaller value is allowed).
|
||||||
*/
|
*/
|
||||||
DataProcessor(int ind, detectorType dtype, Fifo*& f, fileFormat* ftype,
|
DataProcessor(int ind, detectorType dtype, Fifo* f, fileFormat* ftype,
|
||||||
bool fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr,
|
bool fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr,
|
||||||
uint32_t* freq, uint32_t* timer,
|
uint32_t* freq, uint32_t* timer,
|
||||||
bool* fp, bool* act, bool* depaden, bool* sm,
|
bool* fp, bool* act, bool* depaden, bool* sm,
|
||||||
@ -121,7 +121,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
* Set Fifo pointer to the one given
|
* Set Fifo pointer to the one given
|
||||||
* @param f address of Fifo pointer
|
* @param f address of Fifo pointer
|
||||||
*/
|
*/
|
||||||
void SetFifo(Fifo*& f);
|
void SetFifo(Fifo* f);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset parameters for new acquisition (including all scans)
|
* Reset parameters for new acquisition (including all scans)
|
||||||
|
@ -31,7 +31,7 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
* @param ajh additional json header
|
* @param ajh additional json header
|
||||||
* @param sm pointer to silent mode
|
* @param sm pointer to silent mode
|
||||||
*/
|
*/
|
||||||
DataStreamer(int ind, Fifo*& f, uint32_t* dr, std::vector<ROI>* r,
|
DataStreamer(int ind, Fifo* f, uint32_t* dr, std::vector<ROI>* r,
|
||||||
uint64_t* fi, int* fd, char* ajh, bool* sm);
|
uint64_t* fi, int* fd, char* ajh, bool* sm);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,7 +63,7 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
* Set Fifo pointer to the one given
|
* Set Fifo pointer to the one given
|
||||||
* @param f address of Fifo pointer
|
* @param f address of Fifo pointer
|
||||||
*/
|
*/
|
||||||
void SetFifo(Fifo*& f);
|
void SetFifo(Fifo* f);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset parameters for new acquisition (including all scans)
|
* Reset parameters for new acquisition (including all scans)
|
||||||
|
@ -37,7 +37,7 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
* @param depaden pointer to deactivated padding enable
|
* @param depaden pointer to deactivated padding enable
|
||||||
* @param sm pointer to silent mode
|
* @param sm pointer to silent mode
|
||||||
*/
|
*/
|
||||||
Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s,
|
Listener(int ind, detectorType dtype, Fifo* f, runStatus* s,
|
||||||
uint32_t* portno, char* e, uint64_t* nf, uint32_t* dr,
|
uint32_t* portno, char* e, uint64_t* nf, uint32_t* dr,
|
||||||
uint32_t* us, uint32_t* as, uint32_t* fpf,
|
uint32_t* us, uint32_t* as, uint32_t* fpf,
|
||||||
frameDiscardPolicy* fdp, bool* act, bool* depaden, bool* sm);
|
frameDiscardPolicy* fdp, bool* act, bool* depaden, bool* sm);
|
||||||
@ -96,7 +96,7 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
* Set Fifo pointer to the one given
|
* Set Fifo pointer to the one given
|
||||||
* @param f address of Fifo pointer
|
* @param f address of Fifo pointer
|
||||||
*/
|
*/
|
||||||
void SetFifo(Fifo*& f);
|
void SetFifo(Fifo* f);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset parameters for new acquisition (including all scans)
|
* Reset parameters for new acquisition (including all scans)
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
#include "receiver_defs.h"
|
#include "receiver_defs.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
#include "container_utils.h"
|
||||||
class GeneralData;
|
class GeneralData;
|
||||||
class Listener;
|
class Listener;
|
||||||
class DataProcessor;
|
class DataProcessor;
|
||||||
@ -18,6 +18,7 @@ class Fifo;
|
|||||||
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class slsReceiverImplementation: private virtual slsDetectorDefs {
|
class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||||
public:
|
public:
|
||||||
@ -767,8 +768,6 @@ private:
|
|||||||
//*** receiver parameters ***
|
//*** receiver parameters ***
|
||||||
/** Number of Threads */
|
/** Number of Threads */
|
||||||
int numThreads;
|
int numThreads;
|
||||||
/** Number of Jobs */
|
|
||||||
int numberofJobs;
|
|
||||||
/** Number of channels in roi for jungfrauctb */
|
/** Number of channels in roi for jungfrauctb */
|
||||||
uint32_t nroichannels;
|
uint32_t nroichannels;
|
||||||
/** Maximum Number of Listening Threads/ UDP Ports */
|
/** Maximum Number of Listening Threads/ UDP Ports */
|
||||||
@ -832,13 +831,13 @@ private:
|
|||||||
/** General Data Properties */
|
/** General Data Properties */
|
||||||
GeneralData* generalData;
|
GeneralData* generalData;
|
||||||
/** Listener Objects that listen to UDP and push into fifo */
|
/** Listener Objects that listen to UDP and push into fifo */
|
||||||
std::vector <Listener*> listener;
|
std::vector<std::unique_ptr<Listener>> listener;
|
||||||
/** DataProcessor Objects that pull from fifo and process data */
|
/** DataProcessor Objects that pull from fifo and process data */
|
||||||
std::vector <DataProcessor*> dataProcessor;
|
std::vector<std::unique_ptr<DataProcessor>> dataProcessor;
|
||||||
/** DataStreamer Objects that stream data via ZMQ */
|
/** DataStreamer Objects that stream data via ZMQ */
|
||||||
std::vector <DataStreamer*> dataStreamer;
|
std::vector<std::unique_ptr<DataStreamer>> dataStreamer;
|
||||||
/** Fifo Structure to store addresses of memory writes */
|
/** Fifo Structure to store addresses of memory writes */
|
||||||
std::vector <Fifo*> fifo;
|
std::vector<std::unique_ptr<Fifo>> fifo;
|
||||||
|
|
||||||
//***callback parameters***
|
//***callback parameters***
|
||||||
/**
|
/**
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
const std::string DataProcessor::TypeName = "DataProcessor";
|
const std::string DataProcessor::TypeName = "DataProcessor";
|
||||||
|
|
||||||
|
|
||||||
DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo*& f,
|
DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo* f,
|
||||||
fileFormat* ftype, bool fwenable,
|
fileFormat* ftype, bool fwenable,
|
||||||
bool* dsEnable, bool* gpEnable, uint32_t* dr,
|
bool* dsEnable, bool* gpEnable, uint32_t* dr,
|
||||||
uint32_t* freq, uint32_t* timer,
|
uint32_t* freq, uint32_t* timer,
|
||||||
@ -125,7 +125,7 @@ void DataProcessor::StopRunning() {
|
|||||||
runningFlag = false;
|
runningFlag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataProcessor::SetFifo(Fifo*& f) {
|
void DataProcessor::SetFifo(Fifo* f) {
|
||||||
fifo = f;
|
fifo = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
const std::string DataStreamer::TypeName = "DataStreamer";
|
const std::string DataStreamer::TypeName = "DataStreamer";
|
||||||
|
|
||||||
|
|
||||||
DataStreamer::DataStreamer(int ind, Fifo*& f, uint32_t* dr, std::vector<ROI>* r,
|
DataStreamer::DataStreamer(int ind, Fifo* f, uint32_t* dr, std::vector<ROI>* r,
|
||||||
uint64_t* fi, int* fd, char* ajh, bool* sm) :
|
uint64_t* fi, int* fd, char* ajh, bool* sm) :
|
||||||
ThreadObject(ind),
|
ThreadObject(ind),
|
||||||
runningFlag(0),
|
runningFlag(0),
|
||||||
@ -70,7 +70,7 @@ void DataStreamer::StopRunning() {
|
|||||||
runningFlag = false;
|
runningFlag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataStreamer::SetFifo(Fifo*& f) {
|
void DataStreamer::SetFifo(Fifo* f) {
|
||||||
fifo = f;
|
fifo = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
const std::string Listener::TypeName = "Listener";
|
const std::string Listener::TypeName = "Listener";
|
||||||
|
|
||||||
|
|
||||||
Listener::Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s,
|
Listener::Listener(int ind, detectorType dtype, Fifo* f, runStatus* s,
|
||||||
uint32_t* portno, char* e, uint64_t* nf, uint32_t* dr,
|
uint32_t* portno, char* e, uint64_t* nf, uint32_t* dr,
|
||||||
uint32_t* us, uint32_t* as, uint32_t* fpf,
|
uint32_t* us, uint32_t* as, uint32_t* fpf,
|
||||||
frameDiscardPolicy* fdp, bool* act, bool* depaden, bool* sm) :
|
frameDiscardPolicy* fdp, bool* act, bool* depaden, bool* sm) :
|
||||||
@ -108,7 +108,7 @@ void Listener::StopRunning() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Listener::SetFifo(Fifo*& f) {
|
void Listener::SetFifo(Fifo* f) {
|
||||||
fifo = f;
|
fifo = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,20 +42,9 @@ void slsReceiverImplementation::DeleteMembers() {
|
|||||||
generalData=0;
|
generalData=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto* it : listener)
|
|
||||||
delete it;
|
|
||||||
listener.clear();
|
listener.clear();
|
||||||
|
|
||||||
for (auto* it : dataProcessor)
|
|
||||||
delete it;
|
|
||||||
dataProcessor.clear();
|
dataProcessor.clear();
|
||||||
|
|
||||||
for (auto* it : dataStreamer)
|
|
||||||
delete it;
|
|
||||||
dataStreamer.clear();
|
dataStreamer.clear();
|
||||||
|
|
||||||
for (auto* it : fifo)
|
|
||||||
delete it;
|
|
||||||
fifo.clear();
|
fifo.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +72,6 @@ void slsReceiverImplementation::InitializeMembers() {
|
|||||||
|
|
||||||
//*** receiver parameters ***
|
//*** receiver parameters ***
|
||||||
numThreads = 1;
|
numThreads = 1;
|
||||||
numberofJobs = 1;
|
|
||||||
nroichannels = 0;
|
nroichannels = 0;
|
||||||
status = IDLE;
|
status = IDLE;
|
||||||
activated = true;
|
activated = true;
|
||||||
@ -217,14 +205,13 @@ uint64_t slsReceiverImplementation::getTotalFramesCaught() const {
|
|||||||
uint64_t sum = 0;
|
uint64_t sum = 0;
|
||||||
uint32_t flagsum = 0;
|
uint32_t flagsum = 0;
|
||||||
|
|
||||||
std::vector<DataProcessor*>::const_iterator it;
|
for (const auto& it : dataProcessor){
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
|
flagsum += it->GetMeasurementStartedFlag();
|
||||||
flagsum += ((*it)->GetMeasurementStartedFlag() ? 1 : 0);
|
sum += it->GetNumTotalFramesCaught();
|
||||||
sum += (*it)->GetNumTotalFramesCaught();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//no data processed
|
//no data processed
|
||||||
if (flagsum != dataProcessor.size()) return 0;
|
if (flagsum != dataProcessor.size())
|
||||||
|
return 0;
|
||||||
|
|
||||||
return (sum/dataProcessor.size());
|
return (sum/dataProcessor.size());
|
||||||
}
|
}
|
||||||
@ -233,13 +220,13 @@ uint64_t slsReceiverImplementation::getFramesCaught() const {
|
|||||||
uint64_t sum = 0;
|
uint64_t sum = 0;
|
||||||
uint32_t flagsum = 0;
|
uint32_t flagsum = 0;
|
||||||
|
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
|
for (const auto& it : dataProcessor){
|
||||||
flagsum += ((*it)->GetAcquisitionStartedFlag() ? 1 : 0);
|
flagsum += it->GetMeasurementStartedFlag();
|
||||||
sum += (*it)->GetNumFramesCaught();
|
sum += it->GetNumFramesCaught();
|
||||||
}
|
}
|
||||||
|
|
||||||
//no data processed
|
//no data processed
|
||||||
if (flagsum != dataProcessor.size()) return 0;
|
if (flagsum != dataProcessor.size())
|
||||||
|
return 0;
|
||||||
|
|
||||||
return (sum/dataProcessor.size());
|
return (sum/dataProcessor.size());
|
||||||
}
|
}
|
||||||
@ -248,13 +235,13 @@ int64_t slsReceiverImplementation::getAcquisitionIndex() const {
|
|||||||
uint64_t sum = 0;
|
uint64_t sum = 0;
|
||||||
uint32_t flagsum = 0;
|
uint32_t flagsum = 0;
|
||||||
|
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it){
|
for (const auto& it : dataProcessor){
|
||||||
flagsum += ((*it)->GetAcquisitionStartedFlag() ? 1 : 0);
|
flagsum += it->GetMeasurementStartedFlag();
|
||||||
sum += (*it)->GetActualProcessedAcquisitionIndex();
|
sum += it->GetActualProcessedAcquisitionIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
//no data processed
|
//no data processed
|
||||||
if (flagsum != dataProcessor.size()) return -1;
|
if (flagsum != dataProcessor.size())
|
||||||
|
return -1;
|
||||||
|
|
||||||
return (sum/dataProcessor.size());
|
return (sum/dataProcessor.size());
|
||||||
}
|
}
|
||||||
@ -409,25 +396,25 @@ void slsReceiverImplementation::setDetectorHostname(const char *c){
|
|||||||
|
|
||||||
void slsReceiverImplementation::setMultiDetectorSize(const int* size) {
|
void slsReceiverImplementation::setMultiDetectorSize(const int* size) {
|
||||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||||
char message[100];
|
std::string log_message = "Detector Size: (";
|
||||||
strcpy(message, "Detector Size: (");
|
|
||||||
for (int i = 0; i < MAX_DIMENSIONS; ++i) {
|
for (int i = 0; i < MAX_DIMENSIONS; ++i) {
|
||||||
if (myDetectorType == EIGER && (!i))
|
if (myDetectorType == EIGER && (!i))
|
||||||
numDet[i] = size[i]*2;
|
numDet[i] = size[i]*2;
|
||||||
else
|
else
|
||||||
numDet[i] = size[i];
|
numDet[i] = size[i];
|
||||||
sprintf(message,"%s%d",message,numDet[i]);
|
log_message += std::to_string(numDet[i]);
|
||||||
if (i < MAX_DIMENSIONS-1 )
|
if (i < MAX_DIMENSIONS-1 )
|
||||||
strcat(message,",");
|
log_message += ", ";
|
||||||
}
|
}
|
||||||
strcat(message,")");
|
log_message += ")";
|
||||||
FILE_LOG(logINFO) << message;
|
FILE_LOG(logINFO) << log_message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void slsReceiverImplementation::setFlippedData(int axis, int enable){
|
void slsReceiverImplementation::setFlippedData(int axis, int enable){
|
||||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||||
if(axis<0 || axis>1) return;
|
if(axis<0 || axis>1)
|
||||||
|
return;
|
||||||
flippedData[axis] = enable==0?0:1;
|
flippedData[axis] = enable==0?0:1;
|
||||||
FILE_LOG(logINFO) << "Flipped Data: " << flippedData[0] << " , " << flippedData[1];
|
FILE_LOG(logINFO) << "Flipped Data: " << flippedData[0] << " , " << flippedData[1];
|
||||||
}
|
}
|
||||||
@ -439,11 +426,8 @@ int slsReceiverImplementation::setGapPixelsEnable(const bool b) {
|
|||||||
|
|
||||||
// side effects
|
// side effects
|
||||||
generalData->SetGapPixelsEnable(b, dynamicRange);
|
generalData->SetGapPixelsEnable(b, dynamicRange);
|
||||||
// to update npixelsx, npixelsy in file writer
|
for (const auto& it : dataProcessor)
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
it->SetPixelDimension();
|
||||||
(*it)->SetPixelDimension();
|
|
||||||
|
|
||||||
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
|
|
||||||
if (SetupFifoStructure() == FAIL)
|
if (SetupFifoStructure() == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -463,9 +447,9 @@ void slsReceiverImplementation::setFileFormat(const fileFormat f){
|
|||||||
fileFormatType = BINARY;
|
fileFormatType = BINARY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//destroy file writer, set file format and create file writer
|
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
for(const auto& it : dataProcessor)
|
||||||
(*it)->SetFileFormat(f);
|
it->SetFileFormat(f);
|
||||||
|
|
||||||
FILE_LOG(logINFO) << "File Format:" << getFileFormatType(fileFormatType);
|
FILE_LOG(logINFO) << "File Format:" << getFileFormatType(fileFormatType);
|
||||||
}
|
}
|
||||||
@ -612,17 +596,15 @@ int slsReceiverImplementation::setROI(const std::vector<slsDetectorDefs::ROI> i)
|
|||||||
|
|
||||||
generalData->SetROI(i);
|
generalData->SetROI(i);
|
||||||
framesPerFile = generalData->maxFramesPerFile;
|
framesPerFile = generalData->maxFramesPerFile;
|
||||||
|
|
||||||
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
|
|
||||||
if (SetupFifoStructure() == FAIL)
|
if (SetupFifoStructure() == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
for (const auto& it : listener)
|
||||||
(*it)->SetGeneralData(generalData);
|
it->SetGeneralData(generalData);
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
for (const auto& it : dataProcessor)
|
||||||
(*it)->SetGeneralData(generalData);
|
it->SetGeneralData(generalData);
|
||||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
for (const auto& it : dataStreamer)
|
||||||
(*it)->SetGeneralData(generalData);
|
it->SetGeneralData(generalData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -667,22 +649,17 @@ int slsReceiverImplementation::setDataStreamEnable(const bool enable) {
|
|||||||
dataStreamEnable = enable;
|
dataStreamEnable = enable;
|
||||||
|
|
||||||
//data sockets have to be created again as the client ones are
|
//data sockets have to be created again as the client ones are
|
||||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
|
||||||
delete(*it);
|
|
||||||
dataStreamer.clear();
|
dataStreamer.clear();
|
||||||
|
|
||||||
if (enable) {
|
if (enable) {
|
||||||
for ( int i = 0; i < numThreads; ++i ) {
|
for ( int i = 0; i < numThreads; ++i ) {
|
||||||
try {
|
try {
|
||||||
DataStreamer* s = new DataStreamer(i, fifo[i], &dynamicRange,
|
dataStreamer.push_back(sls::make_unique<DataStreamer>(i, fifo[i].get(), &dynamicRange,
|
||||||
&roi, &fileIndex, flippedData, additionalJsonHeader, &silentMode);
|
&roi, &fileIndex, flippedData, additionalJsonHeader, &silentMode));
|
||||||
dataStreamer.push_back(s);
|
|
||||||
dataStreamer[i]->SetGeneralData(generalData);
|
dataStreamer[i]->SetGeneralData(generalData);
|
||||||
dataStreamer[i]->CreateZmqSockets(&numThreads, streamingPort, streamingSrcIP);
|
dataStreamer[i]->CreateZmqSockets(&numThreads, streamingPort, streamingSrcIP);
|
||||||
}
|
}
|
||||||
catch(...) {
|
catch(...) {
|
||||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
|
||||||
delete(*it);
|
|
||||||
dataStreamer.clear();
|
dataStreamer.clear();
|
||||||
dataStreamEnable = false;
|
dataStreamEnable = false;
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@ -767,7 +744,6 @@ int slsReceiverImplementation::setNumberofSamples(const uint64_t i) {
|
|||||||
numberOfSamples = i;
|
numberOfSamples = i;
|
||||||
|
|
||||||
generalData->setNumberofSamples(i, nroichannels);
|
generalData->setNumberofSamples(i, nroichannels);
|
||||||
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
|
|
||||||
if (SetupFifoStructure() == FAIL)
|
if (SetupFifoStructure() == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -780,15 +756,11 @@ int slsReceiverImplementation::setNumberofSamples(const uint64_t i) {
|
|||||||
int slsReceiverImplementation::setDynamicRange(const uint32_t i) {
|
int slsReceiverImplementation::setDynamicRange(const uint32_t i) {
|
||||||
if (dynamicRange != i) {
|
if (dynamicRange != i) {
|
||||||
dynamicRange = i;
|
dynamicRange = i;
|
||||||
|
|
||||||
//side effects
|
|
||||||
generalData->SetDynamicRange(i,tengigaEnable);
|
generalData->SetDynamicRange(i,tengigaEnable);
|
||||||
generalData->SetGapPixelsEnable(gapPixelsEnable, dynamicRange);
|
generalData->SetGapPixelsEnable(gapPixelsEnable, dynamicRange);
|
||||||
// to update npixelsx, npixelsy in file writer
|
// to update npixelsx, npixelsy in file writer
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
for (const auto& it : dataProcessor)
|
||||||
(*it)->SetPixelDimension();
|
it->SetPixelDimension();
|
||||||
|
|
||||||
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
|
|
||||||
if (SetupFifoStructure() == FAIL)
|
if (SetupFifoStructure() == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -802,8 +774,6 @@ int slsReceiverImplementation::setTenGigaEnable(const bool b) {
|
|||||||
tengigaEnable = b;
|
tengigaEnable = b;
|
||||||
//side effects
|
//side effects
|
||||||
generalData->SetTenGigaEnable(b,dynamicRange);
|
generalData->SetTenGigaEnable(b,dynamicRange);
|
||||||
|
|
||||||
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
|
|
||||||
if (SetupFifoStructure() == FAIL)
|
if (SetupFifoStructure() == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -815,8 +785,6 @@ int slsReceiverImplementation::setTenGigaEnable(const bool b) {
|
|||||||
int slsReceiverImplementation::setFifoDepth(const uint32_t i) {
|
int slsReceiverImplementation::setFifoDepth(const uint32_t i) {
|
||||||
if (fifoDepth != i) {
|
if (fifoDepth != i) {
|
||||||
fifoDepth = i;
|
fifoDepth = i;
|
||||||
|
|
||||||
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
|
|
||||||
if (SetupFifoStructure() == FAIL)
|
if (SetupFifoStructure() == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -887,11 +855,7 @@ int slsReceiverImplementation::setDetectorType(const detectorType d) {
|
|||||||
udpSocketBufferSize = generalData->defaultUdpSocketBufferSize;
|
udpSocketBufferSize = generalData->defaultUdpSocketBufferSize;
|
||||||
framesPerFile = generalData->maxFramesPerFile;
|
framesPerFile = generalData->maxFramesPerFile;
|
||||||
|
|
||||||
//local network parameters
|
|
||||||
SetLocalNetworkParameters();
|
SetLocalNetworkParameters();
|
||||||
|
|
||||||
//create fifo structure
|
|
||||||
numberofJobs = -1;
|
|
||||||
if (SetupFifoStructure() == FAIL) {
|
if (SetupFifoStructure() == FAIL) {
|
||||||
FILE_LOG(logERROR) << "Could not allocate memory for fifo structure";
|
FILE_LOG(logERROR) << "Could not allocate memory for fifo structure";
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@ -901,37 +865,31 @@ int slsReceiverImplementation::setDetectorType(const detectorType d) {
|
|||||||
for ( int i = 0; i < numThreads; ++i ) {
|
for ( int i = 0; i < numThreads; ++i ) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Listener* l = new Listener(i, myDetectorType, fifo[i], &status,
|
auto fifo_ptr = fifo[i].get();
|
||||||
|
listener.push_back(sls::make_unique<Listener>(i, myDetectorType, fifo_ptr, &status,
|
||||||
&udpPortNum[i], eth, &numberOfFrames, &dynamicRange,
|
&udpPortNum[i], eth, &numberOfFrames, &dynamicRange,
|
||||||
&udpSocketBufferSize, &actualUDPSocketBufferSize, &framesPerFile,
|
&udpSocketBufferSize, &actualUDPSocketBufferSize, &framesPerFile,
|
||||||
&frameDiscardMode, &activated, &deactivatedPaddingEnable, &silentMode);
|
&frameDiscardMode, &activated, &deactivatedPaddingEnable, &silentMode));
|
||||||
listener.push_back(l);
|
dataProcessor.push_back(sls::make_unique<DataProcessor>(i, myDetectorType, fifo_ptr, &fileFormatType,
|
||||||
|
|
||||||
DataProcessor* p = new DataProcessor(i, myDetectorType, fifo[i], &fileFormatType,
|
|
||||||
fileWriteEnable, &dataStreamEnable, &gapPixelsEnable,
|
fileWriteEnable, &dataStreamEnable, &gapPixelsEnable,
|
||||||
&dynamicRange, &streamingFrequency, &streamingTimerInMs,
|
&dynamicRange, &streamingFrequency, &streamingTimerInMs,
|
||||||
&framePadding, &activated, &deactivatedPaddingEnable, &silentMode,
|
&framePadding, &activated, &deactivatedPaddingEnable, &silentMode,
|
||||||
rawDataReadyCallBack, rawDataModifyReadyCallBack, pRawDataReady);
|
rawDataReadyCallBack, rawDataModifyReadyCallBack, pRawDataReady));
|
||||||
dataProcessor.push_back(p);
|
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
FILE_LOG(logERROR) << "Could not create listener/dataprocessor threads (index:" << i << ")";
|
FILE_LOG(logERROR) << "Could not create listener/dataprocessor threads (index:" << i << ")";
|
||||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
|
||||||
delete(*it);
|
|
||||||
listener.clear();
|
listener.clear();
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
|
||||||
delete(*it);
|
|
||||||
dataProcessor.clear();
|
dataProcessor.clear();
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//set up writer and callbacks
|
//set up writer and callbacks
|
||||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
|
||||||
(*it)->SetGeneralData(generalData);
|
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
|
||||||
(*it)->SetGeneralData(generalData);
|
|
||||||
|
|
||||||
|
for (const auto& it : listener)
|
||||||
|
it->SetGeneralData(generalData);
|
||||||
|
for (const auto& it : dataProcessor)
|
||||||
|
it->SetGeneralData(generalData);
|
||||||
SetThreadPriorities();
|
SetThreadPriorities();
|
||||||
|
|
||||||
// check udp socket buffer size
|
// check udp socket buffer size
|
||||||
@ -967,14 +925,12 @@ void slsReceiverImplementation::setDetectorPositionId(const int i){
|
|||||||
/***acquisition functions***/
|
/***acquisition functions***/
|
||||||
void slsReceiverImplementation::resetAcquisitionCount() {
|
void slsReceiverImplementation::resetAcquisitionCount() {
|
||||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
for (const auto& it : listener)
|
||||||
(*it)->ResetParametersforNewAcquisition();
|
it->ResetParametersforNewAcquisition();
|
||||||
|
for (const auto& it : dataProcessor)
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
it->ResetParametersforNewAcquisition();
|
||||||
(*it)->ResetParametersforNewAcquisition();
|
for (const auto& it: dataStreamer)
|
||||||
|
it->ResetParametersforNewAcquisition();
|
||||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
|
||||||
(*it)->ResetParametersforNewAcquisition();
|
|
||||||
|
|
||||||
FILE_LOG(logINFO) << "Acquisition Count has been reset";
|
FILE_LOG(logINFO) << "Acquisition Count has been reset";
|
||||||
}
|
}
|
||||||
@ -996,7 +952,7 @@ int slsReceiverImplementation::startReceiver(char *c) {
|
|||||||
//callbacks
|
//callbacks
|
||||||
if (startAcquisitionCallBack) {
|
if (startAcquisitionCallBack) {
|
||||||
startAcquisitionCallBack(filePath, fileName, fileIndex,
|
startAcquisitionCallBack(filePath, fileName, fileIndex,
|
||||||
(generalData->imageSize) * numberofJobs + (generalData->fifoBufferHeaderSize), pStartAcquisition);
|
(generalData->imageSize) + (generalData->fifoBufferHeaderSize), pStartAcquisition);
|
||||||
if (rawDataReadyCallBack != NULL) {
|
if (rawDataReadyCallBack != NULL) {
|
||||||
FILE_LOG(logINFO) << "Data Write has been defined externally";
|
FILE_LOG(logINFO) << "Data Write has been defined externally";
|
||||||
}
|
}
|
||||||
@ -1038,11 +994,12 @@ void slsReceiverImplementation::stopReceiver(){
|
|||||||
bool running = true;
|
bool running = true;
|
||||||
while(running) {
|
while(running) {
|
||||||
running = false;
|
running = false;
|
||||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
for (const auto& it : listener)
|
||||||
if ((*it)->IsRunning())
|
if (it->IsRunning())
|
||||||
running = true;
|
running = true;
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
|
||||||
if ((*it)->IsRunning())
|
for (const auto& it : dataProcessor)
|
||||||
|
if (it->IsRunning())
|
||||||
running = true;
|
running = true;
|
||||||
usleep(5000);
|
usleep(5000);
|
||||||
}
|
}
|
||||||
@ -1052,9 +1009,9 @@ void slsReceiverImplementation::stopReceiver(){
|
|||||||
if (fileWriteEnable && fileFormatType == HDF5) {
|
if (fileWriteEnable && fileFormatType == HDF5) {
|
||||||
uint64_t maxIndexCaught = 0;
|
uint64_t maxIndexCaught = 0;
|
||||||
bool anycaught = false;
|
bool anycaught = false;
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
|
for (const auto& it : dataProcessor) {
|
||||||
maxIndexCaught = std::max(maxIndexCaught, (*it)->GetProcessedMeasurementIndex());
|
maxIndexCaught = std::max(maxIndexCaught, it->GetProcessedMeasurementIndex());
|
||||||
if((*it)->GetMeasurementStartedFlag())
|
if(it->GetMeasurementStartedFlag())
|
||||||
anycaught = true;
|
anycaught = true;
|
||||||
}
|
}
|
||||||
//to create virtual file & set files/acquisition to 0 (only hdf5 at the moment)
|
//to create virtual file & set files/acquisition to 0 (only hdf5 at the moment)
|
||||||
@ -1065,8 +1022,8 @@ void slsReceiverImplementation::stopReceiver(){
|
|||||||
running = true;
|
running = true;
|
||||||
while(running) {
|
while(running) {
|
||||||
running = false;
|
running = false;
|
||||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
for (const auto& it : dataStreamer)
|
||||||
if ((*it)->IsRunning())
|
if (it->IsRunning())
|
||||||
running = true;
|
running = true;
|
||||||
usleep(5000);
|
usleep(5000);
|
||||||
}
|
}
|
||||||
@ -1107,46 +1064,39 @@ void slsReceiverImplementation::stopReceiver(){
|
|||||||
void slsReceiverImplementation::startReadout(){
|
void slsReceiverImplementation::startReadout(){
|
||||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||||
if(status == RUNNING){
|
if(status == RUNNING){
|
||||||
|
|
||||||
// wait for incoming delayed packets
|
// wait for incoming delayed packets
|
||||||
//current packets caught
|
int totalPacketsReceived = 0;
|
||||||
volatile int totalP = 0,prev=-1;
|
int previousValue=-1;
|
||||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
for(const auto& it : listener)
|
||||||
totalP += (*it)->GetPacketsCaught();
|
totalPacketsReceived += it->GetPacketsCaught();
|
||||||
|
|
||||||
//wait for all packets
|
//wait for all packets
|
||||||
if((unsigned long long int)totalP!=numberOfFrames*generalData->packetsPerFrame*listener.size()){
|
const auto numPacketsToReceive = numberOfFrames * generalData->packetsPerFrame * listener.size();
|
||||||
|
if(totalPacketsReceived != numPacketsToReceive){
|
||||||
|
while(totalPacketsReceived != previousValue){
|
||||||
|
FILE_LOG(logDEBUG3) << "waiting for all packets, previousValue:" << previousValue <<
|
||||||
|
" totalPacketsReceived: " << totalPacketsReceived;
|
||||||
|
usleep(5*1000);/* TODO! Need to find optimal time **/
|
||||||
|
previousValue = totalPacketsReceived;
|
||||||
|
totalPacketsReceived = 0;
|
||||||
|
for(const auto& it : listener)
|
||||||
|
totalPacketsReceived += it->GetPacketsCaught();
|
||||||
|
|
||||||
//wait as long as there is change from prev totalP,
|
FILE_LOG(logDEBUG3) << "\tupdated: totalPacketsReceived:" << totalPacketsReceived;
|
||||||
while(prev != totalP){
|
|
||||||
FILE_LOG(logDEBUG3) << "waiting for all packets prevP:" << prev <<
|
|
||||||
" totalP: " << totalP;
|
|
||||||
//usleep(1*1000*1000);usleep(1*1000*1000);usleep(1*1000*1000);usleep(1*1000*1000);
|
|
||||||
usleep(5*1000);/* Need to find optimal time **/
|
|
||||||
|
|
||||||
prev = totalP;
|
|
||||||
totalP = 0;
|
|
||||||
|
|
||||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
|
||||||
totalP += (*it)->GetPacketsCaught();
|
|
||||||
FILE_LOG(logDEBUG3) << "\tupdated: totalP:" << totalP;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//set status
|
|
||||||
status = TRANSMITTING;
|
status = TRANSMITTING;
|
||||||
FILE_LOG(logINFO) << "Status: Transmitting";
|
FILE_LOG(logINFO) << "Status: Transmitting";
|
||||||
}
|
}
|
||||||
//shut down udp sockets so as to make listeners push dummy (end) packets for processors
|
//shut down udp sockets to make listeners push dummy (end) packets for processors
|
||||||
shutDownUDPSockets();
|
shutDownUDPSockets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void slsReceiverImplementation::shutDownUDPSockets() {
|
void slsReceiverImplementation::shutDownUDPSockets() {
|
||||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
for (const auto& it : listener)
|
||||||
(*it)->ShutDownUDPSocket();
|
it->ShutDownUDPSocket();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1155,10 +1105,10 @@ void slsReceiverImplementation::closeFiles() {
|
|||||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||||
uint64_t maxIndexCaught = 0;
|
uint64_t maxIndexCaught = 0;
|
||||||
bool anycaught = false;
|
bool anycaught = false;
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
|
for (const auto& it : dataProcessor) {
|
||||||
(*it)->CloseFiles();
|
it->CloseFiles();
|
||||||
maxIndexCaught = std::max(maxIndexCaught, (*it)->GetProcessedMeasurementIndex());
|
maxIndexCaught = std::max(maxIndexCaught, it->GetProcessedMeasurementIndex());
|
||||||
if((*it)->GetMeasurementStartedFlag())
|
if(it->GetMeasurementStartedFlag())
|
||||||
anycaught = true;
|
anycaught = true;
|
||||||
}
|
}
|
||||||
//to create virtual file & set files/acquisition to 0 (only hdf5 at the moment)
|
//to create virtual file & set files/acquisition to 0 (only hdf5 at the moment)
|
||||||
@ -1169,11 +1119,10 @@ void slsReceiverImplementation::closeFiles() {
|
|||||||
int slsReceiverImplementation::restreamStop() {
|
int slsReceiverImplementation::restreamStop() {
|
||||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||||
bool ret = OK;
|
bool ret = OK;
|
||||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) {
|
for (const auto& it : dataStreamer){
|
||||||
if ((*it)->RestreamStop() == FAIL)
|
if (it->RestreamStop() == FAIL)
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if fail, prints in datastreamer
|
// if fail, prints in datastreamer
|
||||||
if (ret == OK) {
|
if (ret == OK) {
|
||||||
FILE_LOG(logINFO) << "Restreaming Dummy Header via ZMQ successful";
|
FILE_LOG(logINFO) << "Restreaming Dummy Header via ZMQ successful";
|
||||||
@ -1238,8 +1187,8 @@ void slsReceiverImplementation::SetLocalNetworkParameters() {
|
|||||||
void slsReceiverImplementation::SetThreadPriorities() {
|
void slsReceiverImplementation::SetThreadPriorities() {
|
||||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||||
|
|
||||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it){
|
for (const auto& it : listener){
|
||||||
if ((*it)->SetThreadPriority(LISTENER_PRIORITY) == FAIL) {
|
if (it->SetThreadPriority(LISTENER_PRIORITY) == FAIL) {
|
||||||
FILE_LOG(logWARNING) << "Could not prioritize listener threads. (No Root Privileges?)";
|
FILE_LOG(logWARNING) << "Could not prioritize listener threads. (No Root Privileges?)";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1254,34 +1203,27 @@ void slsReceiverImplementation::SetThreadPriorities() {
|
|||||||
|
|
||||||
int slsReceiverImplementation::SetupFifoStructure() {
|
int slsReceiverImplementation::SetupFifoStructure() {
|
||||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||||
numberofJobs = 1;
|
|
||||||
|
|
||||||
|
|
||||||
for (std::vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it)
|
|
||||||
delete(*it);
|
|
||||||
fifo.clear();
|
fifo.clear();
|
||||||
for ( int i = 0; i < numThreads; ++i ) {
|
for ( int i = 0; i < numThreads; ++i ) {
|
||||||
|
|
||||||
//create fifo structure
|
//create fifo structure
|
||||||
try {
|
try {
|
||||||
Fifo* f = new Fifo (i,
|
fifo.push_back(sls::make_unique<Fifo>(i,
|
||||||
(generalData->imageSize) * numberofJobs + (generalData->fifoBufferHeaderSize),
|
(generalData->imageSize) + (generalData->fifoBufferHeaderSize),
|
||||||
fifoDepth);
|
fifoDepth));
|
||||||
fifo.push_back(f);
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
FILE_LOG(logERROR) << "Could not allocate memory for fifo structure of index " << i;
|
FILE_LOG(logERROR) << "Could not allocate memory for fifo structure of index " << i;
|
||||||
for (std::vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it)
|
|
||||||
delete(*it);
|
|
||||||
fifo.clear();
|
fifo.clear();
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
//set the listener & dataprocessor threads to point to the right fifo
|
//set the listener & dataprocessor threads to point to the right fifo
|
||||||
if(listener.size())listener[i]->SetFifo(fifo[i]);
|
if(listener.size())listener[i]->SetFifo(fifo[i].get());
|
||||||
if(dataProcessor.size())dataProcessor[i]->SetFifo(fifo[i]);
|
if(dataProcessor.size())dataProcessor[i]->SetFifo(fifo[i].get());
|
||||||
if(dataStreamer.size())dataStreamer[i]->SetFifo(fifo[i]);
|
if(dataStreamer.size())dataStreamer[i]->SetFifo(fifo[i].get());
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE_LOG(logINFO) << "Memory Allocated Per Fifo: " << ( ((generalData->imageSize) * numberofJobs + (generalData->fifoBufferHeaderSize)) * fifoDepth) << " bytes" ;
|
FILE_LOG(logINFO) << "Memory Allocated Per Fifo: " << ( ((generalData->imageSize) + (generalData->fifoBufferHeaderSize)) * fifoDepth) << " bytes" ;
|
||||||
FILE_LOG(logINFO) << numThreads << " Fifo structure(s) reconstructed";
|
FILE_LOG(logINFO) << numThreads << " Fifo structure(s) reconstructed";
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@ -1290,16 +1232,17 @@ int slsReceiverImplementation::SetupFifoStructure() {
|
|||||||
|
|
||||||
void slsReceiverImplementation::ResetParametersforNewMeasurement() {
|
void slsReceiverImplementation::ResetParametersforNewMeasurement() {
|
||||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
|
||||||
(*it)->ResetParametersforNewMeasurement();
|
for (const auto& it : listener)
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
it->ResetParametersforNewMeasurement();
|
||||||
(*it)->ResetParametersforNewMeasurement();
|
for (const auto& it : dataProcessor)
|
||||||
|
it->ResetParametersforNewMeasurement();
|
||||||
|
|
||||||
if (dataStreamEnable) {
|
if (dataStreamEnable) {
|
||||||
char fnametostream[MAX_STR_LENGTH];
|
char fnametostream[MAX_STR_LENGTH];
|
||||||
snprintf(fnametostream, MAX_STR_LENGTH, "%s/%s", filePath, fileName);
|
snprintf(fnametostream, MAX_STR_LENGTH, "%s/%s", filePath, fileName);
|
||||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
for (const auto& it : dataStreamer)
|
||||||
(*it)->ResetParametersforNewMeasurement(fnametostream);
|
it->ResetParametersforNewMeasurement(fnametostream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1345,16 +1288,16 @@ int slsReceiverImplementation::SetupWriter() {
|
|||||||
void slsReceiverImplementation::StartRunning() {
|
void slsReceiverImplementation::StartRunning() {
|
||||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||||
//set running mask and post semaphore to start the inner loop in execution thread
|
//set running mask and post semaphore to start the inner loop in execution thread
|
||||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it) {
|
for (const auto& it : listener){
|
||||||
(*it)->StartRunning();
|
it->StartRunning();
|
||||||
(*it)->Continue();
|
it->Continue();
|
||||||
}
|
}
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it){
|
for (const auto& it : dataProcessor){
|
||||||
(*it)->StartRunning();
|
it->StartRunning();
|
||||||
(*it)->Continue();
|
it->Continue();
|
||||||
}
|
}
|
||||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){
|
for (const auto& it : dataStreamer){
|
||||||
(*it)->StartRunning();
|
it->StartRunning();
|
||||||
(*it)->Continue();
|
it->Continue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,6 +99,7 @@ T minusOneIfDifferent(const std::vector<T>& container)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO!(Erik)Should try to move away from using this in the slsDetectorPackage
|
//TODO!(Erik)Should try to move away from using this in the slsDetectorPackage
|
||||||
|
inline
|
||||||
std::string concatenateIfDifferent(std::vector<std::string> container)
|
std::string concatenateIfDifferent(std::vector<std::string> container)
|
||||||
{
|
{
|
||||||
if (allEqual(container)) {
|
if (allEqual(container)) {
|
||||||
@ -110,7 +111,7 @@ std::string concatenateIfDifferent(std::vector<std::string> container)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
inline
|
||||||
std::vector<std::string> split(const std::string& strToSplit, char delimeter)
|
std::vector<std::string> split(const std::string& strToSplit, char delimeter)
|
||||||
{
|
{
|
||||||
std::stringstream ss(strToSplit);
|
std::stringstream ss(strToSplit);
|
||||||
@ -122,6 +123,7 @@ std::vector<std::string> split(const std::string& strToSplit, char delimeter)
|
|||||||
return splittedStrings;
|
return splittedStrings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
std::string concatenateNonEmptyStrings(const std::vector<std::string>& vec){
|
std::string concatenateNonEmptyStrings(const std::vector<std::string>& vec){
|
||||||
std::string ret;
|
std::string ret;
|
||||||
for (const auto& s : vec)
|
for (const auto& s : vec)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user