mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-26 00:00:02 +02:00
rest implementation, index issues
This commit is contained in:
parent
39560969f4
commit
0bacb903ea
@ -24,7 +24,6 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
||||
/**
|
||||
* Constructor
|
||||
* Calls Base Class CreateThread(), sets ErrorMask if error and increments NumberofDataProcessors
|
||||
* @param ind self index
|
||||
* @param f address of Fifo pointer
|
||||
* @param ftype pointer to file format type
|
||||
* @param fwenable pointer to file writer enable
|
||||
@ -32,7 +31,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
|
||||
*/
|
||||
DataProcessor(int ind, Fifo*& f, fileFormat* ftype, bool* fwenable, bool* dsEnable,
|
||||
DataProcessor(Fifo*& f, fileFormat* ftype, bool* fwenable, bool* dsEnable,
|
||||
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,
|
||||
char*, uint32_t, void*),
|
||||
void *pDataReadycb);
|
||||
|
@ -20,14 +20,13 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
||||
/**
|
||||
* Constructor
|
||||
* Calls Base Class CreateThread(), sets ErrorMask if error and increments NumberofDataStreamers
|
||||
* @param ind self index
|
||||
* @param f address of Fifo pointer
|
||||
* @param dr pointer to dynamic range
|
||||
* @param freq pointer to streaming frequency
|
||||
* @param timer pointer to timer if streaming frequency is random
|
||||
* @param sEnable pointer to short frame enable
|
||||
*/
|
||||
DataStreamer(int ind, Fifo*& f, uint32_t* dr, uint32_t* freq, uint32_t* timer, int* sEnable);
|
||||
DataStreamer(Fifo*& f, uint32_t* dr, uint32_t* freq, uint32_t* timer, int* sEnable);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
|
@ -20,12 +20,11 @@ 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 fifoDepth fifo depth
|
||||
* @param success true if successful, else false
|
||||
*/
|
||||
Fifo(int ind, uint32_t fifoItemSize, uint32_t fifoDepth, bool &success);
|
||||
Fifo(uint32_t fifoItemSize, uint32_t fifoDepth, bool &success);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
|
@ -21,7 +21,6 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
||||
/**
|
||||
* Constructor
|
||||
* Calls Base Class CreateThread(), sets ErrorMask if error and increments NumberofListerners
|
||||
* @param ind self index
|
||||
* @param dtype detector type
|
||||
* @param f address of Fifo pointer
|
||||
* @param s pointer to receiver status
|
||||
@ -31,7 +30,7 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
||||
* @param nf pointer to number of images to catch
|
||||
* @param dr pointer to dynamic range
|
||||
*/
|
||||
Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s, uint32_t* portno, char* e, int* act, uint64_t* nf, uint32_t* dr);
|
||||
Listener(detectorType dtype, Fifo*& f, runStatus* s, uint32_t* portno, char* e, int* act, uint64_t* nf, uint32_t* dr);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
|
@ -19,8 +19,9 @@ class ThreadObject : private virtual slsReceiverDefs {
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
* @param ind self index
|
||||
*/
|
||||
ThreadObject();
|
||||
ThreadObject(int ind);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
|
@ -27,6 +27,29 @@ class UDPInterface {
|
||||
*
|
||||
* UDPInterface *udp_interface = UDPInterface::create()
|
||||
*
|
||||
* Sequence of Calls from client (upon setting receiver)
|
||||
* -setDetectorType
|
||||
* -setMultiDetectorSize
|
||||
* -setDetectorPositionId
|
||||
* -initialize
|
||||
* -setUDPPortNumber,setUDPPortNumber2,setEthernetInterface
|
||||
* -setFilePath
|
||||
* -setFileName
|
||||
* -setFileIndex
|
||||
* -setFileFormat
|
||||
* -setFileWriteEnable
|
||||
* -setOverwriteEnable
|
||||
* -setFrameIndexEnable
|
||||
* -setAcquisitionPeriod
|
||||
* -setNumberOfFrames
|
||||
* -setAcquisitionTime
|
||||
* -setDynamicRange
|
||||
* -setFlippedData
|
||||
* -setActivate
|
||||
* -setTenGigaEnable
|
||||
* -setStreamingPort
|
||||
* -setDataStreamEnable
|
||||
*
|
||||
*
|
||||
* supported sequence of method-calls:
|
||||
*
|
||||
|
@ -115,27 +115,9 @@ public:
|
||||
* Overridden method
|
||||
* Shuts down and deletes UDP Sockets
|
||||
* TCPIPInterface can also call this in case of illegal shutdown of receiver
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int shutDownUDPSockets();
|
||||
void shutDownUDPSockets();
|
||||
|
||||
/**
|
||||
* Overridden method
|
||||
* Get the buffer-current frame read by receiver
|
||||
* @param c pointer to current file name
|
||||
* @param raw address of pointer, pointing to current frame to send to gui
|
||||
* @param startAcq start index of the acquisition
|
||||
* @param startFrame start index of the scan
|
||||
*/
|
||||
void readFrame(char* c,char** raw, uint64_t &startAcq, uint64_t &startFrame);
|
||||
|
||||
/**
|
||||
* Overridden method
|
||||
* Closes file / all files(data compression involves multiple files)
|
||||
* TCPIPInterface can also call this in case of illegal shutdown of receiver
|
||||
* @param i thread index valid for datacompression using root files, -1 for all threads
|
||||
*/
|
||||
void closeFile(int i = -1);
|
||||
|
||||
uint64_t getTotalFramesCaught() const;
|
||||
|
||||
|
@ -177,7 +177,6 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase
|
||||
|
||||
/**
|
||||
* Closes file / all files(data compression involves multiple files)
|
||||
* TCPIPInterface can also call this in case of illegal shutdown of receiver
|
||||
*/
|
||||
void closeFiles();
|
||||
|
||||
@ -248,11 +247,6 @@ private:
|
||||
/** Number of Jobs */
|
||||
int numberofJobs;
|
||||
|
||||
//*** mutex ***
|
||||
/** Status mutex */
|
||||
pthread_mutex_t statusMutex;
|
||||
|
||||
|
||||
//** class objects ***
|
||||
/** General Data Properties */
|
||||
GeneralData* generalData;
|
||||
|
@ -31,12 +31,12 @@ uint64_t DataProcessor::RunningMask(0x0);
|
||||
pthread_mutex_t DataProcessor::Mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
|
||||
DataProcessor::DataProcessor(int ind, Fifo*& f, fileFormat* ftype, bool* fwenable, bool* dsEnable,
|
||||
DataProcessor::DataProcessor(Fifo*& f, fileFormat* ftype, bool* fwenable, bool* dsEnable,
|
||||
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,
|
||||
char*, uint32_t, void*),
|
||||
void *pDataReadycb) :
|
||||
|
||||
ThreadObject(),
|
||||
ThreadObject(NumberofDataProcessors),
|
||||
generalData(0),
|
||||
fifo(f),
|
||||
file(0),
|
||||
@ -53,8 +53,6 @@ DataProcessor::DataProcessor(int ind, Fifo*& f, fileFormat* ftype, bool* fwenabl
|
||||
rawDataReadyCallBack(dataReadycb),
|
||||
pRawDataReady(pDataReadycb)
|
||||
{
|
||||
index = ind;
|
||||
|
||||
if(ThreadObject::CreateThread()){
|
||||
pthread_mutex_lock(&Mutex);
|
||||
ErrorMask ^= (1<<index);
|
||||
|
@ -24,8 +24,8 @@ uint64_t DataStreamer::RunningMask(0x0);
|
||||
pthread_mutex_t DataStreamer::Mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
|
||||
DataStreamer::DataStreamer(int ind, Fifo*& f, uint32_t* dr, uint32_t* freq, uint32_t* timer, int* sEnable) :
|
||||
ThreadObject(),
|
||||
DataStreamer::DataStreamer(Fifo*& f, uint32_t* dr, uint32_t* freq, uint32_t* timer, int* sEnable) :
|
||||
ThreadObject(NumberofDataStreamers),
|
||||
generalData(0),
|
||||
fifo(f),
|
||||
zmqSocket(0),
|
||||
@ -40,10 +40,6 @@ DataStreamer::DataStreamer(int ind, Fifo*& f, uint32_t* dr, uint32_t* freq, uint
|
||||
firstMeasurementIndex(0),
|
||||
completeBuffer(0)
|
||||
{
|
||||
index = NumberofDataStreamers;
|
||||
cprintf(RED, "%d: Number of DataStreamers: %d\n", index, NumberofDataStreamers);
|
||||
//index = ind;
|
||||
|
||||
if(ThreadObject::CreateThread()){
|
||||
pthread_mutex_lock(&Mutex);
|
||||
ErrorMask ^= (1<<index);
|
||||
|
@ -14,8 +14,8 @@ using namespace std;
|
||||
|
||||
int Fifo::NumberofFifoClassObjects(0);
|
||||
|
||||
Fifo::Fifo(int ind, uint32_t fifoItemSize, uint32_t fifoDepth, bool &success):
|
||||
index(ind),
|
||||
Fifo::Fifo(uint32_t fifoItemSize, uint32_t fifoDepth, bool &success):
|
||||
index(NumberofFifoClassObjects),
|
||||
memory(0),
|
||||
fifoBound(0),
|
||||
fifoFree(0),
|
||||
|
@ -27,8 +27,8 @@ uint64_t Listener::RunningMask(0x0);
|
||||
pthread_mutex_t Listener::Mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
|
||||
Listener::Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s, uint32_t* portno, char* e, int* act, uint64_t* nf, uint32_t* dr) :
|
||||
ThreadObject(),
|
||||
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),
|
||||
fifo(f),
|
||||
myDetectorType(dtype),
|
||||
@ -50,8 +50,6 @@ Listener::Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s, uint32_t
|
||||
carryOverPacket(0),
|
||||
listeningPacket(0)
|
||||
{
|
||||
index = ind;
|
||||
|
||||
if(ThreadObject::CreateThread()){
|
||||
pthread_mutex_lock(&Mutex);
|
||||
ErrorMask ^= (1<<index);
|
||||
|
@ -12,8 +12,8 @@ using namespace std;
|
||||
|
||||
|
||||
|
||||
ThreadObject::ThreadObject():
|
||||
index(0),
|
||||
ThreadObject::ThreadObject(int ind):
|
||||
index(ind),
|
||||
alive(false),
|
||||
killThread(false),
|
||||
thread(0)
|
||||
|
@ -90,7 +90,11 @@ void UDPRESTImplementation::initialize_REST(){
|
||||
string rest_state = "";
|
||||
std::string answer = "";
|
||||
|
||||
// HORRIBLE FIX to get the main receiver
|
||||
/*
|
||||
* HORRIBLE FIX to get the main receiver
|
||||
* TODO: use detID (from baseclass)
|
||||
* it i set by the client before calling initialize()
|
||||
*/
|
||||
string filename = getFileName();
|
||||
if (filename.substr(filename.length() - 2) == "d0"){
|
||||
is_main_receiver = true;
|
||||
@ -236,14 +240,18 @@ void UDPRESTImplementation::stopReceiver(){
|
||||
if(status == RUNNING)
|
||||
startReadout();
|
||||
|
||||
while(status == TRANSMITTING)
|
||||
usleep(5000);
|
||||
/**
|
||||
* while(status == TRANSMITTING)
|
||||
* usleep(5000);
|
||||
* This has been changed, you check if all the threads are done processing
|
||||
* and set the final status
|
||||
*/
|
||||
|
||||
|
||||
//change status
|
||||
status = IDLE;
|
||||
|
||||
FILE_LOG(logDEBUG) << __AT__ << "exited, status " << endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -326,31 +334,6 @@ int UDPRESTImplementation::shutDownUDPSockets(){
|
||||
|
||||
|
||||
|
||||
/* FIXME
|
||||
* do you really need this, this is called if registerDataCallback() is activated
|
||||
* in your gui to get data from receiver. you probably have a different way
|
||||
* of reconstructing complete data set from all receivers
|
||||
*/
|
||||
void UDPRESTImplementation::readFrame(char* c,char** raw, uint64_t &startAcq, uint64_t &startFrame){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||
strcpy(c,"");
|
||||
*raw = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* FIXME
|
||||
* Its called by TCP in case of illegal shut down such as Ctrl + c.
|
||||
* Upto you what you want to do with it.
|
||||
*/
|
||||
void UDPRESTImplementation::closeFile(int ithr){
|
||||
FILE_LOG(logDEBUG) << __AT__ << "called for thread " << ithr;
|
||||
FILE_LOG(logDEBUG) << __AT__ << "exited for thread " << ithr;
|
||||
}
|
||||
|
||||
|
||||
uint64_t UDPRESTImplementation::getTotalFramesCaught() const{
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
return (0);
|
||||
|
@ -55,9 +55,6 @@ void UDPStandardImplementation::InitializeMembers() {
|
||||
numThreads = 1;
|
||||
numberofJobs = 1;
|
||||
|
||||
//*** mutex ***
|
||||
pthread_mutex_init(&statusMutex,NULL);
|
||||
|
||||
//** class objects ***
|
||||
generalData = 0;
|
||||
}
|
||||
@ -196,7 +193,7 @@ int UDPStandardImplementation::setDataStreamEnable(const bool enable) {\
|
||||
if (enable) {
|
||||
bool error = false;
|
||||
for ( int i = 0; i < numThreads; ++i ) {
|
||||
dataStreamer.push_back(new DataStreamer(i, fifo[i], &dynamicRange, &frameToGuiFrequency, &frameToGuiTimerinMS, &shortFrameEnable));
|
||||
dataStreamer.push_back(new DataStreamer(fifo[i], &dynamicRange, &frameToGuiFrequency, &frameToGuiTimerinMS, &shortFrameEnable));
|
||||
dataStreamer[i]->SetGeneralData(generalData);
|
||||
// check again
|
||||
if (streamingPort == 0)
|
||||
@ -375,8 +372,8 @@ int UDPStandardImplementation::setDetectorType(const detectorType d) {
|
||||
|
||||
//create threads
|
||||
for ( int i=0; i < numThreads; ++i ) {
|
||||
listener.push_back(new Listener(i, myDetectorType, fifo[i], &status, &udpPortNum[i], eth, &activated, &numberOfFrames, &dynamicRange));
|
||||
dataProcessor.push_back(new DataProcessor(i, fifo[i], &fileFormatType, &fileWriteEnable, &dataStreamEnable,
|
||||
listener.push_back(new Listener(myDetectorType, fifo[i], &status, &udpPortNum[i], eth, &activated, &numberOfFrames, &dynamicRange));
|
||||
dataProcessor.push_back(new DataProcessor(fifo[i], &fileFormatType, &fileWriteEnable, &dataStreamEnable,
|
||||
rawDataReadyCallBack,pRawDataReady));
|
||||
if (Listener::GetErrorMask() || DataProcessor::GetErrorMask()) {
|
||||
FILE_LOG (logERROR) << "Error: Could not creates listener/dataprocessor threads (index:" << i << ")";
|
||||
@ -467,9 +464,7 @@ int UDPStandardImplementation::startReceiver(char *c) {
|
||||
FILE_LOG(logINFO) << "Ready ...";
|
||||
|
||||
//status
|
||||
pthread_mutex_lock(&statusMutex);
|
||||
status = RUNNING;
|
||||
pthread_mutex_unlock(&(statusMutex));
|
||||
|
||||
//Let Threads continue to be ready for acquisition
|
||||
StartRunning();
|
||||
@ -509,9 +504,7 @@ void UDPStandardImplementation::stopReceiver(){
|
||||
usleep(5000);
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&statusMutex);
|
||||
status = RUN_FINISHED;
|
||||
pthread_mutex_unlock(&(statusMutex));
|
||||
FILE_LOG(logINFO) << "Status: " << runStatusType(status);
|
||||
|
||||
|
||||
@ -541,9 +534,7 @@ void UDPStandardImplementation::stopReceiver(){
|
||||
}
|
||||
|
||||
//change status
|
||||
pthread_mutex_lock(&statusMutex);
|
||||
status = IDLE;
|
||||
pthread_mutex_unlock(&(statusMutex));
|
||||
|
||||
FILE_LOG(logINFO) << "Receiver Stopped";
|
||||
FILE_LOG(logINFO) << "Status: " << runStatusType(status);
|
||||
@ -588,10 +579,7 @@ void UDPStandardImplementation::startReadout(){
|
||||
}
|
||||
|
||||
//set status
|
||||
pthread_mutex_lock(&statusMutex);
|
||||
status = TRANSMITTING;
|
||||
pthread_mutex_unlock(&statusMutex);
|
||||
|
||||
FILE_LOG(logINFO) << "Status: Transmitting";
|
||||
}
|
||||
//shut down udp sockets so as to make listeners push dummy (end) packets for processors
|
||||
@ -732,7 +720,7 @@ int UDPStandardImplementation::SetupFifoStructure() {
|
||||
for ( int i = 0; i < numThreads; i++ ) {
|
||||
//create fifo structure
|
||||
bool success = true;
|
||||
fifo.push_back( new Fifo (i,
|
||||
fifo.push_back( new Fifo (
|
||||
(generalData->imageSize) * numberofJobs + (generalData->fifoBufferHeaderSize),
|
||||
fifoDepth, success));
|
||||
if (!success) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user