using framescaught instead of frameindex in gui to get data

This commit is contained in:
Dhanya Maliakal 2015-08-19 15:48:14 +02:00
parent 225b67f5e5
commit 79e13c6db7

View File

@ -495,8 +495,9 @@ void* postProcessing::processData(int delflag) {
*/ */
int progress = -1; int progress = 0;
char currentfName[MAX_STR_LENGTH]=""; char currentfName[MAX_STR_LENGTH]="";
int caught = -1;
int currentAcquisitionIndex = -1; int currentAcquisitionIndex = -1;
int currentFrameIndex = -1; int currentFrameIndex = -1;
bool newData = false; bool newData = false;
@ -529,20 +530,23 @@ void* postProcessing::processData(int delflag) {
//get progress //get progress
pthread_mutex_lock(&mg); pthread_mutex_lock(&mg);
if(setReceiverOnline() == ONLINE_FLAG) if(setReceiverOnline() == ONLINE_FLAG)
currentAcquisitionIndex = getReceiverCurrentFrameIndex(); caught = getFramesCaughtByReceiver();//getReceiverCurrentFrameIndex();
pthread_mutex_unlock(&mg); pthread_mutex_unlock(&mg);
//updating progress //updating progress
if(currentAcquisitionIndex != -1){ if(currentAcquisitionIndex != -1){
setCurrentProgress(caught);
/*
if(subframe){ if(subframe){
pthread_mutex_lock(&mg); pthread_mutex_lock(&mg);
setCurrentProgress(getFramesCaughtByReceiver()); setCurrentProgress(getFramesCaughtByReceiver());
pthread_mutex_unlock(&mg); pthread_mutex_unlock(&mg);
}else }else
setCurrentProgress(currentAcquisitionIndex+1); setCurrentProgress(currentAcquisitionIndex+1);
*/
} }
#ifdef VERY_VERY_DEBUG #ifdef VERY_VERY_DEBUG
cout << "currentAcquisitionIndex:" << currentAcquisitionIndex << endl; cout << "caught:" << caught << endl;
#endif #endif
@ -585,70 +589,98 @@ void* postProcessing::processData(int delflag) {
if (dataReady){
//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(currentAcquisitionIndex > progress) if(caught > progress){
newData = true; newData = true;
/*
// keeping acquiringdone at 1 to get more time to get data
if(acquiringDone > 0){cout<<"going to maintain acquiidne"<<endl;
pthread_mutex_lock(&mg);
acquiringDone = 1;
//#ifdef VERY_VERY_DEBUG
cout << "Keeping acquiringDone at 1 " << endl;
//#endif
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 #endif
} }
if(newData){ if(newData){
//#ifdef VERY_VERY_DEBUG #ifdef VERY_VERY_DEBUG
cout << "new data" << endl; cout << "new data" << endl;
//#endif
if(setReceiverOnline()==ONLINE_FLAG){
//get data
strcpy(currentfName,"");
pthread_mutex_lock(&mg);
//int* receiverData = new int [getTotalNumberOfChannels()];
int* receiverData = readFrameFromReceiver(currentfName,currentAcquisitionIndex,currentFrameIndex);
pthread_mutex_unlock(&mg);
//if detector returned null
if(setReceiverOnline()==OFFLINE_FLAG)
receiverData = NULL;
//no data or wrong data for print out
if(receiverData == NULL){
currentAcquisitionIndex = -1;
cout<<"****Detector Data returned is NULL***"<<endl;
}
//not garbage frame
if(currentAcquisitionIndex < 0){
#ifdef VERY_VERY_DEBUG
cout<<"****Detector returned mismatched indices/garbage or acquisition is over. Trying again.***"<<endl;
#endif #endif
if(receiverData) //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);
pthread_mutex_unlock(&mg);
//if detector returned null
if(setReceiverOnline()==OFFLINE_FLAG)
receiverData = NULL;
//no data or wrong data for print out
if(receiverData == NULL){
currentAcquisitionIndex = -1;
cout<<"****Detector Data returned is NULL***"<<endl;
}
// garbage frame
if(currentAcquisitionIndex < 0){
#ifdef VERY_VERY_DEBUG
cout<<"****Detector returned mismatched indices/garbage or acquisition is over. Trying again.***"<<endl;
#endif
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;
}else if (currentAcquisitionIndex > progress){ if ((fdata) && (dataReady)){
// cout << "DATAREADY 3" << endl;
thisData = new detectorData(fdata,NULL,NULL,getCurrentProgress(),currentfName,getTotalNumberOfChannels());
dataReady(thisData, currentFrameIndex, pCallbackArg);
delete thisData;
fdata = NULL;
progress = caught;
#ifdef VERY_VERY_DEBUG #ifdef VERY_VERY_DEBUG
cout << "GOT data" << endl; cout << "progress:" << progress << endl;
#endif #endif
fdata = decodeData(receiverData); newData = false;
delete [] receiverData;
if ((fdata) && (dataReady)){
// cout << "DATAREADY 3" << endl;
thisData = new detectorData(fdata,NULL,NULL,getCurrentProgress(),currentfName,getTotalNumberOfChannels());
dataReady(thisData, currentFrameIndex, pCallbackArg);
delete thisData;
fdata = NULL;
progress = currentAcquisitionIndex;
#ifdef VERY_VERY_DEBUG #ifdef VERY_VERY_DEBUG
cout << "progress:" << progress << endl; cout << "newData set to false" << endl;
#endif
newData = false;
#ifdef VERY_VERY_DEBUG
cout << "newData set to false" << endl;
#endif #endif
}
} }
} }
} }
} }
}
} }
} }