mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 21:07:13 +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:
@ -86,7 +86,7 @@ public:
|
|||||||
retval.append("Could not create UDP socket to start receiver\n");
|
retval.append("Could not create UDP socket to start receiver\n");
|
||||||
|
|
||||||
if(slsErrorMask&COULDNOT_CREATE_FILE)
|
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)
|
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");
|
||||||
|
@ -494,8 +494,9 @@ enum correctionFlags {
|
|||||||
FLAT_FIELD_CORRECTION, /**< data are flat field corrected */
|
FLAT_FIELD_CORRECTION, /**< data are flat field corrected */
|
||||||
RATE_CORRECTION, /**< data are rate corrected */
|
RATE_CORRECTION, /**< data are rate corrected */
|
||||||
ANGULAR_CONVERSION,/**< angular conversion is calculated */
|
ANGULAR_CONVERSION,/**< angular conversion is calculated */
|
||||||
WRITE_FILE,
|
WRITE_FILE, /**< file write enable */
|
||||||
I0_NORMALIZATION
|
I0_NORMALIZATION,
|
||||||
|
OVERWRITE_FILE /**< file over write enable */
|
||||||
};
|
};
|
||||||
/** port type */
|
/** port type */
|
||||||
enum portType {
|
enum portType {
|
||||||
|
@ -138,7 +138,9 @@ enum {
|
|||||||
|
|
||||||
F_ENABLE_COMPRESSION, /**< enable compression in receiver */
|
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!!! */
|
/* Always append functions hereafter!!! */
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -35,8 +35,8 @@ unsigned int eigergetphotonenergy = 8000;
|
|||||||
unsigned int EigerGetPhotonEnergy(){return eigergetphotonenergy;}
|
unsigned int EigerGetPhotonEnergy(){return eigergetphotonenergy;}
|
||||||
/* for later */
|
/* for later */
|
||||||
int eigernumberofexposureseries = 1;
|
int eigernumberofexposureseries = 1;
|
||||||
unsigned int EigerGetNumberOfExposureSeries(){return eigernumberofexposureseries;}
|
int EigerGetNumberOfExposureSeries(){return eigernumberofexposureseries;}
|
||||||
int EigerSetNumberOfExposureSeries(unsigned int i){eigernumberofexposureseries = i;}
|
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];
|
char iname[10];
|
||||||
strcpy(iname,EigerGetDACName((int)ind));
|
strcpy(iname,EigerGetDACName((int)ind));
|
||||||
//#ifdef VERBOSE
|
//#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
|
//#endif
|
||||||
if(val >= 0)
|
if(val >= 0)
|
||||||
EigerSetDAC(iname,val/1000);
|
EigerSetDAC(iname,val/1000);
|
||||||
@ -267,7 +270,7 @@ int64_t setTimer(enum timerIndex ind, int64_t val){
|
|||||||
if(val >= 0){
|
if(val >= 0){
|
||||||
printf(" Setting exp time: %fs\n",val/(1E9));
|
printf(" Setting exp time: %fs\n",val/(1E9));
|
||||||
EigerSetExposureTime(val/(1E9));
|
EigerSetExposureTime(val/(1E9));
|
||||||
}return EigerGetExposureTime();
|
}return (EigerGetExposureTime()*(1E9));
|
||||||
case FRAME_PERIOD:
|
case FRAME_PERIOD:
|
||||||
if(val >= 0){
|
if(val >= 0){
|
||||||
printf(" Setting acq period: %fs\n",val/(1E9));
|
printf(" Setting acq period: %fs\n",val/(1E9));
|
||||||
|
@ -144,6 +144,7 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1)
|
|||||||
|
|
||||||
/** set correction mask to 0*/
|
/** set correction mask to 0*/
|
||||||
thisMultiDetector->correctionMask=1<<WRITE_FILE;
|
thisMultiDetector->correctionMask=1<<WRITE_FILE;
|
||||||
|
thisMultiDetector->correctionMask|=(1<<OVERWRITE_FILE);
|
||||||
/** set deat time*/
|
/** set deat time*/
|
||||||
thisMultiDetector->tDead=0;
|
thisMultiDetector->tDead=0;
|
||||||
/** sets bad channel list file to none */
|
/** 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 multiSlsDetector::setFrameIndex(int index){
|
||||||
int ret=-100, ret1;
|
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;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1168,6 +1168,13 @@ class multiSlsDetector : public slsDetectorUtils {
|
|||||||
*/
|
*/
|
||||||
int enableWriteToFile(int enable=-1);
|
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
|
* set frame index to 0 or -1
|
||||||
* @param index is the frame index
|
* @param index is the frame index
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <math.h>
|
||||||
#include "svnInfoLib.h"
|
#include "svnInfoLib.h"
|
||||||
|
|
||||||
|
|
||||||
@ -3482,7 +3483,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
|
|||||||
|
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< "Setting timer "<< index << " to " << t << "ns" << std::endl;
|
std::cout<< "Setting timer "<< index << " to " << t << "ns/value" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||||
if (connectControl() == OK){
|
if (connectControl() == OK){
|
||||||
@ -3496,7 +3497,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
|
|||||||
setErrorMask((getErrorMask())|(DETECTOR_TIMER_VALUE_NOT_SET));
|
setErrorMask((getErrorMask())|(DETECTOR_TIMER_VALUE_NOT_SET));
|
||||||
} else {
|
} else {
|
||||||
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||||
thisDetector->timerValue[index]=retval;
|
thisDetector->timerValue[index]=retval;
|
||||||
}
|
}
|
||||||
controlSocket->Disconnect();
|
controlSocket->Disconnect();
|
||||||
if (ret==FORCE_UPDATE) {
|
if (ret==FORCE_UPDATE) {
|
||||||
@ -3534,7 +3535,6 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//send acquisiton period/frame number to receiver
|
//send acquisiton period/frame number to receiver
|
||||||
if((index==FRAME_NUMBER)||(index==FRAME_PERIOD))
|
if((index==FRAME_NUMBER)||(index==FRAME_PERIOD))
|
||||||
{
|
{
|
||||||
@ -3545,14 +3545,16 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
|
|||||||
if(t == -1)
|
if(t == -1)
|
||||||
args[1] = -1;
|
args[1] = -1;
|
||||||
|
|
||||||
|
|
||||||
if(index==FRAME_NUMBER){
|
if(index==FRAME_NUMBER){
|
||||||
#ifdef VERBOSE
|
#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
|
#endif
|
||||||
args[0] = FRAME_NUMBER;
|
args[0] = FRAME_NUMBER;
|
||||||
}else{
|
}else{
|
||||||
#ifdef VERBOSE
|
#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
|
#endif
|
||||||
args[0] = FRAME_PERIOD;
|
args[0] = FRAME_PERIOD;
|
||||||
//if acquisition period is zero, then #frames/buffer depends on exposure time and not acq 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];
|
args[1] = timerValue[ACQUISITION_TIME];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (connectData() == OK)
|
if (connectData() == OK)
|
||||||
ret=thisReceiver->sendIntArray(fnum,ut,args);
|
ret=thisReceiver->sendIntArray(fnum,ut,args);
|
||||||
if((ut != retval)|| (ret==FAIL)){
|
if((ut != retval)|| (ret==FAIL)){
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
if(index==FRAME_PERIOD){
|
if(index==FRAME_PERIOD){
|
||||||
cout << "ERROR:Acquisition Period in receiver set incorrectly to " << ut << " instead of " << retval << endl;
|
//exptime sent if acq period = 0
|
||||||
setErrorMask((getErrorMask())|(RECEIVER_ACQ_PERIOD_NOT_SET));
|
if(retval){
|
||||||
|
cout << "ERROR:Acquisition Period in receiver set incorrectly to " << ut << " instead of " << retval << endl;
|
||||||
|
setErrorMask((getErrorMask())|(RECEIVER_ACQ_PERIOD_NOT_SET));
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
cout << "ERROR:Number of Frames in receiver set incorrectly to " << ut << " instead of " << retval << endl;
|
cout << "ERROR:Number of Frames in receiver set incorrectly to " << ut << " instead of " << retval << endl;
|
||||||
setErrorMask((getErrorMask())|(RECEIVER_FRAME_NUM_NOT_SET));
|
setErrorMask((getErrorMask())|(RECEIVER_FRAME_NUM_NOT_SET));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ret==FORCE_UPDATE)
|
if(ret==FORCE_UPDATE)
|
||||||
updateReceiver();
|
updateReceiver();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return thisDetector->timerValue[index];
|
return thisDetector->timerValue[index];
|
||||||
@ -4873,39 +4879,38 @@ 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 <<
|
std::cout << "file path:" << fileIO::getFilePath() << endl;
|
||||||
"file name:" << fileIO::getFileName() << endl <<
|
std::cout << "file name:" << fileIO::getFileName() << endl;
|
||||||
"write enable:" << parentDet->enableWriteToFileMask();
|
std::cout << "file index:" << fileIO::getFileIndex() << endl;
|
||||||
if(thisDetector->myDetectorType != EIGER){
|
std::cout << "write enable:" << parentDet->enableWriteToFileMask() << endl;
|
||||||
std::cout << "file index:" << fileIO::getFileIndex() << endl <<
|
std::cout << "overwrite enable:" << parentDet->enableOverwriteMask() << endl;
|
||||||
"frame index needed:" << ((setTimer(FRAME_NUMBER,-1)*setTimer(CYCLES_NUMBER,-1))>1) << endl <<
|
std::cout << "frame index needed:" << ((thisDetector->timerValue[FRAME_NUMBER]*thisDetector->timerValue[CYCLES_NUMBER])>1) << endl;
|
||||||
"frame period:" << setTimer(FRAME_PERIOD,-1) ;
|
std::cout << "frame period:" << thisDetector->timerValue[FRAME_PERIOD] << endl;
|
||||||
}
|
std::cout << "frame number:" << thisDetector->timerValue[FRAME_NUMBER] << endl;
|
||||||
std::cout << endl;
|
std::cout << "dynamic range:" << thisDetector->dynamicRange << endl << endl;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
if(thisDetector->myDetectorType == EIGER)
|
if(thisDetector->myDetectorType == EIGER)
|
||||||
setDetectorHostname();
|
setDetectorHostname();
|
||||||
setFilePath(fileIO::getFilePath());
|
setFilePath(fileIO::getFilePath());
|
||||||
setFileName(fileIO::getFileName());
|
setFileName(fileIO::getFileName());
|
||||||
|
setFileIndex(fileIO::getFileIndex());
|
||||||
enableWriteToFile(parentDet->enableWriteToFileMask());
|
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){
|
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();
|
setUDPConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
else{
|
|
||||||
setTimer(FRAME_NUMBER,thisDetector->timerValue[FRAME_NUMBER]);
|
|
||||||
setDynamicRange(thisDetector->dynamicRange);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return thisDetector->receiver_hostname;
|
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 slsDetector::setFrameIndex(int index){
|
||||||
int fnum=F_SET_FRAME_INDEX;
|
int fnum=F_SET_FRAME_INDEX;
|
||||||
|
@ -1549,6 +1549,13 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
|||||||
*/
|
*/
|
||||||
int enableWriteToFile(int enable=-1);
|
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
|
* set frame index to 0 or -1
|
||||||
|
@ -208,6 +208,9 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
|||||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdEnablefwrite;
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdEnablefwrite;
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
|
descrToFuncMap[i].m_pFuncName="overwrite"; //
|
||||||
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdOverwrite;
|
||||||
|
i++;
|
||||||
|
|
||||||
descrToFuncMap[i].m_pFuncName="currentfname"; //OK
|
descrToFuncMap[i].m_pFuncName="currentfname"; //OK
|
||||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdFileName;
|
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){
|
string slsDetectorCommand::cmdEnablefwrite(int narg, char *args[], int action){
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
char ans[100];
|
char ans[100];
|
||||||
|
|
||||||
if (action==HELP_ACTION) {
|
if (action==HELP_ACTION) {
|
||||||
return helpFileName(narg, args, action);
|
return helpEnablefwrite(narg, args, action);
|
||||||
}
|
}
|
||||||
if (action==PUT_ACTION) {
|
if (action==PUT_ACTION) {
|
||||||
if (sscanf(args[1],"%d",&i))
|
if (sscanf(args[1],"%d",&i))
|
||||||
myDet->enableWriteToFile(i);
|
myDet->enableWriteToFile(i);
|
||||||
@ -1597,6 +1600,40 @@ string slsDetectorCommand::helpEnablefwrite(int narg, char *args[], int action){
|
|||||||
return os.str();
|
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){
|
string slsDetectorCommand::cmdFileIndex(int narg, char *args[], int action){
|
||||||
char ans[100];
|
char ans[100];
|
||||||
int i;
|
int i;
|
||||||
@ -3304,7 +3341,7 @@ string slsDetectorCommand::helpDAC(int narg, char *args[], int action) {
|
|||||||
|
|
||||||
ostringstream os;
|
ostringstream os;
|
||||||
if (action==PUT_ACTION || action==HELP_ACTION) {
|
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 << std::endl;
|
||||||
|
|
||||||
os << "vcalibration " << "dacu\t sets the calibration pulse amplitude in dac units (0-1024)." << 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 helpCounter(int narg, char *args[], int action);
|
||||||
static string helpADC(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 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);
|
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 cmdCounter(int narg, char *args[], int action);
|
||||||
string cmdADC(int narg, char *args[], int action);
|
string cmdADC(int narg, char *args[], int action);
|
||||||
string cmdEnablefwrite(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);
|
string cmdReceiver(int narg, char *args[], int action);
|
||||||
|
|
||||||
|
|
||||||
|
@ -643,6 +643,14 @@ virtual int* readFrameFromReceiver(char* fName, int &fIndex)=0;
|
|||||||
*/
|
*/
|
||||||
virtual int exitReceiver()=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
|
Sets/Gets receiver file write enable
|
||||||
@param enable 1 or 0 to set/reset 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;
|
virtual int enableWriteToFile(int enable=-1)=0;
|
||||||
|
|
||||||
|
|
||||||
/** Starts acquisition, calibrates pedestal and writes to fpga
|
/** Starts acquisition, calibrates pedestal and writes to fpga
|
||||||
/returns number of frames
|
/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 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);};
|
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 scanTag;
|
||||||
int numberOfFrames;
|
int numberOfFrames;
|
||||||
bool doFileWrite;
|
bool doFileWrite;
|
||||||
|
bool doFileOverWrite;
|
||||||
|
|
||||||
EigerReceiverScanConfiguration():
|
EigerReceiverScanConfiguration():
|
||||||
dynamicRange(-1),
|
dynamicRange(-1),
|
||||||
scanTag(-1),
|
scanTag(-1),
|
||||||
numberOfFrames(-1),
|
numberOfFrames(-1),
|
||||||
doFileWrite(false) {};
|
doFileWrite(false),
|
||||||
|
doFileOverWrite(false){};
|
||||||
};
|
};
|
||||||
|
|
||||||
class EigerReceiverImplementation: public EigerReceiver {
|
class EigerReceiverImplementation: public EigerReceiver {
|
||||||
@ -163,6 +165,11 @@ public:
|
|||||||
return(scan_config.doFileWrite);
|
return(scan_config.doFileWrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getEnableOverwrite() const {
|
||||||
|
DEBUG("getEnableOverwrite() returns " << scan_config.doFileOverWrite);
|
||||||
|
return(scan_config.doFileOverWrite);
|
||||||
|
}
|
||||||
|
|
||||||
slsDetectorDefs::runStatus getStatus() const {
|
slsDetectorDefs::runStatus getStatus() const {
|
||||||
DEBUG("getStatus(): return " <<status);
|
DEBUG("getStatus(): return " <<status);
|
||||||
return(status);
|
return(status);
|
||||||
@ -204,6 +211,12 @@ public:
|
|||||||
return(getEnableFileWrite());
|
return(getEnableFileWrite());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int setEnableOverwrite(const int i) {
|
||||||
|
DEBUG("setEnableOverwrite() called with " << i);
|
||||||
|
scan_config.doFileOverWrite = i;
|
||||||
|
return(getEnableOverwrite());
|
||||||
|
}
|
||||||
|
|
||||||
int startReceiver(char message[]) {
|
int startReceiver(char message[]) {
|
||||||
DEBUG("startReceiver(): return 0.");
|
DEBUG("startReceiver(): return 0.");
|
||||||
status = slsDetectorDefs::RUNNING;
|
status = slsDetectorDefs::RUNNING;
|
||||||
|
@ -115,6 +115,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual int getEnableFileWrite() const = 0;
|
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)
|
* Set File Name (without frame index, file index and extension)
|
||||||
@param c file name
|
@param c file name
|
||||||
@ -167,6 +173,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual int setEnableFileWrite(const int i) = 0;
|
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
|
* 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
|
@param message is the error message if there is an error
|
||||||
|
@ -38,7 +38,9 @@ slsReceiverFunctionList::slsReceiverFunctionList(detectorType det):
|
|||||||
eth(NULL),
|
eth(NULL),
|
||||||
maxPacketsPerFile(0),
|
maxPacketsPerFile(0),
|
||||||
enableFileWrite(1),
|
enableFileWrite(1),
|
||||||
|
overwrite(1),
|
||||||
fileIndex(0),
|
fileIndex(0),
|
||||||
|
scanTag(0),
|
||||||
frameIndexNeeded(0),
|
frameIndexNeeded(0),
|
||||||
acqStarted(false),
|
acqStarted(false),
|
||||||
measurementStarted(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){
|
int32_t slsReceiverFunctionList::setScanTag(int32_t stag){
|
||||||
if(stag >= 0)
|
if(stag >= 0){
|
||||||
receiver->setScanTag(stag);
|
if(myDetectorType == EIGER)
|
||||||
return receiver->getScanTag();
|
receiver->setScanTag(stag);
|
||||||
|
else
|
||||||
|
scanTag = stag;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(myDetectorType == EIGER)
|
||||||
|
return receiver->getScanTag();
|
||||||
|
else
|
||||||
|
return scanTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t slsReceiverFunctionList::setDynamicRange(int32_t dr){
|
int32_t slsReceiverFunctionList::setDynamicRange(int32_t dr){
|
||||||
@ -437,7 +460,8 @@ int64_t slsReceiverFunctionList::setAcquisitionPeriod(int64_t index){
|
|||||||
if(index >= 0){
|
if(index >= 0){
|
||||||
if(index != acquisitionPeriod){
|
if(index != acquisitionPeriod){
|
||||||
acquisitionPeriod = index;
|
acquisitionPeriod = index;
|
||||||
setupFifoStructure();
|
if(myDetectorType != EIGER)
|
||||||
|
setupFifoStructure();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return acquisitionPeriod;
|
return acquisitionPeriod;
|
||||||
@ -982,7 +1006,12 @@ int slsReceiverFunctionList::createNewFile(){
|
|||||||
sfilefd = NULL;
|
sfilefd = NULL;
|
||||||
}
|
}
|
||||||
//open file
|
//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;
|
cout << "Error: Could not create file " << savefilename << endl;
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
@ -141,8 +141,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
int setEnableFileWrite(int i);
|
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 */
|
/** File write enable */
|
||||||
int enableFileWrite;
|
int enableFileWrite;
|
||||||
|
|
||||||
|
/** File over write enable */
|
||||||
|
int overwrite;
|
||||||
|
|
||||||
/** Complete File name */
|
/** Complete File name */
|
||||||
char savefilename[MAX_STR_LENGTH];
|
char savefilename[MAX_STR_LENGTH];
|
||||||
|
|
||||||
@ -389,6 +396,9 @@ private:
|
|||||||
/** File Index */
|
/** File Index */
|
||||||
int fileIndex;
|
int fileIndex;
|
||||||
|
|
||||||
|
/** scan tag */
|
||||||
|
int scanTag;
|
||||||
|
|
||||||
/** if frame index required in file name */
|
/** if frame index required in file name */
|
||||||
int frameIndexNeeded;
|
int frameIndexNeeded;
|
||||||
|
|
||||||
|
@ -321,6 +321,9 @@ int slsReceiverFuncs::function_table(){
|
|||||||
flist[F_ENABLE_COMPRESSION] = &slsReceiverFuncs::enable_compression;
|
flist[F_ENABLE_COMPRESSION] = &slsReceiverFuncs::enable_compression;
|
||||||
flist[F_SET_DETECTOR_HOSTNAME] = &slsReceiverFuncs::set_detector_hostname;
|
flist[F_SET_DETECTOR_HOSTNAME] = &slsReceiverFuncs::set_detector_hostname;
|
||||||
flist[F_SET_DYNAMIC_RANGE] = &slsReceiverFuncs::set_dynamic_range;
|
flist[F_SET_DYNAMIC_RANGE] = &slsReceiverFuncs::set_dynamic_range;
|
||||||
|
flist[F_ENABLE_OVERWRITE] = &slsReceiverFuncs::enable_overwrite;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//General Functions
|
//General Functions
|
||||||
flist[F_LOCK_SERVER] = &slsReceiverFuncs::lock_receiver;
|
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 */
|
/** set dynamic range */
|
||||||
int set_dynamic_range();
|
int set_dynamic_range();
|
||||||
|
|
||||||
|
/** enable overwrite */
|
||||||
|
int enable_overwrite();
|
||||||
|
|
||||||
|
|
||||||
//General Functions
|
//General Functions
|
||||||
/** Locks Receiver */
|
/** Locks Receiver */
|
||||||
|
Reference in New Issue
Block a user