mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-01-17 15:38:41 +01:00
slsReceiver: remove static members in Listener, DataProcessing and DataStreamer:
* Needed when more than one receiver is created by process * Replace NumberofXxxx by explicit index in constructor * Remove Error[Mask], use return value in constructor signature * Replace RunningMask by individual Running flags * Remove obsolete Mutex objects
This commit is contained in:
@@ -44,7 +44,7 @@ class BinaryFileStatic {
|
|||||||
{
|
{
|
||||||
ostringstream osfn;
|
ostringstream osfn;
|
||||||
osfn << fpath << "/" << fnameprefix;
|
osfn << fpath << "/" << fnameprefix;
|
||||||
if (dindex >= 0) osfn << "_d" << ((unitindex >= numunits) ? unitindex : (dindex * numunits + unitindex)); //if unit index > numunits, all receivers in one program (userReceiver)
|
if (dindex >= 0) osfn << "_d" << (dindex * numunits + unitindex);
|
||||||
if (frindexenable) osfn << "_f" << setfill('0') << setw(12) << fnum;
|
if (frindexenable) osfn << "_f" << setfill('0') << setw(12) << fnum;
|
||||||
osfn << "_" << findex;
|
osfn << "_" << findex;
|
||||||
osfn << ".raw";
|
osfn << ".raw";
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* Calls Base Class CreateThread(), sets ErrorMask if error and increments NumberofDataProcessors
|
* Calls Base Class CreateThread(), sets ErrorMask if error and increments NumberofDataProcessors
|
||||||
|
* @param ret OK or FAIL if thread creation succeeded or failed
|
||||||
|
* @param ind self index
|
||||||
* @param f address of Fifo pointer
|
* @param f address of Fifo pointer
|
||||||
* @param ftype pointer to file format type
|
* @param ftype pointer to file format type
|
||||||
* @param fwenable file writer enable
|
* @param fwenable file writer enable
|
||||||
@@ -35,7 +37,7 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
* @param dataReadycb pointer to data ready call back function
|
* @param dataReadycb pointer to data ready call back function
|
||||||
* @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(Fifo*& f, fileFormat* ftype, bool fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr,
|
DataProcessor(int& ret, int ind, Fifo*& f, fileFormat* ftype, bool fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr,
|
||||||
uint32_t* freq, uint32_t* timer,
|
uint32_t* freq, uint32_t* timer,
|
||||||
void (*dataReadycb)(uint64_t, uint32_t, uint32_t, uint64_t,
|
void (*dataReadycb)(uint64_t, uint32_t, uint32_t, uint64_t,
|
||||||
uint64_t, uint16_t, uint16_t, uint16_t, uint16_t,
|
uint64_t, uint16_t, uint16_t, uint16_t, uint16_t,
|
||||||
@@ -54,32 +56,13 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
~DataProcessor();
|
~DataProcessor();
|
||||||
|
|
||||||
|
|
||||||
//*** static functions ***
|
|
||||||
/**
|
|
||||||
* Get ErrorMask
|
|
||||||
* @return ErrorMask
|
|
||||||
*/
|
|
||||||
static uint64_t GetErrorMask();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get RunningMask
|
|
||||||
* @return RunningMask
|
|
||||||
*/
|
|
||||||
static uint64_t GetRunningMask();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reset RunningMask
|
|
||||||
*/
|
|
||||||
static void ResetRunningMask();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Silent Mode
|
|
||||||
* @param mode 1 sets 0 unsets
|
|
||||||
*/
|
|
||||||
static void SetSilentMode(bool mode);
|
|
||||||
|
|
||||||
//*** non static functions ***
|
|
||||||
//*** getters ***
|
//*** getters ***
|
||||||
|
/**
|
||||||
|
* Returns if the thread is currently running
|
||||||
|
* @returns true if thread is running, else false
|
||||||
|
*/
|
||||||
|
bool IsRunning();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get acquisition started flag
|
* Get acquisition started flag
|
||||||
* @return acquisition started flag
|
* @return acquisition started flag
|
||||||
@@ -177,7 +160,7 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
* @param findex pointer to file index
|
* @param findex pointer to file index
|
||||||
* @param owenable pointer to over write enable
|
* @param owenable pointer to over write enable
|
||||||
* @param dindex pointer to detector index
|
* @param dindex pointer to detector index
|
||||||
* @param nunits pointer to number of theads/ units per detector
|
* @param nunits pointer to number of threads/ units per detector
|
||||||
* @param nf pointer to number of images in acquisition
|
* @param nf pointer to number of images in acquisition
|
||||||
* @param dr pointer to dynamic range
|
* @param dr pointer to dynamic range
|
||||||
* @param portno pointer to udp port number
|
* @param portno pointer to udp port number
|
||||||
@@ -213,6 +196,12 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
*/
|
*/
|
||||||
void SetPixelDimension();
|
void SetPixelDimension();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Silent Mode
|
||||||
|
* @param mode 1 sets 0 unsets
|
||||||
|
*/
|
||||||
|
void SetSilentMode(bool mode);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@@ -222,12 +211,6 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
*/
|
*/
|
||||||
std::string GetType();
|
std::string GetType();
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns if the thread is currently running
|
|
||||||
* @returns true if thread is running, else false
|
|
||||||
*/
|
|
||||||
bool IsRunning();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Record First Indices (firstAcquisitionIndex, firstMeasurementIndex)
|
* Record First Indices (firstAcquisitionIndex, firstMeasurementIndex)
|
||||||
* @param fnum frame index to record
|
* @param fnum frame index to record
|
||||||
@@ -292,17 +275,8 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
/** type of thread */
|
/** type of thread */
|
||||||
static const std::string TypeName;
|
static const std::string TypeName;
|
||||||
|
|
||||||
/** Total Number of DataProcessor Objects */
|
/** Object running status */
|
||||||
static int NumberofDataProcessors;
|
bool runningFlag;
|
||||||
|
|
||||||
/** Mask of errors on any object eg.thread creation */
|
|
||||||
static uint64_t ErrorMask;
|
|
||||||
|
|
||||||
/** Mask of all listener objects running */
|
|
||||||
static uint64_t RunningMask;
|
|
||||||
|
|
||||||
/** mutex to update static items among objects (threads)*/
|
|
||||||
static pthread_mutex_t Mutex;
|
|
||||||
|
|
||||||
/** GeneralData (Detector Data) object */
|
/** GeneralData (Detector Data) object */
|
||||||
const GeneralData* generalData;
|
const GeneralData* generalData;
|
||||||
@@ -310,9 +284,6 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
/** Fifo structure */
|
/** Fifo structure */
|
||||||
Fifo* fifo;
|
Fifo* fifo;
|
||||||
|
|
||||||
/** Silent Mode */
|
|
||||||
static bool SilentMode;
|
|
||||||
|
|
||||||
|
|
||||||
//individual members
|
//individual members
|
||||||
/** File writer implemented as binary or hdf5 File */
|
/** File writer implemented as binary or hdf5 File */
|
||||||
@@ -380,6 +351,8 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
uint64_t currentFrameIndex;
|
uint64_t currentFrameIndex;
|
||||||
|
|
||||||
|
|
||||||
|
/** Silent Mode */
|
||||||
|
bool silentMode;
|
||||||
|
|
||||||
//call back
|
//call back
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* Calls Base Class CreateThread(), sets ErrorMask if error and increments NumberofDataStreamers
|
* Calls Base Class CreateThread(), sets ErrorMask if error and increments NumberofDataStreamers
|
||||||
|
* @param ret OK or FAIL if thread creation succeeded or failed
|
||||||
|
* @param ind self index
|
||||||
* @param f address of Fifo pointer
|
* @param f address of Fifo pointer
|
||||||
* @param dr pointer to dynamic range
|
* @param dr pointer to dynamic range
|
||||||
* @param sEnable pointer to short frame enable
|
* @param sEnable pointer to short frame enable
|
||||||
@@ -27,7 +29,7 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
* @param fd flipped data enable for x and y dimensions
|
* @param fd flipped data enable for x and y dimensions
|
||||||
* @param ajh additional json header
|
* @param ajh additional json header
|
||||||
*/
|
*/
|
||||||
DataStreamer(Fifo*& f, uint32_t* dr, int* sEnable, uint64_t* fi, int* fd, char* ajh);
|
DataStreamer(int& ret, int ind, Fifo*& f, uint32_t* dr, int* sEnable, uint64_t* fi, int* fd, char* ajh);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
@@ -35,34 +37,12 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
*/
|
*/
|
||||||
~DataStreamer();
|
~DataStreamer();
|
||||||
|
|
||||||
|
|
||||||
//*** static functions ***
|
|
||||||
/**
|
|
||||||
* Get RunningMask
|
|
||||||
* @return RunningMask
|
|
||||||
*/
|
|
||||||
static uint64_t GetErrorMask();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get RunningMask
|
|
||||||
* @return RunningMask
|
|
||||||
*/
|
|
||||||
static uint64_t GetRunningMask();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reset RunningMask
|
|
||||||
*/
|
|
||||||
static void ResetRunningMask();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Silent Mode
|
|
||||||
* @param mode 1 sets 0 unsets
|
|
||||||
*/
|
|
||||||
static void SetSilentMode(bool mode);
|
|
||||||
|
|
||||||
//*** non static functions ***
|
|
||||||
//*** getters ***
|
//*** getters ***
|
||||||
|
/**
|
||||||
|
* Returns if the thread is currently running
|
||||||
|
* @returns true if thread is running, else false
|
||||||
|
*/
|
||||||
|
bool IsRunning();
|
||||||
|
|
||||||
|
|
||||||
//*** setters ***
|
//*** setters ***
|
||||||
@@ -123,7 +103,13 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
* Restream stop dummy packet
|
* Restream stop dummy packet
|
||||||
* @return OK or FAIL
|
* @return OK or FAIL
|
||||||
*/
|
*/
|
||||||
int restreamStop();
|
int RestreamStop();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Silent Mode
|
||||||
|
* @param mode 1 sets 0 unsets
|
||||||
|
*/
|
||||||
|
void SetSilentMode(bool mode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@@ -133,12 +119,6 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
*/
|
*/
|
||||||
std::string GetType();
|
std::string GetType();
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns if the thread is currently running
|
|
||||||
* @returns true if thread is running, else false
|
|
||||||
*/
|
|
||||||
bool IsRunning();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Record First Indices (firstAcquisitionIndex, firstMeasurementIndex)
|
* Record First Indices (firstAcquisitionIndex, firstMeasurementIndex)
|
||||||
* @param fnum frame index to record
|
* @param fnum frame index to record
|
||||||
@@ -179,17 +159,8 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
/** type of thread */
|
/** type of thread */
|
||||||
static const std::string TypeName;
|
static const std::string TypeName;
|
||||||
|
|
||||||
/** Total Number of DataStreamer Objects */
|
/** Object running status */
|
||||||
static int NumberofDataStreamers;
|
bool runningFlag;
|
||||||
|
|
||||||
/** Mask of errors on any object eg.thread creation */
|
|
||||||
static uint64_t ErrorMask;
|
|
||||||
|
|
||||||
/** Mask of all listener objects running */
|
|
||||||
static uint64_t RunningMask;
|
|
||||||
|
|
||||||
/** mutex to update static items among objects (threads)*/
|
|
||||||
static pthread_mutex_t Mutex;
|
|
||||||
|
|
||||||
/** GeneralData (Detector Data) object */
|
/** GeneralData (Detector Data) object */
|
||||||
const GeneralData* generalData;
|
const GeneralData* generalData;
|
||||||
@@ -197,9 +168,6 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
/** Fifo structure */
|
/** Fifo structure */
|
||||||
Fifo* fifo;
|
Fifo* fifo;
|
||||||
|
|
||||||
/** Silent Mode */
|
|
||||||
static bool SilentMode;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** ZMQ Socket - Receiver to Client */
|
/** ZMQ Socket - Receiver to Client */
|
||||||
@@ -237,5 +205,8 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
|
|
||||||
/** additional json header */
|
/** additional json header */
|
||||||
char* additionJsonHeader;
|
char* additionJsonHeader;
|
||||||
|
|
||||||
|
/** Silent Mode */
|
||||||
|
bool silentMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -20,11 +20,12 @@ class Fifo : private virtual slsReceiverDefs {
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* Calls CreateFifos that creates fifos and allocates memory
|
* Calls CreateFifos that creates fifos and allocates memory
|
||||||
|
* @param ind self index
|
||||||
* @param fifoItemSize size of each fifo item
|
* @param fifoItemSize size of each fifo item
|
||||||
* @param depth fifo depth
|
* @param depth fifo depth
|
||||||
* @param success true if successful, else false
|
* @param success true if successful, else false
|
||||||
*/
|
*/
|
||||||
Fifo(uint32_t fifoItemSize, uint32_t depth, bool &success);
|
Fifo(int ind, uint32_t fifoItemSize, uint32_t depth, bool &success);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
@@ -88,9 +89,6 @@ class Fifo : private virtual slsReceiverDefs {
|
|||||||
void DestroyFifos();
|
void DestroyFifos();
|
||||||
|
|
||||||
|
|
||||||
/** Total Number of Fifo Class Objects */
|
|
||||||
static int NumberofFifoClassObjects;
|
|
||||||
|
|
||||||
/** Self Index */
|
/** Self Index */
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public:
|
|||||||
{
|
{
|
||||||
ostringstream osfn;
|
ostringstream osfn;
|
||||||
osfn << fpath << "/" << fnameprefix;
|
osfn << fpath << "/" << fnameprefix;
|
||||||
if (dindex >= 0) osfn << "_d" << ((unitindex >= numunits) ? unitindex : (dindex * numunits + unitindex)); //if unit index > numunits, all receivers in one program (userReceiver)
|
if (dindex >= 0) osfn << "_d" << (dindex * numunits + unitindex);
|
||||||
if (frindexenable) osfn << "_f" << setfill('0') << setw(12) << fnum;
|
if (frindexenable) osfn << "_f" << setfill('0') << setw(12) << fnum;
|
||||||
osfn << "_" << findex;
|
osfn << "_" << findex;
|
||||||
osfn << ".h5";
|
osfn << ".h5";
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* Calls Base Class CreateThread(), sets ErrorMask if error and increments NumberofListerners
|
* Calls Base Class CreateThread(), sets ErrorMask if error and increments NumberofListerners
|
||||||
|
* @param ret OK or FAIL if thread creation succeeded or failed
|
||||||
|
* @param ind self index
|
||||||
* @param dtype detector type
|
* @param dtype detector type
|
||||||
* @param f address of Fifo pointer
|
* @param f address of Fifo pointer
|
||||||
* @param s pointer to receiver status
|
* @param s pointer to receiver status
|
||||||
@@ -30,7 +32,8 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
* @param nf pointer to number of images to catch
|
* @param nf pointer to number of images to catch
|
||||||
* @param dr pointer to dynamic range
|
* @param dr pointer to dynamic range
|
||||||
*/
|
*/
|
||||||
Listener(detectorType dtype, Fifo*& f, runStatus* s, uint32_t* portno, char* e, int* act, uint64_t* nf, uint32_t* dr);
|
Listener(int& ret, int ind, detectorType dtype, Fifo*& f, runStatus* s,
|
||||||
|
uint32_t* portno, char* e, int* act, uint64_t* nf, uint32_t* dr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
@@ -39,33 +42,13 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
~Listener();
|
~Listener();
|
||||||
|
|
||||||
|
|
||||||
//*** static functions ***
|
|
||||||
/**
|
|
||||||
* Get ErrorMask
|
|
||||||
* @return ErrorMask
|
|
||||||
*/
|
|
||||||
static uint64_t GetErrorMask();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get RunningMask
|
|
||||||
* @return RunningMask
|
|
||||||
*/
|
|
||||||
static uint64_t GetRunningMask();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reset RunningMask
|
|
||||||
*/
|
|
||||||
static void ResetRunningMask();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Silent Mode
|
|
||||||
* @param mode 1 sets 0 unsets
|
|
||||||
*/
|
|
||||||
static void SetSilentMode(bool mode);
|
|
||||||
|
|
||||||
|
|
||||||
//*** non static functions ***
|
|
||||||
//*** getters ***
|
//*** getters ***
|
||||||
|
/**
|
||||||
|
* Returns if the thread is currently running
|
||||||
|
* @returns true if thread is running, else false
|
||||||
|
*/
|
||||||
|
bool IsRunning();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get acquisition started flag
|
* Get acquisition started flag
|
||||||
* @return acquisition started flag
|
* @return acquisition started flag
|
||||||
@@ -142,6 +125,12 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
*/
|
*/
|
||||||
void ShutDownUDPSocket();
|
void ShutDownUDPSocket();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Silent Mode
|
||||||
|
* @param mode 1 sets 0 unsets
|
||||||
|
*/
|
||||||
|
void SetSilentMode(bool mode);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -153,12 +142,6 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
*/
|
*/
|
||||||
std::string GetType();
|
std::string GetType();
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns if the thread is currently running
|
|
||||||
* @returns true if thread is running, else false
|
|
||||||
*/
|
|
||||||
bool IsRunning();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Record First Indices (firstAcquisitionIndex, firstMeasurementIndex)
|
* Record First Indices (firstAcquisitionIndex, firstMeasurementIndex)
|
||||||
* @param fnum frame index to record
|
* @param fnum frame index to record
|
||||||
@@ -205,17 +188,8 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
/** type of thread */
|
/** type of thread */
|
||||||
static const std::string TypeName;
|
static const std::string TypeName;
|
||||||
|
|
||||||
/** Total Number of Listener Objects */
|
/** Object running status */
|
||||||
static int NumberofListeners;
|
bool runningFlag;
|
||||||
|
|
||||||
/** Mask of errors on any object eg.thread creation */
|
|
||||||
static uint64_t ErrorMask;
|
|
||||||
|
|
||||||
/** Mask of all listener objects running */
|
|
||||||
static uint64_t RunningMask;
|
|
||||||
|
|
||||||
/** Mutex to update static items among objects (threads)*/
|
|
||||||
static pthread_mutex_t Mutex;
|
|
||||||
|
|
||||||
/** GeneralData (Detector Data) object */
|
/** GeneralData (Detector Data) object */
|
||||||
const GeneralData* generalData;
|
const GeneralData* generalData;
|
||||||
@@ -223,9 +197,6 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
/** Fifo structure */
|
/** Fifo structure */
|
||||||
Fifo* fifo;
|
Fifo* fifo;
|
||||||
|
|
||||||
/** Silent Mode */
|
|
||||||
static bool SilentMode;
|
|
||||||
|
|
||||||
|
|
||||||
// individual members
|
// individual members
|
||||||
/** Detector Type */
|
/** Detector Type */
|
||||||
@@ -303,5 +274,8 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
|
|
||||||
/** number of images for statistic */
|
/** number of images for statistic */
|
||||||
uint32_t numFramesStatistic;
|
uint32_t numFramesStatistic;
|
||||||
|
|
||||||
|
/** Silent Mode */
|
||||||
|
bool silentMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -22,18 +22,8 @@ using namespace std;
|
|||||||
|
|
||||||
const string DataProcessor::TypeName = "DataProcessor";
|
const string DataProcessor::TypeName = "DataProcessor";
|
||||||
|
|
||||||
int DataProcessor::NumberofDataProcessors(0);
|
|
||||||
|
|
||||||
uint64_t DataProcessor::ErrorMask(0x0);
|
DataProcessor::DataProcessor(int& ret, int ind, Fifo*& f, fileFormat* ftype, bool fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr,
|
||||||
|
|
||||||
uint64_t DataProcessor::RunningMask(0x0);
|
|
||||||
|
|
||||||
pthread_mutex_t DataProcessor::Mutex = PTHREAD_MUTEX_INITIALIZER;
|
|
||||||
|
|
||||||
bool DataProcessor::SilentMode(false);
|
|
||||||
|
|
||||||
|
|
||||||
DataProcessor::DataProcessor(Fifo*& f, fileFormat* ftype, bool fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr,
|
|
||||||
uint32_t* freq, uint32_t* timer,
|
uint32_t* freq, uint32_t* timer,
|
||||||
void (*dataReadycb)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t,
|
void (*dataReadycb)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t,
|
||||||
uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
|
uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
|
||||||
@@ -44,7 +34,8 @@ DataProcessor::DataProcessor(Fifo*& f, fileFormat* ftype, bool fwenable, bool* d
|
|||||||
char*, uint32_t &, void*),
|
char*, uint32_t &, void*),
|
||||||
void *pDataReadycb) :
|
void *pDataReadycb) :
|
||||||
|
|
||||||
ThreadObject(NumberofDataProcessors),
|
ThreadObject(ind),
|
||||||
|
runningFlag(0),
|
||||||
generalData(0),
|
generalData(0),
|
||||||
fifo(f),
|
fifo(f),
|
||||||
file(0),
|
file(0),
|
||||||
@@ -65,18 +56,16 @@ DataProcessor::DataProcessor(Fifo*& f, fileFormat* ftype, bool fwenable, bool* d
|
|||||||
numTotalFramesCaught(0),
|
numTotalFramesCaught(0),
|
||||||
numFramesCaught(0),
|
numFramesCaught(0),
|
||||||
currentFrameIndex(0),
|
currentFrameIndex(0),
|
||||||
|
silentMode(false),
|
||||||
rawDataReadyCallBack(dataReadycb),
|
rawDataReadyCallBack(dataReadycb),
|
||||||
rawDataModifyReadyCallBack(dataModifyReadycb),
|
rawDataModifyReadyCallBack(dataModifyReadycb),
|
||||||
pRawDataReady(pDataReadycb)
|
pRawDataReady(pDataReadycb)
|
||||||
{
|
{
|
||||||
if(ThreadObject::CreateThread()){
|
ret = FAIL;
|
||||||
pthread_mutex_lock(&Mutex);
|
if(ThreadObject::CreateThread() == OK)
|
||||||
ErrorMask ^= (1<<index);
|
ret = OK;
|
||||||
pthread_mutex_unlock(&Mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
NumberofDataProcessors++;
|
FILE_LOG(logDEBUG) << "DataProcessor " << ind << " created";
|
||||||
FILE_LOG(logDEBUG) << "Number of DataProcessors: " << NumberofDataProcessors;
|
|
||||||
|
|
||||||
memset((void*)&timerBegin, 0, sizeof(timespec));
|
memset((void*)&timerBegin, 0, sizeof(timespec));
|
||||||
}
|
}
|
||||||
@@ -86,35 +75,15 @@ DataProcessor::~DataProcessor() {
|
|||||||
if (file) delete file;
|
if (file) delete file;
|
||||||
if (tempBuffer) delete [] tempBuffer;
|
if (tempBuffer) delete [] tempBuffer;
|
||||||
ThreadObject::DestroyThread();
|
ThreadObject::DestroyThread();
|
||||||
NumberofDataProcessors--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** static functions */
|
|
||||||
|
|
||||||
uint64_t DataProcessor::GetErrorMask() {
|
|
||||||
return ErrorMask;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t DataProcessor::GetRunningMask() {
|
|
||||||
return RunningMask;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataProcessor::ResetRunningMask() {
|
|
||||||
RunningMask = 0x0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataProcessor::SetSilentMode(bool mode) {
|
|
||||||
SilentMode = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** non static functions */
|
|
||||||
/** getters */
|
/** getters */
|
||||||
string DataProcessor::GetType(){
|
string DataProcessor::GetType(){
|
||||||
return TypeName;
|
return TypeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DataProcessor::IsRunning() {
|
bool DataProcessor::IsRunning() {
|
||||||
return ((1 << index) & RunningMask);
|
return runningFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DataProcessor::GetAcquisitionStartedFlag(){
|
bool DataProcessor::GetAcquisitionStartedFlag(){
|
||||||
@@ -149,16 +118,12 @@ uint64_t DataProcessor::GetProcessedMeasurementIndex() {
|
|||||||
|
|
||||||
/** setters */
|
/** setters */
|
||||||
void DataProcessor::StartRunning() {
|
void DataProcessor::StartRunning() {
|
||||||
pthread_mutex_lock(&Mutex);
|
runningFlag = true;
|
||||||
RunningMask |= (1<<index);
|
|
||||||
pthread_mutex_unlock(&Mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DataProcessor::StopRunning() {
|
void DataProcessor::StopRunning() {
|
||||||
pthread_mutex_lock(&Mutex);
|
runningFlag = false;
|
||||||
RunningMask ^= (1<<index);
|
|
||||||
pthread_mutex_unlock(&Mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataProcessor::SetFifo(Fifo*& f) {
|
void DataProcessor::SetFifo(Fifo*& f) {
|
||||||
@@ -173,6 +138,7 @@ void DataProcessor::ResetParametersforNewAcquisition() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DataProcessor::ResetParametersforNewMeasurement(){
|
void DataProcessor::ResetParametersforNewMeasurement(){
|
||||||
|
runningFlag = false;
|
||||||
numFramesCaught = 0;
|
numFramesCaught = 0;
|
||||||
firstMeasurementIndex = 0;
|
firstMeasurementIndex = 0;
|
||||||
measurementStartedFlag = false;
|
measurementStartedFlag = false;
|
||||||
@@ -253,7 +219,7 @@ void DataProcessor::SetupFileWriter(bool fwe, int* nd, char* fname, char* fpath,
|
|||||||
if (g)
|
if (g)
|
||||||
generalData = g;
|
generalData = g;
|
||||||
// fix xcoord as detector is not providing it right now
|
// fix xcoord as detector is not providing it right now
|
||||||
xcoordin1D = ((NumberofDataProcessors > (*nunits)) ? index : ((*dindex) * (*nunits)) + index);
|
xcoordin1D = ((*dindex) * (*nunits)) + index;
|
||||||
|
|
||||||
|
|
||||||
if (file) {
|
if (file) {
|
||||||
@@ -267,13 +233,13 @@ void DataProcessor::SetupFileWriter(bool fwe, int* nd, char* fname, char* fpath,
|
|||||||
file = new HDF5File(index, generalData->maxFramesPerFile,
|
file = new HDF5File(index, generalData->maxFramesPerFile,
|
||||||
nd, fname, fpath, findex, owenable,
|
nd, fname, fpath, findex, owenable,
|
||||||
dindex, nunits, nf, dr, portno,
|
dindex, nunits, nf, dr, portno,
|
||||||
generalData->nPixelsX, generalData->nPixelsY, &SilentMode);
|
generalData->nPixelsX, generalData->nPixelsY, &silentMode);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
file = new BinaryFile(index, generalData->maxFramesPerFile,
|
file = new BinaryFile(index, generalData->maxFramesPerFile,
|
||||||
nd, fname, fpath, findex, owenable,
|
nd, fname, fpath, findex, owenable,
|
||||||
dindex, nunits, nf, dr, portno, &SilentMode);
|
dindex, nunits, nf, dr, portno, &silentMode);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -499,6 +465,10 @@ void DataProcessor::SetPixelDimension() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DataProcessor::SetSilentMode(bool mode) {
|
||||||
|
silentMode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** eiger specific */
|
/** eiger specific */
|
||||||
void DataProcessor::InsertGapPixels(char* buf, uint32_t dr) {
|
void DataProcessor::InsertGapPixels(char* buf, uint32_t dr) {
|
||||||
|
|||||||
@@ -15,19 +15,10 @@ using namespace std;
|
|||||||
|
|
||||||
const string DataStreamer::TypeName = "DataStreamer";
|
const string DataStreamer::TypeName = "DataStreamer";
|
||||||
|
|
||||||
int DataStreamer::NumberofDataStreamers(0);
|
|
||||||
|
|
||||||
uint64_t DataStreamer::ErrorMask(0x0);
|
DataStreamer::DataStreamer(int& ret, int ind, Fifo*& f, uint32_t* dr, int* sEnable, uint64_t* fi, int* fd, char* ajh) :
|
||||||
|
ThreadObject(ind),
|
||||||
uint64_t DataStreamer::RunningMask(0x0);
|
runningFlag(0),
|
||||||
|
|
||||||
pthread_mutex_t DataStreamer::Mutex = PTHREAD_MUTEX_INITIALIZER;
|
|
||||||
|
|
||||||
bool DataStreamer::SilentMode(false);
|
|
||||||
|
|
||||||
|
|
||||||
DataStreamer::DataStreamer(Fifo*& f, uint32_t* dr, int* sEnable, uint64_t* fi, int* fd, char* ajh) :
|
|
||||||
ThreadObject(NumberofDataStreamers),
|
|
||||||
generalData(0),
|
generalData(0),
|
||||||
fifo(f),
|
fifo(f),
|
||||||
zmqSocket(0),
|
zmqSocket(0),
|
||||||
@@ -40,16 +31,14 @@ DataStreamer::DataStreamer(Fifo*& f, uint32_t* dr, int* sEnable, uint64_t* fi, i
|
|||||||
firstMeasurementIndex(0),
|
firstMeasurementIndex(0),
|
||||||
completeBuffer(0),
|
completeBuffer(0),
|
||||||
flippedData(fd),
|
flippedData(fd),
|
||||||
additionJsonHeader(ajh)
|
additionJsonHeader(ajh),
|
||||||
|
silentMode(false)
|
||||||
{
|
{
|
||||||
if(ThreadObject::CreateThread()){
|
ret = FAIL;
|
||||||
pthread_mutex_lock(&Mutex);
|
if(ThreadObject::CreateThread() == OK)
|
||||||
ErrorMask ^= (1<<index);
|
ret = OK;
|
||||||
pthread_mutex_unlock(&Mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
NumberofDataStreamers++;
|
FILE_LOG(logDEBUG) << "DataStreamer " << ind << " created";
|
||||||
FILE_LOG(logDEBUG) << "Number of DataStreamers: " << NumberofDataStreamers;
|
|
||||||
|
|
||||||
strcpy(fileNametoStream, "");
|
strcpy(fileNametoStream, "");
|
||||||
}
|
}
|
||||||
@@ -59,51 +48,26 @@ DataStreamer::~DataStreamer() {
|
|||||||
CloseZmqSocket();
|
CloseZmqSocket();
|
||||||
if (completeBuffer) delete [] completeBuffer;
|
if (completeBuffer) delete [] completeBuffer;
|
||||||
ThreadObject::DestroyThread();
|
ThreadObject::DestroyThread();
|
||||||
NumberofDataStreamers--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** static functions */
|
|
||||||
|
|
||||||
uint64_t DataStreamer::GetErrorMask() {
|
|
||||||
return ErrorMask;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t DataStreamer::GetRunningMask() {
|
|
||||||
return RunningMask;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataStreamer::ResetRunningMask() {
|
|
||||||
RunningMask = 0x0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataStreamer::SetSilentMode(bool mode) {
|
|
||||||
SilentMode = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** non static functions */
|
|
||||||
/** getters */
|
/** getters */
|
||||||
string DataStreamer::GetType(){
|
string DataStreamer::GetType(){
|
||||||
return TypeName;
|
return TypeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DataStreamer::IsRunning() {
|
bool DataStreamer::IsRunning() {
|
||||||
return ((1 << index) & RunningMask);
|
return runningFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** setters */
|
/** setters */
|
||||||
void DataStreamer::StartRunning() {
|
void DataStreamer::StartRunning() {
|
||||||
pthread_mutex_lock(&Mutex);
|
runningFlag = true;
|
||||||
RunningMask |= (1<<index);
|
|
||||||
pthread_mutex_unlock(&Mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DataStreamer::StopRunning() {
|
void DataStreamer::StopRunning() {
|
||||||
pthread_mutex_lock(&Mutex);
|
runningFlag = false;
|
||||||
RunningMask ^= (1<<index);
|
|
||||||
pthread_mutex_unlock(&Mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataStreamer::SetFifo(Fifo*& f) {
|
void DataStreamer::SetFifo(Fifo*& f) {
|
||||||
@@ -116,6 +80,7 @@ void DataStreamer::ResetParametersforNewAcquisition() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DataStreamer::ResetParametersforNewMeasurement(char* fname){
|
void DataStreamer::ResetParametersforNewMeasurement(char* fname){
|
||||||
|
runningFlag = false;
|
||||||
firstMeasurementIndex = 0;
|
firstMeasurementIndex = 0;
|
||||||
measurementStartedFlag = false;
|
measurementStartedFlag = false;
|
||||||
strcpy(fileNametoStream, fname);
|
strcpy(fileNametoStream, fname);
|
||||||
@@ -295,7 +260,7 @@ int DataStreamer::SendHeader(sls_detector_header* header, uint32_t size, uint32_
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int DataStreamer::restreamStop() {
|
int DataStreamer::RestreamStop() {
|
||||||
//send dummy header
|
//send dummy header
|
||||||
int ret = zmqSocket->SendHeaderData(index, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
int ret = zmqSocket->SendHeaderData(index, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
@@ -304,3 +269,9 @@ int DataStreamer::restreamStop() {
|
|||||||
}
|
}
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DataStreamer::SetSilentMode(bool mode) {
|
||||||
|
silentMode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,10 +12,9 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int Fifo::NumberofFifoClassObjects(0);
|
|
||||||
|
|
||||||
Fifo::Fifo(uint32_t fifoItemSize, uint32_t depth, bool &success):
|
Fifo::Fifo(int ind, uint32_t fifoItemSize, uint32_t depth, bool &success):
|
||||||
index(NumberofFifoClassObjects),
|
index(ind),
|
||||||
memory(0),
|
memory(0),
|
||||||
fifoBound(0),
|
fifoBound(0),
|
||||||
fifoFree(0),
|
fifoFree(0),
|
||||||
@@ -24,7 +23,7 @@ Fifo::Fifo(uint32_t fifoItemSize, uint32_t depth, bool &success):
|
|||||||
status_fifoBound(0),
|
status_fifoBound(0),
|
||||||
status_fifoFree(depth){
|
status_fifoFree(depth){
|
||||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
NumberofFifoClassObjects++;
|
success = true;
|
||||||
if(CreateFifos(fifoItemSize) == FAIL)
|
if(CreateFifos(fifoItemSize) == FAIL)
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
@@ -34,7 +33,6 @@ Fifo::~Fifo() {
|
|||||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
//cprintf(BLUE,"Fifo Object %d: Goodbye\n", index);
|
//cprintf(BLUE,"Fifo Object %d: Goodbye\n", index);
|
||||||
DestroyFifos();
|
DestroyFifos();
|
||||||
NumberofFifoClassObjects--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -18,19 +18,11 @@ using namespace std;
|
|||||||
|
|
||||||
const string Listener::TypeName = "Listener";
|
const string Listener::TypeName = "Listener";
|
||||||
|
|
||||||
int Listener::NumberofListeners(0);
|
|
||||||
|
|
||||||
uint64_t Listener::ErrorMask(0x0);
|
Listener::Listener(int& ret, int ind, detectorType dtype, Fifo*& f, runStatus* s,
|
||||||
|
uint32_t* portno, char* e, int* act, uint64_t* nf, uint32_t* dr) :
|
||||||
uint64_t Listener::RunningMask(0x0);
|
ThreadObject(ind),
|
||||||
|
runningFlag(0),
|
||||||
pthread_mutex_t Listener::Mutex = PTHREAD_MUTEX_INITIALIZER;
|
|
||||||
|
|
||||||
bool Listener::SilentMode(false);
|
|
||||||
|
|
||||||
|
|
||||||
Listener::Listener(detectorType dtype, Fifo*& f, runStatus* s, uint32_t* portno, char* e, int* act, uint64_t* nf, uint32_t* dr) :
|
|
||||||
ThreadObject(NumberofListeners),
|
|
||||||
generalData(0),
|
generalData(0),
|
||||||
fifo(f),
|
fifo(f),
|
||||||
myDetectorType(dtype),
|
myDetectorType(dtype),
|
||||||
@@ -51,15 +43,14 @@ Listener::Listener(detectorType dtype, Fifo*& f, runStatus* s, uint32_t* portno,
|
|||||||
carryOverFlag(0),
|
carryOverFlag(0),
|
||||||
carryOverPacket(0),
|
carryOverPacket(0),
|
||||||
listeningPacket(0),
|
listeningPacket(0),
|
||||||
udpSocketAlive(0)
|
udpSocketAlive(0),
|
||||||
|
silentMode(false)
|
||||||
{
|
{
|
||||||
if(ThreadObject::CreateThread()){
|
ret = FAIL;
|
||||||
pthread_mutex_lock(&Mutex);
|
if(ThreadObject::CreateThread() == OK)
|
||||||
ErrorMask ^= (1<<index);
|
ret = OK;
|
||||||
pthread_mutex_unlock(&Mutex);
|
|
||||||
}
|
FILE_LOG(logDEBUG) << "Listener " << ind << " created";
|
||||||
NumberofListeners++;
|
|
||||||
FILE_LOG(logDEBUG) << "Number of Listeners: " << NumberofListeners;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -70,35 +61,15 @@ Listener::~Listener() {
|
|||||||
if (carryOverPacket) delete [] carryOverPacket;
|
if (carryOverPacket) delete [] carryOverPacket;
|
||||||
if (listeningPacket) delete [] listeningPacket;
|
if (listeningPacket) delete [] listeningPacket;
|
||||||
ThreadObject::DestroyThread();
|
ThreadObject::DestroyThread();
|
||||||
NumberofListeners--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** static functions */
|
|
||||||
|
|
||||||
uint64_t Listener::GetErrorMask() {
|
|
||||||
return ErrorMask;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t Listener::GetRunningMask() {
|
|
||||||
return RunningMask;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Listener::ResetRunningMask() {
|
|
||||||
RunningMask = 0x0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Listener::SetSilentMode(bool mode) {
|
|
||||||
SilentMode = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** non static functions */
|
|
||||||
/** getters */
|
/** getters */
|
||||||
string Listener::GetType(){
|
string Listener::GetType(){
|
||||||
return TypeName;
|
return TypeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Listener::IsRunning() {
|
bool Listener::IsRunning() {
|
||||||
return ((1 << index) & RunningMask);
|
return runningFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Listener::GetAcquisitionStartedFlag(){
|
bool Listener::GetAcquisitionStartedFlag(){
|
||||||
@@ -119,16 +90,12 @@ uint64_t Listener::GetLastFrameIndexCaught() {
|
|||||||
|
|
||||||
/** setters */
|
/** setters */
|
||||||
void Listener::StartRunning() {
|
void Listener::StartRunning() {
|
||||||
pthread_mutex_lock(&Mutex);
|
runningFlag = true;
|
||||||
RunningMask |= (1<<index);
|
|
||||||
pthread_mutex_unlock(&Mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Listener::StopRunning() {
|
void Listener::StopRunning() {
|
||||||
pthread_mutex_lock(&Mutex);
|
runningFlag = false;
|
||||||
RunningMask ^= (1<<index);
|
|
||||||
pthread_mutex_unlock(&Mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -146,6 +113,7 @@ void Listener::ResetParametersforNewAcquisition() {
|
|||||||
|
|
||||||
|
|
||||||
void Listener::ResetParametersforNewMeasurement() {
|
void Listener::ResetParametersforNewMeasurement() {
|
||||||
|
runningFlag = false;
|
||||||
measurementStartedFlag = false;
|
measurementStartedFlag = false;
|
||||||
numPacketsCaught = 0;
|
numPacketsCaught = 0;
|
||||||
firstMeasurementIndex = 0;
|
firstMeasurementIndex = 0;
|
||||||
@@ -181,7 +149,7 @@ void Listener::RecordFirstIndices(uint64_t fnum) {
|
|||||||
firstAcquisitionIndex = fnum;
|
firstAcquisitionIndex = fnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!SilentMode) {
|
if(!silentMode) {
|
||||||
if (!index) cprintf(BLUE,"%d First Acquisition Index:%lu\n"
|
if (!index) cprintf(BLUE,"%d First Acquisition Index:%lu\n"
|
||||||
"%d First Measurement Index:%lu\n",
|
"%d First Measurement Index:%lu\n",
|
||||||
index, firstAcquisitionIndex,
|
index, firstAcquisitionIndex,
|
||||||
@@ -252,6 +220,10 @@ void Listener::ShutDownUDPSocket() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Listener::SetSilentMode(bool mode) {
|
||||||
|
silentMode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Listener::ThreadExecution() {
|
void Listener::ThreadExecution() {
|
||||||
char* buffer;
|
char* buffer;
|
||||||
@@ -304,7 +276,7 @@ void Listener::ThreadExecution() {
|
|||||||
fifo->PushAddress(buffer);
|
fifo->PushAddress(buffer);
|
||||||
|
|
||||||
//Statistics
|
//Statistics
|
||||||
if(!SilentMode) {
|
if(!silentMode) {
|
||||||
numFramesStatistic++;
|
numFramesStatistic++;
|
||||||
if (numFramesStatistic >= generalData->maxFramesPerFile)
|
if (numFramesStatistic >= generalData->maxFramesPerFile)
|
||||||
PrintFifoStatistics();
|
PrintFifoStatistics();
|
||||||
|
|||||||
@@ -216,26 +216,31 @@ int UDPStandardImplementation::setDataStreamEnable(const bool enable) {
|
|||||||
dataStreamer.clear();
|
dataStreamer.clear();
|
||||||
|
|
||||||
if (enable) {
|
if (enable) {
|
||||||
bool error = false;
|
|
||||||
for ( int i = 0; i < numThreads; ++i ) {
|
for ( int i = 0; i < numThreads; ++i ) {
|
||||||
dataStreamer.push_back(new DataStreamer(fifo[i], &dynamicRange, &shortFrameEnable, &fileIndex, flippedData, additionalJsonHeader));
|
|
||||||
dataStreamer[i]->SetGeneralData(generalData);
|
int ret = FAIL;
|
||||||
if (dataStreamer[i]->CreateZmqSockets(&numThreads, streamingPort, streamingSrcIP) == FAIL) {
|
DataStreamer* s = new DataStreamer(ret, i, fifo[i], &dynamicRange, &shortFrameEnable, &fileIndex, flippedData, additionalJsonHeader);
|
||||||
error = true;
|
if (ret == FAIL)
|
||||||
break;
|
cprintf(RED,"Error: Could not create data callback threads\n");
|
||||||
|
else {
|
||||||
|
dataStreamer.push_back(s);
|
||||||
|
dataStreamer[i]->SetGeneralData(generalData);
|
||||||
|
if (dataStreamer[i]->CreateZmqSockets(&numThreads, streamingPort, streamingSrcIP) == FAIL) {
|
||||||
|
cprintf(RED,"Error: Could not create zmq sockets\n");
|
||||||
|
ret = FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// error in creating threads or zmq sockets
|
||||||
|
if (ret == FAIL) {
|
||||||
|
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
||||||
|
delete(*it);
|
||||||
|
dataStreamer.clear();
|
||||||
|
dataStreamEnable = false;
|
||||||
|
return FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (DataStreamer::GetErrorMask() || error) {
|
|
||||||
if (DataStreamer::GetErrorMask())
|
|
||||||
cprintf(RED,"Error: Could not create data callback threads\n");
|
|
||||||
else
|
|
||||||
cprintf(RED,"Error: Could not create zmq sockets\n");
|
|
||||||
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
|
||||||
delete(*it);
|
|
||||||
dataStreamer.clear();
|
|
||||||
dataStreamEnable = false;
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
SetThreadPriorities();
|
SetThreadPriorities();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -311,9 +316,12 @@ int UDPStandardImplementation::setFifoDepth(const uint32_t i) {
|
|||||||
void UDPStandardImplementation::setSilentMode(const uint32_t i){
|
void UDPStandardImplementation::setSilentMode(const uint32_t i){
|
||||||
silentMode = i;
|
silentMode = i;
|
||||||
|
|
||||||
Listener::SetSilentMode(i);
|
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||||
DataProcessor::SetSilentMode(i);
|
(*it)->SetSilentMode(i);
|
||||||
DataStreamer::SetSilentMode(i);
|
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||||
|
(*it)->SetSilentMode(i);
|
||||||
|
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
||||||
|
(*it)->SetSilentMode(i);
|
||||||
|
|
||||||
FILE_LOG(logINFO) << "Silent Mode: " << i;
|
FILE_LOG(logINFO) << "Silent Mode: " << i;
|
||||||
}
|
}
|
||||||
@@ -363,12 +371,18 @@ int UDPStandardImplementation::setDetectorType(const detectorType d) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//create threads
|
//create threads
|
||||||
for ( int i=0; i < numThreads; ++i ) {
|
for ( int i = 0; i < numThreads; ++i ) {
|
||||||
listener.push_back(new Listener(myDetectorType, fifo[i], &status, &udpPortNum[i], eth, &activated, &numberOfFrames, &dynamicRange));
|
|
||||||
dataProcessor.push_back(new DataProcessor(fifo[i], &fileFormatType,
|
int ret = FAIL;
|
||||||
fileWriteEnable, &dataStreamEnable, &gapPixelsEnable, &dynamicRange, &frameToGuiFrequency, &frameToGuiTimerinMS,
|
Listener* l = new Listener(ret, i, myDetectorType, fifo[i], &status, &udpPortNum[i], eth, &activated, &numberOfFrames, &dynamicRange);
|
||||||
rawDataReadyCallBack, rawDataModifyReadyCallBack, pRawDataReady));
|
DataProcessor* p = NULL;
|
||||||
if (Listener::GetErrorMask() || DataProcessor::GetErrorMask()) {
|
if (ret == OK)
|
||||||
|
p = new DataProcessor(ret, i, fifo[i], &fileFormatType,
|
||||||
|
fileWriteEnable, &dataStreamEnable, &gapPixelsEnable, &dynamicRange, &frameToGuiFrequency, &frameToGuiTimerinMS,
|
||||||
|
rawDataReadyCallBack, rawDataModifyReadyCallBack, pRawDataReady);
|
||||||
|
|
||||||
|
// error in creating threads
|
||||||
|
if (ret == FAIL) {
|
||||||
FILE_LOG(logERROR) << "Could not create listener/dataprocessor threads (index:" << i << ")";
|
FILE_LOG(logERROR) << "Could not create listener/dataprocessor threads (index:" << i << ")";
|
||||||
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||||
delete(*it);
|
delete(*it);
|
||||||
@@ -378,6 +392,9 @@ int UDPStandardImplementation::setDetectorType(const detectorType d) {
|
|||||||
dataProcessor.clear();
|
dataProcessor.clear();
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
listener.push_back(l);
|
||||||
|
dataProcessor.push_back(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
//set up writer and callbacks
|
//set up writer and callbacks
|
||||||
@@ -474,14 +491,20 @@ void UDPStandardImplementation::stopReceiver(){
|
|||||||
//set status to transmitting
|
//set status to transmitting
|
||||||
startReadout();
|
startReadout();
|
||||||
|
|
||||||
//wait for the processes to be done
|
//wait for the processes (Listener and DataProcessor) to be done
|
||||||
while(Listener::GetRunningMask()){
|
bool running = true;
|
||||||
usleep(5000);
|
while(running) {
|
||||||
}
|
running = false;
|
||||||
while(DataProcessor::GetRunningMask()){
|
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||||
usleep(5000);
|
if ((*it)->IsRunning())
|
||||||
|
running = true;
|
||||||
|
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||||
|
if ((*it)->IsRunning())
|
||||||
|
running = true;
|
||||||
|
usleep(5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//create virtual file
|
//create virtual file
|
||||||
if (fileWriteEnable && fileFormatType == HDF5) {
|
if (fileWriteEnable && fileFormatType == HDF5) {
|
||||||
uint64_t maxIndexCaught = 0;
|
uint64_t maxIndexCaught = 0;
|
||||||
@@ -495,9 +518,15 @@ void UDPStandardImplementation::stopReceiver(){
|
|||||||
dataProcessor[0]->EndofAcquisition(maxIndexCaught); //to create virtual file
|
dataProcessor[0]->EndofAcquisition(maxIndexCaught); //to create virtual file
|
||||||
}
|
}
|
||||||
|
|
||||||
while(DataStreamer::GetRunningMask()){
|
//wait for the processes (DataStreamer) to be done
|
||||||
usleep(5000);
|
running = true;
|
||||||
}
|
while(running) {
|
||||||
|
running = false;
|
||||||
|
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
||||||
|
if ((*it)->IsRunning())
|
||||||
|
running = true;
|
||||||
|
usleep(5000);
|
||||||
|
}
|
||||||
|
|
||||||
status = RUN_FINISHED;
|
status = RUN_FINISHED;
|
||||||
FILE_LOG(logINFO) << "Status: " << runStatusType(status);
|
FILE_LOG(logINFO) << "Status: " << runStatusType(status);
|
||||||
@@ -603,7 +632,7 @@ void UDPStandardImplementation::closeFiles() {
|
|||||||
int UDPStandardImplementation::restreamStop() {
|
int UDPStandardImplementation::restreamStop() {
|
||||||
bool ret = OK;
|
bool ret = OK;
|
||||||
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) {
|
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) {
|
||||||
if ((*it)->restreamStop() == FAIL)
|
if ((*it)->RestreamStop() == FAIL)
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -667,11 +696,13 @@ int UDPStandardImplementation::SetupFifoStructure() {
|
|||||||
delete(*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
|
||||||
bool success = true;
|
bool success = true;
|
||||||
fifo.push_back( new Fifo (
|
Fifo* f = new Fifo (i,
|
||||||
(generalData->imageSize) * numberofJobs + (generalData->fifoBufferHeaderSize),
|
(generalData->imageSize) * numberofJobs + (generalData->fifoBufferHeaderSize),
|
||||||
fifoDepth, success));
|
fifoDepth, success);
|
||||||
|
//error
|
||||||
if (!success) {
|
if (!success) {
|
||||||
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 (vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it)
|
for (vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it)
|
||||||
@@ -679,6 +710,8 @@ int UDPStandardImplementation::SetupFifoStructure() {
|
|||||||
fifo.clear();
|
fifo.clear();
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
fifo.push_back(f);
|
||||||
|
|
||||||
//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]);
|
||||||
if(dataProcessor.size())dataProcessor[i]->SetFifo(fifo[i]);
|
if(dataProcessor.size())dataProcessor[i]->SetFifo(fifo[i]);
|
||||||
@@ -693,10 +726,6 @@ int UDPStandardImplementation::SetupFifoStructure() {
|
|||||||
|
|
||||||
|
|
||||||
void UDPStandardImplementation::ResetParametersforNewMeasurement() {
|
void UDPStandardImplementation::ResetParametersforNewMeasurement() {
|
||||||
Listener::ResetRunningMask();
|
|
||||||
DataProcessor::ResetRunningMask();
|
|
||||||
DataStreamer::ResetRunningMask();
|
|
||||||
|
|
||||||
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||||
(*it)->ResetParametersforNewMeasurement();
|
(*it)->ResetParametersforNewMeasurement();
|
||||||
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||||
|
|||||||
Reference in New Issue
Block a user