some changes refactoring and reducing time spent

This commit is contained in:
Dhanya Maliakal 2015-11-13 17:47:44 +01:00
parent ab9e01f212
commit c43af96487
4 changed files with 53 additions and 41 deletions

View File

@ -355,7 +355,7 @@ void setDAC(enum detDacIndex ind, int val, int imod, int mV, int retval[]){
ret[1] = retval[mV];
setDAC(VCMP_RL,val,imod,mV,retval);
ret[2] = retval[mV];
setDAC(VCMP_RL,val,imod,mV,retval);
setDAC(VCMP_RR,val,imod,mV,retval);
ret[3] = retval[mV];
if((ret[0]== ret[1])&&

View File

@ -330,14 +330,17 @@ void slsDetectorUtils::acquire(int delflag){
break;
//offline
if(setReceiverOnline()==OFFLINE_FLAG){
pthread_mutex_lock(&mg);
// wait until data processing thread has finished the data
pthread_mutex_lock(&mg);
acquiringDone = 1;
pthread_mutex_unlock(&mg);
if (*threadedProcessing) {
sem_wait(&sem_queue);
pthread_mutex_lock(&mg);
acquiringDone = 0;
pthread_mutex_unlock(&mg);
}
#ifdef VERBOSE
@ -354,8 +357,12 @@ void slsDetectorUtils::acquire(int delflag){
if((*correctionMask)&(1<<WRITE_FILE))
closeDataFile();
}
pthread_mutex_unlock(&mg);
}else{
}
//online
else{
pthread_mutex_lock(&mg);
acquiringDone = 1;
pthread_mutex_unlock(&mg);

View File

@ -505,59 +505,65 @@ void* postProcessing::processData(int delflag) {
cout.flush();
cout<<flush;
usleep(20000); //20ms
usleep(2000); //2ms need this else connecting error to receiver (too fast?)
//get progress
pthread_mutex_lock(&mg);
if(setReceiverOnline() == ONLINE_FLAG)
caught = getFramesCaughtByReceiver();//getReceiverCurrentFrameIndex();
pthread_mutex_unlock(&mg);
if(setReceiverOnline() == ONLINE_FLAG){
pthread_mutex_lock(&mg);
caught = getFramesCaughtByReceiver();
pthread_mutex_unlock(&mg);
}
//updating progress
if(currentAcquisitionIndex != -1){
if(caught!= -1){
setCurrentProgress(caught);
}
#ifdef VERY_VERY_DEBUG
cout << "caught:" << caught << endl;
#endif
}
// IF detector acquisition is done, let the acquire() thread know to finish up and force join thread
//detector acquistion done, wait for all frames received
if(acquiringDone > 0){
#ifdef VERY_VERY_DEBUG
if(acquiringDone == 1)
cout << "acquiring seems to be done" << endl;
if(acquiringDone == 1) cout << "acquiring seems to be done" << endl;
#endif
//so that it checks for last frame for some number of checks, then checks join thread
pthread_mutex_lock(&mg);
acquiringDone++;
//IF GUI, check for last frames (counter upto 5)
if(dataReady){
pthread_mutex_lock(&mg);
acquiringDone++;
pthread_mutex_unlock(&mg);
#ifdef VERY_VERY_DEBUG
cout << "acquiringDone :" << acquiringDone << endl;
#endif
pthread_mutex_unlock(&mg);
//go through once more to get last nth frame data
if (acquiringDone >= 5){cout<<"acquiringdone:"<<acquiringDone<<endl;
if((!nthframe) ||(!newData)){
#ifdef VERY_VERY_DEBUG
cout << "gonna post for it to end" << endl;
#endif
sem_post(&sem_queue);
#ifdef VERY_VERY_DEBUG
cout << "Sem posted" << endl;
#endif
}
//post to stopReceiver in acquire(), but continue reading frames
if (!dataReady || (acquiringDone >= 5)){
if(!dataReady || (!nthframe) ||(!newData)){
#ifdef VERY_VERY_DEBUG
cout << "gonna post for it to end" << endl;
#endif
sem_post(&sem_queue);
#ifdef VERY_VERY_DEBUG
cout << "Sem posted" << endl;
#endif
}
}
}
//random reads and for nthframe, checks if there is no new data
else if((!nthframe) ||(!newData)){
//cout <<"cecking now" << endl;
if (checkJoinThread())
if (checkJoinThread()){
break;
}
}
@ -568,23 +574,22 @@ void* postProcessing::processData(int delflag) {
if(!newData){
if(caught > progress){
newData = true;
/*
// keeping acquiringdone at 1 to get more time to get data
if(acquiringDone > 0){cout<<"going to maintain acquiidne"<<endl;
// If new data and acquiringDone>0 (= det acq over), reset to get more frames
if(dataReady && (acquiringDone > 0)){
pthread_mutex_lock(&mg);
acquiringDone = 1;
//#ifdef VERY_VERY_DEBUG
#ifdef VERY_VERY_DEBUG
cout << "Keeping acquiringDone at 1 " << endl;
//#endif
#endif
pthread_mutex_unlock(&mg);
}*/
}
}
#ifdef VERY_VERY_DEBUG
cout << "currentAcquisitionIndex:" << currentAcquisitionIndex << " progress:" << progress << endl;
#endif
}
if(newData){
#ifdef VERY_VERY_DEBUG
cout << "new data" << endl;