mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-22 17:47:59 +02:00
parallelized settimer, setfileindex, setonline, setreceiveronline, getreceiverstatus, resetframescaught, setFrameIndex, setFileName, getFramesCaughtByReceiver; added getFramesCaughtbyAnyreceiver to avoid threadpool and to use in post processing
This commit is contained in:
@ -6111,7 +6111,8 @@ string slsDetector::setReceiver(string receiverIP){
|
||||
else
|
||||
printf("Disabling Data Streaming\n");
|
||||
// push client state to receiver
|
||||
parentDet->enableDataStreamingFromReceiver(clientSockets);
|
||||
/*parentDet->enableDataStreamingFromReceiver(clientSockets);*/
|
||||
enableDataStreamingFromReceiver(clientSockets);
|
||||
pthread_mutex_unlock(&ms);
|
||||
}
|
||||
}
|
||||
@ -7587,19 +7588,23 @@ slsDetectorDefs::synchronizationMode slsDetector::setSynchronization(synchroniza
|
||||
|
||||
/*receiver*/
|
||||
int slsDetector::setReceiverOnline(int off) {
|
||||
// int prev = thisDetector->receiverOnlineFlag;
|
||||
if (off!=GET_ONLINE_FLAG) {
|
||||
if(strcmp(thisDetector->receiver_hostname,"none")){
|
||||
thisDetector->receiverOnlineFlag=off;
|
||||
if (thisDetector->receiverOnlineFlag==ONLINE_FLAG){
|
||||
setReceiverTCPSocket();
|
||||
if(thisDetector->receiverOnlineFlag==OFFLINE_FLAG){
|
||||
std::cout << "cannot connect to receiver" << endl;
|
||||
setErrorMask((getErrorMask())|(CANNOT_CONNECT_TO_RECEIVER));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (off!=GET_ONLINE_FLAG) {
|
||||
// setting flag to offline
|
||||
if (off == OFFLINE_FLAG)
|
||||
thisDetector->receiverOnlineFlag = off;
|
||||
// set flag to online only if hostname not none
|
||||
else if(strcmp(thisDetector->receiver_hostname,"none")){
|
||||
thisDetector->receiverOnlineFlag=off;
|
||||
}
|
||||
if (thisDetector->receiverOnlineFlag==ONLINE_FLAG){
|
||||
setReceiverTCPSocket();
|
||||
// error in connecting
|
||||
if(thisDetector->receiverOnlineFlag==OFFLINE_FLAG){
|
||||
std::cout << "cannot connect to receiver" << endl;
|
||||
setErrorMask((getErrorMask())|(CANNOT_CONNECT_TO_RECEIVER));
|
||||
}
|
||||
}
|
||||
}
|
||||
return thisDetector->receiverOnlineFlag;
|
||||
}
|
||||
|
||||
|
@ -1636,6 +1636,11 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
*/
|
||||
int getFramesCaughtByReceiver();
|
||||
|
||||
/** gets the number of frames caught by any one receiver (to avoid using threadpool)
|
||||
\returns number of frames caught by any one receiver (master receiver if exists)
|
||||
*/
|
||||
int getFramesCaughtByAnyReceiver() {getFramesCaughtByReceiver();};
|
||||
|
||||
/** gets the current frame index of receiver
|
||||
\returns current frame index of receiver
|
||||
*/
|
||||
|
@ -490,6 +490,11 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
|
||||
*/
|
||||
virtual int getFramesCaughtByReceiver()=0;
|
||||
|
||||
/** gets the number of frames caught by any one receiver (to avoid using threadpool)
|
||||
\returns number of frames caught by any one receiver (master receiver if exists)
|
||||
*/
|
||||
virtual int getFramesCaughtByAnyReceiver()=0;
|
||||
|
||||
/**
|
||||
\returns current frame index of receiver
|
||||
*/
|
||||
|
@ -2295,10 +2295,9 @@ string slsDetectorCommand::cmdAcquire(int narg, char *args[], int action) {
|
||||
|
||||
|
||||
myDet->setOnline(ONLINE_FLAG);
|
||||
int r_online = myDet->setReceiverOnline(ONLINE_FLAG);
|
||||
|
||||
if (myDet->getExternalGuiFlag())
|
||||
myDet->setReceiverOnline(ONLINE_FLAG);
|
||||
else if (myDet->setReceiverOnline(ONLINE_FLAG) == ONLINE_FLAG) {
|
||||
if ((!myDet->getExternalGuiFlag()) && (r_online == ONLINE_FLAG)) {
|
||||
// command line: must be off, if receiver on or there was -1, then
|
||||
if (myDet->enableDataStreamingFromReceiver(-1) != 0){
|
||||
//switch it off, if error
|
||||
@ -2310,7 +2309,7 @@ string slsDetectorCommand::cmdAcquire(int narg, char *args[], int action) {
|
||||
|
||||
if(myDet->acquire() == FAIL)
|
||||
return string("acquire unsuccessful");
|
||||
if(myDet->setReceiverOnline()==ONLINE_FLAG){
|
||||
if(r_online){
|
||||
char answer[100];
|
||||
sprintf(answer,"\nAcquired %d",myDet->getFramesCaughtByReceiver());
|
||||
return string(answer);
|
||||
|
@ -50,8 +50,10 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
struct timespec begin,end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
#endif
|
||||
|
||||
//not in the loop for real time acqusition yet,
|
||||
//in the real time acquisition loop, processing thread will wait for a post each time
|
||||
@ -140,9 +142,8 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
if(receiver){
|
||||
pthread_mutex_lock(&mg); //cout << "lock"<< endl;
|
||||
if(getReceiverStatus()!=IDLE)
|
||||
stopReceiver();
|
||||
if(setReceiverOnline()==OFFLINE_FLAG)
|
||||
*stoppedFlag=1;
|
||||
if(stopReceiver() == FAIL)
|
||||
*stoppedFlag=1;
|
||||
pthread_mutex_unlock(&mg);//cout << "unlock"<< endl;
|
||||
}
|
||||
|
||||
@ -156,7 +157,8 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
//resets frames caught in receiver
|
||||
if(receiver){
|
||||
pthread_mutex_lock(&mg); //cout << "lock"<< endl;
|
||||
resetFramesCaught();
|
||||
if (resetFramesCaught() == FAIL)
|
||||
*stoppedFlag=1;
|
||||
pthread_mutex_unlock(&mg);//cout << "unlock"<< endl;
|
||||
}
|
||||
|
||||
@ -332,10 +334,13 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
|
||||
while (dataQueueSize()) usleep(100000);
|
||||
// cout << "mglock " << endl;;
|
||||
|
||||
|
||||
|
||||
pthread_mutex_lock(&mg); //cout << "lock"<< endl;
|
||||
// cout << "done " << endl;;
|
||||
//offline
|
||||
if(setReceiverOnline()==OFFLINE_FLAG){
|
||||
if(!receiver){
|
||||
if ((getDetectorsType()==GOTTHARD) || (getDetectorsType()==MOENCH) || (getDetectorsType()==JUNGFRAU)|| (getDetectorsType()==JUNGFRAUCTB) ){
|
||||
if((*correctionMask)&(1<<WRITE_FILE))
|
||||
closeDataFile();
|
||||
@ -343,14 +348,8 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
}
|
||||
//online
|
||||
else{
|
||||
|
||||
if(setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG){
|
||||
stopAcquisition();
|
||||
stopReceiver();
|
||||
pthread_mutex_unlock(&mg);
|
||||
break;
|
||||
}
|
||||
stopReceiver();
|
||||
if (stopReceiver() == FAIL)
|
||||
*stoppedFlag = 1;
|
||||
// cout<<"***********receiver stopped"<<endl;
|
||||
}
|
||||
pthread_mutex_unlock(&mg);//cout << "unlock"<< endl;
|
||||
@ -507,8 +506,8 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
setAcquiringFlag(false);
|
||||
sem_destroy(&sem_newRTAcquisition);
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
#ifdef VERBOSE
|
||||
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;
|
||||
#endif
|
||||
return OK;
|
||||
|
@ -669,6 +669,11 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
||||
*/
|
||||
virtual int getFramesCaughtByReceiver()=0;
|
||||
|
||||
/** gets the number of frames caught by any one receiver (to avoid using threadpool)
|
||||
\returns number of frames caught by any one receiver (master receiver if exists)
|
||||
*/
|
||||
virtual int getFramesCaughtByAnyReceiver()=0;
|
||||
|
||||
/**
|
||||
\returns current frame index of receiver
|
||||
*/
|
||||
|
Reference in New Issue
Block a user