mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-01-16 09:15:54 +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;
|
||||
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;
|
||||
osfn << "_" << findex;
|
||||
osfn << ".raw";
|
||||
|
||||
@@ -24,6 +24,8 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
||||
/**
|
||||
* Constructor
|
||||
* 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 ftype pointer to file format type
|
||||
* @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 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,
|
||||
void (*dataReadycb)(uint64_t, uint32_t, uint32_t, uint64_t,
|
||||
uint64_t, uint16_t, uint16_t, uint16_t, uint16_t,
|
||||
@@ -54,32 +56,13 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
||||
~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 ***
|
||||
/**
|
||||
* Returns if the thread is currently running
|
||||
* @returns true if thread is running, else false
|
||||
*/
|
||||
bool IsRunning();
|
||||
|
||||
/**
|
||||
* Get 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 owenable pointer to over write enable
|
||||
* @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 dr pointer to dynamic range
|
||||
* @param portno pointer to udp port number
|
||||
@@ -213,6 +196,12 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
||||
*/
|
||||
void SetPixelDimension();
|
||||
|
||||
/**
|
||||
* Set Silent Mode
|
||||
* @param mode 1 sets 0 unsets
|
||||
*/
|
||||
void SetSilentMode(bool mode);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -222,12 +211,6 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
||||
*/
|
||||
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)
|
||||
* @param fnum frame index to record
|
||||
@@ -292,17 +275,8 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
||||
/** type of thread */
|
||||
static const std::string TypeName;
|
||||
|
||||
/** Total Number of DataProcessor Objects */
|
||||
static int NumberofDataProcessors;
|
||||
|
||||
/** 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;
|
||||
/** Object running status */
|
||||
bool runningFlag;
|
||||
|
||||
/** GeneralData (Detector Data) object */
|
||||
const GeneralData* generalData;
|
||||
@@ -310,9 +284,6 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
||||
/** Fifo structure */
|
||||
Fifo* fifo;
|
||||
|
||||
/** Silent Mode */
|
||||
static bool SilentMode;
|
||||
|
||||
|
||||
//individual members
|
||||
/** File writer implemented as binary or hdf5 File */
|
||||
@@ -380,6 +351,8 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
||||
uint64_t currentFrameIndex;
|
||||
|
||||
|
||||
/** Silent Mode */
|
||||
bool silentMode;
|
||||
|
||||
//call back
|
||||
/**
|
||||
|
||||
@@ -20,6 +20,8 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
||||
/**
|
||||
* Constructor
|
||||
* 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 dr pointer to dynamic range
|
||||
* @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 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
|
||||
@@ -35,34 +37,12 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
||||
*/
|
||||
~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 ***
|
||||
|
||||
/**
|
||||
* Returns if the thread is currently running
|
||||
* @returns true if thread is running, else false
|
||||
*/
|
||||
bool IsRunning();
|
||||
|
||||
|
||||
//*** setters ***
|
||||
@@ -123,7 +103,13 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
||||
* Restream stop dummy packet
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int restreamStop();
|
||||
int RestreamStop();
|
||||
|
||||
/**
|
||||
* Set Silent Mode
|
||||
* @param mode 1 sets 0 unsets
|
||||
*/
|
||||
void SetSilentMode(bool mode);
|
||||
|
||||
private:
|
||||
|
||||
@@ -133,12 +119,6 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
||||
*/
|
||||
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)
|
||||
* @param fnum frame index to record
|
||||
@@ -179,17 +159,8 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
||||
/** type of thread */
|
||||
static const std::string TypeName;
|
||||
|
||||
/** Total Number of DataStreamer Objects */
|
||||
static int NumberofDataStreamers;
|
||||
|
||||
/** 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;
|
||||
/** Object running status */
|
||||
bool runningFlag;
|
||||
|
||||
/** GeneralData (Detector Data) object */
|
||||
const GeneralData* generalData;
|
||||
@@ -197,9 +168,6 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
||||
/** Fifo structure */
|
||||
Fifo* fifo;
|
||||
|
||||
/** Silent Mode */
|
||||
static bool SilentMode;
|
||||
|
||||
|
||||
|
||||
/** ZMQ Socket - Receiver to Client */
|
||||
@@ -237,5 +205,8 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
||||
|
||||
/** additional json header */
|
||||
char* additionJsonHeader;
|
||||
|
||||
/** Silent Mode */
|
||||
bool silentMode;
|
||||
};
|
||||
|
||||
|
||||
@@ -20,11 +20,12 @@ class Fifo : private virtual slsReceiverDefs {
|
||||
/**
|
||||
* Constructor
|
||||
* Calls CreateFifos that creates fifos and allocates memory
|
||||
* @param ind self index
|
||||
* @param fifoItemSize size of each fifo item
|
||||
* @param depth fifo depth
|
||||
* @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
|
||||
@@ -88,9 +89,6 @@ class Fifo : private virtual slsReceiverDefs {
|
||||
void DestroyFifos();
|
||||
|
||||
|
||||
/** Total Number of Fifo Class Objects */
|
||||
static int NumberofFifoClassObjects;
|
||||
|
||||
/** Self Index */
|
||||
int index;
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
{
|
||||
ostringstream osfn;
|
||||
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;
|
||||
osfn << "_" << findex;
|
||||
osfn << ".h5";
|
||||
|
||||
@@ -21,6 +21,8 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
||||
/**
|
||||
* Constructor
|
||||
* 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 f address of Fifo pointer
|
||||
* @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 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
|
||||
@@ -39,33 +42,13 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
||||
~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 ***
|
||||
/**
|
||||
* Returns if the thread is currently running
|
||||
* @returns true if thread is running, else false
|
||||
*/
|
||||
bool IsRunning();
|
||||
|
||||
/**
|
||||
* Get acquisition started flag
|
||||
* @return acquisition started flag
|
||||
@@ -142,6 +125,12 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
||||
*/
|
||||
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();
|
||||
|
||||
/**
|
||||
* Returns if the thread is currently running
|
||||
* @returns true if thread is running, else false
|
||||
*/
|
||||
bool IsRunning();
|
||||
|
||||
/**
|
||||
* Record First Indices (firstAcquisitionIndex, firstMeasurementIndex)
|
||||
* @param fnum frame index to record
|
||||
@@ -205,17 +188,8 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
||||
/** type of thread */
|
||||
static const std::string TypeName;
|
||||
|
||||
/** Total Number of Listener Objects */
|
||||
static int NumberofListeners;
|
||||
|
||||
/** 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;
|
||||
/** Object running status */
|
||||
bool runningFlag;
|
||||
|
||||
/** GeneralData (Detector Data) object */
|
||||
const GeneralData* generalData;
|
||||
@@ -223,9 +197,6 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
||||
/** Fifo structure */
|
||||
Fifo* fifo;
|
||||
|
||||
/** Silent Mode */
|
||||
static bool SilentMode;
|
||||
|
||||
|
||||
// individual members
|
||||
/** Detector Type */
|
||||
@@ -303,5 +274,8 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
||||
|
||||
/** number of images for statistic */
|
||||
uint32_t numFramesStatistic;
|
||||
|
||||
/** Silent Mode */
|
||||
bool silentMode;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user