mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-19 08:17:13 +02:00
rest implementation, index issues
This commit is contained in:
@ -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) {
|
||||
|
Reference in New Issue
Block a user