mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 15:20:02 +02:00
moved to vector of unique pointer in slsReceiverImplementation
This commit is contained in:
parent
b50d359ee6
commit
014dfaa251
@ -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:
|
||||||
@ -832,13 +833,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
delete receiver;
|
delete receiver;
|
||||||
cprintf(BLUE,"Exiting [ Tid: %ld ]\n", (long)syscall(SYS_gettid));
|
cprintf(BLUE,"Exiting [ Tid: %ld ]\n", (long)syscall(SYS_gettid));
|
||||||
FILE_LOG(logINFO) << "Goodbye!";
|
// FILE_LOG(logINFO) << "Goodbye!";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,20 +39,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();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -472,8 +461,10 @@ 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
|
// to update npixelsx, npixelsy in file writer
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
// for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||||
(*it)->SetPixelDimension();
|
// (*it)->SetPixelDimension();
|
||||||
|
for (const auto& it : dataProcessor)
|
||||||
|
it->SetPixelDimension();
|
||||||
|
|
||||||
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
|
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
|
||||||
if (SetupFifoStructure() == FAIL)
|
if (SetupFifoStructure() == FAIL)
|
||||||
@ -496,8 +487,10 @@ void slsReceiverImplementation::setFileFormat(const fileFormat f){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//destroy file writer, set file format and create file writer
|
//destroy file writer, set file format and create file writer
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
// for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||||
(*it)->SetFileFormat(f);
|
// (*it)->SetFileFormat(f);
|
||||||
|
for(const auto& it : dataProcessor)
|
||||||
|
it->SetFileFormat(f);
|
||||||
|
|
||||||
FILE_LOG(logINFO) << "File Format:" << getFileFormatType(fileFormatType);
|
FILE_LOG(logINFO) << "File Format:" << getFileFormatType(fileFormatType);
|
||||||
}
|
}
|
||||||
@ -649,12 +642,13 @@ int slsReceiverImplementation::setROI(const std::vector<slsDetectorDefs::ROI> i)
|
|||||||
if (SetupFifoStructure() == FAIL)
|
if (SetupFifoStructure() == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
|
||||||
(*it)->SetGeneralData(generalData);
|
for (const auto& it : listener)
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
it->SetGeneralData(generalData);
|
||||||
(*it)->SetGeneralData(generalData);
|
for (const auto& it : dataProcessor)
|
||||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
it->SetGeneralData(generalData);
|
||||||
(*it)->SetGeneralData(generalData);
|
for (const auto& it : dataStreamer)
|
||||||
|
it->SetGeneralData(generalData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -699,22 +693,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;
|
||||||
@ -817,8 +806,10 @@ int slsReceiverImplementation::setDynamicRange(const uint32_t i) {
|
|||||||
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 (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||||
(*it)->SetPixelDimension();
|
// (*it)->SetPixelDimension();
|
||||||
|
for (const auto& it : dataProcessor)
|
||||||
|
it->SetPixelDimension();
|
||||||
|
|
||||||
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
|
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
|
||||||
if (SetupFifoStructure() == FAIL)
|
if (SetupFifoStructure() == FAIL)
|
||||||
@ -937,37 +928,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
|
||||||
@ -1069,11 +1054,18 @@ 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 (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||||
if ((*it)->IsRunning())
|
// if ((*it)->IsRunning())
|
||||||
|
// running = true;
|
||||||
|
for (const auto& it : listener)
|
||||||
|
if (it->IsRunning())
|
||||||
running = true;
|
running = true;
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
|
||||||
if ((*it)->IsRunning())
|
// for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||||
|
// if ((*it)->IsRunning())
|
||||||
|
// running = true;
|
||||||
|
for (const auto& it : dataProcessor)
|
||||||
|
if (it->IsRunning())
|
||||||
running = true;
|
running = true;
|
||||||
usleep(5000);
|
usleep(5000);
|
||||||
}
|
}
|
||||||
@ -1083,9 +1075,14 @@ 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 (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
|
||||||
maxIndexCaught = std::max(maxIndexCaught, (*it)->GetProcessedMeasurementIndex());
|
// maxIndexCaught = std::max(maxIndexCaught, (*it)->GetProcessedMeasurementIndex());
|
||||||
if((*it)->GetMeasurementStartedFlag())
|
// if((*it)->GetMeasurementStartedFlag())
|
||||||
|
// anycaught = true;
|
||||||
|
// }
|
||||||
|
for (const auto& it : dataProcessor) {
|
||||||
|
maxIndexCaught = std::max(maxIndexCaught, it->GetProcessedMeasurementIndex());
|
||||||
|
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)
|
||||||
@ -1096,8 +1093,11 @@ 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 (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
||||||
if ((*it)->IsRunning())
|
// if ((*it)->IsRunning())
|
||||||
|
// running = true;
|
||||||
|
for (const auto& it : dataStreamer)
|
||||||
|
if (it->IsRunning())
|
||||||
running = true;
|
running = true;
|
||||||
usleep(5000);
|
usleep(5000);
|
||||||
}
|
}
|
||||||
@ -1176,8 +1176,10 @@ void slsReceiverImplementation::startReadout(){
|
|||||||
|
|
||||||
|
|
||||||
void slsReceiverImplementation::shutDownUDPSockets() {
|
void slsReceiverImplementation::shutDownUDPSockets() {
|
||||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
// for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||||
(*it)->ShutDownUDPSocket();
|
// (*it)->ShutDownUDPSocket();
|
||||||
|
for (const auto& it : listener)
|
||||||
|
it->ShutDownUDPSocket();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1185,10 +1187,16 @@ void slsReceiverImplementation::shutDownUDPSockets() {
|
|||||||
void slsReceiverImplementation::closeFiles() {
|
void slsReceiverImplementation::closeFiles() {
|
||||||
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 (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
|
||||||
(*it)->CloseFiles();
|
// (*it)->CloseFiles();
|
||||||
maxIndexCaught = std::max(maxIndexCaught, (*it)->GetProcessedMeasurementIndex());
|
// maxIndexCaught = std::max(maxIndexCaught, (*it)->GetProcessedMeasurementIndex());
|
||||||
if((*it)->GetMeasurementStartedFlag())
|
// if((*it)->GetMeasurementStartedFlag())
|
||||||
|
// anycaught = true;
|
||||||
|
// }
|
||||||
|
for (const auto& it : dataProcessor) {
|
||||||
|
it->CloseFiles();
|
||||||
|
maxIndexCaught = std::max(maxIndexCaught, it->GetProcessedMeasurementIndex());
|
||||||
|
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)
|
||||||
@ -1198,11 +1206,14 @@ void slsReceiverImplementation::closeFiles() {
|
|||||||
|
|
||||||
int slsReceiverImplementation::restreamStop() {
|
int slsReceiverImplementation::restreamStop() {
|
||||||
bool ret = OK;
|
bool ret = OK;
|
||||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) {
|
// for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) {
|
||||||
if ((*it)->RestreamStop() == FAIL)
|
// if ((*it)->RestreamStop() == FAIL)
|
||||||
|
// ret = FAIL;
|
||||||
|
// }
|
||||||
|
for (const auto& it : dataStreamer){
|
||||||
|
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";
|
||||||
@ -1266,8 +1277,14 @@ void slsReceiverImplementation::SetLocalNetworkParameters() {
|
|||||||
|
|
||||||
void slsReceiverImplementation::SetThreadPriorities() {
|
void slsReceiverImplementation::SetThreadPriorities() {
|
||||||
|
|
||||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it){
|
// for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it){
|
||||||
if ((*it)->SetThreadPriority(LISTENER_PRIORITY) == FAIL) {
|
// if ((*it)->SetThreadPriority(LISTENER_PRIORITY) == FAIL) {
|
||||||
|
// FILE_LOG(logWARNING) << "Could not prioritize listener threads. (No Root Privileges?)";
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
for (const auto& it : listener){
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
@ -1283,29 +1300,27 @@ void slsReceiverImplementation::SetThreadPriorities() {
|
|||||||
int slsReceiverImplementation::SetupFifoStructure() {
|
int slsReceiverImplementation::SetupFifoStructure() {
|
||||||
numberofJobs = 1;
|
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* f = new Fifo (i,
|
||||||
|
// (generalData->imageSize) * numberofJobs + (generalData->fifoBufferHeaderSize),
|
||||||
|
// fifoDepth);
|
||||||
|
// fifo.push_back(f);
|
||||||
|
fifo.push_back(sls::make_unique<Fifo>(i,
|
||||||
(generalData->imageSize) * numberofJobs + (generalData->fifoBufferHeaderSize),
|
(generalData->imageSize) * numberofJobs + (generalData->fifoBufferHeaderSize),
|
||||||
fifoDepth);
|
fifoDepth));
|
||||||
fifo.push_back(f);
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
cprintf(RED,"Error: Could not allocate memory for fifo structure of index %d\n", i);
|
cprintf(RED,"Error: Could not allocate memory for fifo structure of index %d\n", 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) * numberofJobs + (generalData->fifoBufferHeaderSize)) * fifoDepth) << " bytes" ;
|
||||||
@ -1316,16 +1331,18 @@ int slsReceiverImplementation::SetupFifoStructure() {
|
|||||||
|
|
||||||
|
|
||||||
void slsReceiverImplementation::ResetParametersforNewMeasurement() {
|
void slsReceiverImplementation::ResetParametersforNewMeasurement() {
|
||||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
for (const auto& it : listener)
|
||||||
(*it)->ResetParametersforNewMeasurement();
|
it->ResetParametersforNewMeasurement();
|
||||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
for (const auto& it : dataProcessor)
|
||||||
(*it)->ResetParametersforNewMeasurement();
|
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 (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
||||||
(*it)->ResetParametersforNewMeasurement(fnametostream);
|
// (*it)->ResetParametersforNewMeasurement(fnametostream);
|
||||||
|
for (const auto& it : dataStreamer)
|
||||||
|
it->ResetParametersforNewMeasurement(fnametostream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1368,16 +1385,16 @@ int slsReceiverImplementation::SetupWriter() {
|
|||||||
|
|
||||||
void slsReceiverImplementation::StartRunning() {
|
void slsReceiverImplementation::StartRunning() {
|
||||||
//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