mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-07 18:40:42 +02:00
some changes refactoring and reducing time spent
This commit is contained in:
parent
ab9e01f212
commit
c43af96487
Binary file not shown.
@ -355,7 +355,7 @@ void setDAC(enum detDacIndex ind, int val, int imod, int mV, int retval[]){
|
|||||||
ret[1] = retval[mV];
|
ret[1] = retval[mV];
|
||||||
setDAC(VCMP_RL,val,imod,mV,retval);
|
setDAC(VCMP_RL,val,imod,mV,retval);
|
||||||
ret[2] = retval[mV];
|
ret[2] = retval[mV];
|
||||||
setDAC(VCMP_RL,val,imod,mV,retval);
|
setDAC(VCMP_RR,val,imod,mV,retval);
|
||||||
ret[3] = retval[mV];
|
ret[3] = retval[mV];
|
||||||
|
|
||||||
if((ret[0]== ret[1])&&
|
if((ret[0]== ret[1])&&
|
||||||
|
@ -330,14 +330,17 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
//offline
|
||||||
if(setReceiverOnline()==OFFLINE_FLAG){
|
if(setReceiverOnline()==OFFLINE_FLAG){
|
||||||
pthread_mutex_lock(&mg);
|
|
||||||
// wait until data processing thread has finished the data
|
// wait until data processing thread has finished the data
|
||||||
|
pthread_mutex_lock(&mg);
|
||||||
acquiringDone = 1;
|
acquiringDone = 1;
|
||||||
|
pthread_mutex_unlock(&mg);
|
||||||
if (*threadedProcessing) {
|
if (*threadedProcessing) {
|
||||||
sem_wait(&sem_queue);
|
sem_wait(&sem_queue);
|
||||||
|
pthread_mutex_lock(&mg);
|
||||||
acquiringDone = 0;
|
acquiringDone = 0;
|
||||||
|
pthread_mutex_unlock(&mg);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
@ -354,8 +357,12 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
if((*correctionMask)&(1<<WRITE_FILE))
|
if((*correctionMask)&(1<<WRITE_FILE))
|
||||||
closeDataFile();
|
closeDataFile();
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&mg);
|
|
||||||
}else{
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//online
|
||||||
|
else{
|
||||||
pthread_mutex_lock(&mg);
|
pthread_mutex_lock(&mg);
|
||||||
acquiringDone = 1;
|
acquiringDone = 1;
|
||||||
pthread_mutex_unlock(&mg);
|
pthread_mutex_unlock(&mg);
|
||||||
|
@ -505,59 +505,65 @@ void* postProcessing::processData(int delflag) {
|
|||||||
|
|
||||||
cout.flush();
|
cout.flush();
|
||||||
cout<<flush;
|
cout<<flush;
|
||||||
usleep(20000); //20ms
|
usleep(2000); //2ms need this else connecting error to receiver (too fast?)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//get progress
|
//get progress
|
||||||
pthread_mutex_lock(&mg);
|
if(setReceiverOnline() == ONLINE_FLAG){
|
||||||
if(setReceiverOnline() == ONLINE_FLAG)
|
pthread_mutex_lock(&mg);
|
||||||
caught = getFramesCaughtByReceiver();//getReceiverCurrentFrameIndex();
|
caught = getFramesCaughtByReceiver();
|
||||||
pthread_mutex_unlock(&mg);
|
pthread_mutex_unlock(&mg);
|
||||||
|
}
|
||||||
|
|
||||||
//updating progress
|
//updating progress
|
||||||
if(currentAcquisitionIndex != -1){
|
if(caught!= -1){
|
||||||
setCurrentProgress(caught);
|
setCurrentProgress(caught);
|
||||||
|
|
||||||
}
|
|
||||||
#ifdef VERY_VERY_DEBUG
|
#ifdef VERY_VERY_DEBUG
|
||||||
cout << "caught:" << caught << endl;
|
cout << "caught:" << caught << endl;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//detector acquistion done, wait for all frames received
|
||||||
// IF detector acquisition is done, let the acquire() thread know to finish up and force join thread
|
|
||||||
if(acquiringDone > 0){
|
if(acquiringDone > 0){
|
||||||
#ifdef VERY_VERY_DEBUG
|
#ifdef VERY_VERY_DEBUG
|
||||||
if(acquiringDone == 1)
|
if(acquiringDone == 1) cout << "acquiring seems to be done" << endl;
|
||||||
cout << "acquiring seems to be done" << endl;
|
|
||||||
#endif
|
#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
|
#ifdef VERY_VERY_DEBUG
|
||||||
cout << "acquiringDone :" << acquiringDone << endl;
|
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
|
#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
|
//random reads and for nthframe, checks if there is no new data
|
||||||
else if((!nthframe) ||(!newData)){
|
else if((!nthframe) ||(!newData)){
|
||||||
//cout <<"cecking now" << endl;
|
//cout <<"cecking now" << endl;
|
||||||
if (checkJoinThread())
|
if (checkJoinThread()){
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -568,23 +574,22 @@ void* postProcessing::processData(int delflag) {
|
|||||||
if(!newData){
|
if(!newData){
|
||||||
if(caught > progress){
|
if(caught > progress){
|
||||||
newData = true;
|
newData = true;
|
||||||
/*
|
|
||||||
// keeping acquiringdone at 1 to get more time to get data
|
// If new data and acquiringDone>0 (= det acq over), reset to get more frames
|
||||||
if(acquiringDone > 0){cout<<"going to maintain acquiidne"<<endl;
|
if(dataReady && (acquiringDone > 0)){
|
||||||
pthread_mutex_lock(&mg);
|
pthread_mutex_lock(&mg);
|
||||||
acquiringDone = 1;
|
acquiringDone = 1;
|
||||||
//#ifdef VERY_VERY_DEBUG
|
#ifdef VERY_VERY_DEBUG
|
||||||
cout << "Keeping acquiringDone at 1 " << endl;
|
cout << "Keeping acquiringDone at 1 " << endl;
|
||||||
//#endif
|
#endif
|
||||||
pthread_mutex_unlock(&mg);
|
pthread_mutex_unlock(&mg);
|
||||||
}*/
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#ifdef VERY_VERY_DEBUG
|
|
||||||
cout << "currentAcquisitionIndex:" << currentAcquisitionIndex << " progress:" << progress << endl;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(newData){
|
if(newData){
|
||||||
#ifdef VERY_VERY_DEBUG
|
#ifdef VERY_VERY_DEBUG
|
||||||
cout << "new data" << endl;
|
cout << "new data" << endl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user