mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-28 17:10:03 +02:00
made the scans work, where the the dummy message from rxr doesnt stop it from listening for the scans/measurement, only at set join thread
This commit is contained in:
parent
2a508435c7
commit
64843c1c76
@ -5305,11 +5305,18 @@ void multiSlsDetector::readFrameFromReceiver(){
|
||||
|
||||
|
||||
volatile uint64_t dataThreadMask = 0x0;
|
||||
|
||||
//wait for real time acquisition to start
|
||||
bool running = true;
|
||||
sem_wait(&sem_newRTAcquisition);
|
||||
if(checkJoinThread())
|
||||
running = false;
|
||||
|
||||
for(int i = 0; i < numSockets; ++i)
|
||||
dataThreadMask|=(1<<i);
|
||||
|
||||
//exit when last message for each socket received
|
||||
while(true){
|
||||
while(running){
|
||||
//memset(((char*)multiframe),0xFF,slsdatabytes*thisMultiDetector->numberOfDetectors); //reset frame memory
|
||||
|
||||
//get each frame
|
||||
@ -5354,21 +5361,36 @@ void multiSlsDetector::readFrameFromReceiver(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//all done
|
||||
if(!dataThreadMask)
|
||||
break;
|
||||
if(!dataThreadMask){
|
||||
sem_wait(&sem_newRTAcquisition);
|
||||
//done with complete acquisition
|
||||
if(checkJoinThread())
|
||||
break;
|
||||
else{
|
||||
//starting a new scan/measurement
|
||||
for(int i = 0; i < numSockets; ++i)
|
||||
dataThreadMask|=(1<<i);
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
|
||||
//send data to callback
|
||||
fdata = decodeData(multiframe);
|
||||
if ((fdata) && (dataReady)){
|
||||
thisData = new detectorData(fdata,NULL,NULL,getCurrentProgress(),currentFileName.c_str(),nx,ny);
|
||||
dataReady(thisData, currentFrameIndex, currentSubFrameIndex, pCallbackArg);
|
||||
delete thisData;
|
||||
fdata = NULL;
|
||||
//cout<<"Send frame #"<< currentFrameIndex << " to gui"<<endl;
|
||||
if(running){
|
||||
fdata = decodeData(multiframe);
|
||||
if ((fdata) && (dataReady)){
|
||||
thisData = new detectorData(fdata,NULL,NULL,getCurrentProgress(),currentFileName.c_str(),nx,ny);
|
||||
dataReady(thisData, currentFrameIndex, currentSubFrameIndex, pCallbackArg);
|
||||
delete thisData;
|
||||
fdata = NULL;
|
||||
//cout<<"Send frame #"<< currentFrameIndex << " to gui"<<endl;
|
||||
}
|
||||
setCurrentProgress(currentAcquisitionIndex+1);
|
||||
setCurrentProgress(currentAcquisitionIndex+1);
|
||||
}
|
||||
|
||||
//setting it back for each scan/measurement
|
||||
running = true;
|
||||
}
|
||||
|
||||
//free resources
|
||||
|
@ -45,6 +45,7 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
struct timespec begin,end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
|
||||
|
||||
//ensure acquire isnt started multiple times by same client
|
||||
if(getAcquiringFlag() == false)
|
||||
setAcquiringFlag(true);
|
||||
@ -53,6 +54,10 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
//not in the loop for real time acqusition yet,
|
||||
//in the real time acquisition loop, processing thread will wait for a post each time
|
||||
sem_init(&sem_newRTAcquisition,1,0);
|
||||
|
||||
|
||||
bool receiver = (setReceiverOnline()==ONLINE_FLAG);
|
||||
if(!receiver){
|
||||
@ -220,6 +225,10 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
ResetPositionIndex();
|
||||
|
||||
for (int ip=0; ip<np; ip++) {
|
||||
|
||||
//let processing thread listen to these packets
|
||||
sem_post(&sem_newRTAcquisition);
|
||||
|
||||
// cout << "positions " << endl;
|
||||
if (*stoppedFlag==0) {
|
||||
if (getNumberOfPositions()>0) {
|
||||
@ -462,6 +471,9 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
}
|
||||
|
||||
|
||||
//let processing thread continue and checkjointhread
|
||||
sem_post(&sem_newRTAcquisition);
|
||||
|
||||
// waiting for the data processing thread to finish!
|
||||
if (*threadedProcessing) {
|
||||
#ifdef VERBOSE
|
||||
@ -499,6 +511,7 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
#endif
|
||||
|
||||
setAcquiringFlag(false);
|
||||
sem_destroy(&sem_newRTAcquisition);
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
cout << "Elapsed time for acquisition:" << (( end.tv_sec - begin.tv_sec ) + ( end.tv_nsec - begin.tv_nsec ) / 1000000000.0) << " seconds" << endl;
|
||||
|
@ -878,12 +878,10 @@ virtual int setReceiverFifoDepth(int i = -1)=0;
|
||||
int (*acquisition_finished)(double,int,void*);
|
||||
int (*measurement_finished)(int,int,void*);
|
||||
void *acqFinished_p, *measFinished_p;
|
||||
|
||||
|
||||
|
||||
int (*progress_call)(double,void*);
|
||||
void *pProgressCallArg;
|
||||
|
||||
sem_t sem_newRTAcquisition;
|
||||
|
||||
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user