mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-13 16:02:14 +02:00
changing to random read when no gui at beginnning of acquire
This commit is contained in:
parent
816543f358
commit
62c92dd364
@ -44,8 +44,18 @@ slsDetectorUtils::slsDetectorUtils() {
|
|||||||
void slsDetectorUtils::acquire(int delflag){
|
void slsDetectorUtils::acquire(int delflag){
|
||||||
|
|
||||||
bool receiver = (setReceiverOnline()==ONLINE_FLAG);
|
bool receiver = (setReceiverOnline()==ONLINE_FLAG);
|
||||||
if(!receiver)
|
if(!receiver){
|
||||||
setDetectorIndex(-1);
|
setDetectorIndex(-1);
|
||||||
|
}else{
|
||||||
|
//put receiver read frequency to random if no gui
|
||||||
|
int ret = setReadReceiverFrequency(0);
|
||||||
|
if(ret>0 && (acquisition_finished == NULL)){
|
||||||
|
std::cout << "Error: receiver read frequency is set to " << ret << " but should be > 0 only when using gui." << std::endl;
|
||||||
|
ret = setReadReceiverFrequency(1,0);
|
||||||
|
std::cout << "Current receiver read frequency: " << ret << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int nc=setTimer(CYCLES_NUMBER,-1);
|
int nc=setTimer(CYCLES_NUMBER,-1);
|
||||||
int nf=setTimer(FRAME_NUMBER,-1);
|
int nf=setTimer(FRAME_NUMBER,-1);
|
||||||
if (nc==0) nc=1;
|
if (nc==0) nc=1;
|
||||||
@ -53,10 +63,6 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
|
|
||||||
int multiframe = nc*nf;
|
int multiframe = nc*nf;
|
||||||
|
|
||||||
//
|
|
||||||
if(setDynamicRange() == 32) subframe = 1;
|
|
||||||
else subframe = 0;
|
|
||||||
|
|
||||||
pthread_mutex_lock(&mg);
|
pthread_mutex_lock(&mg);
|
||||||
acquiringDone = 0;
|
acquiringDone = 0;
|
||||||
pthread_mutex_unlock(&mg);
|
pthread_mutex_unlock(&mg);
|
||||||
@ -135,7 +141,7 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
*stoppedFlag=1;
|
*stoppedFlag=1;
|
||||||
|
|
||||||
//multi detectors shouldnt have different receiver read frequencies enabled/disabled
|
//multi detectors shouldnt have different receiver read frequencies enabled/disabled
|
||||||
if(setReadReceiverFrequency(0) < 0){
|
if(setReadReceiverFrequency(0) < 0){
|
||||||
std::cout << "Error: The receiver read frequency is invalid:" << setReadReceiverFrequency(0) << std::endl;
|
std::cout << "Error: The receiver read frequency is invalid:" << setReadReceiverFrequency(0) << std::endl;
|
||||||
*stoppedFlag=1;
|
*stoppedFlag=1;
|
||||||
}
|
}
|
||||||
@ -362,13 +368,6 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
pthread_mutex_unlock(&mg);
|
pthread_mutex_unlock(&mg);
|
||||||
}
|
}
|
||||||
pthread_mutex_lock(&mg);
|
pthread_mutex_lock(&mg);
|
||||||
/* startReceiverReadout();
|
|
||||||
while(getReceiverStatus() != RUN_FINISHED){
|
|
||||||
pthread_mutex_unlock(&mg);
|
|
||||||
usleep(50000);
|
|
||||||
pthread_mutex_lock(&mg);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
stopReceiver();
|
stopReceiver();
|
||||||
pthread_mutex_unlock(&mg);
|
pthread_mutex_unlock(&mg);
|
||||||
}
|
}
|
||||||
|
@ -483,16 +483,6 @@ void* postProcessing::processData(int delflag) {
|
|||||||
}
|
}
|
||||||
//receiver
|
//receiver
|
||||||
else{
|
else{
|
||||||
/*
|
|
||||||
//without gui loop
|
|
||||||
while(1){
|
|
||||||
if (checkJoinThread()) break;
|
|
||||||
usleep(200000);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/*if(setReadReceiverFrequency()>0)) ******Not implemented yet ********
|
|
||||||
* else
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
int progress = 0;
|
int progress = 0;
|
||||||
@ -509,23 +499,13 @@ void* postProcessing::processData(int delflag) {
|
|||||||
std::cout << "receiver read freq:" << nthframe << std::endl;
|
std::cout << "receiver read freq:" << nthframe << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//if nth frame
|
|
||||||
if(nthframe){
|
|
||||||
/*newData = true;//unnecessary to read every data, 09.12.2014**/
|
|
||||||
//and no gui
|
|
||||||
if(!dataReady){
|
|
||||||
std::cout << "Error: receiver read freq is set to " << nthframe << " but should be > 0 only when using gui." << std::endl;
|
|
||||||
nthframe = 0;
|
|
||||||
std::cout << "Current receiver read frequency: " << nthframe << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//repeat forever until joined by the calling thread
|
//repeat forever until joined by the calling thread
|
||||||
while(1){
|
while(1){
|
||||||
|
|
||||||
cout.flush();
|
cout.flush();
|
||||||
cout<<flush;
|
cout<<flush;
|
||||||
usleep(20000);
|
usleep(20000); //20ms
|
||||||
|
|
||||||
|
|
||||||
//get progress
|
//get progress
|
||||||
@ -537,14 +517,7 @@ void* postProcessing::processData(int delflag) {
|
|||||||
//updating progress
|
//updating progress
|
||||||
if(currentAcquisitionIndex != -1){
|
if(currentAcquisitionIndex != -1){
|
||||||
setCurrentProgress(caught);
|
setCurrentProgress(caught);
|
||||||
/*
|
|
||||||
if(subframe){
|
|
||||||
pthread_mutex_lock(&mg);
|
|
||||||
setCurrentProgress(getFramesCaughtByReceiver());
|
|
||||||
pthread_mutex_unlock(&mg);
|
|
||||||
}else
|
|
||||||
setCurrentProgress(currentAcquisitionIndex+1);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
#ifdef VERY_VERY_DEBUG
|
#ifdef VERY_VERY_DEBUG
|
||||||
cout << "caught:" << caught << endl;
|
cout << "caught:" << caught << endl;
|
||||||
@ -569,15 +542,15 @@ void* postProcessing::processData(int delflag) {
|
|||||||
pthread_mutex_unlock(&mg);
|
pthread_mutex_unlock(&mg);
|
||||||
//go through once more to get last nth frame data
|
//go through once more to get last nth frame data
|
||||||
if (acquiringDone >= 5){cout<<"acquiringdone:"<<acquiringDone<<endl;
|
if (acquiringDone >= 5){cout<<"acquiringdone:"<<acquiringDone<<endl;
|
||||||
if((!nthframe) ||(!newData)){
|
if((!nthframe) ||(!newData)){
|
||||||
#ifdef VERY_VERY_DEBUG
|
#ifdef VERY_VERY_DEBUG
|
||||||
cout << "gonna post for it to end" << endl;
|
cout << "gonna post for it to end" << endl;
|
||||||
#endif
|
#endif
|
||||||
sem_post(&sem_queue);
|
sem_post(&sem_queue);
|
||||||
#ifdef VERY_VERY_DEBUG
|
#ifdef VERY_VERY_DEBUG
|
||||||
cout << "Sem posted" << endl;
|
cout << "Sem posted" << endl;
|
||||||
#endif
|
#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
|
||||||
@ -591,11 +564,11 @@ void* postProcessing::processData(int delflag) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//for random reads, ask only if it has new data
|
//for random reads, ask only if it has new data
|
||||||
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
|
// keeping acquiringdone at 1 to get more time to get data
|
||||||
if(acquiringDone > 0){cout<<"going to maintain acquiidne"<<endl;
|
if(acquiringDone > 0){cout<<"going to maintain acquiidne"<<endl;
|
||||||
pthread_mutex_lock(&mg);
|
pthread_mutex_lock(&mg);
|
||||||
@ -606,81 +579,81 @@ void* postProcessing::processData(int delflag) {
|
|||||||
pthread_mutex_unlock(&mg);
|
pthread_mutex_unlock(&mg);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
}
|
}
|
||||||
#ifdef VERY_VERY_DEBUG
|
#ifdef VERY_VERY_DEBUG
|
||||||
cout << "currentAcquisitionIndex:" << currentAcquisitionIndex << " progress:" << progress << endl;
|
cout << "currentAcquisitionIndex:" << currentAcquisitionIndex << " progress:" << progress << endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if(newData){
|
||||||
|
#ifdef VERY_VERY_DEBUG
|
||||||
|
cout << "new data" << endl;
|
||||||
|
#endif
|
||||||
|
//no gui
|
||||||
|
if (!dataReady){
|
||||||
|
progress = caught;
|
||||||
|
#ifdef VERY_VERY_DEBUG
|
||||||
|
cout << "progress:" << progress << endl;
|
||||||
|
#endif
|
||||||
|
newData = false;
|
||||||
|
#ifdef VERY_VERY_DEBUG
|
||||||
|
cout << "newData set to false" << endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
//gui
|
||||||
|
else{
|
||||||
|
if(setReceiverOnline()==ONLINE_FLAG){
|
||||||
|
//get data
|
||||||
|
strcpy(currentfName,"");
|
||||||
|
pthread_mutex_lock(&mg);
|
||||||
|
//int* receiverData = new int [getTotalNumberOfChannels()];
|
||||||
|
int* receiverData = readFrameFromReceiver(currentfName,currentAcquisitionIndex,currentFrameIndex,currentSubFrameIndex);
|
||||||
|
pthread_mutex_unlock(&mg);
|
||||||
|
|
||||||
if(newData){
|
//if detector returned null
|
||||||
#ifdef VERY_VERY_DEBUG
|
if(setReceiverOnline()==OFFLINE_FLAG)
|
||||||
cout << "new data" << endl;
|
receiverData = NULL;
|
||||||
#endif
|
|
||||||
//no gui
|
|
||||||
if (!dataReady){
|
|
||||||
progress = caught;
|
|
||||||
#ifdef VERY_VERY_DEBUG
|
|
||||||
cout << "progress:" << progress << endl;
|
|
||||||
#endif
|
|
||||||
newData = false;
|
|
||||||
#ifdef VERY_VERY_DEBUG
|
|
||||||
cout << "newData set to false" << endl;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
//gui
|
|
||||||
else{
|
|
||||||
if(setReceiverOnline()==ONLINE_FLAG){
|
|
||||||
//get data
|
|
||||||
strcpy(currentfName,"");
|
|
||||||
pthread_mutex_lock(&mg);
|
|
||||||
//int* receiverData = new int [getTotalNumberOfChannels()];
|
|
||||||
int* receiverData = readFrameFromReceiver(currentfName,currentAcquisitionIndex,currentFrameIndex,currentSubFrameIndex);
|
|
||||||
pthread_mutex_unlock(&mg);
|
|
||||||
|
|
||||||
//if detector returned null
|
//no data or wrong data for print out
|
||||||
if(setReceiverOnline()==OFFLINE_FLAG)
|
if(receiverData == NULL){
|
||||||
receiverData = NULL;
|
currentAcquisitionIndex = -1;
|
||||||
|
cout<<"****Detector Data returned is NULL***"<<endl;
|
||||||
|
}
|
||||||
|
|
||||||
//no data or wrong data for print out
|
// garbage frame
|
||||||
if(receiverData == NULL){
|
if(currentAcquisitionIndex < 0){
|
||||||
currentAcquisitionIndex = -1;
|
|
||||||
cout<<"****Detector Data returned is NULL***"<<endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// garbage frame
|
|
||||||
if(currentAcquisitionIndex < 0){
|
|
||||||
#ifdef VERY_VERY_DEBUG
|
#ifdef VERY_VERY_DEBUG
|
||||||
cout<<"****Detector returned mismatched indices/garbage or acquisition is over. Trying again.***"<<endl;
|
cout<<"****Detector returned mismatched indices/garbage or acquisition is over. Trying again.***"<<endl;
|
||||||
#endif
|
#endif
|
||||||
if(receiverData)
|
if(receiverData)
|
||||||
delete [] receiverData;
|
|
||||||
}
|
|
||||||
//not garbage frame
|
|
||||||
else{// if (currentAcquisitionIndex > progress){
|
|
||||||
#ifdef VERY_VERY_DEBUG
|
|
||||||
cout << "GOT data" << endl;
|
|
||||||
#endif
|
|
||||||
fdata = decodeData(receiverData);
|
|
||||||
delete [] receiverData;
|
delete [] receiverData;
|
||||||
if ((fdata) && (dataReady)){
|
}
|
||||||
// cout << "DATAREADY 3" << endl;
|
//not garbage frame
|
||||||
thisData = new detectorData(fdata,NULL,NULL,getCurrentProgress(),currentfName,getTotalNumberOfChannels());
|
else{// if (currentAcquisitionIndex > progress){
|
||||||
dataReady(thisData, currentFrameIndex, currentSubFrameIndex, pCallbackArg);
|
|
||||||
delete thisData;
|
|
||||||
fdata = NULL;
|
|
||||||
progress = caught;
|
|
||||||
#ifdef VERY_VERY_DEBUG
|
#ifdef VERY_VERY_DEBUG
|
||||||
cout << "progress:" << progress << endl;
|
cout << "GOT data" << endl;
|
||||||
#endif
|
#endif
|
||||||
newData = false;
|
fdata = decodeData(receiverData);
|
||||||
|
delete [] receiverData;
|
||||||
|
if ((fdata) && (dataReady)){
|
||||||
|
// cout << "DATAREADY 3" << endl;
|
||||||
|
thisData = new detectorData(fdata,NULL,NULL,getCurrentProgress(),currentfName,getTotalNumberOfChannels());
|
||||||
|
dataReady(thisData, currentFrameIndex, currentSubFrameIndex, pCallbackArg);
|
||||||
|
delete thisData;
|
||||||
|
fdata = NULL;
|
||||||
|
progress = caught;
|
||||||
#ifdef VERY_VERY_DEBUG
|
#ifdef VERY_VERY_DEBUG
|
||||||
cout << "newData set to false" << endl;
|
cout << "progress:" << progress << endl;
|
||||||
|
#endif
|
||||||
|
newData = false;
|
||||||
|
#ifdef VERY_VERY_DEBUG
|
||||||
|
cout << "newData set to false" << endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -302,8 +302,6 @@ s
|
|||||||
|
|
||||||
/** set when detector finishes acquiring */
|
/** set when detector finishes acquiring */
|
||||||
int acquiringDone;
|
int acquiringDone;
|
||||||
/**sub frame*/
|
|
||||||
int subframe;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user