mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-29 01:20:02 +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;
|
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)
|
for(int i = 0; i < numSockets; ++i)
|
||||||
dataThreadMask|=(1<<i);
|
dataThreadMask|=(1<<i);
|
||||||
|
|
||||||
//exit when last message for each socket received
|
//exit when last message for each socket received
|
||||||
while(true){
|
while(running){
|
||||||
//memset(((char*)multiframe),0xFF,slsdatabytes*thisMultiDetector->numberOfDetectors); //reset frame memory
|
//memset(((char*)multiframe),0xFF,slsdatabytes*thisMultiDetector->numberOfDetectors); //reset frame memory
|
||||||
|
|
||||||
//get each frame
|
//get each frame
|
||||||
@ -5354,21 +5361,36 @@ void multiSlsDetector::readFrameFromReceiver(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//all done
|
//all done
|
||||||
if(!dataThreadMask)
|
if(!dataThreadMask){
|
||||||
break;
|
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
|
//send data to callback
|
||||||
fdata = decodeData(multiframe);
|
if(running){
|
||||||
if ((fdata) && (dataReady)){
|
fdata = decodeData(multiframe);
|
||||||
thisData = new detectorData(fdata,NULL,NULL,getCurrentProgress(),currentFileName.c_str(),nx,ny);
|
if ((fdata) && (dataReady)){
|
||||||
dataReady(thisData, currentFrameIndex, currentSubFrameIndex, pCallbackArg);
|
thisData = new detectorData(fdata,NULL,NULL,getCurrentProgress(),currentFileName.c_str(),nx,ny);
|
||||||
delete thisData;
|
dataReady(thisData, currentFrameIndex, currentSubFrameIndex, pCallbackArg);
|
||||||
fdata = NULL;
|
delete thisData;
|
||||||
//cout<<"Send frame #"<< currentFrameIndex << " to gui"<<endl;
|
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
|
//free resources
|
||||||
|
@ -45,6 +45,7 @@ int slsDetectorUtils::acquire(int delflag){
|
|||||||
struct timespec begin,end;
|
struct timespec begin,end;
|
||||||
clock_gettime(CLOCK_REALTIME, &begin);
|
clock_gettime(CLOCK_REALTIME, &begin);
|
||||||
|
|
||||||
|
|
||||||
//ensure acquire isnt started multiple times by same client
|
//ensure acquire isnt started multiple times by same client
|
||||||
if(getAcquiringFlag() == false)
|
if(getAcquiringFlag() == false)
|
||||||
setAcquiringFlag(true);
|
setAcquiringFlag(true);
|
||||||
@ -53,6 +54,10 @@ int slsDetectorUtils::acquire(int delflag){
|
|||||||
return FAIL;
|
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);
|
bool receiver = (setReceiverOnline()==ONLINE_FLAG);
|
||||||
if(!receiver){
|
if(!receiver){
|
||||||
@ -220,6 +225,10 @@ int slsDetectorUtils::acquire(int delflag){
|
|||||||
ResetPositionIndex();
|
ResetPositionIndex();
|
||||||
|
|
||||||
for (int ip=0; ip<np; ip++) {
|
for (int ip=0; ip<np; ip++) {
|
||||||
|
|
||||||
|
//let processing thread listen to these packets
|
||||||
|
sem_post(&sem_newRTAcquisition);
|
||||||
|
|
||||||
// cout << "positions " << endl;
|
// cout << "positions " << endl;
|
||||||
if (*stoppedFlag==0) {
|
if (*stoppedFlag==0) {
|
||||||
if (getNumberOfPositions()>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!
|
// waiting for the data processing thread to finish!
|
||||||
if (*threadedProcessing) {
|
if (*threadedProcessing) {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
@ -499,6 +511,7 @@ int slsDetectorUtils::acquire(int delflag){
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
setAcquiringFlag(false);
|
setAcquiringFlag(false);
|
||||||
|
sem_destroy(&sem_newRTAcquisition);
|
||||||
|
|
||||||
clock_gettime(CLOCK_REALTIME, &end);
|
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;
|
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 (*acquisition_finished)(double,int,void*);
|
||||||
int (*measurement_finished)(int,int,void*);
|
int (*measurement_finished)(int,int,void*);
|
||||||
void *acqFinished_p, *measFinished_p;
|
void *acqFinished_p, *measFinished_p;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int (*progress_call)(double,void*);
|
int (*progress_call)(double,void*);
|
||||||
void *pProgressCallArg;
|
void *pProgressCallArg;
|
||||||
|
|
||||||
|
sem_t sem_newRTAcquisition;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user