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
$(CXX) -Wall -o $@ -c $< $(INCLUDES) $(DFLAGS) $(FLAGS) -fPIC $(EPICSFLAGS)
$(CXX) -Wall -o $@ -c $< $(INCLUDES) $(DFLAGS) $(FLAGS) -fPIC $(EPICSFLAGS) -L/usr/lib64/
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)
clean:

View File

@ -108,11 +108,11 @@ enum {
//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 */

View File

@ -117,14 +117,14 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1)
thisMultiDetector->maxNumberOfChannels=0;
/** set trimDsdir, calDir and filePath to default to home directory*/
strcpy(thisMultiDetector->filePath,getenv("HOME"));
/** set fileName to default to run*/
strcpy(thisMultiDetector->fileName,"run");
/** set fileIndex to default to 0*/
thisMultiDetector->fileIndex=0;
/** set progress Index to default to 0*/
thisMultiDetector->progressIndex=0;
/** 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++) {
#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();
//assigned before creating detector
stoppedFlag=&thisMultiDetector->stoppedFlag;
threadedProcessing=&thisMultiDetector->threadedProcessing;
actionMask=&thisMultiDetector->actionMask;
@ -243,13 +222,35 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1)
currentSettings=&thisMultiDetector->currentSettings;
currentThresholdEV=&thisMultiDetector->currentThresholdEV;
filePath=thisMultiDetector->filePath;
fileName=thisMultiDetector->fileName;
fileIndex=&thisMultiDetector->fileIndex;
moveFlag=NULL;
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();
getMaxMods();
@ -3508,7 +3509,6 @@ int multiSlsDetector::readDataFile(string fname, int *data) {
int multiSlsDetector::setReceiverOnline(int off) {
if (off!=GET_ONLINE_FLAG) {
int ret=-100,ret1;
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++)
if (detectors[i]){
@ -3518,9 +3518,7 @@ int multiSlsDetector::setReceiverOnline(int off) {
else if (ret!=ret1)
ret=-1;
}
thisMultiDetector->receiverOnlineFlag=ret;
}
return thisMultiDetector->receiverOnlineFlag;
return ret;
}
@ -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;
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
if (detectors[idet]) {
if(getNumberOfDetectors()>1)
setDetectorIndex(idet);
ret1=detectors[idet]->setReceiverFileName(fileName);
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);
ret1=detectors[idet]->setFileName(s);
if (ret=="error")
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;
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
if (detectors[idet]) {
ret1=detectors[idet]->setReceiverFileIndex(fileIndex);
ret1=detectors[idet]->setFileIndex(i);
if (ret==-100)
ret=ret1;
else if (ret!=ret1)

View File

@ -105,15 +105,12 @@ class multiSlsDetector : public slsDetectorUtils {
/** total number of frames to be acquired */
int totalProgress;
/** current index of the output file */
int fileIndex;
/** path of the output files */
char filePath[MAX_STR_LENGTH];
/** name root of the output files */
char fileName[MAX_STR_LENGTH];
/** path of the output files */
char filePath[MAX_STR_LENGTH];
/** corrections to be applied to the data \see ::correctionFlags */
int correctionMask;
@ -186,10 +183,6 @@ class multiSlsDetector : public slsDetectorUtils {
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();
/**
Sets up the receiver file name
@param fileName file name
\returns file name
*/
string setReceiverFileName(string fileName="");
/**
Sets up the receiver file directory
@param fileName fileDir file directory
Sets up the file directory
@param s file directory
\returns file dir
*/
string setReceiverFileDir(string fileDir="");
string setFilePath(string s="");
/**
Sets up the receiver file index
@param fileIndex file index
Sets up the file name
@param s file name
\returns file name
*/
string setFileName(string s="");
/**
Sets up the file index
@param i 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

View File

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

View File

@ -100,12 +100,9 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
int progressIndex;
/** total number of frames to be acquired */
int totalProgress;
/** current index of the output file */
int fileIndex;
/** path of the output files */
char filePath[MAX_STR_LENGTH];
/** name root of the output files */
char fileName[MAX_STR_LENGTH];
/* size of the detector */
@ -1392,26 +1389,42 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
*/
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
@param fileName fileDir file directory
Sets up the file directory
@param s fileDir file directory
\returns file dir
*/
string setReceiverFileDir(string fileDir="");
string setFilePath(string s="");
/**
Sets up the receiver file index
@param fileIndex file index
Sets up the file name
@param s file name
\returns file name
*/
string setFileName(string s="");
/**
Sets up the file index
@param i 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
@ -1424,6 +1437,8 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
*/
int stopReceiver();
int DetectorStopReceiver();
/** gets the status of the listening mode of receiver
\returns status
*/

View File

@ -430,28 +430,6 @@ class slsDetectorBase : public virtual slsDetectorDefs {
*/
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
\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");
#endif
myDet->setOnline(ONLINE_FLAG);
bool receiver=myDet->setReceiverOnline();
//receiver
if(myDet->setReceiverOnline()==ONLINE_FLAG){
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();
if(receiver)
if(myDet->startReceiver()==OK)
usleep(2000000);
if(myDet->getReceiverStatus()!=RUNNING)
return string("could not start receiver");
}
}
else return string("could not start receiver");
myDet->acquire();
if(receiver)
myDet->stopReceiver();
return string("");
}
@ -1336,25 +1330,11 @@ string slsDetectorCommand::helpTrimEn(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);
}
if(myDet->setReceiverOnline()==ONLINE_FLAG){
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
else if(action==PUT_ACTION)
myDet->setFilePath(string(args[1]));
}
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){
if (action==HELP_ACTION) {
if (action==HELP_ACTION)
return helpFileName(narg, args, action);
}
if(myDet->setReceiverOnline()==ONLINE_FLAG){
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)
else if (action==PUT_ACTION)
myDet->setFileName(string(args[1]));
return string(myDet->getFileName());
@ -1443,21 +1414,11 @@ string slsDetectorCommand::cmdFileIndex(int narg, char *args[], int action){
if (action==HELP_ACTION) {
return helpFileName(narg, args, action);
}
else if (action==PUT_ACTION)
else if (action==PUT_ACTION){
if(!sscanf(args[1],"%d",&i))
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);
}
sprintf(ans,"%d", myDet->getFileIndex());
return string(ans);
@ -2193,23 +2154,9 @@ string slsDetectorCommand::cmdNetworkParameter(int narg, char *args[], int actio
t=SERVER_MAC;
} else return ("unknown network parameter")+cmd;
if (action==PUT_ACTION){
if(!strcmp(myDet->setNetworkParameter(t, args[1]),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");
}
}
}
if (action==PUT_ACTION)
myDet->setNetworkParameter(t, args[1]);
return myDet->getNetworkParameter(t);
}
@ -2313,15 +2260,11 @@ string slsDetectorCommand::cmdLock(int narg, char *args[], int action) {
else if(cmd=="r_lock"){
if(myDet->setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG)
return string("could not connect to receiver");
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]);
if(myDet->lockReceiver(val)!=val)
return string("could not lock/unlock receiver");
}
sprintf(ans,"%d",myDet->lockReceiver());
}
@ -2361,18 +2304,16 @@ string slsDetectorCommand::cmdLastClient(int narg, char *args[], int action) {
if (action==PUT_ACTION)
return string("cannot set");
if(cmd=="lastclient"){
myDet->setOnline(ONLINE_FLAG);
return myDet->getLastClientIP();
}
else if(cmd=="r_lastclient"){
if(myDet->setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG)
return string("could not connect to receiver");
else if(cmd=="r_lastclient")
return myDet->getReceiverLastClientIP();
}
return string("cannot decode command");
}
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->setReceiverOnline(ONLINE_FLAG);
if(cmd=="receiver"){
if (action==PUT_ACTION) {
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
if(!strcasecmp(args[1],"start"))
myDet->startReceiver();
}
}
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 if(!strcasecmp(args[1],"stop"))
myDet->stopReceiver();
else
return helpReceiver(narg, args, action);
}

