changed everything to depend on receiver online shared memory flag, and if it is online is only checked rarely

This commit is contained in:
Dhanya Maliakal 2016-11-22 14:01:07 +01:00
parent 09d146ee55
commit c70f453de4
3 changed files with 88 additions and 70 deletions

View File

@ -1311,7 +1311,7 @@ int slsDetector::activate(int const enable){
#endif #endif
if(ret!=FAIL){ if(ret!=FAIL){
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){ if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Activating/Deactivating Receiver: " << retval << std::endl; std::cout << "Activating/Deactivating Receiver: " << retval << std::endl;
#endif #endif
@ -1623,9 +1623,9 @@ int slsDetector::setDetectorType(detectorType const type){
//receiver //receiver
if((retType != GENERIC) && (setReceiverOnline()==ONLINE_FLAG)) { if((retType != GENERIC) && (thisDetector->receiverOnlineFlag==ONLINE_FLAG)) {
retval = FAIL; retval = FAIL;
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){ if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Sending detector type to Receiver " << (int)thisDetector->myDetectorType << std::endl; std::cout << "Sending detector type to Receiver " << (int)thisDetector->myDetectorType << std::endl;
#endif #endif
@ -1997,7 +1997,7 @@ int64_t slsDetector::getId( idMode mode, int imod){
retval=SVNREVLIB; retval=SVNREVLIB;
retval=(retval<<32) | SVNDATELIB; retval=(retval<<32) | SVNDATELIB;
} else if (mode==RECEIVER_VERSION) { } else if (mode==RECEIVER_VERSION) {
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) { if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
if (connectData() == OK){ if (connectData() == OK){
ret=thisReceiver->getInt(fnum2,retval); ret=thisReceiver->getInt(fnum2,retval);
disconnectData(); disconnectData();
@ -4068,7 +4068,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
args[0] = index; args[0] = index;
args[1] = thisDetector->timerValue[index]; args[1] = thisDetector->timerValue[index];
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){ if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
//set #frames, #cycles //set #frames, #cycles
if((index==FRAME_NUMBER)||(index==CYCLES_NUMBER)){ if((index==FRAME_NUMBER)||(index==CYCLES_NUMBER)){
@ -4629,7 +4629,7 @@ int slsDetector::setDynamicRange(int n){
if(ret != FAIL){ if(ret != FAIL){
retval = thisDetector->dynamicRange; retval = thisDetector->dynamicRange;
if((n==-1) && (ret!= FORCE_UPDATE)) n =-1; if((n==-1) && (ret!= FORCE_UPDATE)) n =-1;
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){ if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Sending/Getting dynamic range to/from receiver " << n << std::endl; std::cout << "Sending/Getting dynamic range to/from receiver " << n << std::endl;
#endif #endif
@ -5142,7 +5142,7 @@ int slsDetector::setRateCorrection(double t){
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "Setting Rate Correction to " << arg << endl; std::cout<< "Setting Rate Correction to " << arg << endl;
#endif #endif
if (setOnline(ONLINE_FLAG)==ONLINE_FLAG) { if (thisDetector->onlineFlag==ONLINE_FLAG) {
if (connectControl() == OK){ if (connectControl() == OK){
controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&fnum,sizeof(fnum));
controlSocket->SendDataOnly(&arg,sizeof(arg)); controlSocket->SendDataOnly(&arg,sizeof(arg));
@ -5224,7 +5224,7 @@ double slsDetector::getRateCorrectionTau(){
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "Setting Rate Correction to " << arg << endl; std::cout<< "Setting Rate Correction to " << arg << endl;
#endif #endif
if (setOnline(ONLINE_FLAG)==ONLINE_FLAG) { if (thisDetector->onlineFlag==ONLINE_FLAG) {
if (connectControl() == OK){ if (connectControl() == OK){
controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&fnum,sizeof(fnum));
controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
@ -5768,7 +5768,7 @@ int slsDetector::setUDPConnection(){
#endif #endif
//set up receiver for UDP Connection and get receivermac address //set up receiver for UDP Connection and get receivermac address
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){ if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Setting up UDP Connection for Receiver " << args[0] << "\t" << args[1] << std::endl; std::cout << "Setting up UDP Connection for Receiver " << args[0] << "\t" << args[1] << std::endl;
#endif #endif
@ -5934,7 +5934,6 @@ int slsDetector::configureMAC(){
pthread_mutex_unlock(&ms); pthread_mutex_unlock(&ms);
//connect to receiver //connect to receiver
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Sending adc val to receiver " << retval << std::endl; std::cout << "Sending adc val to receiver " << retval << std::endl;
#endif #endif
@ -5944,7 +5943,6 @@ int slsDetector::configureMAC(){
} }
if(ret==FAIL) if(ret==FAIL)
setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC)); setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC));
}
} }
} }
@ -6544,7 +6542,7 @@ int slsDetector::programFPGA(string fname){
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "Sending programming binary to detector " << endl; std::cout<< "Sending programming binary to detector " << endl;
#endif #endif
if (setOnline(ONLINE_FLAG)==ONLINE_FLAG) { if (thisDetector->onlineFlag==ONLINE_FLAG) {
if (connectControl() == OK){ if (connectControl() == OK){
controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&fnum,sizeof(fnum));
controlSocket->SendDataOnly(&filesize,sizeof(filesize)); controlSocket->SendDataOnly(&filesize,sizeof(filesize));
@ -6639,7 +6637,7 @@ int slsDetector::resetFPGA(){
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "Sending reset to FPGA " << endl; std::cout<< "Sending reset to FPGA " << endl;
#endif #endif
if (setOnline(ONLINE_FLAG)==ONLINE_FLAG) { if (thisDetector->onlineFlag==ONLINE_FLAG) {
if (connectControl() == OK){ if (connectControl() == OK){
controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&fnum,sizeof(fnum));
@ -6675,7 +6673,7 @@ int slsDetector::powerChip(int ival){
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "Sending power on/off/get to the chip " << endl; std::cout<< "Sending power on/off/get to the chip " << endl;
#endif #endif
if (setOnline(ONLINE_FLAG)==ONLINE_FLAG) { if (thisDetector->onlineFlag==ONLINE_FLAG) {
if (connectControl() == OK){ if (connectControl() == OK){
controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&fnum,sizeof(fnum));
controlSocket->SendDataOnly(&ival,sizeof(ival)); controlSocket->SendDataOnly(&ival,sizeof(ival));
@ -7049,10 +7047,10 @@ string slsDetector::checkReceiverOnline() {
thisDetector->receiverOnlineFlag=OFFLINE_FLAG; thisDetector->receiverOnlineFlag=OFFLINE_FLAG;
delete dataSocket; delete dataSocket;
dataSocket=NULL; dataSocket=NULL;
retval = FAIL;
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "receiver offline!" << std::endl; std::cout<< "receiver offline!" << std::endl;
#endif #endif
return string(thisDetector->receiver_hostname);
} else { } else {
thisDetector->receiverOnlineFlag=ONLINE_FLAG; thisDetector->receiverOnlineFlag=ONLINE_FLAG;
dataSocket->SetTimeOut(100); dataSocket->SetTimeOut(100);
@ -7060,9 +7058,9 @@ string slsDetector::checkReceiverOnline() {
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "receiver online!" << std::endl; std::cout<< "receiver online!" << std::endl;
#endif #endif
return string("");
} }
} }
return retval;
} }
@ -7158,7 +7156,7 @@ string slsDetector::setFilePath(string s) {
} }
} }
else if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){ else{
strcpy(arg,s.c_str()); strcpy(arg,s.c_str());
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Sending file path to receiver " << arg << std::endl; std::cout << "Sending file path to receiver " << arg << std::endl;
@ -7207,27 +7205,25 @@ string slsDetector::setFileName(string s) {
} }
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){ strcpy(arg,s.c_str());
strcpy(arg,s.c_str());
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Sending file name to receiver " << arg << std::endl; std::cout << "Sending file name to receiver " << arg << std::endl;
#endif #endif
if (connectData() == OK){ if (connectData() == OK){
ret=thisReceiver->sendString(fnum,retval,arg); ret=thisReceiver->sendString(fnum,retval,arg);
disconnectData(); disconnectData();
}
if(ret!=FAIL){
#ifdef VERBOSE
std::cout << "Complete file prefix from receiver: " << retval << std::endl;
#endif
pthread_mutex_lock(&ms);
fileIO::setFileName(parentDet->getNameFromReceiverFilePrefix(string(retval)));
pthread_mutex_unlock(&ms);
}
if(ret==FORCE_UPDATE)
updateReceiver();
} }
if(ret!=FAIL){
#ifdef VERBOSE
std::cout << "Complete file prefix from receiver: " << retval << std::endl;
#endif
pthread_mutex_lock(&ms);
fileIO::setFileName(parentDet->getNameFromReceiverFilePrefix(string(retval)));
pthread_mutex_unlock(&ms);
}
if(ret==FORCE_UPDATE)
updateReceiver();
} }
pthread_mutex_lock(&ms); pthread_mutex_lock(&ms);
@ -7256,7 +7252,7 @@ int slsDetector::setFileIndex(int i) {
} }
} }
else if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){ else{
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Sending file index to receiver " << arg << std::endl; std::cout << "Sending file index to receiver " << arg << std::endl;
#endif #endif
@ -7284,7 +7280,7 @@ int slsDetector::startReceiver(){
int ret = FAIL; int ret = FAIL;
char mess[MAX_STR_LENGTH] = ""; char mess[MAX_STR_LENGTH] = "";
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) { if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Starting Receiver " << std::endl; std::cout << "Starting Receiver " << std::endl;
#endif #endif
@ -7321,7 +7317,7 @@ int slsDetector::stopReceiver(){
if(thisDetector->myDetectorType != EIGER && thisDetector->myDetectorType != JUNGFRAU) if(thisDetector->myDetectorType != EIGER && thisDetector->myDetectorType != JUNGFRAU)
detectorSendToReceiver(false); detectorSendToReceiver(false);
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) { if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Stopping Receiver " << std::endl; std::cout << "Stopping Receiver " << std::endl;
#endif #endif
@ -7347,7 +7343,7 @@ slsDetectorDefs::runStatus slsDetector::startReceiverReadout(){
int retval=-1; int retval=-1;
runStatus s=ERROR; runStatus s=ERROR;
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) { if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Starting Receiver Readout" << std::endl; std::cout << "Starting Receiver Readout" << std::endl;
#endif #endif
@ -7405,7 +7401,7 @@ slsDetectorDefs::runStatus slsDetector::getReceiverStatus(){
int retval=-1; int retval=-1;
runStatus s=ERROR; runStatus s=ERROR;
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) { if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Getting Receiver Status" << std::endl; std::cout << "Getting Receiver Status" << std::endl;
#endif #endif
@ -7430,7 +7426,7 @@ int slsDetector::getFramesCaughtByReceiver(){
int ret = FAIL; int ret = FAIL;
int retval=-1; int retval=-1;
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) { if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Getting Frames Caught by Receiver " << std::endl; std::cout << "Getting Frames Caught by Receiver " << std::endl;
#endif #endif
@ -7452,7 +7448,7 @@ int slsDetector::getReceiverCurrentFrameIndex(){
int ret = FAIL; int ret = FAIL;
int retval=-1; int retval=-1;
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) { if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Getting Current Frame Index of Receiver " << std::endl; std::cout << "Getting Current Frame Index of Receiver " << std::endl;
#endif #endif
@ -7475,7 +7471,7 @@ int slsDetector::resetFramesCaught(){
int ret = FAIL; int ret = FAIL;
char mess[MAX_STR_LENGTH] = ""; char mess[MAX_STR_LENGTH] = "";
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) { if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Reset Frames Caught by Receiver" << std::endl; std::cout << "Reset Frames Caught by Receiver" << std::endl;
#endif #endif
@ -7502,7 +7498,7 @@ int slsDetector::lockReceiver(int lock){
int arg=lock; int arg=lock;
if(setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG){ if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Locking or Unlocking Receiver " << std::endl; std::cout << "Locking or Unlocking Receiver " << std::endl;
#endif #endif
@ -7527,7 +7523,7 @@ string slsDetector::getReceiverLastClientIP(){
int ret = FAIL; int ret = FAIL;
char retval[INET_ADDRSTRLEN]=""; char retval[INET_ADDRSTRLEN]="";
if(setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG){ if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Geting Last Client IP connected to Receiver " << std::endl; std::cout << "Geting Last Client IP connected to Receiver " << std::endl;
#endif #endif
@ -7585,7 +7581,7 @@ int slsDetector::updateReceiver() {
int ret=OK; int ret=OK;
char mess[MAX_STR_LENGTH]=""; char mess[MAX_STR_LENGTH]="";
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) { if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
if (connectData() == OK){ if (connectData() == OK){
dataSocket->SendDataOnly(&fnum,sizeof(fnum)); dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
@ -7612,7 +7608,7 @@ int slsDetector::exitReceiver(){
int retval; int retval;
int fnum=F_EXIT_RECEIVER; int fnum=F_EXIT_RECEIVER;
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) { if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
if (dataSocket) { if (dataSocket) {
dataSocket->Connect(); dataSocket->Connect();
dataSocket->SendDataOnly(&fnum,sizeof(fnum)); dataSocket->SendDataOnly(&fnum,sizeof(fnum));
@ -7648,7 +7644,7 @@ int slsDetector::enableWriteToFile(int enable){
} }
} }
else if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){ else if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Sending enable file write to receiver " << arg << std::endl; std::cout << "Sending enable file write to receiver " << arg << std::endl;
#endif #endif
@ -7690,7 +7686,7 @@ int slsDetector::overwriteFile(int enable){
} }
} }
else if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){ else if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Sending enable file write to receiver " << arg << std::endl; std::cout << "Sending enable file write to receiver " << arg << std::endl;
#endif #endif
@ -7729,7 +7725,7 @@ int slsDetector::setFrameIndex(int index){
pthread_mutex_unlock(&ms); pthread_mutex_unlock(&ms);
} }
else if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){ else if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Sending frame index to receiver " << arg << std::endl; std::cout << "Sending frame index to receiver " << arg << std::endl;
#endif #endif
@ -7809,7 +7805,7 @@ int slsDetector::setReadReceiverFrequency(int getFromReceiver, int freq){
if(!getFromReceiver) if(!getFromReceiver)
return retval; return retval;
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){ if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Sending read frequency to receiver " << arg << std::endl; std::cout << "Sending read frequency to receiver " << arg << std::endl;
#endif #endif
@ -7838,7 +7834,7 @@ int slsDetector::setReceiverReadTimer(int time_in_ms){
int arg = time_in_ms; int arg = time_in_ms;
int retval = -1; int retval = -1;
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){ if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Sending read timer to receiver " << arg << std::endl; std::cout << "Sending read timer to receiver " << arg << std::endl;
#endif #endif
@ -7866,7 +7862,7 @@ int slsDetector::enableDataStreamingFromReceiver(int enable){
int arg = enable; int arg = enable;
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){ if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "***************Sending Data Streaming in Receiver " << arg << std::endl; std::cout << "***************Sending Data Streaming in Receiver " << arg << std::endl;
#endif #endif
@ -7895,7 +7891,7 @@ int slsDetector::enableReceiverCompression(int i){
int retval=-1; int retval=-1;
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){ if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Getting/Enabling/Disabling Receiver Compression with argument " << i << std::endl; std::cout << "Getting/Enabling/Disabling Receiver Compression with argument " << i << std::endl;
#endif #endif
@ -7917,7 +7913,7 @@ void slsDetector::setDetectorHostname(){
char retval[MAX_STR_LENGTH]=""; char retval[MAX_STR_LENGTH]="";
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){ if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Sending detector hostname to Receiver " << thisDetector->hostname << std::endl; std::cout << "Sending detector hostname to Receiver " << thisDetector->hostname << std::endl;
#endif #endif
@ -7966,7 +7962,7 @@ int slsDetector::enableTenGigabitEthernet(int i){
if(configureMAC() != FAIL){ if(configureMAC() != FAIL){
ret = FAIL; ret = FAIL;
retval=-1; retval=-1;
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){ if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Enabling / Disabling 10Gbe in receiver: " << i << std::endl; std::cout << "Enabling / Disabling 10Gbe in receiver: " << i << std::endl;
#endif #endif
@ -7994,7 +7990,7 @@ int slsDetector::setReceiverFifoDepth(int i){
int retval=-1; int retval=-1;
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){ if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
#ifdef VERBOSE #ifdef VERBOSE
if(i ==-1) if(i ==-1)
std::cout<< "Getting Receiver Fifo Depth" << endl; std::cout<< "Getting Receiver Fifo Depth" << endl;
@ -8029,7 +8025,7 @@ int slsDetector::setCTBPattern(string fname) {
char retval[MAX_STR_LENGTH]=""; char retval[MAX_STR_LENGTH]="";
// if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){ // if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
// #ifdef VERBOSE // #ifdef VERBOSE
// std::cout << "Sending detector hostname to Receiver " << thisDetector->hostname << std::endl; // std::cout << "Sending detector hostname to Receiver " << thisDetector->hostname << std::endl;
// #endif // #endif

View File

@ -1233,12 +1233,13 @@ string slsDetectorCommand::cmdAcquire(int narg, char *args[], int action) {
myDet->setOnline(ONLINE_FLAG); myDet->setOnline(ONLINE_FLAG);
myDet->setReceiverOnline(ONLINE_FLAG);
if(myDet->acquire() == FAIL) if(myDet->acquire() == FAIL)
return string("acquire unsuccessful"); return string("acquire unsuccessful");
if(myDet->setReceiverOnline()==ONLINE_FLAG){ if(myDet->setReceiverOnline()==ONLINE_FLAG){
char answer[100]; char answer[100];
sprintf(answer,"\n%d",myDet->getFramesCaughtByReceiver()); sprintf(answer,"\nAcquired %d",myDet->getFramesCaughtByReceiver());
return string(answer); return string(answer);
} }
@ -1277,6 +1278,7 @@ string slsDetectorCommand::cmdData(int narg, char *args[], int action) {
b=myDet->setThreadedProcessing(-1); b=myDet->setThreadedProcessing(-1);
myDet->setThreadedProcessing(0); myDet->setThreadedProcessing(0);
myDet->setOnline(ONLINE_FLAG); myDet->setOnline(ONLINE_FLAG);
myDet->setReceiverOnline(ONLINE_FLAG);
myDet->readAll(); myDet->readAll();
//processdata in receiver is useful only for gui purposes //processdata in receiver is useful only for gui purposes
if(myDet->setReceiverOnline()==OFFLINE_FLAG) if(myDet->setReceiverOnline()==OFFLINE_FLAG)
@ -1311,6 +1313,7 @@ string slsDetectorCommand::cmdFrame(int narg, char *args[], int action) {
b=myDet->setThreadedProcessing(-1); b=myDet->setThreadedProcessing(-1);
myDet->setThreadedProcessing(0); myDet->setThreadedProcessing(0);
myDet->setOnline(ONLINE_FLAG); myDet->setOnline(ONLINE_FLAG);
myDet->setReceiverOnline(ONLINE_FLAG);
myDet->readFrame(); myDet->readFrame();
//processdata in receiver is useful only for gui purposes //processdata in receiver is useful only for gui purposes
if(myDet->setReceiverOnline()==OFFLINE_FLAG) if(myDet->setReceiverOnline()==OFFLINE_FLAG)
@ -1719,6 +1722,7 @@ string slsDetectorCommand::cmdExitServer(int narg, char *args[], int action){
return string("Error closing server\n"); return string("Error closing server\n");
} }
else if (cmd=="exitreceiver"){ else if (cmd=="exitreceiver"){
myDet->setReceiverOnline(ONLINE_FLAG);
if(myDet->exitReceiver()!=OK) if(myDet->exitReceiver()!=OK)
return string("Receiver shut down\n"); return string("Receiver shut down\n");
else else
@ -1840,6 +1844,7 @@ string slsDetectorCommand::helpTrimEn(int narg, char *args[], int action) {
string slsDetectorCommand::cmdOutDir(int narg, char *args[], int action){ string slsDetectorCommand::cmdOutDir(int narg, char *args[], int action){
myDet->setReceiverOnline(ONLINE_FLAG);
if (action==HELP_ACTION) if (action==HELP_ACTION)
return helpOutDir(narg, args, action); return helpOutDir(narg, args, action);
@ -1864,6 +1869,7 @@ string slsDetectorCommand::helpOutDir(int narg, char *args[], int action){
string slsDetectorCommand::cmdFileName(int narg, char *args[], int action){ string slsDetectorCommand::cmdFileName(int narg, char *args[], int action){
myDet->setReceiverOnline(ONLINE_FLAG);
if (action==HELP_ACTION) if (action==HELP_ACTION)
return helpFileName(narg, args, action); return helpFileName(narg, args, action);
if (cmd=="fname") { if (cmd=="fname") {
@ -1893,7 +1899,7 @@ string slsDetectorCommand::cmdEnablefwrite(int narg, char *args[], int action){
int i; int i;
char ans[100]; char ans[100];
myDet->setReceiverOnline(ONLINE_FLAG);
if (action==HELP_ACTION) { if (action==HELP_ACTION) {
return helpEnablefwrite(narg, args, action); return helpEnablefwrite(narg, args, action);
} }
@ -1925,7 +1931,7 @@ string slsDetectorCommand::cmdOverwrite(int narg, char *args[], int action){
int i; int i;
char ans[100]; char ans[100];
myDet->setReceiverOnline(ONLINE_FLAG);
if (action==HELP_ACTION) { if (action==HELP_ACTION) {
return helpOverwrite(narg, args, action); return helpOverwrite(narg, args, action);
} }
@ -1957,7 +1963,7 @@ string slsDetectorCommand::helpOverwrite(int narg, char *args[], int action){
string slsDetectorCommand::cmdFileIndex(int narg, char *args[], int action){ string slsDetectorCommand::cmdFileIndex(int narg, char *args[], int action){
char ans[100]; char ans[100];
int i; int i;
myDet->setReceiverOnline(ONLINE_FLAG);
if (action==HELP_ACTION) { if (action==HELP_ACTION) {
return helpFileName(narg, args, action); return helpFileName(narg, args, action);
} }
@ -2070,6 +2076,8 @@ string slsDetectorCommand::cmdRateCorr(int narg, char *args[], int action){
double fval; double fval;
char answer[1000]; char answer[1000];
myDet->setOnline(ONLINE_FLAG);
if (action==PUT_ACTION) { if (action==PUT_ACTION) {
sscanf(args[1],"%lf",&fval); sscanf(args[1],"%lf",&fval);
myDet->setRateCorrection(fval); myDet->setRateCorrection(fval);
@ -2767,6 +2775,7 @@ string slsDetectorCommand::cmdNetworkParameter(int narg, char *args[], int actio
return helpNetworkParameter(narg,args,action); return helpNetworkParameter(narg,args,action);
myDet->setOnline(ONLINE_FLAG); myDet->setOnline(ONLINE_FLAG);
myDet->setReceiverOnline(ONLINE_FLAG);
if (cmd=="detectormac") { if (cmd=="detectormac") {
t=DETECTOR_MAC; t=DETECTOR_MAC;
@ -2936,6 +2945,7 @@ string slsDetectorCommand::cmdLock(int narg, char *args[], int action) {
else if(cmd=="r_lock"){ else if(cmd=="r_lock"){
myDet->setReceiverOnline(ONLINE_FLAG);
if (action==PUT_ACTION) { if (action==PUT_ACTION) {
if (sscanf(args[1],"%d",&val)) if (sscanf(args[1],"%d",&val))
myDet->lockReceiver(val); myDet->lockReceiver(val);
@ -2986,8 +2996,10 @@ string slsDetectorCommand::cmdLastClient(int narg, char *args[], int action) {
return myDet->getLastClientIP(); return myDet->getLastClientIP();
} }
else if(cmd=="r_lastclient") else if(cmd=="r_lastclient"){
myDet->setReceiverOnline(ONLINE_FLAG);
return myDet->getReceiverLastClientIP(); return myDet->getReceiverLastClientIP();
}
return string("cannot decode command"); return string("cannot decode command");
} }
@ -3033,6 +3045,7 @@ string slsDetectorCommand::cmdOnline(int narg, char *args[], int action) {
} }
else if(cmd=="activate"){ else if(cmd=="activate"){
myDet->setOnline(ONLINE_FLAG); myDet->setOnline(ONLINE_FLAG);
myDet->setReceiverOnline(ONLINE_FLAG);
if (action==PUT_ACTION) { if (action==PUT_ACTION) {
if (!sscanf(args[1],"%d",&ival)) if (!sscanf(args[1],"%d",&ival))
return string("Could not scan activate mode ")+string(args[1]); return string("Could not scan activate mode ")+string(args[1]);
@ -3054,11 +3067,12 @@ string slsDetectorCommand::cmdOnline(int narg, char *args[], int action) {
else{ else{
if (action==PUT_ACTION) if (action==PUT_ACTION)
return string("cannot set"); return string("cannot set");
myDet->setReceiverOnline(ONLINE_FLAG);
strcpy(ans,myDet->checkReceiverOnline().c_str()); strcpy(ans,myDet->checkReceiverOnline().c_str());
if(!strlen(ans)) if(!strlen(ans))
strcpy(ans,"All receiver online"); strcpy(ans,"All receiver online");
else else
strcat(ans," :Not receiver online"); strcat(ans," :Not all receiver online");
} }
return ans; return ans;
@ -3095,6 +3109,7 @@ string slsDetectorCommand::cmdConfigureMac(int narg, char *args[], int action) {
if (action==PUT_ACTION){ if (action==PUT_ACTION){
myDet->setOnline(ONLINE_FLAG); myDet->setOnline(ONLINE_FLAG);
myDet->setReceiverOnline(ONLINE_FLAG);
ret=myDet->configureMAC(); ret=myDet->configureMAC();
} }
else else
@ -3165,6 +3180,7 @@ string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int action) {
} else if (cmd=="maxmod") { } else if (cmd=="maxmod") {
ret=myDet->getMaxNumberOfModules(); ret=myDet->getMaxNumberOfModules();
} else if (cmd=="dr") { } else if (cmd=="dr") {
myDet->setReceiverOnline(ONLINE_FLAG);
ret=myDet->setDynamicRange(val); ret=myDet->setDynamicRange(val);
} else if (cmd=="roi") { } else if (cmd=="roi") {
myDet->getROI(ret); myDet->getROI(ret);
@ -3404,6 +3420,7 @@ string slsDetectorCommand::cmdSN(int narg, char *args[], int action) {
} }
if (cmd=="receiverversion") { if (cmd=="receiverversion") {
myDet->setReceiverOnline(ONLINE_FLAG);
sprintf(answer,"%llx",myDet->getId(RECEIVER_VERSION)); sprintf(answer,"%llx",myDet->getId(RECEIVER_VERSION));
return string(answer); return string(answer);
} }
@ -4082,6 +4099,7 @@ string slsDetectorCommand::cmdTimer(int narg, char *args[], int action) {
myDet->setOnline(ONLINE_FLAG); myDet->setOnline(ONLINE_FLAG);
myDet->setReceiverOnline(ONLINE_FLAG);
ret=myDet->setTimer(index,t); ret=myDet->setTimer(index,t);
if (index==ACQUISITION_TIME || index==SUBFRAME_ACQUISITION_TIME || index==FRAME_PERIOD || index==DELAY_AFTER_TRIGGER) if (index==ACQUISITION_TIME || index==SUBFRAME_ACQUISITION_TIME || index==FRAME_PERIOD || index==DELAY_AFTER_TRIGGER)
@ -4509,10 +4527,12 @@ string slsDetectorCommand::cmdConfiguration(int narg, char *args[], int action)
} }
return sval; return sval;
} else if (cmd=="rx_printconfig"){ } else if (cmd=="rx_printconfig"){
myDet->setReceiverOnline(ONLINE_FLAG);
if (action==PUT_ACTION) if (action==PUT_ACTION)
return string("cannot put"); return string("cannot put");
return string(""+myDet->printReceiverConfiguration()); return string(""+myDet->printReceiverConfiguration());
}else if (cmd=="parameters") { }else if (cmd=="parameters") {
myDet->setReceiverOnline(ONLINE_FLAG);
if (action==PUT_ACTION) { if (action==PUT_ACTION) {
sval=string(args[1]); sval=string(args[1]);
myDet->retrieveDetectorSetup(sval); myDet->retrieveDetectorSetup(sval);
@ -4522,6 +4542,7 @@ string slsDetectorCommand::cmdConfiguration(int narg, char *args[], int action)
} }
return sval; return sval;
} else if (cmd=="setup") { } else if (cmd=="setup") {
myDet->setReceiverOnline(ONLINE_FLAG);
if (action==PUT_ACTION) { if (action==PUT_ACTION) {
sval=string(args[1]); sval=string(args[1]);
myDet->retrieveDetectorSetup(sval,2); myDet->retrieveDetectorSetup(sval,2);
@ -4576,6 +4597,7 @@ string slsDetectorCommand::cmdReceiver(int narg, char *args[], int action) {
myDet->setOnline(ONLINE_FLAG); myDet->setOnline(ONLINE_FLAG);
myDet->setReceiverOnline(ONLINE_FLAG);
if(cmd=="receiver"){ if(cmd=="receiver"){
if (action==PUT_ACTION) { if (action==PUT_ACTION) {

View File

@ -286,12 +286,6 @@ int slsDetectorUtils::acquire(int delflag){
//send receiver file name //send receiver file name
pthread_mutex_lock(&mg); pthread_mutex_lock(&mg);
setFileName(fileIO::getFileName()); setFileName(fileIO::getFileName());
if(setReceiverOnline()==OFFLINE_FLAG){
stopReceiver();
*stoppedFlag=1;
pthread_mutex_unlock(&mg);
break;
}
//start receiver //start receiver
if(startReceiver() == FAIL) { if(startReceiver() == FAIL) {
stopReceiver(); stopReceiver();
@ -349,6 +343,12 @@ int slsDetectorUtils::acquire(int delflag){
} }
//online //online
else{ else{
if(setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG){
stopAcquisition();
stopReceiver();
pthread_mutex_unlock(&mg);
break;
}
stopReceiver(); stopReceiver();
// cout<<"***********receiver stopped"<<endl; // cout<<"***********receiver stopped"<<endl;
} }