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