ensuring acquire, p receiver start and the gui enables and disables data streaming accordingly. those with api will have to know what they want before acquiring

This commit is contained in:
Dhanya Maliakal
2017-06-22 16:44:29 +02:00
parent cd86c708dc
commit bbbd4731d7
3 changed files with 28 additions and 26 deletions

View File

@ -5656,7 +5656,7 @@ int multiSlsDetector::enableDataStreamingFromReceiver(int enable){
} }
} }
}else enable = dataSocketsStarted; }
int ret=-100, ret1; int ret=-100, ret1;
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) { for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
@ -5670,11 +5670,11 @@ int multiSlsDetector::enableDataStreamingFromReceiver(int enable){
ret=-1; ret=-1;
} }
} }
/*
if(enable == -1) if(ret != dataSocketsStarted)
return dataSocketsStarted; return -1;
*/
return (dataSocketsStarted & ret); return ret;
} }
int multiSlsDetector::enableReceiverCompression(int i){ int multiSlsDetector::enableReceiverCompression(int i){

View File

@ -1319,7 +1319,15 @@ string slsDetectorCommand::cmdAcquire(int narg, char *args[], int action) {
myDet->setOnline(ONLINE_FLAG); myDet->setOnline(ONLINE_FLAG);
myDet->setReceiverOnline(ONLINE_FLAG); if (myDet->setReceiverOnline(ONLINE_FLAG) == ONLINE_FLAG) {
//if it was not off
if (myDet->enableDataStreamingFromReceiver(-1) != 0){
//switch it off, if error
if (myDet->enableDataStreamingFromReceiver(0) != 0) {
return string("could not disable data streaming in receiver\n");
}
}
}
if(myDet->acquire() == FAIL) if(myDet->acquire() == FAIL)
return string("acquire unsuccessful"); return string("acquire unsuccessful");
@ -4830,12 +4838,23 @@ string slsDetectorCommand::cmdReceiver(int narg, char *args[], int action) {
myDet->setOnline(ONLINE_FLAG); myDet->setOnline(ONLINE_FLAG);
myDet->setReceiverOnline(ONLINE_FLAG); int receivers = myDet->setReceiverOnline(ONLINE_FLAG);
if(cmd=="receiver"){ if(cmd=="receiver"){
if (action==PUT_ACTION) { if (action==PUT_ACTION) {
if(!strcasecmp(args[1],"start")) if(!strcasecmp(args[1],"start")) {
//to ensure data streaming enable is the same across client and receiver
if (receivers == ONLINE_FLAG) {
//if it was not off
if (myDet->enableDataStreamingFromReceiver(-1) != 0){
//switch it off, if error
if (myDet->enableDataStreamingFromReceiver(0) != 0) {
return string("could not disable data streaming in receiver\n");
}
}
}
myDet->startReceiver(); myDet->startReceiver();
}
else if(!strcasecmp(args[1],"stop")){ else if(!strcasecmp(args[1],"stop")){
//myDet->stopReceiver(); //myDet->stopReceiver();
// myDet->startReceiverReadout(); // myDet->startReceiverReadout();

View File

@ -62,18 +62,6 @@ int slsDetectorUtils::acquire(int delflag){
bool receiver = (setReceiverOnline()==ONLINE_FLAG); bool receiver = (setReceiverOnline()==ONLINE_FLAG);
if(!receiver){ if(!receiver){
setDetectorIndex(-1); setDetectorIndex(-1);
}else{
//put receiver read frequency to random if no gui
int ret = setReadReceiverFrequency(0);
if(ret>0 && (dataReady == NULL)){
ret = setReadReceiverFrequency(1,0);
std::cout << "No Data call back and hence receiver read frequency reset to " << ret <<" (Random)" << std::endl;
}
//start/stop data streaming threads if threads in client enabled/disabled
ret = enableDataStreamingFromReceiver(-1);
// cout<<"getting datastream:"<<ret<<endl;
// cout<<"result of enabledatastream:"<<enableDataStreamingFromReceiver(ret)<<endl;
} }
int nc=setTimer(CYCLES_NUMBER,-1); int nc=setTimer(CYCLES_NUMBER,-1);
@ -154,11 +142,6 @@ int slsDetectorUtils::acquire(int delflag){
pthread_mutex_lock(&mg); //cout << "lock"<< endl; pthread_mutex_lock(&mg); //cout << "lock"<< endl;
if(getReceiverStatus()!=IDLE) if(getReceiverStatus()!=IDLE)
stopReceiver(); stopReceiver();
//multi detectors shouldnt have different receiver read frequencies enabled/disabled
if(setReadReceiverFrequency(0) < 0){
std::cout << "Error: The receiver read frequency is invalid:" << setReadReceiverFrequency(0) << std::endl;
*stoppedFlag=1;
}
if(setReceiverOnline()==OFFLINE_FLAG) if(setReceiverOnline()==OFFLINE_FLAG)
*stoppedFlag=1; *stoppedFlag=1;
pthread_mutex_unlock(&mg);//cout << "unlock"<< endl; pthread_mutex_unlock(&mg);//cout << "unlock"<< endl;