mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 22:40:02 +02:00
105 lines
2.0 KiB
C++
105 lines
2.0 KiB
C++
/************************************************
|
|
* @file DataProcessor.h
|
|
* @short creates data processor thread that
|
|
* pulls pointers to memory addresses from fifos
|
|
* and processes data stored in them & writes them to file
|
|
***********************************************/
|
|
#ifndef DATAPROCESSOR_H
|
|
#define DATAPROCESSOR_H
|
|
/**
|
|
*@short creates & manages a data processor thread each
|
|
*/
|
|
|
|
#include "ThreadObject.h"
|
|
|
|
class Fifo;
|
|
|
|
class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
|
|
|
public:
|
|
/**
|
|
* Constructor
|
|
* Calls Base Class CreateThread(), sets ErrorMask if error and increments NumberofDataProcessors
|
|
* @param f address of Fifo pointer
|
|
*/
|
|
DataProcessor(Fifo*& f);
|
|
|
|
/**
|
|
* Destructor
|
|
* Calls Base Class DestroyThread() and decrements NumberofDataProcessors
|
|
*/
|
|
~DataProcessor();
|
|
|
|
|
|
/**
|
|
* Get RunningMask
|
|
* @return RunningMask
|
|
*/
|
|
static uint64_t GetErrorMask();
|
|
|
|
/**
|
|
* Reset RunningMask
|
|
*/
|
|
static void ResetRunningMask();
|
|
|
|
|
|
/**
|
|
* Set bit in RunningMask to allow thread to run
|
|
*/
|
|
void StartRunning();
|
|
|
|
/**
|
|
* Reset bit in RunningMask to prevent thread from running
|
|
*/
|
|
void StopRunning();
|
|
|
|
/**
|
|
* Set Fifo pointer to the one given
|
|
* @param f address of Fifo pointer
|
|
*/
|
|
void SetFifo(Fifo*& f);
|
|
|
|
private:
|
|
|
|
/**
|
|
* Get Type
|
|
* @return type
|
|
*/
|
|
std::string GetType();
|
|
|
|
/**
|
|
* Returns if the thread is currently running
|
|
* @returns true if thread is running, else false
|
|
*/
|
|
bool IsRunning();
|
|
|
|
/**
|
|
* Thread Exeution for DataProcessor Class
|
|
* Pop bound addresses, process them,
|
|
* write to file if needed & free the address
|
|
*/
|
|
void ThreadExecution();
|
|
|
|
|
|
|
|
/** 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;
|
|
|
|
/** Fifo structure */
|
|
Fifo* fifo;
|
|
};
|
|
|
|
#endif
|