mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-18 15:57:13 +02:00
removed command threaded
This commit is contained in:
@ -14,8 +14,8 @@ else ()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11")
|
||||
endif ()
|
||||
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
|
||||
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=thread")
|
||||
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=thread")
|
||||
|
||||
find_package(Qt4)
|
||||
find_package(Qwt 6)
|
||||
|
@ -406,7 +406,7 @@ void multiSlsDetector::initializeDetectorStructure() {
|
||||
for (int i = 0; i < MAX_TIMERS; ++i) {
|
||||
thisMultiDetector->timerValue[i] = 0;
|
||||
}
|
||||
thisMultiDetector->threadedProcessing = 1;
|
||||
|
||||
thisMultiDetector->acquiringFlag = false;
|
||||
thisMultiDetector->receiverOnlineFlag = OFFLINE_FLAG;
|
||||
thisMultiDetector->receiver_upstream = false;
|
||||
@ -3661,7 +3661,6 @@ void multiSlsDetector::setCurrentProgress(int i){
|
||||
|
||||
|
||||
int multiSlsDetector::acquire(){
|
||||
|
||||
//ensure acquire isnt started multiple times by same client
|
||||
if (isAcquireReady() == FAIL)
|
||||
return FAIL;
|
||||
@ -3676,12 +3675,9 @@ int multiSlsDetector::acquire(){
|
||||
//in the real time acquistion loop, main thread will wait for processing thread to be done each time (which in turn waits for receiver/ext process)
|
||||
sem_init(&sem_endRTAcquisition,1,0);
|
||||
|
||||
|
||||
bool receiver = (setReceiverOnline()==ONLINE_FLAG);
|
||||
|
||||
progressIndex=0;
|
||||
thisMultiDetector->stoppedFlag=0;
|
||||
void *status;
|
||||
setJoinThread(0);
|
||||
|
||||
int nm=thisMultiDetector->timerValue[MEASUREMENTS_NUMBER];
|
||||
@ -3696,9 +3692,7 @@ int multiSlsDetector::acquire(){
|
||||
thisMultiDetector->stoppedFlag=1;
|
||||
}
|
||||
|
||||
// start processing thread
|
||||
if (thisMultiDetector->threadedProcessing)
|
||||
startProcessingThread();
|
||||
startProcessingThread();
|
||||
|
||||
//resets frames caught in receiver
|
||||
if(receiver){
|
||||
@ -3725,20 +3719,15 @@ int multiSlsDetector::acquire(){
|
||||
sem_post(&sem_newRTAcquisition);
|
||||
}
|
||||
|
||||
// detector start
|
||||
startAndReadAll();
|
||||
|
||||
if (thisMultiDetector->threadedProcessing==0){
|
||||
processData();
|
||||
}
|
||||
|
||||
// stop receiver
|
||||
std::lock_guard<std::mutex> lock(mg);
|
||||
if(receiver){
|
||||
if (stopReceiver() == FAIL) {
|
||||
thisMultiDetector->stoppedFlag = 1;
|
||||
} else {
|
||||
if (thisMultiDetector->threadedProcessing && dataReady)
|
||||
if (dataReady)
|
||||
sem_wait(&sem_endRTAcquisition); // waits for receiver's external process to be done sending data to gui
|
||||
}
|
||||
}
|
||||
@ -3754,17 +3743,10 @@ int multiSlsDetector::acquire(){
|
||||
|
||||
}//end measurements loop im
|
||||
|
||||
|
||||
// waiting for the data processing thread to finish!
|
||||
if (thisMultiDetector->threadedProcessing) {
|
||||
setJoinThread(1);
|
||||
|
||||
//let processing thread continue and checkjointhread
|
||||
sem_post(&sem_newRTAcquisition);
|
||||
|
||||
// pthread_join(dataProcessingThread, &status);
|
||||
dataProcessingThread.join();
|
||||
}
|
||||
setJoinThread(1);
|
||||
sem_post(&sem_newRTAcquisition);
|
||||
dataProcessingThread.join();
|
||||
|
||||
|
||||
if(progress_call)
|
||||
@ -3790,13 +3772,6 @@ int multiSlsDetector::acquire(){
|
||||
|
||||
|
||||
|
||||
int multiSlsDetector::setThreadedProcessing(int enable) {
|
||||
if (enable>=0)
|
||||
thisMultiDetector->threadedProcessing=enable;
|
||||
return thisMultiDetector->threadedProcessing;
|
||||
}
|
||||
|
||||
|
||||
void multiSlsDetector::startProcessingThread() {
|
||||
setTotalProgress();
|
||||
dataProcessingThread = std::thread(&multiSlsDetector::processData, this);
|
||||
@ -3821,35 +3796,23 @@ void multiSlsDetector::processData() {
|
||||
else{
|
||||
int caught = -1;
|
||||
while(true){
|
||||
|
||||
// set only in startThread
|
||||
if (thisMultiDetector->threadedProcessing==0)
|
||||
setTotalProgress();
|
||||
|
||||
// to exit acquire by typing q
|
||||
if (kbhit()!=0){
|
||||
char c = fgetc(stdin);
|
||||
if (c=='q') {
|
||||
if (fgetc(stdin) == 'q') {
|
||||
std::cout<<"Caught the command to stop acquisition"<<std::endl;
|
||||
stopAcquisition();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//get progress
|
||||
if(setReceiverOnline() == ONLINE_FLAG){
|
||||
std::lock_guard<std::mutex> lock(mg);
|
||||
caught = getFramesCaughtByReceiver(0);
|
||||
}
|
||||
|
||||
//updating progress
|
||||
if(caught!= -1){
|
||||
setCurrentProgress(caught);
|
||||
}
|
||||
|
||||
// exiting loop
|
||||
if (thisMultiDetector->threadedProcessing==0)
|
||||
break;
|
||||
if (checkJoinThread()){
|
||||
break;
|
||||
}
|
||||
|
@ -102,9 +102,6 @@ private:
|
||||
/** timer values */
|
||||
int64_t timerValue[MAX_TIMERS];
|
||||
|
||||
/** threaded processing flag (i.e. if data are processed and written to
|
||||
* file in a separate thread) */
|
||||
int threadedProcessing;
|
||||
|
||||
/** flag for acquiring */
|
||||
bool acquiringFlag;
|
||||
@ -1573,11 +1570,7 @@ public:
|
||||
*/
|
||||
int acquire();
|
||||
|
||||
/**
|
||||
* Set/get if the data processing thread si enabled
|
||||
* @param enable 0 no data processing thread, 1 separate thread, -1 get
|
||||
*/
|
||||
int setThreadedProcessing(int enable=-1);
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if detector position is out of bounds
|
||||
|
@ -439,7 +439,7 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
|
||||
thisDetector->nTrimEn = 0;
|
||||
for(int i = 0; i < MAX_TRIMEN; ++i)
|
||||
thisDetector->trimEnergies[i] = 0;
|
||||
thisDetector->threadedProcessing = 1;
|
||||
// thisDetector->threadedProcessing = 1;
|
||||
thisDetector->nROI = 0;
|
||||
memset(thisDetector->roiLimits, 0, MAX_ROIS * sizeof(ROI));
|
||||
thisDetector->roFlags = NORMAL_READOUT;
|
||||
|
@ -126,7 +126,7 @@ private:
|
||||
|
||||
/** threaded processing flag
|
||||
* (i.e. if data are processed in a separate thread) */
|
||||
int threadedProcessing;
|
||||
// int threadedProcessing;
|
||||
|
||||
/** number of rois defined */
|
||||
int nROI;
|
||||
|
@ -812,12 +812,12 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdRateCorr;
|
||||
++i;
|
||||
|
||||
/*! \page data
|
||||
- <b>threaded [i]</b> Sets/gets the data processing threaded flag. 1 is threaded, 0 unthreaded.
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName="threaded"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdThreaded;
|
||||
++i;
|
||||
// /*! \page data
|
||||
// - <b>threaded [i]</b> Sets/gets the data processing threaded flag. 1 is threaded, 0 unthreaded.
|
||||
// */
|
||||
// descrToFuncMap[i].m_pFuncName="threaded"; //
|
||||
// descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdThreaded;
|
||||
// ++i;
|
||||
|
||||
/*! \page data
|
||||
- <b>darkimage fn</b> Loads the dark image to the detector from file fn (pedestal image). Cannot get. For Gotthard only.
|
||||
@ -2161,15 +2161,15 @@ string slsDetectorCommand::cmdData(int narg, char *args[], int action, int detPo
|
||||
} else if (action==HELP_ACTION) {
|
||||
return helpData(HELP_ACTION);
|
||||
} else {
|
||||
b=myDet->setThreadedProcessing(-1);
|
||||
myDet->setThreadedProcessing(0);
|
||||
myDet->setOnline(ONLINE_FLAG, detPos);
|
||||
myDet->setReceiverOnline(ONLINE_FLAG, detPos);
|
||||
myDet->readAll(detPos);
|
||||
//processdata in receiver is useful only for gui purposes
|
||||
if(myDet->setReceiverOnline(detPos)==OFFLINE_FLAG)
|
||||
myDet->processData();
|
||||
myDet->setThreadedProcessing(b);
|
||||
// b=myDet->setThreadedProcessing(-1);
|
||||
// myDet->setThreadedProcessing(0);
|
||||
// myDet->setOnline(ONLINE_FLAG, detPos);
|
||||
// myDet->setReceiverOnline(ONLINE_FLAG, detPos);
|
||||
// myDet->readAll(detPos);
|
||||
// //processdata in receiver is useful only for gui purposes
|
||||
// if(myDet->setReceiverOnline(detPos)==OFFLINE_FLAG)
|
||||
// myDet->processData();
|
||||
// myDet->setThreadedProcessing(b);
|
||||
return string("");
|
||||
}
|
||||
}
|
||||
@ -2744,21 +2744,21 @@ string slsDetectorCommand::helpRateCorr(int action){
|
||||
|
||||
|
||||
|
||||
string slsDetectorCommand::cmdThreaded(int narg, char *args[], int action, int detPos){
|
||||
int ival;
|
||||
char answer[1000];
|
||||
// string slsDetectorCommand::cmdThreaded(int narg, char *args[], int action, int detPos){
|
||||
// int ival;
|
||||
// char answer[1000];
|
||||
|
||||
if (action==HELP_ACTION)
|
||||
return helpThreaded(action);
|
||||
// if (action==HELP_ACTION)
|
||||
// return helpThreaded(action);
|
||||
|
||||
if (action==PUT_ACTION) {
|
||||
if (sscanf(args[1],"%d",&ival))
|
||||
myDet->setThreadedProcessing(ival);
|
||||
}
|
||||
sprintf(answer,"%d",myDet->setThreadedProcessing());
|
||||
return string(answer);
|
||||
// if (action==PUT_ACTION) {
|
||||
// if (sscanf(args[1],"%d",&ival))
|
||||
// myDet->setThreadedProcessing(ival);
|
||||
// }
|
||||
// sprintf(answer,"%d",myDet->setThreadedProcessing());
|
||||
// return string(answer);
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
|
||||
string slsDetectorCommand::helpThreaded(int action){
|
||||
|
@ -113,7 +113,7 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
|
||||
std::string cmdFileName(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdFileIndex(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdRateCorr(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdThreaded(int narg, char *args[], int action, int detPos = -1);
|
||||
// std::string cmdThreaded(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdNetworkParameter(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdPort(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdLock(int narg, char *args[], int action, int detPos = -1);
|
||||
|
Reference in New Issue
Block a user