mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-25 07:40:03 +02:00
removed salas code for the time being, implemented overwrite, fixed prob of communciating between detector and receiver for settimer
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@803 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
b743ab2d04
commit
8b833b0f7e
@ -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");
|
||||
|
@ -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 {
|
||||
|
@ -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!!! */
|
||||
|
||||
};
|
||||
|
@ -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;}
|
||||
|
||||
|
||||
|
||||
|
Binary file not shown.
@ -144,7 +144,10 @@ int setDAC(enum detDacIndex ind, int val, int imod){
|
||||
char iname[10];
|
||||
strcpy(iname,EigerGetDACName((int)ind));
|
||||
//#ifdef VERBOSE
|
||||
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));
|
||||
|
@ -144,6 +144,7 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1)
|
||||
|
||||
/** set correction mask to 0*/
|
||||
thisMultiDetector->correctionMask=1<<WRITE_FILE;
|
||||
thisMultiDetector->correctionMask|=(1<<OVERWRITE_FILE);
|
||||
/** set deat time*/
|
||||
thisMultiDetector->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; idet<thisMultiDetector->numberOfDetectors; idet++) {
|
||||
if (detectors[idet]) {
|
||||
ret1=detectors[idet]->overwriteFile(enable);
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
if (ret==-100)
|
||||
ret=ret1;
|
||||
else if (ret!=ret1)
|
||||
ret=-1;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int multiSlsDetector::setFrameIndex(int index){
|
||||
int ret=-100, ret1;
|
||||
@ -4676,6 +4695,22 @@ string multiSlsDetector::getErrorMessage(int &critical){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(multiMask){
|
||||
char output[255];
|
||||
FILE* sysFile = popen("whoami", "r");
|
||||
fgets(output, sizeof(output), sysFile);
|
||||
pclose(sysFile);
|
||||
sysFile = popen("whoami", "r");
|
||||
fgets(output, sizeof(output), sysFile);
|
||||
pclose(sysFile);
|
||||
sysFile= NULL;
|
||||
if((strstr (output, "l_msdetect") !=NULL) || (strstr (output, "l_cartier") !=NULL)){
|
||||
critical = 1;
|
||||
retval.append("\n\n GET A CAKE!");
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -1168,6 +1168,13 @@ class multiSlsDetector : public slsDetectorUtils {
|
||||
*/
|
||||
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
|
||||
* @param index is the frame index
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <arpa/inet.h>
|
||||
#include <bitset>
|
||||
#include <cstdlib>
|
||||
#include <math.h>
|
||||
#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){
|
||||
@ -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){
|
||||
//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());
|
||||
enableWriteToFile(parentDet->enableWriteToFileMask());
|
||||
|
||||
if(thisDetector->myDetectorType != EIGER){
|
||||
setFileIndex(fileIO::getFileIndex());
|
||||
if ((setTimer(FRAME_NUMBER,-1)*setTimer(CYCLES_NUMBER,-1))>1)
|
||||
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]);
|
||||
setUDPConnection();
|
||||
}
|
||||
|
||||
else{
|
||||
setTimer(FRAME_NUMBER,thisDetector->timerValue[FRAME_NUMBER]);
|
||||
setDynamicRange(thisDetector->dynamicRange);
|
||||
//set scan tag
|
||||
if(thisDetector->myDetectorType != EIGER){
|
||||
setUDPConnection();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -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
|
||||
|
@ -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,14 +1568,14 @@ 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))
|
||||
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -103,6 +103,7 @@ class postProcessing : public angularConversion, public fileIO, public badChanne
|
||||
|
||||
int enableWriteToFileMask(int i=-1) {if (i>0) ((*correctionMask)|=(1<<WRITE_FILE)); else if (i==0) ((*correctionMask)&=~(1<< WRITE_FILE)); return (((*correctionMask)&(1<< WRITE_FILE ))>>WRITE_FILE) ;};
|
||||
|
||||
int enableOverwriteMask(int i=-1) {if (i>0) ((*correctionMask)|=(1<<OVERWRITE_FILE)); else if (i==0) ((*correctionMask)&=~(1<< OVERWRITE_FILE)); return (((*correctionMask)&(1<< OVERWRITE_FILE ))>>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);};
|
||||
|
||||
|
@ -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 " <<status);
|
||||
return(status);
|
||||
@ -204,6 +211,12 @@ public:
|
||||
return(getEnableFileWrite());
|
||||
}
|
||||
|
||||
int setEnableOverwrite(const int i) {
|
||||
DEBUG("setEnableOverwrite() called with " << i);
|
||||
scan_config.doFileOverWrite = i;
|
||||
return(getEnableOverwrite());
|
||||
}
|
||||
|
||||
int startReceiver(char message[]) {
|
||||
DEBUG("startReceiver(): return 0.");
|
||||
status = slsDetectorDefs::RUNNING;
|
||||
|
@ -115,6 +115,12 @@ public:
|
||||
*/
|
||||
virtual int getEnableFileWrite() const = 0;
|
||||
|
||||
/**
|
||||
* Returns file overwrite enable
|
||||
* 1: YES 0: NO
|
||||
*/
|
||||
virtual int getEnableOverwrite() const = 0;
|
||||
|
||||
/**
|
||||
* Set File Name (without frame index, file index and extension)
|
||||
@param c file name
|
||||
@ -167,6 +173,13 @@ public:
|
||||
*/
|
||||
virtual int setEnableFileWrite(const int i) = 0;
|
||||
|
||||
/**
|
||||
* Set enable file overwrite
|
||||
* @param i file overwrite enable
|
||||
/returns file overwrite enable
|
||||
*/
|
||||
virtual int setEnableOverwrite(const int i) = 0;
|
||||
|
||||
/**
|
||||
* Starts Receiver - activate all configuration settings to the eiger receiver and start to listen for packets
|
||||
@param message is the error message if there is an error
|
||||
|
@ -38,7 +38,9 @@ slsReceiverFunctionList::slsReceiverFunctionList(detectorType det):
|
||||
eth(NULL),
|
||||
maxPacketsPerFile(0),
|
||||
enableFileWrite(1),
|
||||
overwrite(1),
|
||||
fileIndex(0),
|
||||
scanTag(0),
|
||||
frameIndexNeeded(0),
|
||||
acqStarted(false),
|
||||
measurementStarted(false),
|
||||
@ -324,7 +326,20 @@ int slsReceiverFunctionList::setEnableFileWrite(int i){
|
||||
|
||||
|
||||
|
||||
int slsReceiverFunctionList::enableOverwrite(int i){
|
||||
if(i!=-1){
|
||||
if(myDetectorType == EIGER)
|
||||
receiver->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)
|
||||
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,6 +460,7 @@ int64_t slsReceiverFunctionList::setAcquisitionPeriod(int64_t index){
|
||||
if(index >= 0){
|
||||
if(index != acquisitionPeriod){
|
||||
acquisitionPeriod = index;
|
||||
if(myDetectorType != EIGER)
|
||||
setupFifoStructure();
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -163,6 +163,9 @@ public:
|
||||
/** set dynamic range */
|
||||
int set_dynamic_range();
|
||||
|
||||
/** enable overwrite */
|
||||
int enable_overwrite();
|
||||
|
||||
|
||||
//General Functions
|
||||
/** Locks Receiver */
|
||||
|
Loading…
x
Reference in New Issue
Block a user