From 62c92dd36420612474beae176933a605508ae885 Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Thu, 12 Nov 2015 15:05:56 +0100 Subject: [PATCH] changing to random read when no gui at beginnning of acquire --- .../slsDetector/slsDetectorUtils.cpp | 27 ++- .../slsDetectorAnalysis/postProcessing.cpp | 167 ++++++++---------- .../slsDetectorAnalysis/postProcessing.h | 2 - 3 files changed, 83 insertions(+), 113 deletions(-) diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp b/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp index f87959114..bd34ab5ba 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp @@ -44,8 +44,18 @@ slsDetectorUtils::slsDetectorUtils() { void slsDetectorUtils::acquire(int delflag){ bool receiver = (setReceiverOnline()==ONLINE_FLAG); - if(!receiver) - setDetectorIndex(-1); + if(!receiver){ + 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 nf=setTimer(FRAME_NUMBER,-1); if (nc==0) nc=1; @@ -53,10 +63,6 @@ void slsDetectorUtils::acquire(int delflag){ int multiframe = nc*nf; - // - if(setDynamicRange() == 32) subframe = 1; - else subframe = 0; - pthread_mutex_lock(&mg); acquiringDone = 0; pthread_mutex_unlock(&mg); @@ -135,7 +141,7 @@ void slsDetectorUtils::acquire(int delflag){ *stoppedFlag=1; //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; *stoppedFlag=1; } @@ -362,13 +368,6 @@ void slsDetectorUtils::acquire(int delflag){ pthread_mutex_unlock(&mg); } pthread_mutex_lock(&mg); - /* startReceiverReadout(); - while(getReceiverStatus() != RUN_FINISHED){ - pthread_mutex_unlock(&mg); - usleep(50000); - pthread_mutex_lock(&mg); - } -*/ stopReceiver(); pthread_mutex_unlock(&mg); } diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp index 91b57757f..44d806db0 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp +++ b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp @@ -483,16 +483,6 @@ void* postProcessing::processData(int delflag) { } //receiver else{ - /* - //without gui loop - while(1){ - if (checkJoinThread()) break; - usleep(200000); - } - */ - /*if(setReadReceiverFrequency()>0)) ******Not implemented yet ******** - * else - */ int progress = 0; @@ -509,23 +499,13 @@ void* postProcessing::processData(int delflag) { std::cout << "receiver read freq:" << nthframe << std::endl; #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 while(1){ cout.flush(); cout<= 5){cout<<"acquiringdone:"< progress){ - newData = true; -/* + //for random reads, ask only if it has new data + 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"< progress){ -#ifdef VERY_VERY_DEBUG - cout << "GOT data" << endl; -#endif - fdata = decodeData(receiverData); + if(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; + } + //not garbage frame + else{// if (currentAcquisitionIndex > progress){ #ifdef VERY_VERY_DEBUG - cout << "progress:" << progress << endl; + cout << "GOT data" << endl; #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 - cout << "newData set to false" << endl; + cout << "progress:" << progress << endl; +#endif + newData = false; +#ifdef VERY_VERY_DEBUG + cout << "newData set to false" << endl; #endif - } } } } } + } } } diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.h b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.h index cfcf831e0..29ff77fad 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.h +++ b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.h @@ -302,8 +302,6 @@ s /** set when detector finishes acquiring */ int acquiringDone; - /**sub frame*/ - int subframe; /**