filepath, filename and index set from slsdet or multislsdet, moving all receiver coding from slsdetectorcommand to slsdetector

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@312 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d 2012-10-24 11:59:04 +00:00
parent 9b323c9e7e
commit b52f9a8569
12 changed files with 596 additions and 594 deletions

View File

@ -40,11 +40,11 @@ picassoServer: $(SRC_MYTHEN_SVC)
%.o : %.cpp %.h %.o : %.cpp %.h
$(CXX) -Wall -o $@ -c $< $(INCLUDES) $(DFLAGS) $(FLAGS) -fPIC $(EPICSFLAGS) $(CXX) -Wall -o $@ -c $< $(INCLUDES) $(DFLAGS) $(FLAGS) -fPIC $(EPICSFLAGS) -L/usr/lib64/
package: $(OBJS) package: $(OBJS)
$(CXX) -shared -Wl,-soname,libSlsDetector.so -o libSlsDetector.so $(OBJS) -lc $(INCLUDES) $(DFLAGS) $(FLAGS) $(EPICSFLAGS) $(CXX) -shared -Wl,-soname,libSlsDetector.so -o libSlsDetector.so $(OBJS) -lc $(INCLUDES) $(DFLAGS) $(FLAGS) $(EPICSFLAGS) -L/usr/lib64/
ar rcs libSlsDetector.a $(OBJS) ar rcs libSlsDetector.a $(OBJS)
clean: clean:

View File

