implemented sending hostname to the receiver for eiger

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@764 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d 2014-03-11 10:49:35 +00:00
parent bba0f46b58
commit f854477aae
9 changed files with 136 additions and 12 deletions

View File

@ -30,6 +30,7 @@ using namespace std;
#define COULDNOT_CREATE_UDP_SOCKET 0x0200000000000000ULL #define COULDNOT_CREATE_UDP_SOCKET 0x0200000000000000ULL
#define COULDNOT_CREATE_FILE 0x0100000000000000ULL #define COULDNOT_CREATE_FILE 0x0100000000000000ULL
#define COULDNOT_ENABLE_COMPRESSION 0x0080000000000000ULL #define COULDNOT_ENABLE_COMPRESSION 0x0080000000000000ULL
#define RECEIVER_DET_HOSTNAME_NOT_SET 0x0040000000000000ULL
@ -89,6 +90,10 @@ public:
if(slsErrorMask&COULDNOT_ENABLE_COMPRESSION) 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"); 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");

View File

@ -136,7 +136,9 @@ enum {
F_READ_RECEIVER_FREQUENCY, /**< sets the frequency of receiver sending frames to gui */ 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!!! */ /* Always append functions hereafter!!! */
}; };

View File

@ -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 //send acquisiton period to receiver
if((setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) && ((index==FRAME_PERIOD)||(index==FRAME_NUMBER)) && (ret != FAIL) && (t != -1)){ 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){ if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Setting up receiver with" << endl << std::cout << "Setting up receiver with" << endl <<
"file path:" << fileIO::getFilePath() << endl << "file path:" << fileIO::getFilePath() << endl <<
"file name:" << fileIO::getFileName() << endl << "file name:" << fileIO::getFileName() << endl <<
"write enable:" << parentDet->enableWriteToFileMask() << endl; "write enable:" << parentDet->enableWriteToFileMask() << endl;
if(thisDetector->myDetectorType != EIGER){ if(thisDetector->myDetectorType != EIGER){
std::cout << "file index:" << fileIO::getFileIndex() << endl << std::cout << "file index:" << fileIO::getFileIndex() << endl <<
"frame index needed:" << ((setTimer(FRAME_NUMBER,-1)*setTimer(CYCLES_NUMBER,-1))>1) << endl << "frame index needed:" << ((setTimer(FRAME_NUMBER,-1)*setTimer(CYCLES_NUMBER,-1))>1) << endl <<
"frame period:" << setTimer(FRAME_PERIOD,-1) << endl; "frame period:" << setTimer(FRAME_PERIOD,-1) << endl;
} }
std::cout << endl; std::cout << endl;
#endif #endif
if(thisDetector->myDetectorType == EIGER)
setDetectorHostname();
setFilePath(fileIO::getFilePath()); setFilePath(fileIO::getFilePath());
setFileName(fileIO::getFileName()); setFileName(fileIO::getFileName());
enableWriteToFile(parentDet->enableWriteToFileMask()); enableWriteToFile(parentDet->enableWriteToFileMask());
@ -6532,3 +6534,21 @@ int slsDetector::enableReceiverCompression(int i){
return retval; 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));
}
}

View File

@ -1615,6 +1615,10 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
*/ */
int enableReceiverCompression(int i = -1); int enableReceiverCompression(int i = -1);
/** send the detector host name to the eiger receiver
* for various handshaking required with the detector
*/
void setDetectorHostname();
protected: protected:

View File

@ -35,6 +35,12 @@ public:
*/ */
runStatus getStatus(); runStatus getStatus();
/**
* Returns detector hostname
/returns hostname
*/
char* getDetectorHostname();
/** /**
* Returns File Name * Returns File Name
*/ */
@ -65,6 +71,13 @@ public:
*/ */
int getEnableFileWrite(); int getEnableFileWrite();
/**
* Set detector hostname
@param c hostname
/returns hostname
*/
char* setDetectorHostname(char c[]);
/** /**
* Set File Name (without frame index, file index and extension) * Set File Name (without frame index, file index and extension)
@param c file name @param c file name

View File

@ -239,9 +239,18 @@ int32_t slsReceiverFunctionList::setDynamicRange(int32_t dr){
return eigerRxr->getDynamicRange(); return eigerRxr->getDynamicRange();
} }
char* slsReceiverFunctionList::setDetectorHostname(char c[]){
if(strlen(c))
eigerRxr->setDetectorHostname(c);
return eigerRxr->getDetectorHostname();
}
#endif #endif
char* slsReceiverFunctionList::setFileName(char c[]){ char* slsReceiverFunctionList::setFileName(char c[]){
if(strlen(c)){ if(strlen(c)){
#ifdef EIGER_RECEIVER_H #ifdef EIGER_RECEIVER_H

View File

@ -128,6 +128,12 @@ public:
*/ */
bool getMeasurementStarted(){return measurementStarted;}; bool getMeasurementStarted(){return measurementStarted;};
/**
* Set detector hostname
* @param c hostname
*/
char* setDetectorHostname(char c[]);
/** /**
* Set File Name (without frame index, file index and extension) * Set File Name (without frame index, file index and extension)
* @param c file name * @param c file name

View File

@ -318,6 +318,8 @@ int slsReceiverFuncs::function_table(){
flist[F_START_READOUT] = &slsReceiverFuncs::start_readout; flist[F_START_READOUT] = &slsReceiverFuncs::start_readout;
flist[F_SET_TIMER] = &slsReceiverFuncs::set_timer; flist[F_SET_TIMER] = &slsReceiverFuncs::set_timer;
flist[F_ENABLE_COMPRESSION] = &slsReceiverFuncs::enable_compression; flist[F_ENABLE_COMPRESSION] = &slsReceiverFuncs::enable_compression;
flist[F_SET_DETECTOR_HOSTNAME] = &slsReceiverFuncs::set_detector_hostname;
//General Functions //General Functions
flist[F_LOCK_SERVER] = &slsReceiverFuncs::lock_receiver; 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;
}

View File

@ -157,6 +157,11 @@ public:
/** enable compression */ /** enable compression */
int enable_compression(); int enable_compression();
/** set detector hostname for eiger */
int set_detector_hostname();
//General Functions //General Functions
/** Locks Receiver */ /** Locks Receiver */