View File

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

View File

@ -585,6 +585,33 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
*/
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:
static const int64_t thisSoftwareVersion=0x20120124;

View File

@ -39,61 +39,61 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
\param s 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
\param s file name to be set
\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
\param i start file index to be set
\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
\param i frame index to be set
\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
\param i detector index to be set
\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
*/
string getFilePath() {return string(filePath);};
virtual string getFilePath() {return string(filePath);};
/**
\returns the output files root name
*/
string getFileName() {return string(fileName);};
virtual string getFileName() {return string(fileName);};
/**
\returns the output file index
*/
int getFileIndex() {return *fileIndex;};
virtual int getFileIndex() {return *fileIndex;};
/**
\returns the output frame index
*/
int getFrameIndex() {return frameIndex;};
virtual int getFrameIndex() {return frameIndex;};
/**
\returns the detector index
*/
int getDetectorIndex() {return detIndex;};
virtual int getDetectorIndex() {return detIndex;};
string createFileName();
@ -227,6 +227,7 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
*/
int readDataFile(ifstream &infile, short int *data, int offset=0);
friend class slsDetector;
protected:
@ -241,6 +242,9 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
string getCurrentReceiverFilePrefix(){return currentReceiverFilePrefix;};
string currentFileName;
string currentReceiverFilePrefix;