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