@ -108,11 +108,11 @@ enum {
//receiver //receiver
F_SET_RECEIVER_FILE_NAME, /**< sets receiver file name */ F_SET_FILE_PATH, /**< sets receiver file directory */
F_SET_RECEIVER_FILE_DIR, /**< sets receiver file directory */ F_SET_FILE_NAME, /**< sets receiver file name */
F_SET_RECEIVER_FILE_INDEX, /**< sets receiver file index */ F_SET_FILE_INDEX, /**< sets receiver file index */
F_START_RECEIVER, /**< starts the receiver listening mode */ F_START_RECEIVER, /**< starts the receiver listening mode */

View File

@ -117,14 +117,14 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1)
thisMultiDetector->maxNumberOfChannels=0; thisMultiDetector->maxNumberOfChannels=0;
/** set trimDsdir, calDir and filePath to default to home directory*/ /** set trimDsdir, calDir and filePath to default to home directory*/
strcpy(thisMultiDetector->filePath,getenv("HOME")); strcpy(thisMultiDetector->filePath,getenv("HOME"));
/** set fileName to default to run*/ /** set fileName to default to run*/
strcpy(thisMultiDetector->fileName,"run"); strcpy(thisMultiDetector->fileName,"run");
/** set fileIndex to default to 0*/ /** set fileIndex to default to 0*/
thisMultiDetector->fileIndex=0; thisMultiDetector->fileIndex=0;
/** set progress Index to default to 0*/ /** set progress Index to default to 0*/
thisMultiDetector->progressIndex=0; thisMultiDetector->progressIndex=0;
/** set total number of frames to be acquired to default to 1*/ /** set total number of frames to be acquired to default to 1*/
@ -193,28 +193,7 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1)
} }
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) { //assigned before creating detector
#ifdef VERBOSE
cout << thisMultiDetector->detectorIds[i] << endl;
#endif
detectors[i]=new slsDetector(thisMultiDetector->detectorIds[i], this);
// setAngularConversionPointer(detectors[i]->getAngularConversionPointer(),detectors[i]->getNModsPointer(),detectors[i]->getNChans()*detectors[i]->getNChips(), i);
}
for (int i=thisMultiDetector->numberOfDetectors; i<MAXDET; i++)
detectors[i]=NULL;
/** modifies the last PID accessing the detector system*/
thisMultiDetector->lastPID=getpid();
stoppedFlag=&thisMultiDetector->stoppedFlag; stoppedFlag=&thisMultiDetector->stoppedFlag;
threadedProcessing=&thisMultiDetector->threadedProcessing; threadedProcessing=&thisMultiDetector->threadedProcessing;
actionMask=&thisMultiDetector->actionMask; actionMask=&thisMultiDetector->actionMask;
@ -243,13 +222,35 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1)
currentSettings=&thisMultiDetector->currentSettings; currentSettings=&thisMultiDetector->currentSettings;
currentThresholdEV=&thisMultiDetector->currentThresholdEV; currentThresholdEV=&thisMultiDetector->currentThresholdEV;
filePath=thisMultiDetector->filePath;
fileName=thisMultiDetector->fileName;
fileIndex=&thisMultiDetector->fileIndex;
moveFlag=NULL; moveFlag=NULL;
sampleDisplacement=thisMultiDetector->sampleDisplacement; sampleDisplacement=thisMultiDetector->sampleDisplacement;
filePath=thisMultiDetector->filePath;
fileName=thisMultiDetector->fileName;
fileIndex=&thisMultiDetector->fileIndex;
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
#ifdef VERBOSE
cout << thisMultiDetector->detectorIds[i] << endl;
#endif
detectors[i]=new slsDetector(thisMultiDetector->detectorIds[i], this);
// setAngularConversionPointer(detectors[i]->getAngularConversionPointer(),detectors[i]->getNModsPointer(),detectors[i]->getNChans()*detectors[i]->getNChips(), i);
}
for (int i=thisMultiDetector->numberOfDetectors; i<MAXDET; i++)
detectors[i]=NULL;
/** modifies the last PID accessing the detector system*/
thisMultiDetector->lastPID=getpid();
getNMods(); getNMods();
getMaxMods(); getMaxMods();
@ -3508,7 +3509,6 @@ int multiSlsDetector::readDataFile(string fname, int *data) {
int multiSlsDetector::setReceiverOnline(int off) { int multiSlsDetector::setReceiverOnline(int off) {
if (off!=GET_ONLINE_FLAG) {
int ret=-100,ret1; int ret=-100,ret1;
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) for (int i=0; i<thisMultiDetector->numberOfDetectors; i++)
if (detectors[i]){ if (detectors[i]){
@ -3518,9 +3518,7 @@ int multiSlsDetector::setReceiverOnline(int off) {
else if (ret!=ret1) else if (ret!=ret1)
ret=-1; ret=-1;
} }
thisMultiDetector->receiverOnlineFlag=ret; return ret;
}
return thisMultiDetector->receiverOnlineFlag;
} }
@ -3542,31 +3540,34 @@ string multiSlsDetector::checkReceiverOnline() {
string multiSlsDetector::setFilePath(string s) {
if(!s.empty())
fileIO::setFilePath(s);
/*
string ret="error", ret1;
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
if (detectors[idet]) {
ret1=detectors[idet]->setFilePath(s);
if (ret=="error")
ret=ret1;
else if (ret!=ret1)
ret="";
}
}
return ret;*/
return fileIO::getFilePath();
}
string multiSlsDetector::setReceiverFileName(string fileName) {
string multiSlsDetector::setFileName(string s) {
string ret="error", ret1; string ret="error", ret1;
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) { for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
if (detectors[idet]) { if (detectors[idet]) {
if(getNumberOfDetectors()>1) if(getNumberOfDetectors()>1)
setDetectorIndex(idet); setDetectorIndex(idet);
ret1=detectors[idet]->setReceiverFileName(fileName); ret1=detectors[idet]->setFileName(s);
if (ret=="error")
ret=ret1;
else if (ret!=ret1)
ret="";
}
}
return ret;
}
string multiSlsDetector::setReceiverFileDir(string fileDir) {
string ret="error", ret1;
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
if (detectors[idet]) {
ret1=detectors[idet]->setReceiverFileDir(fileDir);
if (ret=="error") if (ret=="error")
ret=ret1; ret=ret1;
else if (ret!=ret1) else if (ret!=ret1)
@ -3578,12 +3579,12 @@ string multiSlsDetector::setReceiverFileDir(string fileDir) {
int multiSlsDetector::setReceiverFileIndex(int fileIndex) { int multiSlsDetector::setFileIndex(int i) {
int ret=-100, ret1; int ret=-100, ret1;
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) { for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
if (detectors[idet]) { if (detectors[idet]) {
ret1=detectors[idet]->setReceiverFileIndex(fileIndex); ret1=detectors[idet]->setFileIndex(i);
if (ret==-100) if (ret==-100)
ret=ret1; ret=ret1;
else if (ret!=ret1) else if (ret!=ret1)

View File

@ -105,15 +105,12 @@ class multiSlsDetector : public slsDetectorUtils {
/** total number of frames to be acquired */ /** total number of frames to be acquired */
int totalProgress; int totalProgress;
/** current index of the output file */ /** current index of the output file */
int fileIndex; int fileIndex;
/** path of the output files */
char filePath[MAX_STR_LENGTH];
/** name root of the output files */ /** name root of the output files */
char fileName[MAX_STR_LENGTH]; char fileName[MAX_STR_LENGTH];
/** path of the output files */
char filePath[MAX_STR_LENGTH];
/** corrections to be applied to the data \see ::correctionFlags */ /** corrections to be applied to the data \see ::correctionFlags */
int correctionMask; int correctionMask;
@ -186,10 +183,6 @@ class multiSlsDetector : public slsDetectorUtils {
int scanPrecision[MAX_SCAN_LEVELS]; int scanPrecision[MAX_SCAN_LEVELS];
//receiver
/** online receiver flag - is set if the receiver is connected, unset if socket connection is not possible */
int receiverOnlineFlag;
}; };
@ -1027,26 +1020,42 @@ class multiSlsDetector : public slsDetectorUtils {
*/ */
string checkReceiverOnline(); string checkReceiverOnline();
/**
Sets up the receiver file name
@param fileName file name
\returns file name
*/
string setReceiverFileName(string fileName="");
/** /**
Sets up the receiver file directory Sets up the file directory
@param fileName fileDir file directory @param s file directory
\returns file dir \returns file dir
*/ */
string setReceiverFileDir(string fileDir=""); string setFilePath(string s="");
/** /**
Sets up the receiver file index Sets up the file name
@param fileIndex file index @param s file name
\returns file name
*/
string setFileName(string s="");
/**
Sets up the file index
@param i file index
\returns file index \returns file index
*/ */
int setReceiverFileIndex(int fileIndex=-1); int setFileIndex(int i=-1);
/**
\returns file dir
*/
string getFilePath(){return setFilePath();};
/**
\returns file name
*/
string getFileName(){return setFileName();};
/**
\returns file index
*/
int getFileIndex(){return setFileIndex();};
/** Starts the listening mode of receiver /** Starts the listening mode of receiver

View File

@ -112,6 +112,7 @@ int slsDetector::freeSharedMemory() {
slsDetector::slsDetector(int id,multiSlsDetector *p) :slsDetectorUtils(), slsDetector::slsDetector(int id,multiSlsDetector *p) :slsDetectorUtils(),
thisDetector(NULL), thisDetector(NULL),
detId(id), detId(id),
parentDet(p),
shmId(-1), shmId(-1),
controlSocket(NULL), controlSocket(NULL),
stopSocket(NULL), stopSocket(NULL),
@ -122,8 +123,7 @@ slsDetector::slsDetector(int id,multiSlsDetector *p) :slsDetectorUtils(),
dacs(NULL), dacs(NULL),
adcs(NULL), adcs(NULL),
chipregs(NULL), chipregs(NULL),
chanregs(NULL), chanregs(NULL)
parentDet(p)
{ {
@ -161,6 +161,7 @@ slsDetector::slsDetector(int id,multiSlsDetector *p) :slsDetectorUtils(),
slsDetector::slsDetector(detectorType type, int id,multiSlsDetector *p): slsDetectorUtils(), slsDetector::slsDetector(detectorType type, int id,multiSlsDetector *p): slsDetectorUtils(),
thisDetector(NULL), thisDetector(NULL),
detId(id), detId(id),
parentDet(p),
shmId(-1), shmId(-1),
controlSocket(NULL), controlSocket(NULL),
stopSocket(NULL), stopSocket(NULL),
@ -171,8 +172,7 @@ slsDetector::slsDetector(detectorType type, int id,multiSlsDetector *p): slsDete
dacs(NULL), dacs(NULL),
adcs(NULL), adcs(NULL),
chipregs(NULL), chipregs(NULL),
chanregs(NULL), chanregs(NULL)
parentDet(p)
{ {
while (shmId<0) { while (shmId<0) {
/**Initlializes shared memory \sa initSharedMemory /**Initlializes shared memory \sa initSharedMemory
@ -213,6 +213,7 @@ slsDetector::~slsDetector(){
slsDetector::slsDetector(char *name, int id, int cport,multiSlsDetector *p) : slsDetectorUtils(), slsDetector::slsDetector(char *name, int id, int cport,multiSlsDetector *p) : slsDetectorUtils(),
thisDetector(NULL), thisDetector(NULL),
detId(id), detId(id),
parentDet(p),
shmId(-1), shmId(-1),
controlSocket(NULL), controlSocket(NULL),
stopSocket(NULL), stopSocket(NULL),
@ -223,8 +224,8 @@ slsDetector::slsDetector(char *name, int id, int cport,multiSlsDetector *p) : sl
dacs(NULL), dacs(NULL),
adcs(NULL), adcs(NULL),
chipregs(NULL), chipregs(NULL),
chanregs(NULL), chanregs(NULL)
parentDet(p)
{ {
detectorType type=(detectorType)getDetectorType(name, cport); detectorType type=(detectorType)getDetectorType(name, cport);
@ -521,21 +522,20 @@ int slsDetector::initializeDetectorSize(detectorType type) {
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*4; thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*4;
else else
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*thisDetector->dynamicRange/8; thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*thisDetector->dynamicRange/8;
/** set trimDsdir, calDir and filePath to default to home directory*/ /** set trimDsdir, calDir to default to home directory*/
strcpy(thisDetector->settingsDir,getenv("HOME")); strcpy(thisDetector->settingsDir,getenv("HOME"));
strcpy(thisDetector->calDir,getenv("HOME")); strcpy(thisDetector->calDir,getenv("HOME"));
strcpy(thisDetector->filePath,getenv("HOME"));
/** sets trimbit file */ /** sets trimbit file */
strcpy(thisDetector->settingsFile,"none"); strcpy(thisDetector->settingsFile,"none");
/** set fileName to default to run*/
strcpy(thisDetector->fileName,"run");
/** set fileIndex to default to 0*/
thisDetector->fileIndex=0;
/** set progress Index to default to 0*/ /** set progress Index to default to 0*/
thisDetector->progressIndex=0; thisDetector->progressIndex=0;
/** set total number of frames to be acquired to default to 1*/ /** set total number of frames to be acquired to default to 1*/
thisDetector->totalProgress=1; thisDetector->totalProgress=1;
/** set trimDsdir, calDir and filePath to default to home directory*/
strcpy(thisDetector->filePath,getenv("HOME"));
/** set number of trim energies to 0*/ /** set number of trim energies to 0*/
thisDetector->nTrimEn=0; thisDetector->nTrimEn=0;
/** set correction mask to 0*/ /** set correction mask to 0*/
@ -664,13 +664,14 @@ int slsDetector::initializeDetectorSize(detectorType type) {
currentSettings=&thisDetector->currentSettings; currentSettings=&thisDetector->currentSettings;
currentThresholdEV=&thisDetector->currentThresholdEV; currentThresholdEV=&thisDetector->currentThresholdEV;
filePath=thisDetector->filePath;
fileName=thisDetector->fileName;
fileIndex=&thisDetector->fileIndex;
moveFlag=&thisDetector->moveFlag; moveFlag=&thisDetector->moveFlag;
sampleDisplacement=NULL; sampleDisplacement=NULL;
settingsFile=thisDetector->settingsFile; settingsFile=thisDetector->settingsFile;
filePath=thisDetector->filePath;
fileName=parentDet->fileName;
fileIndex=parentDet->fileIndex;
// setAngularConversionPointer(thisDetector->angOff,&thisDetector->nMods, thisDetector->nChans*thisDetector->nChips); // setAngularConversionPointer(thisDetector->angOff,&thisDetector->nMods, thisDetector->nChans*thisDetector->nChips);
@ -971,7 +972,7 @@ int slsDetector::setTCPSocket(string const name, int const control_port, int con
char thisName[MAX_STR_LENGTH]; char thisName[MAX_STR_LENGTH];
int thisCP, thisSP, thisDP; int thisCP, thisSP;
int retval=OK; int retval=OK;
if (strcmp(name.c_str(),"")!=0) { if (strcmp(name.c_str(),"")!=0) {
@ -3612,7 +3613,7 @@ int slsDetector::setTotalProgress() {
npos=thisDetector->numberOfPositions; npos=thisDetector->numberOfPositions;
if (timerValue[MEASUREMENTS_NUMBER]>0) if (timerValue[MEASUREMENTS_NUMBER]>0)
nc=timerValue[MEASUREMENTS_NUMBER]; nm=timerValue[MEASUREMENTS_NUMBER];
if ((thisDetector->nScanSteps[0]>0) && (thisDetector->actionMask & (1 << MAX_ACTIONS))) if ((thisDetector->nScanSteps[0]>0) && (thisDetector->actionMask & (1 << MAX_ACTIONS)))
@ -3621,7 +3622,7 @@ int slsDetector::setTotalProgress() {
if ((thisDetector->nScanSteps[1]>0) && (thisDetector->actionMask & (1 << (MAX_ACTIONS+1)))) if ((thisDetector->nScanSteps[1]>0) && (thisDetector->actionMask & (1 << (MAX_ACTIONS+1))))
nscan[1]=thisDetector->nScanSteps[1]; nscan[1]=thisDetector->nScanSteps[1];
thisDetector->totalProgress=nf*nc*npos*nscan[0]*nscan[1]; thisDetector->totalProgress=nf*nc*npos*nm*nscan[0]*nscan[1];
#ifdef VERBOSE #ifdef VERBOSE
cout << "nc " << nc << endl; cout << "nc " << nc << endl;
@ -4033,8 +4034,8 @@ int slsDetector::setFlatFieldCorrection(string fname)
{ {
double data[thisDetector->nModMax[X]*thisDetector->nModMax[Y]*thisDetector->nChans*thisDetector->nChips]; double data[thisDetector->nModMax[X]*thisDetector->nModMax[Y]*thisDetector->nChans*thisDetector->nChips];
//double err[thisDetector->nModMax[X]*thisDetector->nModMax[Y]*thisDetector->nChans*thisDetector->nChips]; //double err[thisDetector->nModMax[X]*thisDetector->nModMax[Y]*thisDetector->nChans*thisDetector->nChips];
double xmed[thisDetector->nModMax[X]*thisDetector->nModMax[Y]*thisDetector->nChans*thisDetector->nChips]; //double xmed[thisDetector->nModMax[X]*thisDetector->nModMax[Y]*thisDetector->nChans*thisDetector->nChips];
int nmed=0; // int nmed=0;
int im=0; int im=0;
int nch; int nch;
thisDetector->nBadFF=0; thisDetector->nBadFF=0;
@ -4289,10 +4290,10 @@ int slsDetector::rateCorrect(double* datain, double *errin, double* dataout, dou
int slsDetector::setBadChannelCorrection(string fname){ int slsDetector::setBadChannelCorrection(string fname){
// int nbadmod;
int nbadmod,ret=0; int ret=0;
int badchanlist[MAX_BADCHANS]; //int badchanlist[MAX_BADCHANS];
int off; //int off;
string fn=fname; string fn=fname;
@ -4460,13 +4461,17 @@ char* slsDetector::setReceiverIP(string receiverIP){
} }
if(wrongFormat) if(wrongFormat)
return ("IP Address should be VALID and in xxx.xxx.xxx.xxx format"); std::cout<< "IP Address should be VALID and in xxx.xxx.xxx.xxx format" << endl;
else{
if(setReceiverTCPSocket()==FAIL) if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
return("Connection to Receiver failed."); setFilePath(fileIO::getFilePath());
setFileName(fileIO::getFileName());
setFileIndex(fileIO::getFileIndex());
}else
std::cout << "cannot connect to receiver" << endl;
}
return thisDetector->receiverIP; return thisDetector->receiverIP;
} }
@ -4576,7 +4581,8 @@ int slsDetector::configureMAC(int adc){
updateDetector(); updateDetector();
} }
} }
} }else
std::cout << "cannot connect to detector" << endl;
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "Configuring MAC - returned "<< retval << std::endl; std::cout<< "Configuring MAC - returned "<< retval << std::endl;
#endif #endif
@ -4803,7 +4809,7 @@ int slsDetector::readConfigurationFile(string const fname){
string ans; string ans;
string str; string str;
ifstream infile; ifstream infile;
char *args[1000]; //char *args[1000];
string sargname, sargval; string sargname, sargval;
int iline=0; int iline=0;
@ -5141,7 +5147,7 @@ int slsDetector::loadCalibrationFile(string fname, int imod) {
ostfn << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im); ostfn << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im);
} }
fn=ostfn.str(); fn=ostfn.str();
if(myMod=getModule(im)){ if((myMod=getModule(im))){
if(readCalibrationFile(fn, myMod->gain, myMod->offset)==FAIL) if(readCalibrationFile(fn, myMod->gain, myMod->offset)==FAIL)
return FAIL; return FAIL;
setModule(*myMod); setModule(*myMod);
@ -5287,7 +5293,7 @@ int slsDetector::setReceiverOnline(int off) {
//Since flag becomes offline if receiver not online. //Since flag becomes offline if receiver not online.
//This ensures server to NOT send to receiver in the next command line comment //This ensures server to NOT send to receiver in the next command line comment
if((off==ONLINE_FLAG)&&(thisDetector->receiverOnlineFlag!=ONLINE_FLAG)) if((off==ONLINE_FLAG)&&(thisDetector->receiverOnlineFlag!=ONLINE_FLAG))
stopReceiver(); DetectorStopReceiver();
} }
return thisDetector->receiverOnlineFlag; return thisDetector->receiverOnlineFlag;
} }
@ -5406,25 +5412,73 @@ int slsDetector::setReceiverTCPSocket(string const name, int const data_port){
string slsDetector::setReceiverFileName(string fileName) {
int fnum=F_SET_RECEIVER_FILE_NAME; string slsDetector::setFilePath(string s) {
int fnum=F_SET_FILE_PATH;
int ret = FAIL; int ret = FAIL;
char mess[100]; char mess[100];
char arg[MAX_STR_LENGTH];
char retval[MAX_STR_LENGTH]="";
struct stat st;
char arg[MAX_STR_LENGTH],retval[MAX_STR_LENGTH]=""; if(thisDetector->receiverOnlineFlag==OFFLINE_FLAG){
if(!s.empty()){
if(stat(s.c_str(),&st))
if(!fileName.empty()){ std::cout << "path does not exist" << endl;
parentDet->setFileName(fileName); else
fileName=parentDet->createReceiverFilePrefix(); fileIO::setFilePath(s);
}
} }
strcpy(arg,fileName.c_str());
else if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
strcpy(arg,s.c_str());
#ifdef VERBOSE
std::cout << "Sending file path to receiver " << arg << std::endl;
#endif
if (dataSocket) {
if (dataSocket->Connect()>=0) {
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->SendDataOnly(arg,MAX_STR_LENGTH);
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret==FAIL){
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Receiver returned error: " << mess << std::endl;
}
dataSocket->ReceiveDataOnly(retval,MAX_STR_LENGTH);
fileIO::setFilePath(s);
}
dataSocket->Disconnect();
if (ret==FORCE_UPDATE)
updateReceiver();
}
}else
std::cout << "cannot connect to receiver" << endl;
return fileIO::getFilePath();
}
string slsDetector::setFileName(string s) {
int fnum=F_SET_FILE_NAME;
int ret = FAIL;
char mess[100];
char arg[MAX_STR_LENGTH];
char retval[MAX_STR_LENGTH]="";
if(!s.empty()){
fileIO::setFileName(s);
s=parentDet->createReceiverFilePrefix();
}
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
if(setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG){
strcpy(arg,s.c_str());
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Sending file name to receiver " << arg << std::endl; std::cout << "Sending file name to receiver " << arg << std::endl;
#endif #endif
if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
if (dataSocket) { if (dataSocket) {
if (dataSocket->Connect()>=0) { if (dataSocket->Connect()>=0) {
dataSocket->SendDataOnly(&fnum,sizeof(fnum)); dataSocket->SendDataOnly(&fnum,sizeof(fnum));
@ -5433,77 +5487,50 @@ string slsDetector::setReceiverFileName(string fileName) {
if (ret==FAIL){ if (ret==FAIL){
dataSocket->ReceiveDataOnly(mess,sizeof(mess)); dataSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Receiver returned error: " << mess << std::endl; std::cout<< "Receiver returned error: " << mess << std::endl;
}
dataSocket->ReceiveDataOnly(retval,MAX_STR_LENGTH);
#ifdef VERBOSE
std::cout << "Complete file prefix from receiver: " << retval << std::endl;
#endif
fileIO::setFileName(parentDet->getNameFromReceiverFilePrefix(string(retval)));
}
dataSocket->Disconnect();
if (ret==FORCE_UPDATE)
updateReceiver();
}
}else }else
dataSocket->ReceiveDataOnly(retval,MAX_STR_LENGTH); std::cout << "cannot connect to receiver" << endl;
} }
dataSocket->Disconnect();
if (ret==FORCE_UPDATE) return fileIO::getFileName();
updateReceiver();
}
}
#ifdef VERBOSE
std::cout << "retval: " << retval << std::endl;
#endif
string ans = parentDet->getNameFromReceiverFilePrefix(string(retval));
parentDet->setFileName(ans);
return ans;
} }
string slsDetector::setReceiverFileDir(string fileDir) {
int fnum=F_SET_RECEIVER_FILE_DIR;
int slsDetector::setFileIndex(int i) {
int fnum=F_SET_FILE_INDEX;
int ret = FAIL; int ret = FAIL;
char mess[100];
char arg[MAX_STR_LENGTH],retval[MAX_STR_LENGTH]="";
strcpy(arg,fileDir.c_str());
#ifdef VERBOSE
std::cout << "Sending file dir to receiver " << arg << std::endl;
#endif
if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
if (dataSocket) {
if (dataSocket->Connect()>=0) {
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->SendDataOnly(arg,MAX_STR_LENGTH);
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret==FAIL){
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Receiver returned error: " << mess << std::endl;
}else{
dataSocket->ReceiveDataOnly(retval,MAX_STR_LENGTH);
parentDet->setFilePath(string(retval));
}
}
dataSocket->Disconnect();
if (ret==FORCE_UPDATE)
updateReceiver();
}
}
return string(retval);
}
int slsDetector::setReceiverFileIndex(int fileIndex) {
int fnum=F_SET_RECEIVER_FILE_INDEX;
int ret = FAIL;
char mess[100];
int retval=-1; int retval=-1;
int arg = i;
char mess[100];
int arg = fileIndex; if(thisDetector->receiverOnlineFlag==OFFLINE_FLAG){
if(i>=0)
fileIO::setFileIndex(i);
}
else if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Sending file dir to receiver " << arg << std::endl; std::cout << "Sending file dir to receiver " << arg << std::endl;
#endif #endif
if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
if (dataSocket) { if (dataSocket) {
if (dataSocket->Connect()>=0) { if (dataSocket->Connect()>=0) {
dataSocket->SendDataOnly(&fnum,sizeof(fnum)); dataSocket->SendDataOnly(&fnum,sizeof(fnum));
@ -5512,18 +5539,19 @@ int slsDetector::setReceiverFileIndex(int fileIndex) {
if (ret==FAIL){ if (ret==FAIL){
dataSocket->ReceiveDataOnly(mess,sizeof(mess)); dataSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Receiver returned error: " << mess << std::endl; std::cout<< "Receiver returned error: " << mess << std::endl;
}else{
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
if(fileIndex!=-1)
parentDet->setFileIndex(retval);
} }
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
fileIO::setFileIndex(retval);
} }
dataSocket->Disconnect(); dataSocket->Disconnect();
if (ret==FORCE_UPDATE) if (ret==FORCE_UPDATE)
updateReceiver(); updateReceiver();
} }
}
return retval; }else
std::cout << "cannot connect to receiver" << endl;
return fileIO::getFileIndex();
} }
@ -5534,11 +5562,11 @@ int slsDetector::startReceiver(){
int ret = FAIL; int ret = FAIL;
char mess[100]; char mess[100];
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) {
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Starting Receiver " << std::endl; std::cout << "Starting Receiver " << std::endl;
#endif #endif
if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
if (dataSocket) { if (dataSocket) {
if (dataSocket->Connect()>=0) { if (dataSocket->Connect()>=0) {
dataSocket->SendDataOnly(&fnum,sizeof(fnum)); dataSocket->SendDataOnly(&fnum,sizeof(fnum));
@ -5552,16 +5580,20 @@ int slsDetector::startReceiver(){
ret=updateReceiver(); ret=updateReceiver();
} }
} }
} }else
std::cout << "cannot connect to receiver" << endl;
//configuremac for gotthard //configuremac for gotthard
if(ret==OK) if(ret==OK)
if(thisDetector->myDetectorType==GOTTHARD) if(thisDetector->myDetectorType==GOTTHARD)
ret=configureMAC(); ret=configureMAC();
//tell the server to send to receiver and not CPU
if(ret==OK){ if(ret==OK){
if (thisDetector->onlineFlag==ONLINE_FLAG) { if (thisDetector->onlineFlag==ONLINE_FLAG) {
#ifdef VERBOSE
std::cout << "Setting detector to send packets via receiver " << std::endl;
#endif
if (controlSocket) { if (controlSocket) {
if (controlSocket->Connect()>=0) { if (controlSocket->Connect()>=0) {
controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&fnum,sizeof(fnum));
@ -5575,7 +5607,8 @@ int slsDetector::startReceiver(){
ret=updateDetector(); ret=updateDetector();
} }
} }
} }else
std::cout << "cannot connect to detector" << endl;
} }
return ret; return ret;
@ -5583,19 +5616,14 @@ int slsDetector::startReceiver(){
int slsDetector::DetectorStopReceiver(){
int slsDetector::stopReceiver(){
int fnum=F_STOP_RECEIVER; int fnum=F_STOP_RECEIVER;
//different iret for server, should not return ok if receiver didnt connect
int ret = FAIL; int ret = FAIL;
char mess[100]; char mess[100];
#ifdef VERBOSE
std::cout << "Stopping Receiver " << std::endl;
#endif
//tell the server to NOT send to receiver and instead to CPU
if (thisDetector->onlineFlag==ONLINE_FLAG) { if (thisDetector->onlineFlag==ONLINE_FLAG) {
#ifdef VERBOSE
std::cout << "Setting detector to send packets via client " << std::endl;
#endif
if (controlSocket) { if (controlSocket) {
if (controlSocket->Connect()>=0) { if (controlSocket->Connect()>=0) {
controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&fnum,sizeof(fnum));
@ -5609,10 +5637,25 @@ int slsDetector::stopReceiver(){
updateDetector(); updateDetector();
} }
} }
} }else
std::cout << "cannot connect to detector" << endl;
return ret;
}
if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
int slsDetector::stopReceiver(){
int fnum=F_STOP_RECEIVER;
int ret = FAIL;
char mess[100];
DetectorStopReceiver();
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) {
#ifdef VERBOSE
std::cout << "Stopping Receiver " << std::endl;
#endif
if (dataSocket) { if (dataSocket) {
if (dataSocket->Connect()>=0) { if (dataSocket->Connect()>=0) {
dataSocket->SendDataOnly(&fnum,sizeof(fnum)); dataSocket->SendDataOnly(&fnum,sizeof(fnum));
@ -5627,8 +5670,14 @@ int slsDetector::stopReceiver(){
ret=updateReceiver(); ret=updateReceiver();
} }
} }
} }else
std::cout << "cannot connect to receiver" << endl;
//increment file index
if(ret==OK){
fileIO::setFileIndex(fileIO::getFileIndex()+1);
setFileIndex(fileIO::getFileIndex());
}
return ret; return ret;
} }
@ -5642,11 +5691,10 @@ slsDetectorDefs::runStatus slsDetector::getReceiverStatus(){
char mess[100]; char mess[100];
runStatus retval=ERROR; runStatus retval=ERROR;
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) {
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Getting Receiver Status" << std::endl; std::cout << "Getting Receiver Status" << std::endl;
#endif #endif
if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
if (dataSocket) { if (dataSocket) {
if (dataSocket->Connect()>=0) { if (dataSocket->Connect()>=0) {
dataSocket->SendDataOnly(&fnum,sizeof(fnum)); dataSocket->SendDataOnly(&fnum,sizeof(fnum));
@ -5662,7 +5710,8 @@ slsDetectorDefs::runStatus slsDetector::getReceiverStatus(){
updateReceiver(); updateReceiver();
} }
} }
} }else
std::cout << "cannot connect to receiver" << endl;
return retval; return retval;
} }
@ -5675,11 +5724,10 @@ int slsDetector::getFramesCaughtByReciver(){
char mess[100]; char mess[100];
int retval=-1; int retval=-1;
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) {
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Getting Frames Caught by Receiver " << std::endl; std::cout << "Getting Frames Caught by Receiver " << std::endl;
#endif #endif
if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
if (dataSocket) { if (dataSocket) {
if (dataSocket->Connect()>=0) { if (dataSocket->Connect()>=0) {
dataSocket->SendDataOnly(&fnum,sizeof(fnum)); dataSocket->SendDataOnly(&fnum,sizeof(fnum));
@ -5695,7 +5743,8 @@ int slsDetector::getFramesCaughtByReciver(){
updateReceiver(); updateReceiver();
} }
} }
} }else
std::cout << "cannot connect to receiver" << endl;
return retval; return retval;
} }
@ -5707,14 +5756,13 @@ int slsDetector::lockReceiver(int lock){
int ret = FAIL; int ret = FAIL;
int retval=-1; int retval=-1;
char mess[100]; char mess[100];
int arg= lock; int arg= lock;
if(setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG){
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Locking or Unlocking Receiver " << std::endl; std::cout << "Locking or Unlocking Receiver " << std::endl;
#endif #endif
if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
if (dataSocket) { if (dataSocket) {
if (dataSocket->Connect()>=0) { if (dataSocket->Connect()>=0) {
dataSocket->SendDataOnly(&fnum,sizeof(fnum)); dataSocket->SendDataOnly(&fnum,sizeof(fnum));
@ -5732,7 +5780,9 @@ int slsDetector::lockReceiver(int lock){
updateReceiver(); updateReceiver();
} }
} }
} }else
std::cout << "cannot connect to receiver" << endl;
return retval; return retval;
} }
@ -5744,15 +5794,13 @@ int slsDetector::lockReceiver(int lock){
string slsDetector::getReceiverLastClientIP(){ string slsDetector::getReceiverLastClientIP(){
int fnum=F_GET_LAST_CLIENT_IP; int fnum=F_GET_LAST_CLIENT_IP;
int ret = FAIL; int ret = FAIL;
char retval[INET_ADDRSTRLEN]; char retval[INET_ADDRSTRLEN]="";
char mess[100]; char mess[100];
if(setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG){
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Geting Last Client IP connected to Receiver " << std::endl; std::cout << "Geting Last Client IP connected to Receiver " << std::endl;
#endif #endif
if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
if (dataSocket) { if (dataSocket) {
if (dataSocket->Connect()>=0) { if (dataSocket->Connect()>=0) {
dataSocket->SendDataOnly(&fnum,sizeof(fnum)); dataSocket->SendDataOnly(&fnum,sizeof(fnum));
@ -5769,7 +5817,9 @@ string slsDetector::getReceiverLastClientIP(){
updateReceiver(); updateReceiver();
} }
} }
} }else
std::cout << "cannot connect to receiver" << endl;
return string(retval); return string(retval);
} }
@ -5789,11 +5839,11 @@ int slsDetector::updateReceiverNoWait() {
#endif #endif
n = dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); n = dataSocket->ReceiveDataOnly(&ind,sizeof(ind));
parentDet->setFileIndex(ind); fileIO::setFileIndex(ind);
n = dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH); n = dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH);
parentDet->setFilePath(path); fileIO::setFilePath(path);
n = dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH); n = dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH);
parentDet->setFileName(path); fileIO::setFileName(path);
return OK; return OK;
} }
@ -5807,7 +5857,7 @@ int slsDetector::updateReceiver() {
int ret=OK; int ret=OK;
char mess[100]; char mess[100];
if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) {
if (dataSocket) { if (dataSocket) {
if (dataSocket->Connect()>=0) { if (dataSocket->Connect()>=0) {
dataSocket->SendDataOnly(&fnum,sizeof(fnum)); dataSocket->SendDataOnly(&fnum,sizeof(fnum));

View File

@ -100,12 +100,9 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
int progressIndex; int progressIndex;
/** total number of frames to be acquired */ /** total number of frames to be acquired */
int totalProgress; int totalProgress;
/** current index of the output file */
int fileIndex;
/** path of the output files */ /** path of the output files */
char filePath[MAX_STR_LENGTH]; char filePath[MAX_STR_LENGTH];
/** name root of the output files */
char fileName[MAX_STR_LENGTH];
/* size of the detector */ /* size of the detector */
@ -1392,26 +1389,42 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
*/ */
int setReceiverTCPSocket(string const name="", int const data_port=-1); int setReceiverTCPSocket(string const name="", int const data_port=-1);
/**
Sets up the receiver file name
@param fileName file name
\returns file name
*/
string setReceiverFileName(string fileName="");
/** /**
Sets up the receiver file directory Sets up the file directory
@param fileName fileDir file directory @param s fileDir file directory
\returns file dir \returns file dir
*/ */
string setReceiverFileDir(string fileDir=""); string setFilePath(string s="");
/** /**
Sets up the receiver file index Sets up the file name
@param fileIndex file index @param s file name
\returns file name
*/
string setFileName(string s="");
/**
Sets up the file index
@param i file index
\returns file index \returns file index
*/ */
int setReceiverFileIndex(int fileIndex=-1); int setFileIndex(int i=-1);
/**
\returns file dir
*/
string getFilePath(){return setFilePath();};
/**
\returns file name
*/
string getFileName(){return setFileName();};
/**
\returns file index
*/
int getFileIndex(){return setFileIndex();};
/** Starts the listening mode of receiver /** Starts the listening mode of receiver
@ -1424,6 +1437,8 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
*/ */
int stopReceiver(); int stopReceiver();
int DetectorStopReceiver();
/** gets the status of the listening mode of receiver /** gets the status of the listening mode of receiver
\returns status \returns status
*/ */

View File

@ -430,28 +430,6 @@ class slsDetectorBase : public virtual slsDetectorDefs {
*/ */
virtual int setReceiverOnline(int const online=GET_ONLINE_FLAG)=0; virtual int setReceiverOnline(int const online=GET_ONLINE_FLAG)=0;
/**
Sets up the receiver file name
@param fileName file name
\returns file name
*/
virtual string setReceiverFileName(string fileName="")=0;
/**
Sets up the receiver file directory
@param fileName fileDir file directory
\returns file dir
*/
virtual string setReceiverFileDir(string fileDir="")=0;
/**
Sets up the receiver file index
@param fileIndex file index
\returns file index
*/
virtual int setReceiverFileIndex(int fileIndex=-1)=0;
/** Starts the listening mode of receiver /** Starts the listening mode of receiver
\returns OK or FAIL \returns OK or FAIL
*/ */

View File

@ -772,26 +772,20 @@ string slsDetectorCommand::cmdAcquire(int narg, char *args[], int action) {
cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n"); cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n");
#endif #endif
myDet->setOnline(ONLINE_FLAG); myDet->setOnline(ONLINE_FLAG);
bool receiver=myDet->setReceiverOnline();
//receiver if(receiver)
if(myDet->setReceiverOnline()==ONLINE_FLAG){ if(myDet->startReceiver()==OK)
if(myDet->setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG)
return string("can not connect to receiver");
if(myDet->getReceiverStatus()!=RUNNING){
//update receiver index
if(myDet->setReceiverFileIndex(myDet->getFileIndex())==-1)
return string("could not set receiver file index");
//start receiver
myDet->startReceiver();
usleep(2000000); usleep(2000000);
if(myDet->getReceiverStatus()!=RUNNING) else return string("could not start receiver");
return string("could not start receiver");
}
}
myDet->acquire(); myDet->acquire();
if(receiver)
myDet->stopReceiver();
return string(""); return string("");
} }
@ -1336,25 +1330,11 @@ string slsDetectorCommand::helpTrimEn(int narg, char *args[], int action) {
string slsDetectorCommand::cmdOutDir(int narg, char *args[], int action){ string slsDetectorCommand::cmdOutDir(int narg, char *args[], int action){
if (action==HELP_ACTION) { if (action==HELP_ACTION)
return helpOutDir(narg, args, action); return helpOutDir(narg, args, action);
}
if(myDet->setReceiverOnline()==ONLINE_FLAG){ else if(action==PUT_ACTION)
if(myDet->setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG)
return string("cannot connect to receiver");
if(action==PUT_ACTION)
myDet->setReceiverFileDir(string(args[1]));
return myDet->setReceiverFileDir();
}
if (action==PUT_ACTION) {
struct stat st;
if(stat(args[1],&st))
return string("path does not exist");
else
myDet->setFilePath(string(args[1])); myDet->setFilePath(string(args[1]));
}
return string(myDet->getFilePath()); return string(myDet->getFilePath());
} }
@ -1374,19 +1354,10 @@ string slsDetectorCommand::helpOutDir(int narg, char *args[], int action){
string slsDetectorCommand::cmdFileName(int narg, char *args[], int action){ string slsDetectorCommand::cmdFileName(int narg, char *args[], int action){
if (action==HELP_ACTION) { if (action==HELP_ACTION)
return helpFileName(narg, args, action); return helpFileName(narg, args, action);
}
if(myDet->setReceiverOnline()==ONLINE_FLAG){ else if (action==PUT_ACTION)
if(myDet->setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG)
return string("cannot connect to receiver");
if(action==PUT_ACTION)
myDet->setReceiverFileName(string(args[1]));
return myDet->setReceiverFileName();
}
if (action==PUT_ACTION)
myDet->setFileName(string(args[1])); myDet->setFileName(string(args[1]));
return string(myDet->getFileName()); return string(myDet->getFileName());
@ -1443,21 +1414,11 @@ string slsDetectorCommand::cmdFileIndex(int narg, char *args[], int action){
if (action==HELP_ACTION) { if (action==HELP_ACTION) {
return helpFileName(narg, args, action); return helpFileName(narg, args, action);
} }
else if (action==PUT_ACTION) else if (action==PUT_ACTION){
if(!sscanf(args[1],"%d",&i)) if(!sscanf(args[1],"%d",&i))
return string("cannot parse file index"); return string("cannot parse file index");
if(myDet->setReceiverOnline()==ONLINE_FLAG){
if(myDet->setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG)
return string("cannot connect to receiver");
if(action==PUT_ACTION)
myDet->setReceiverFileIndex(i);
sprintf(ans,"%d", myDet->setReceiverFileIndex());
return string(ans);
}
if (action==PUT_ACTION)
myDet->setFileIndex(i); myDet->setFileIndex(i);
}
sprintf(ans,"%d", myDet->getFileIndex()); sprintf(ans,"%d", myDet->getFileIndex());
return string(ans); return string(ans);
@ -2193,23 +2154,9 @@ string slsDetectorCommand::cmdNetworkParameter(int narg, char *args[], int actio
t=SERVER_MAC; t=SERVER_MAC;
} else return ("unknown network parameter")+cmd; } else return ("unknown network parameter")+cmd;
if (action==PUT_ACTION){ if (action==PUT_ACTION)
if(!strcmp(myDet->setNetworkParameter(t, args[1]),args[1])){ myDet->setNetworkParameter(t, args[1]);
if(t==RECEIVER_IP){
if(myDet->setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG)
return string("cannot connect to receiver");
//outdir
if(myDet->setReceiverFileDir(myDet->getFilePath()).compare(myDet->getFilePath()))
return string("could not set up receiver file outdir");
//fname
if(myDet->setReceiverFileName(myDet->getFileName()).compare(myDet->getFileName()))
return string("could not set up receiver file name");
//index
if(myDet->setReceiverFileIndex(myDet->getFileIndex())!=myDet->getFileIndex())
return string("could not set up receiver file index");
}
}
}
return myDet->getNetworkParameter(t); return myDet->getNetworkParameter(t);
} }
@ -2313,15 +2260,11 @@ string slsDetectorCommand::cmdLock(int narg, char *args[], int action) {
else if(cmd=="r_lock"){ else if(cmd=="r_lock"){
if(myDet->setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG)
return string("could not connect to receiver");
if (action==PUT_ACTION) { if (action==PUT_ACTION) {
if (!sscanf(args[1],"%d",&val)) if (sscanf(args[1],"%d",&val))
myDet->lockReceiver(val);
else
return string("could not decode lock status")+string(args[1]); return string("could not decode lock status")+string(args[1]);
if(myDet->lockReceiver(val)!=val)
return string("could not lock/unlock receiver");
} }
sprintf(ans,"%d",myDet->lockReceiver()); sprintf(ans,"%d",myDet->lockReceiver());
} }
@ -2361,18 +2304,16 @@ string slsDetectorCommand::cmdLastClient(int narg, char *args[], int action) {
if (action==PUT_ACTION) if (action==PUT_ACTION)
return string("cannot set"); return string("cannot set");
if(cmd=="lastclient"){ if(cmd=="lastclient"){
myDet->setOnline(ONLINE_FLAG); myDet->setOnline(ONLINE_FLAG);
return myDet->getLastClientIP(); return myDet->getLastClientIP();
} }
else if(cmd=="r_lastclient"){ else if(cmd=="r_lastclient")
if(myDet->setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG)
return string("could not connect to receiver");
return myDet->getReceiverLastClientIP(); return myDet->getReceiverLastClientIP();
}
return string("cannot decode command");
} }
string slsDetectorCommand::helpLastClient(int narg, char *args[], int action) { string slsDetectorCommand::helpLastClient(int narg, char *args[], int action) {
@ -3558,37 +3499,13 @@ string slsDetectorCommand::cmdReceiver(int narg, char *args[], int action) {
myDet->setOnline(ONLINE_FLAG); myDet->setOnline(ONLINE_FLAG);
myDet->setReceiverOnline(ONLINE_FLAG);
if(cmd=="receiver"){ if(cmd=="receiver"){
if (action==PUT_ACTION) { if (action==PUT_ACTION) {
if(!strcasecmp(args[1],"start")){ if(!strcasecmp(args[1],"start"))
if(myDet->setReceiverOnline()!=ONLINE_FLAG)
return string("cannot connect to receiver");
if(myDet->getReceiverStatus()==IDLE){
//update receiver index
if(myDet->setReceiverFileIndex(myDet->getFileIndex())==-1)
return string("could not set receiver file index");
//to configure the server
myDet->startReceiver(); myDet->startReceiver();
} else if(!strcasecmp(args[1],"stop"))
} myDet->stopReceiver();
else if(!strcasecmp(args[1],"stop")){
if(myDet->stopReceiver()!=FAIL){
//update index
myDet->setFileIndex(myDet->getFileIndex()+1);
myDet->setReceiverFileIndex(myDet->getFileIndex());
}
else if(myDet->setReceiverOnline()!=ONLINE_FLAG)
return string("cannot connect to receiver");
}
else else
return helpReceiver(narg, args, action); return helpReceiver(narg, args, action);
} }

View File

@ -422,13 +422,14 @@ int slsDetectorUtils::setBadChannelCorrection(string fname, int &nbadtot, int *b
ifstream infile; ifstream infile;
string str; string str;
int interrupt=0; //int interrupt=0;
int ich; //int ich;
int chmin,chmax; //int chmin,chmax;
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Setting bad channel correction to " << fname << std::endl; std::cout << "Setting bad channel correction to " << fname << std::endl;
#endif #endif
int modmi=0, modma=1; // int modmi=0;
int modma=1;
int singlefile=0; int singlefile=0;
string fn; string fn;
@ -615,7 +616,7 @@ int slsDetectorUtils::retrieveDetectorSetup(string const fname1, int level){
slsDetectorCommand *cmd; slsDetectorCommand *cmd;
char ext[100]; // char ext[100];
int skip=0; int skip=0;
string fname; string fname;
string str; string str;
@ -749,7 +750,7 @@ int slsDetectorUtils::dumpDetectorSetup(string const fname, int level){
char ext[100]; // char ext[100];
int iv=0; int iv=0;
string fname1; string fname1;

View File

@ -585,6 +585,33 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
*/ */
virtual string getReceiverLastClientIP()=0; virtual string getReceiverLastClientIP()=0;
/**
Sets up the file directory
@param fileName fileDir file directory
\returns file dir
*/
virtual string setFilePath(string s="")=0;
/**
Sets up the file name
@param fileName file name
\returns file name
*/
virtual string setFileName(string s="")=0;
/**
\returns file dir
*/
virtual string getFilePath()=0;
/**
\returns file name
*/
virtual string getFileName()=0;
protected: protected:
static const int64_t thisSoftwareVersion=0x20120124; static const int64_t thisSoftwareVersion=0x20120124;

View File

@ -23,7 +23,7 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
public: public:
/** default constructor */ /** default constructor */
fileIO(): fileIOStatic() {frameIndex=-1;detIndex=-1;}; fileIO(): fileIOStatic(){frameIndex=-1;detIndex=-1;};
/** virtual destructor */ /** virtual destructor */
virtual ~fileIO(){}; virtual ~fileIO(){};
@ -39,61 +39,61 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
\param s file path \param s file path
\return actual file path \return actual file path
*/ */
string setFilePath(string s) {sprintf(filePath, s.c_str()); return string(filePath);}; virtual string setFilePath(string s) {sprintf(filePath, s.c_str()); return string(filePath);};
/** /**
sets the default output files root name sets the default output files root name
\param s file name to be set \param s file name to be set
\returns actual file name \returns actual file name
*/ */
string setFileName(string s) {sprintf(fileName, s.c_str()); return string(fileName);}; virtual string setFileName(string s) {sprintf(fileName, s.c_str()); return string(fileName);};
/** /**
sets the default output file index sets the default output file index
\param i start file index to be set \param i start file index to be set
\returns actual file index \returns actual file index
*/ */
int setFileIndex(int i) {*fileIndex=i; return *fileIndex;}; virtual int setFileIndex(int i) {*fileIndex=i; return *fileIndex;};
/** /**
sets the default output file index sets the default output file index
\param i frame index to be set \param i frame index to be set
\returns actual frame index \returns actual frame index
*/ */
int setFrameIndex(int i) {frameIndex=i; return frameIndex;}; virtual int setFrameIndex(int i) {frameIndex=i; return frameIndex;};
/** /**
sets the default output file index sets the default output file index
\param i detector index to be set \param i detector index to be set
\returns actual detector index \returns actual detector index
*/ */
int setDetectorIndex(int i) {detIndex=i; return detIndex;}; virtual int setDetectorIndex(int i) {detIndex=i;return detIndex;};
/** /**
\returns the output files path \returns the output files path
*/ */
string getFilePath() {return string(filePath);}; virtual string getFilePath() {return string(filePath);};
/** /**
\returns the output files root name \returns the output files root name
*/ */
string getFileName() {return string(fileName);}; virtual string getFileName() {return string(fileName);};
/** /**
\returns the output file index \returns the output file index
*/ */
int getFileIndex() {return *fileIndex;}; virtual int getFileIndex() {return *fileIndex;};
/** /**
\returns the output frame index \returns the output frame index
*/ */
int getFrameIndex() {return frameIndex;}; virtual int getFrameIndex() {return frameIndex;};
/** /**
\returns the detector index \returns the detector index
*/ */
int getDetectorIndex() {return detIndex;}; virtual int getDetectorIndex() {return detIndex;};
string createFileName(); string createFileName();
@ -227,6 +227,7 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
*/ */
int readDataFile(ifstream &infile, short int *data, int offset=0); int readDataFile(ifstream &infile, short int *data, int offset=0);
friend class slsDetector;
protected: protected:
@ -241,6 +242,9 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
string getCurrentReceiverFilePrefix(){return currentReceiverFilePrefix;}; string getCurrentReceiverFilePrefix(){return currentReceiverFilePrefix;};
string currentFileName; string currentFileName;
string currentReceiverFilePrefix; string currentReceiverFilePrefix;