parallelized settimer, setfileindex, setonline, setreceiveronline, getreceiverstatus, resetframescaught, setFrameIndex, setFileName, getFramesCaughtByReceiver; added getFramesCaughtbyAnyreceiver to avoid threadpool and to use in post processing

This commit is contained in:
Dhanya Maliakal
2017-09-18 16:47:22 +02:00
parent 54d231d3c6
commit a95e2efdb0
10 changed files with 369 additions and 165 deletions

View File

@ -50,8 +50,10 @@ int slsDetectorUtils::acquire(int delflag){
return FAIL;
}
#ifdef VERBOSE
struct timespec begin,end;
clock_gettime(CLOCK_REALTIME, &begin);
#endif
//not in the loop for real time acqusition yet,
//in the real time acquisition loop, processing thread will wait for a post each time
@ -140,9 +142,8 @@ int slsDetectorUtils::acquire(int delflag){
if(receiver){
pthread_mutex_lock(&mg); //cout << "lock"<< endl;
if(getReceiverStatus()!=IDLE)
stopReceiver();
if(setReceiverOnline()==OFFLINE_FLAG)
*stoppedFlag=1;
if(stopReceiver() == FAIL)
*stoppedFlag=1;
pthread_mutex_unlock(&mg);//cout << "unlock"<< endl;
}
@ -156,7 +157,8 @@ int slsDetectorUtils::acquire(int delflag){
//resets frames caught in receiver
if(receiver){
pthread_mutex_lock(&mg); //cout << "lock"<< endl;
resetFramesCaught();
if (resetFramesCaught() == FAIL)
*stoppedFlag=1;
pthread_mutex_unlock(&mg);//cout << "unlock"<< endl;
}
@ -332,10 +334,13 @@ int slsDetectorUtils::acquire(int delflag){
while (dataQueueSize()) usleep(100000);
// cout << "mglock " << endl;;
pthread_mutex_lock(&mg); //cout << "lock"<< endl;
// cout << "done " << endl;;
//offline
if(setReceiverOnline()==OFFLINE_FLAG){
if(!receiver){
if ((getDetectorsType()==GOTTHARD) || (getDetectorsType()==MOENCH) || (getDetectorsType()==JUNGFRAU)|| (getDetectorsType()==JUNGFRAUCTB) ){
if((*correctionMask)&(1<<WRITE_FILE))
closeDataFile();
@ -343,14 +348,8 @@ int slsDetectorUtils::acquire(int delflag){
}
//online
else{
if(setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG){
stopAcquisition();
stopReceiver();
pthread_mutex_unlock(&mg);
break;
}
stopReceiver();
if (stopReceiver() == FAIL)
*stoppedFlag = 1;
// cout<<"***********receiver stopped"<<endl;
}
pthread_mutex_unlock(&mg);//cout << "unlock"<< endl;
@ -507,8 +506,8 @@ int slsDetectorUtils::acquire(int delflag){
setAcquiringFlag(false);
sem_destroy(&sem_newRTAcquisition);
clock_gettime(CLOCK_REALTIME, &end);
#ifdef VERBOSE
clock_gettime(CLOCK_REALTIME, &end);
cout << "Elapsed time for acquisition:" << (( end.tv_sec - begin.tv_sec ) + ( end.tv_nsec - begin.tv_nsec ) / 1000000000.0) << " seconds" << endl;
#endif
return OK;