diff --git a/slsDetectorSoftware/commonFiles/error_defs.h b/slsDetectorSoftware/commonFiles/error_defs.h index f8e6147db..cb7632a0d 100644 --- a/slsDetectorSoftware/commonFiles/error_defs.h +++ b/slsDetectorSoftware/commonFiles/error_defs.h @@ -30,6 +30,7 @@ using namespace std; #define COULDNOT_CREATE_UDP_SOCKET 0x0200000000000000ULL #define COULDNOT_CREATE_FILE 0x0100000000000000ULL #define COULDNOT_ENABLE_COMPRESSION 0x0080000000000000ULL +#define RECEIVER_DET_HOSTNAME_NOT_SET 0x0040000000000000ULL @@ -89,6 +90,10 @@ public: if(slsErrorMask&COULDNOT_ENABLE_COMPRESSION) retval.append("Could not enable/disable data compression in receiver.\nThread creation failed or recompile code with MYROOT1 flag.\n"); + if(slsErrorMask&RECEIVER_DET_HOSTNAME_NOT_SET) + retval.append("Could not send the detector hostname to the receiver.\n"); + + diff --git a/slsDetectorSoftware/commonFiles/sls_detector_funcs.h b/slsDetectorSoftware/commonFiles/sls_detector_funcs.h index 9eabed1cb..8801c9103 100644 --- a/slsDetectorSoftware/commonFiles/sls_detector_funcs.h +++ b/slsDetectorSoftware/commonFiles/sls_detector_funcs.h @@ -136,7 +136,9 @@ enum { F_READ_RECEIVER_FREQUENCY, /**< sets the frequency of receiver sending frames to gui */ - F_ENABLE_COMPRESSION /**< enable compression in receiver */ + F_ENABLE_COMPRESSION, /**< enable compression in receiver */ + + F_SET_DETECTOR_HOSTNAME /**< set detector hostname in receiver */ /* Always append functions hereafter!!! */ }; diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index f88055914..4142105f7 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -3534,7 +3534,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){ - if((ret != FAIL) && (t! = -1)){ + if((ret != FAIL) && (t != -1)){ //send acquisiton period to receiver if((setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) && ((index==FRAME_PERIOD)||(index==FRAME_NUMBER)) && (ret != FAIL) && (t != -1)){ @@ -4849,17 +4849,19 @@ char* slsDetector::setReceiver(string receiverIP){ if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){ #ifdef VERBOSE - std::cout << "Setting up receiver with" << endl << - "file path:" << fileIO::getFilePath() << endl << - "file name:" << fileIO::getFileName() << endl << - "write enable:" << parentDet->enableWriteToFileMask() << endl; - if(thisDetector->myDetectorType != EIGER){ - std::cout << "file index:" << fileIO::getFileIndex() << endl << - "frame index needed:" << ((setTimer(FRAME_NUMBER,-1)*setTimer(CYCLES_NUMBER,-1))>1) << endl << - "frame period:" << setTimer(FRAME_PERIOD,-1) << endl; - } - std::cout << endl; + std::cout << "Setting up receiver with" << endl << + "file path:" << fileIO::getFilePath() << endl << + "file name:" << fileIO::getFileName() << endl << + "write enable:" << parentDet->enableWriteToFileMask() << endl; + if(thisDetector->myDetectorType != EIGER){ + std::cout << "file index:" << fileIO::getFileIndex() << endl << + "frame index needed:" << ((setTimer(FRAME_NUMBER,-1)*setTimer(CYCLES_NUMBER,-1))>1) << endl << + "frame period:" << setTimer(FRAME_PERIOD,-1) << endl; + } + std::cout << endl; #endif + if(thisDetector->myDetectorType == EIGER) + setDetectorHostname(); setFilePath(fileIO::getFilePath()); setFileName(fileIO::getFileName()); enableWriteToFile(parentDet->enableWriteToFileMask()); @@ -6532,3 +6534,21 @@ int slsDetector::enableReceiverCompression(int i){ return retval; } + + +void slsDetector::setDetectorHostname(){ + int fnum=F_SET_DETECTOR_HOSTNAME; + int ret = FAIL; + char retval[MAX_STR_LENGTH]=""; + + + if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){ +#ifdef VERBOSE + std::cout << "Sending detector hostname to Receiver " << thisDetector->hostname << std::endl; +#endif + if (connectData() == OK) + ret=thisReceiver->sendString(fnum,retval,thisDetector->hostname); + if((ret==FAIL) || (strcmp(retval,thisDetector->hostname))) + setErrorMask((getErrorMask())|(RECEIVER_DET_HOSTNAME_NOT_SET)); + } +} diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index fdfa0f70b..4abfd391e 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -1615,6 +1615,10 @@ class slsDetector : public slsDetectorUtils, public energyConversion { */ int enableReceiverCompression(int i = -1); + /** send the detector host name to the eiger receiver + * for various handshaking required with the detector + */ + void setDetectorHostname(); protected: diff --git a/slsDetectorSoftware/slsReceiver/eigerReceiver.h b/slsDetectorSoftware/slsReceiver/eigerReceiver.h index ceaf43f3e..e3989a2f9 100644 --- a/slsDetectorSoftware/slsReceiver/eigerReceiver.h +++ b/slsDetectorSoftware/slsReceiver/eigerReceiver.h @@ -35,6 +35,12 @@ public: */ runStatus getStatus(); + /** + * Returns detector hostname + /returns hostname + */ + char* getDetectorHostname(); + /** * Returns File Name */ @@ -65,6 +71,13 @@ public: */ int getEnableFileWrite(); + /** + * Set detector hostname + @param c hostname + /returns hostname + */ + char* setDetectorHostname(char c[]); + /** * Set File Name (without frame index, file index and extension) @param c file name diff --git a/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.cpp b/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.cpp index 1c7de5a2c..5495b3d2c 100644 --- a/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.cpp +++ b/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.cpp @@ -239,9 +239,18 @@ int32_t slsReceiverFunctionList::setDynamicRange(int32_t dr){ return eigerRxr->getDynamicRange(); } + +char* slsReceiverFunctionList::setDetectorHostname(char c[]){ + if(strlen(c)) + eigerRxr->setDetectorHostname(c); + return eigerRxr->getDetectorHostname(); +} + + #endif + char* slsReceiverFunctionList::setFileName(char c[]){ if(strlen(c)){ #ifdef EIGER_RECEIVER_H diff --git a/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.h b/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.h index ae6957134..1857cf19a 100644 --- a/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.h +++ b/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.h @@ -128,6 +128,12 @@ public: */ bool getMeasurementStarted(){return measurementStarted;}; + /** + * Set detector hostname + * @param c hostname + */ + char* setDetectorHostname(char c[]); + /** * Set File Name (without frame index, file index and extension) * @param c file name diff --git a/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.cpp b/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.cpp index eade92aaf..69157d472 100644 --- a/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.cpp +++ b/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.cpp @@ -318,6 +318,8 @@ int slsReceiverFuncs::function_table(){ flist[F_START_READOUT] = &slsReceiverFuncs::start_readout; flist[F_SET_TIMER] = &slsReceiverFuncs::set_timer; flist[F_ENABLE_COMPRESSION] = &slsReceiverFuncs::enable_compression; + flist[F_SET_DETECTOR_HOSTNAME] = &slsReceiverFuncs::set_detector_hostname; + //General Functions flist[F_LOCK_SERVER] = &slsReceiverFuncs::lock_receiver; @@ -1541,6 +1543,64 @@ int slsReceiverFuncs::enable_compression() { +int slsReceiverFuncs::set_detector_hostname() { + ret=OK; + char retval[MAX_STR_LENGTH]=""; + char hostname[MAX_STR_LENGTH]=""; + strcpy(mess,"Could not set detector hostname"); + + // receive arguments + if(socket->ReceiveDataOnly(hostname,MAX_STR_LENGTH) < 0 ){ + strcpy(mess,"Error reading from socket\n"); + ret = FAIL; + } + + // execute action if the arguments correctly arrived +#ifdef SLS_RECEIVER_FUNCTION_LIST + if (ret==OK) { + + if (lockStatus==1 && socket->differentClients==1){ + sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP); + ret=FAIL; + } +#ifdef EIGER_RECEIVER_H + else + strcpy(retval,slsReceiverList->setDetectorHostname(hostname)); +#endif + + } +#ifdef VERBOSE + if(ret!=FAIL) + cout << "hostname:" << retval << endl; + else + cout << mess << endl; +#endif +#endif + + if(ret==OK && socket->differentClients){ + cout << "Force update" << endl; + ret=FORCE_UPDATE; + } + + // send answer + socket->SendDataOnly(&ret,sizeof(ret)); + if(ret==FAIL) + socket->SendDataOnly(mess,sizeof(mess)); + socket->SendDataOnly(retval,MAX_STR_LENGTH); + + //return ok/fail + return ret; +} + + + + + + + + + + diff --git a/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.h b/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.h index 43b6682e1..5d495efe4 100644 --- a/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.h +++ b/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.h @@ -157,6 +157,11 @@ public: /** enable compression */ int enable_compression(); + /** set detector hostname for eiger */ + int set_detector_hostname(); + + + //General Functions /** Locks Receiver */