diff --git a/slsDetectorSoftware/commonFiles/error_defs.h b/slsDetectorSoftware/commonFiles/error_defs.h index 3703be979..b0696901c 100644 --- a/slsDetectorSoftware/commonFiles/error_defs.h +++ b/slsDetectorSoftware/commonFiles/error_defs.h @@ -86,7 +86,7 @@ public: retval.append("Could not create UDP socket to start receiver\n"); if(slsErrorMask&COULDNOT_CREATE_FILE) - retval.append("Could not create file to start receiver.\nCheck permissions of output directory\n"); + retval.append("Could not create file to start receiver.\nCheck permissions of output directory or the overwrite flag\n"); 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"); diff --git a/slsDetectorSoftware/commonFiles/sls_detector_defs.h b/slsDetectorSoftware/commonFiles/sls_detector_defs.h index a182a381c..dd979f220 100755 --- a/slsDetectorSoftware/commonFiles/sls_detector_defs.h +++ b/slsDetectorSoftware/commonFiles/sls_detector_defs.h @@ -494,8 +494,9 @@ enum correctionFlags { FLAT_FIELD_CORRECTION, /**< data are flat field corrected */ RATE_CORRECTION, /**< data are rate corrected */ ANGULAR_CONVERSION,/**< angular conversion is calculated */ - WRITE_FILE, - I0_NORMALIZATION + WRITE_FILE, /**< file write enable */ + I0_NORMALIZATION, + OVERWRITE_FILE /**< file over write enable */ }; /** port type */ enum portType { diff --git a/slsDetectorSoftware/commonFiles/sls_detector_funcs.h b/slsDetectorSoftware/commonFiles/sls_detector_funcs.h index 8801c9103..23ae01d29 100644 --- a/slsDetectorSoftware/commonFiles/sls_detector_funcs.h +++ b/slsDetectorSoftware/commonFiles/sls_detector_funcs.h @@ -138,7 +138,9 @@ enum { F_ENABLE_COMPRESSION, /**< enable compression in receiver */ - F_SET_DETECTOR_HOSTNAME /**< set detector hostname in receiver */ + F_SET_DETECTOR_HOSTNAME, /**< set detector hostname in receiver */ + + F_ENABLE_OVERWRITE /**< set overwrite flag in receiver */ /* Always append functions hereafter!!! */ }; diff --git a/slsDetectorSoftware/eigerDetectorServer/EigerHighLevelFunctions.c b/slsDetectorSoftware/eigerDetectorServer/EigerHighLevelFunctions.c index 0584e6266..9393ab611 100644 --- a/slsDetectorSoftware/eigerDetectorServer/EigerHighLevelFunctions.c +++ b/slsDetectorSoftware/eigerDetectorServer/EigerHighLevelFunctions.c @@ -35,8 +35,8 @@ unsigned int eigergetphotonenergy = 8000; unsigned int EigerGetPhotonEnergy(){return eigergetphotonenergy;} /* for later */ int eigernumberofexposureseries = 1; -unsigned int EigerGetNumberOfExposureSeries(){return eigernumberofexposureseries;} -int EigerSetNumberOfExposureSeries(unsigned int i){eigernumberofexposureseries = i;} +int EigerGetNumberOfExposureSeries(){return eigernumberofexposureseries;} +int EigerSetNumberOfExposureSeries(int i){eigernumberofexposureseries = i;return 1;} diff --git a/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer b/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer index 813dbe43f..a7fc22c8d 100755 Binary files a/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer and b/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer differ diff --git a/slsDetectorSoftware/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorSoftware/eigerDetectorServer/slsDetectorFunctionList.c index 45ad8ffee..9aaaa50f8 100644 --- a/slsDetectorSoftware/eigerDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorSoftware/eigerDetectorServer/slsDetectorFunctionList.c @@ -144,7 +144,10 @@ int setDAC(enum detDacIndex ind, int val, int imod){ char iname[10]; strcpy(iname,EigerGetDACName((int)ind)); //#ifdef VERBOSE - printf("Setting dac %d: %s to %d mV\n",ind, iname,val); + if(val >= 0) + printf("Setting dac %d: %s to %d mV\n",ind, iname,val); + else + printf("Getting dac %d: %s\n",ind, iname); //#endif if(val >= 0) EigerSetDAC(iname,val/1000); @@ -267,7 +270,7 @@ int64_t setTimer(enum timerIndex ind, int64_t val){ if(val >= 0){ printf(" Setting exp time: %fs\n",val/(1E9)); EigerSetExposureTime(val/(1E9)); - }return EigerGetExposureTime(); + }return (EigerGetExposureTime()*(1E9)); case FRAME_PERIOD: if(val >= 0){ printf(" Setting acq period: %fs\n",val/(1E9)); diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 5b52c58c9..0a3713926 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -144,6 +144,7 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1) /** set correction mask to 0*/ thisMultiDetector->correctionMask=1<correctionMask|=(1<tDead=0; /** sets bad channel list file to none */ @@ -4620,6 +4621,24 @@ int multiSlsDetector::enableWriteToFile(int enable){ +int multiSlsDetector::overwriteFile(int enable){ + int ret=-100, ret1; + + for (int idet=0; idetnumberOfDetectors; idet++) { + if (detectors[idet]) { + ret1=detectors[idet]->overwriteFile(enable); + if(detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask()|(1< #include #include +#include #include "svnInfoLib.h" @@ -3482,7 +3483,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){ #ifdef VERBOSE - std::cout<< "Setting timer "<< index << " to " << t << "ns" << std::endl; + std::cout<< "Setting timer "<< index << " to " << t << "ns/value" << std::endl; #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { if (connectControl() == OK){ @@ -3496,7 +3497,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){ setErrorMask((getErrorMask())|(DETECTOR_TIMER_VALUE_NOT_SET)); } else { controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - thisDetector->timerValue[index]=retval; + thisDetector->timerValue[index]=retval; } controlSocket->Disconnect(); if (ret==FORCE_UPDATE) { @@ -3534,7 +3535,6 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){ - //send acquisiton period/frame number to receiver if((index==FRAME_NUMBER)||(index==FRAME_PERIOD)) { @@ -3545,14 +3545,16 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){ if(t == -1) args[1] = -1; + if(index==FRAME_NUMBER){ #ifdef VERBOSE - std::cout << "Sending/Getting number of frames to/from receiver " << retval << std::endl; + + std::cout << "Setting/Getting number of frames " << index <<" to/from receiver " << args[1] << std::endl; #endif args[0] = FRAME_NUMBER; }else{ #ifdef VERBOSE - std::cout << "Sending/Getting acquisition period to/from receiver " << retval << std::endl; + std::cout << "Setting/Getting acquisition period " << index << " to/from receiver " << args[1] << std::endl; #endif args[0] = FRAME_PERIOD; //if acquisition period is zero, then #frames/buffer depends on exposure time and not acq period @@ -3560,22 +3562,26 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){ args[1] = timerValue[ACQUISITION_TIME]; } + if (connectData() == OK) ret=thisReceiver->sendIntArray(fnum,ut,args); if((ut != retval)|| (ret==FAIL)){ ret = FAIL; if(index==FRAME_PERIOD){ - cout << "ERROR:Acquisition Period in receiver set incorrectly to " << ut << " instead of " << retval << endl; - setErrorMask((getErrorMask())|(RECEIVER_ACQ_PERIOD_NOT_SET)); + //exptime sent if acq period = 0 + if(retval){ + cout << "ERROR:Acquisition Period in receiver set incorrectly to " << ut << " instead of " << retval << endl; + setErrorMask((getErrorMask())|(RECEIVER_ACQ_PERIOD_NOT_SET)); + } }else{ cout << "ERROR:Number of Frames in receiver set incorrectly to " << ut << " instead of " << retval << endl; setErrorMask((getErrorMask())|(RECEIVER_FRAME_NUM_NOT_SET)); } } + if(ret==FORCE_UPDATE) updateReceiver(); } - } } return thisDetector->timerValue[index]; @@ -4873,39 +4879,38 @@ 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(); - 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) ; - } - std::cout << endl; + std::cout << "Setting up receiver with" << endl; + std::cout << "file path:" << fileIO::getFilePath() << endl; + std::cout << "file name:" << fileIO::getFileName() << endl; + std::cout << "file index:" << fileIO::getFileIndex() << endl; + std::cout << "write enable:" << parentDet->enableWriteToFileMask() << endl; + std::cout << "overwrite enable:" << parentDet->enableOverwriteMask() << endl; + std::cout << "frame index needed:" << ((thisDetector->timerValue[FRAME_NUMBER]*thisDetector->timerValue[CYCLES_NUMBER])>1) << endl; + std::cout << "frame period:" << thisDetector->timerValue[FRAME_PERIOD] << endl; + std::cout << "frame number:" << thisDetector->timerValue[FRAME_NUMBER] << endl; + std::cout << "dynamic range:" << thisDetector->dynamicRange << endl << endl; + #endif if(thisDetector->myDetectorType == EIGER) setDetectorHostname(); setFilePath(fileIO::getFilePath()); setFileName(fileIO::getFileName()); + setFileIndex(fileIO::getFileIndex()); enableWriteToFile(parentDet->enableWriteToFileMask()); + overwriteFile(parentDet->enableOverwriteMask()); + if ((thisDetector->timerValue[FRAME_NUMBER]*thisDetector->timerValue[CYCLES_NUMBER])>1) + setFrameIndex(0); + else + setFrameIndex(-1); + + setTimer(FRAME_PERIOD,thisDetector->timerValue[FRAME_PERIOD]); + setTimer(FRAME_NUMBER,thisDetector->timerValue[FRAME_NUMBER]); + setDynamicRange(thisDetector->dynamicRange); + //set scan tag if(thisDetector->myDetectorType != EIGER){ - setFileIndex(fileIO::getFileIndex()); - if ((setTimer(FRAME_NUMBER,-1)*setTimer(CYCLES_NUMBER,-1))>1) - setFrameIndex(0); - else - setFrameIndex(-1); - - setTimer(FRAME_PERIOD,thisDetector->timerValue[FRAME_PERIOD]); setUDPConnection(); } - - else{ - setTimer(FRAME_NUMBER,thisDetector->timerValue[FRAME_NUMBER]); - setDynamicRange(thisDetector->dynamicRange); - } - } return thisDetector->receiver_hostname; @@ -6448,6 +6453,35 @@ int slsDetector::enableWriteToFile(int enable){ +int slsDetector::overwriteFile(int enable){ + int fnum=F_ENABLE_OVERWRITE; + int ret = FAIL; + int retval=-1; + int arg = enable; + + + if(thisDetector->receiverOnlineFlag==OFFLINE_FLAG){ + if(enable>=0) + parentDet->enableOverwriteMask(enable); + } + + else if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){ +#ifdef VERBOSE + std::cout << "Sending enable file write to receiver " << arg << std::endl; +#endif + if (connectData() == OK) + ret=thisReceiver->sendInt(fnum,retval,arg); + if(ret!=FAIL) + parentDet->enableOverwriteMask(retval); + if(ret==FORCE_UPDATE) + updateReceiver(); + } + + return parentDet->enableOverwriteMask(); +} + + + int slsDetector::setFrameIndex(int index){ int fnum=F_SET_FRAME_INDEX; diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index 4abfd391e..e707d7825 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -1549,6 +1549,13 @@ class slsDetector : public slsDetectorUtils, public energyConversion { */ int enableWriteToFile(int enable=-1); + /** + Sets/Gets file overwrite enable + @param enable 1 or 0 to set/reset file overwrite enable + /returns file overwrite enable + */ + int overwriteFile(int enable=-1); + /** * set frame index to 0 or -1 diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index 3e4393720..e3f2b42f5 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -208,6 +208,9 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdEnablefwrite; i++; + descrToFuncMap[i].m_pFuncName="overwrite"; // + descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdOverwrite; + i++; descrToFuncMap[i].m_pFuncName="currentfname"; //OK descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdFileName; @@ -1565,15 +1568,15 @@ string slsDetectorCommand::helpFileName(int narg, char *args[], int action){ } -//enable file write + string slsDetectorCommand::cmdEnablefwrite(int narg, char *args[], int action){ int i; char ans[100]; if (action==HELP_ACTION) { - return helpFileName(narg, args, action); - } + return helpEnablefwrite(narg, args, action); + } if (action==PUT_ACTION) { if (sscanf(args[1],"%d",&i)) myDet->enableWriteToFile(i); @@ -1597,6 +1600,40 @@ string slsDetectorCommand::helpEnablefwrite(int narg, char *args[], int action){ return os.str(); } + +string slsDetectorCommand::cmdOverwrite(int narg, char *args[], int action){ + + int i; + char ans[100]; + + if (action==HELP_ACTION) { + return helpOverwrite(narg, args, action); + } + if (action==PUT_ACTION) { + if (sscanf(args[1],"%d",&i)) + myDet->overwriteFile(i); + else + return string("could not decode overwrite"); + + + } + sprintf(ans,"%d",myDet->overwriteFile()); + return string(ans); +} + + + +string slsDetectorCommand::helpOverwrite(int narg, char *args[], int action){ + ostringstream os; + if (action==GET_ACTION || action==HELP_ACTION) + os << string("When Enabled overwrites files\n"); + if (action==PUT_ACTION || action==HELP_ACTION) + os << string(" i \t should be 1 or 0 or -1\n"); + return os.str(); +} + + + string slsDetectorCommand::cmdFileIndex(int narg, char *args[], int action){ char ans[100]; int i; @@ -3304,7 +3341,7 @@ string slsDetectorCommand::helpDAC(int narg, char *args[], int action) { ostringstream os; if (action==PUT_ACTION || action==HELP_ACTION) { - os << "vthreshold dacu\t sets the detector threshold in dac units (0-1024). The energy is approx 800-15*keV" << std::endl; + os << "vthreshold dacu\t sets the detector threshold in dac units (0-1024) or mV. The energy is approx 800-15*keV" << std::endl; os << std::endl; os << "vcalibration " << "dacu\t sets the calibration pulse amplitude in dac units (0-1024)." << std::endl; diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.h b/slsDetectorSoftware/slsDetector/slsDetectorCommand.h index 54d994350..f6a791eab 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.h @@ -82,6 +82,7 @@ class slsDetectorCommand : public virtual slsDetectorDefs { static string helpCounter(int narg, char *args[], int action); static string helpADC(int narg, char *args[], int action); static string helpEnablefwrite(int narg, char *args[], int action); + static string helpOverwrite(int narg, char *args[], int action); static string helpReceiver(int narg, char *args[], int action); @@ -152,6 +153,7 @@ class slsDetectorCommand : public virtual slsDetectorDefs { string cmdCounter(int narg, char *args[], int action); string cmdADC(int narg, char *args[], int action); string cmdEnablefwrite(int narg, char *args[], int action); + string cmdOverwrite(int narg, char *args[], int action); string cmdReceiver(int narg, char *args[], int action); diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h index ea8afd5b0..49b176cf3 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h @@ -643,6 +643,14 @@ virtual int* readFrameFromReceiver(char* fName, int &fIndex)=0; */ virtual int exitReceiver()=0; +/** + Sets/Gets file overwrite enable + @param enable 1 or 0 to set/reset file overwrite enable + /returns file overwrite enable +*/ +virtual int overwriteFile(int enable=-1)=0; + + /** Sets/Gets receiver file write enable @param enable 1 or 0 to set/reset file write enable @@ -650,7 +658,6 @@ virtual int exitReceiver()=0; */ virtual int enableWriteToFile(int enable=-1)=0; - /** Starts acquisition, calibrates pedestal and writes to fpga /returns number of frames */ diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.h b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.h index 7de4eb7b7..1e70fbd5d 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.h +++ b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.h @@ -103,6 +103,7 @@ class postProcessing : public angularConversion, public fileIO, public badChanne int enableWriteToFileMask(int i=-1) {if (i>0) ((*correctionMask)|=(1<>WRITE_FILE) ;}; + int enableOverwriteMask(int i=-1) {if (i>0) ((*correctionMask)|=(1<>OVERWRITE_FILE) ;}; int setAngularCorrectionMask(int i=-1){if (i==0) (*correctionMask)&=~(1<< ANGULAR_CONVERSION); if (i>0) (*correctionMask)|=(1<< ANGULAR_CONVERSION); return (((*correctionMask)&(1<< ANGULAR_CONVERSION))>>ANGULAR_CONVERSION);}; diff --git a/slsDetectorSoftware/slsReceiver/eigerReceiver.cpp b/slsDetectorSoftware/slsReceiver/eigerReceiver.cpp index c30915292..f10245223 100644 --- a/slsDetectorSoftware/slsReceiver/eigerReceiver.cpp +++ b/slsDetectorSoftware/slsReceiver/eigerReceiver.cpp @@ -36,12 +36,14 @@ struct EigerReceiverScanConfiguration { int scanTag; int numberOfFrames; bool doFileWrite; + bool doFileOverWrite; EigerReceiverScanConfiguration(): dynamicRange(-1), scanTag(-1), numberOfFrames(-1), - doFileWrite(false) {}; + doFileWrite(false), + doFileOverWrite(false){}; }; class EigerReceiverImplementation: public EigerReceiver { @@ -163,6 +165,11 @@ public: return(scan_config.doFileWrite); } + int getEnableOverwrite() const { + DEBUG("getEnableOverwrite() returns " << scan_config.doFileOverWrite); + return(scan_config.doFileOverWrite); + } + slsDetectorDefs::runStatus getStatus() const { DEBUG("getStatus(): return " <setEnableOverwrite(i); + else + overwrite=i; + } + if(myDetectorType == EIGER) + return receiver->getEnableOverwrite(); + else + return overwrite; + +} @@ -373,9 +388,17 @@ int32_t slsReceiverFunctionList::setNumberOfFrames(int32_t fnum){ } int32_t slsReceiverFunctionList::setScanTag(int32_t stag){ - if(stag >= 0) - receiver->setScanTag(stag); - return receiver->getScanTag(); + if(stag >= 0){ + if(myDetectorType == EIGER) + receiver->setScanTag(stag); + else + scanTag = stag; + } + + if(myDetectorType == EIGER) + return receiver->getScanTag(); + else + return scanTag; } int32_t slsReceiverFunctionList::setDynamicRange(int32_t dr){ @@ -437,7 +460,8 @@ int64_t slsReceiverFunctionList::setAcquisitionPeriod(int64_t index){ if(index >= 0){ if(index != acquisitionPeriod){ acquisitionPeriod = index; - setupFifoStructure(); + if(myDetectorType != EIGER) + setupFifoStructure(); } } return acquisitionPeriod; @@ -982,7 +1006,12 @@ int slsReceiverFunctionList::createNewFile(){ sfilefd = NULL; } //open file - if (NULL == (sfilefd = fopen((const char *) (savefilename), "w"))){ + if(!overwrite){ + if (NULL == (sfilefd = fopen((const char *) (savefilename), "wx"))){ + cout << "Error: Could not create new file " << savefilename << endl; + return FAIL; + } + }else if (NULL == (sfilefd = fopen((const char *) (savefilename), "w"))){ cout << "Error: Could not create file " << savefilename << endl; return FAIL; } diff --git a/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.h b/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.h index 810d115b1..96826cf27 100644 --- a/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.h +++ b/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.h @@ -141,8 +141,12 @@ public: */ int setEnableFileWrite(int i); - - + /** + * Enable/disable overwrite + * @param i enable + * Returns enable over write + */ + int enableOverwrite(int i); @@ -377,6 +381,9 @@ private: /** File write enable */ int enableFileWrite; + /** File over write enable */ + int overwrite; + /** Complete File name */ char savefilename[MAX_STR_LENGTH]; @@ -389,6 +396,9 @@ private: /** File Index */ int fileIndex; + /** scan tag */ + int scanTag; + /** if frame index required in file name */ int frameIndexNeeded; diff --git a/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.cpp b/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.cpp index 3400c22c5..730e88906 100644 --- a/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.cpp +++ b/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.cpp @@ -321,6 +321,9 @@ int slsReceiverFuncs::function_table(){ flist[F_ENABLE_COMPRESSION] = &slsReceiverFuncs::enable_compression; flist[F_SET_DETECTOR_HOSTNAME] = &slsReceiverFuncs::set_detector_hostname; flist[F_SET_DYNAMIC_RANGE] = &slsReceiverFuncs::set_dynamic_range; + flist[F_ENABLE_OVERWRITE] = &slsReceiverFuncs::enable_overwrite; + + //General Functions flist[F_LOCK_SERVER] = &slsReceiverFuncs::lock_receiver; @@ -1657,6 +1660,61 @@ int slsReceiverFuncs::set_dynamic_range() { +int slsReceiverFuncs::enable_overwrite() { + ret=OK; + int retval=-1; + int index; + strcpy(mess,"Could not enable/disable overwrite\n"); + + + // receive arguments + if(socket->ReceiveDataOnly(&index,sizeof(index)) < 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; + } + else + retval=slsReceiverList->enableOverwrite(index); + } +#ifdef VERBOSE + if(ret!=FAIL) + cout << "overwrite:" << 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,sizeof(retval)); + + //return ok/fail + return ret; +} + + + + + + + + + + diff --git a/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.h b/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.h index 9b52dfbf4..5f68e5054 100644 --- a/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.h +++ b/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.h @@ -163,6 +163,9 @@ public: /** set dynamic range */ int set_dynamic_range(); + /** enable overwrite */ + int enable_overwrite(); + //General Functions /** Locks Receiver */