From f6a2d599a0cfaf9d6f157c9d90a9c83492bc7128 Mon Sep 17 00:00:00 2001 From: l_maliakal_d Date: Thu, 11 Oct 2012 16:17:07 +0000 Subject: [PATCH] indenting to emacs format and including check and start receiver before doing acquire or status start git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@291 951219d9-93cf-4727-9268-0efd64621fa3 --- .../multiSlsDetector/multiSlsDetector.cpp | 1006 ++--- .../multiSlsDetector/multiSlsDetector.h | 556 +-- .../slsDetector/slsDetector.cpp | 3245 ++++++++--------- slsDetectorSoftware/slsDetector/slsDetector.h | 704 ++-- .../slsDetector/slsDetectorBase.h | 404 +- .../slsDetector/slsDetectorCommand.cpp | 859 ++--- .../slsDetector/slsDetectorCommand.h | 250 +- .../slsDetector/slsDetectorUtils.cpp | 568 +-- .../slsDetector/slsDetectorUtils.h | 160 +- .../slsDetectorAnalysis/energyConversion.cpp | 200 +- 10 files changed, 3984 insertions(+), 3968 deletions(-) diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 47aee0190..eb07b84a9 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -24,7 +24,7 @@ ID: $Id$ using namespace std; - char ans[MAX_STR_LENGTH]; +char ans[MAX_STR_LENGTH]; int multiSlsDetector::freeSharedMemory() { // Detach Memory address @@ -34,18 +34,18 @@ int multiSlsDetector::freeSharedMemory() { } - if (shmdt(thisMultiDetector) == -1) { - perror("shmdt failed\n"); - return FAIL; - } - printf("Shared memory %d detached\n", shmId); - // remove shared memory - if (shmctl(shmId, IPC_RMID, 0) == -1) { - perror("shmctl(IPC_RMID) failed\n"); - return FAIL; - } - printf("Shared memory %d deleted\n", shmId); - return OK; + if (shmdt(thisMultiDetector) == -1) { + perror("shmdt failed\n"); + return FAIL; + } + printf("Shared memory %d detached\n", shmId); + // remove shared memory + if (shmctl(shmId, IPC_RMID, 0) == -1) { + perror("shmctl(IPC_RMID) failed\n"); + return FAIL; + } + printf("Shared memory %d deleted\n", shmId); + return OK; } @@ -62,19 +62,19 @@ int multiSlsDetector::initSharedMemory(int id=0) { sz=sizeof(sharedMultiSlsDetector); - #ifdef VERBOSE +#ifdef VERBOSE std::cout<<"multiSlsDetector: Size of shared memory is "<< sz << " - id " << mem_key << std::endl; #endif - shm_id = shmget(mem_key,sz,IPC_CREAT | 0666); // allocate shared memory + shm_id = shmget(mem_key,sz,IPC_CREAT | 0666); // allocate shared memory if (shm_id < 0) { std::cout<<"*** shmget error (server) ***"<< shm_id << std::endl; return shm_id; } - /** - thisMultiDetector pointer is set to the memory address of the shared memory - */ + /** + thisMultiDetector pointer is set to the memory address of the shared memory + */ thisMultiDetector = (sharedMultiSlsDetector*) shmat(shm_id, NULL, 0); /* attach */ @@ -82,9 +82,9 @@ int multiSlsDetector::initSharedMemory(int id=0) { std::cout<<"*** shmat error (server) ***" << std::endl; return shm_id; } - /** - shm_id returns -1 is shared memory initialization fails - */ + /** + shm_id returns -1 is shared memory initialization fails + */ return shm_id; @@ -119,71 +119,71 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1) - /** 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*/ - thisMultiDetector->totalProgress=1; + /** 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*/ + thisMultiDetector->totalProgress=1; - /** set correction mask to 0*/ - thisMultiDetector->correctionMask=1<tDead=0; - /** sets bad channel list file to none */ - strcpy(thisMultiDetector->badChanFile,"none"); - /** sets flat field correction directory */ - strcpy(thisMultiDetector->flatFieldDir,getenv("HOME")); - /** sets flat field correction file */ - strcpy(thisMultiDetector->flatFieldFile,"none"); - /** set angular direction to 1*/ - thisMultiDetector->angDirection=1; - /** set fine offset to 0*/ - thisMultiDetector->fineOffset=0; - /** set global offset to 0*/ - thisMultiDetector->globalOffset=0; + /** set correction mask to 0*/ + thisMultiDetector->correctionMask=1<tDead=0; + /** sets bad channel list file to none */ + strcpy(thisMultiDetector->badChanFile,"none"); + /** sets flat field correction directory */ + strcpy(thisMultiDetector->flatFieldDir,getenv("HOME")); + /** sets flat field correction file */ + strcpy(thisMultiDetector->flatFieldFile,"none"); + /** set angular direction to 1*/ + thisMultiDetector->angDirection=1; + /** set fine offset to 0*/ + thisMultiDetector->fineOffset=0; + /** set global offset to 0*/ + thisMultiDetector->globalOffset=0; - /** set threshold to -1*/ - thisMultiDetector->currentThresholdEV=-1; - // /** set clockdivider to 1*/ - // thisMultiDetector->clkDiv=1; - /** set number of positions to 0*/ - thisMultiDetector->numberOfPositions=0; - /** sets angular conversion file to none */ - strcpy(thisMultiDetector->angConvFile,"none"); - /** set binsize*/ - thisMultiDetector->binSize=0.001; - thisMultiDetector->stoppedFlag=0; + /** set threshold to -1*/ + thisMultiDetector->currentThresholdEV=-1; + // /** set clockdivider to 1*/ + // thisMultiDetector->clkDiv=1; + /** set number of positions to 0*/ + thisMultiDetector->numberOfPositions=0; + /** sets angular conversion file to none */ + strcpy(thisMultiDetector->angConvFile,"none"); + /** set binsize*/ + thisMultiDetector->binSize=0.001; + thisMultiDetector->stoppedFlag=0; - thisMultiDetector->threadedProcessing=1; + thisMultiDetector->threadedProcessing=1; - thisMultiDetector->actionMask=0; + thisMultiDetector->actionMask=0; - for (int ia=0; iaactionMode[ia]=0; - strcpy(thisMultiDetector->actionScript[ia],"none"); - strcpy(thisMultiDetector->actionParameter[ia],"none"); - } + for (int ia=0; iaactionMode[ia]=0; + strcpy(thisMultiDetector->actionScript[ia],"none"); + strcpy(thisMultiDetector->actionParameter[ia],"none"); + } - for (int iscan=0; iscanscanMode[iscan]=0; - strcpy(thisMultiDetector->scanScript[iscan],"none"); - strcpy(thisMultiDetector->scanParameter[iscan],"none"); - thisMultiDetector->nScanSteps[iscan]=0; - thisMultiDetector->scanPrecision[iscan]=0; - } + thisMultiDetector->scanMode[iscan]=0; + strcpy(thisMultiDetector->scanScript[iscan],"none"); + strcpy(thisMultiDetector->scanParameter[iscan],"none"); + thisMultiDetector->nScanSteps[iscan]=0; + thisMultiDetector->scanPrecision[iscan]=0; + } @@ -208,50 +208,50 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1) - /** modifies the last PID accessing the detector system*/ + /** modifies the last PID accessing the detector system*/ thisMultiDetector->lastPID=getpid(); - stoppedFlag=&thisMultiDetector->stoppedFlag; - threadedProcessing=&thisMultiDetector->threadedProcessing; - actionMask=&thisMultiDetector->actionMask; - actionScript=thisMultiDetector->actionScript; - actionParameter=thisMultiDetector->actionParameter; - nScanSteps=thisMultiDetector->nScanSteps; - scanMode=thisMultiDetector->scanMode; - scanScript=thisMultiDetector->scanScript; - scanParameter=thisMultiDetector->scanParameter; - scanSteps=thisMultiDetector->scanSteps; - scanPrecision=thisMultiDetector->scanPrecision; - numberOfPositions=&thisMultiDetector->numberOfPositions; - detPositions=thisMultiDetector->detPositions; - angConvFile=thisMultiDetector->angConvFile; - correctionMask=&thisMultiDetector->correctionMask; - binSize=&thisMultiDetector->binSize; - fineOffset=&thisMultiDetector->fineOffset; - globalOffset=&thisMultiDetector->globalOffset; - angDirection=&thisMultiDetector->angDirection; - flatFieldDir=thisMultiDetector->flatFieldDir; - flatFieldFile=thisMultiDetector->flatFieldFile; - badChanFile=thisMultiDetector->badChanFile; - timerValue=thisMultiDetector->timerValue; + stoppedFlag=&thisMultiDetector->stoppedFlag; + threadedProcessing=&thisMultiDetector->threadedProcessing; + actionMask=&thisMultiDetector->actionMask; + actionScript=thisMultiDetector->actionScript; + actionParameter=thisMultiDetector->actionParameter; + nScanSteps=thisMultiDetector->nScanSteps; + scanMode=thisMultiDetector->scanMode; + scanScript=thisMultiDetector->scanScript; + scanParameter=thisMultiDetector->scanParameter; + scanSteps=thisMultiDetector->scanSteps; + scanPrecision=thisMultiDetector->scanPrecision; + numberOfPositions=&thisMultiDetector->numberOfPositions; + detPositions=thisMultiDetector->detPositions; + angConvFile=thisMultiDetector->angConvFile; + correctionMask=&thisMultiDetector->correctionMask; + binSize=&thisMultiDetector->binSize; + fineOffset=&thisMultiDetector->fineOffset; + globalOffset=&thisMultiDetector->globalOffset; + angDirection=&thisMultiDetector->angDirection; + flatFieldDir=thisMultiDetector->flatFieldDir; + flatFieldFile=thisMultiDetector->flatFieldFile; + badChanFile=thisMultiDetector->badChanFile; + timerValue=thisMultiDetector->timerValue; - expTime=&timerValue[ACQUISITION_TIME]; + expTime=&timerValue[ACQUISITION_TIME]; - currentSettings=&thisMultiDetector->currentSettings; - currentThresholdEV=&thisMultiDetector->currentThresholdEV; - filePath=thisMultiDetector->filePath; - fileName=thisMultiDetector->fileName; - fileIndex=&thisMultiDetector->fileIndex; - moveFlag=NULL; + currentSettings=&thisMultiDetector->currentSettings; + currentThresholdEV=&thisMultiDetector->currentThresholdEV; + filePath=thisMultiDetector->filePath; + fileName=thisMultiDetector->fileName; + fileIndex=&thisMultiDetector->fileIndex; + moveFlag=NULL; - sampleDisplacement=thisMultiDetector->sampleDisplacement; + sampleDisplacement=thisMultiDetector->sampleDisplacement; - getNMods(); - getMaxMods(); + getNMods(); + getMaxMods(); } @@ -409,7 +409,7 @@ string multiSlsDetector::getHostname(int pos) { } else { for (int ip=0; ipnumberOfDetectors; ip++) { #ifdef VERBOSE - cout << "detector " << ip << endl; + cout << "detector " << ip << endl; #endif if (detectors[ip]) { s+=detectors[ip]->getHostname(); @@ -417,7 +417,7 @@ string multiSlsDetector::getHostname(int pos) { } cout << s <getDetectorsType(); } else if (detectors[0]) - return detectors[0]->getDetectorsType(); + return detectors[0]->getDetectorsType(); return s; } @@ -454,14 +454,14 @@ string multiSlsDetector::sgetDetectorsType(int pos) { } else { for (int ip=0; ipnumberOfDetectors; ip++) { #ifdef VERBOSE - cout << "detector " << ip << endl; + cout << "detector " << ip << endl; #endif if (detectors[ip]) { s+=detectors[ip]->sgetDetectorsType(); s+=string("+"); } #ifdef VERBOSE - cout << "type " << s << endl; + cout << "type " << s << endl; #endif } } @@ -523,7 +523,7 @@ int multiSlsDetector::addSlsDetector(const char *name, int pos) { } } - //checking that the detector doesn't already exists + //checking that the detector doesn't already exists for (id=0; id0) { @@ -680,8 +680,8 @@ int multiSlsDetector::removeSlsDetector(int pos) { single=1; } -// if (pos<0 ) -// pos=thisMultiDetector->numberOfDetectors-1; + // if (pos<0 ) + // pos=thisMultiDetector->numberOfDetectors-1; if (pos>=thisMultiDetector->numberOfDetectors) return thisMultiDetector->numberOfDetectors; @@ -734,14 +734,14 @@ int multiSlsDetector::setMaster(int i) { #ifdef VERBOSE cout << "detector position " << i << " "; #endif - thisMultiDetector->masterPosition=i; - detectors[i]->setMaster(IS_MASTER); + thisMultiDetector->masterPosition=i; + detectors[i]->setMaster(IS_MASTER); } for (int id=0; idnumberOfDetectors; id++) { if (i!=id) { if (detectors[id]) { #ifdef VERBOSE - cout << "detector position " << id << " "; + cout << "detector position " << id << " "; #endif detectors[id]->setMaster(IS_SLAVE); } @@ -750,12 +750,12 @@ int multiSlsDetector::setMaster(int i) { } else if (i==-2) { for (int id=0; idnumberOfDetectors; id++) { - if (detectors[id]) { + if (detectors[id]) { #ifdef VERBOSE - cout << "detector position " << id << " "; + cout << "detector position " << id << " "; #endif - detectors[id]->setMaster(NO_MASTER); - } + detectors[id]->setMaster(NO_MASTER); + } } } @@ -806,11 +806,11 @@ int multiSlsDetector::setMaster(int i) { // SLAVE_STARTS_WHEN_MASTER_STOPS /**< the slave acquires when the master finishes, to avoid deadtime */ // } - /** - Sets/gets the synchronization mode of the various detectors - \param sync syncronization mode - \returns current syncronization mode - */ +/** + Sets/gets the synchronization mode of the various detectors + \param sync syncronization mode + \returns current syncronization mode +*/ slsDetectorDefs::synchronizationMode multiSlsDetector::setSynchronization(synchronizationMode sync) { @@ -900,7 +900,7 @@ int multiSlsDetector::exists() { - // Initialization functions +// Initialization functions @@ -1067,7 +1067,7 @@ int multiSlsDetector::getChanRegs(double* retval,bool fromDetector){ - /* Communication to server */ +/* Communication to server */ @@ -1129,7 +1129,7 @@ int multiSlsDetector::stopAcquisition(){ int multiSlsDetector::startReadOut(){ - int i=0; + int i=0; int ret=OK, ret1=OK; i=thisMultiDetector->masterPosition; if (i>=0) { @@ -1274,7 +1274,7 @@ int* multiSlsDetector::readAll(){ } } - } + } #ifdef VERBOSE std::cout<< "received "<< i<< " frames" << std::endl; @@ -1315,7 +1315,7 @@ int* multiSlsDetector::startAndReadAll(){ } } - } + } #ifdef VERBOSE std::cout<< "MMMM recieved "<< i<< " frames" << std::endl; @@ -1334,23 +1334,23 @@ int multiSlsDetector::startAndReadAllNoWait(){ int i=0; int ret=OK, ret1=OK; - for (i=0; inumberOfDetectors; i++) { - if (i!=thisMultiDetector->masterPosition) - if (detectors[i]) { - ret=detectors[i]->startAndReadAllNoWait(); - if (ret!=OK) - ret1=FAIL; - } - } - i=thisMultiDetector->masterPosition; - if (thisMultiDetector->masterPosition>=0) { + for (i=0; inumberOfDetectors; i++) { + if (i!=thisMultiDetector->masterPosition) if (detectors[i]) { ret=detectors[i]->startAndReadAllNoWait(); if (ret!=OK) ret1=FAIL; } + } + i=thisMultiDetector->masterPosition; + if (thisMultiDetector->masterPosition>=0) { + if (detectors[i]) { + ret=detectors[i]->startAndReadAllNoWait(); + if (ret!=OK) + ret1=FAIL; } - return ret1; + } + return ret1; } @@ -1422,19 +1422,19 @@ void multiSlsDetector::resetFinalDataQueue() { - /* - set or read the acquisition timers - enum timerIndex { - FRAME_NUMBER, - ACQUISITION_TIME, - FRAME_PERIOD, - DELAY_AFTER_TRIGGER, - GATES_NUMBER, - PROBES_NUMBER - CYCLES_NUMBER, - GATE_INTEGRATED_TIME - } - */ +/* + set or read the acquisition timers + enum timerIndex { + FRAME_NUMBER, + ACQUISITION_TIME, + FRAME_PERIOD, + DELAY_AFTER_TRIGGER, + GATES_NUMBER, + PROBES_NUMBER + CYCLES_NUMBER, + GATE_INTEGRATED_TIME + } +*/ int64_t multiSlsDetector::setTimer(timerIndex index, int64_t t){ int i; int64_t ret1=-100, ret; @@ -1451,7 +1451,7 @@ int64_t multiSlsDetector::setTimer(timerIndex index, int64_t t){ } } -// check return values!!! + // check return values!!! thisMultiDetector->timerValue[index]=ret1; @@ -1522,7 +1522,7 @@ int multiSlsDetector::setSpeed(speedVariable index, int value){ - // Flags +// Flags int multiSlsDetector::setDynamicRange(int n, int pos){ // cout << "multi " << endl; @@ -1588,10 +1588,10 @@ double* multiSlsDetector::decodeData(int *datain, double *fdata) { #ifdef VERBOSE cout << "done " << endl; #endif -// for (int j=0; jgetTotalNumberOfChannels(); j++) { -// dataout[ich]=detp[j]; -// ich++; -// } + // for (int j=0; jgetTotalNumberOfChannels(); j++) { + // dataout[ich]=detp[j]; + // ich++; + // } //delete [] detp; } } @@ -1600,15 +1600,15 @@ double* multiSlsDetector::decodeData(int *datain, double *fdata) { } //Correction - /* - enum correctionFlags { - DISCARD_BAD_CHANNELS, - AVERAGE_NEIGHBOURS_FOR_BAD_CHANNELS, - FLAT_FIELD_CORRECTION, - RATE_CORRECTION, - ANGULAR_CONVERSION - } - */ +/* + enum correctionFlags { + DISCARD_BAD_CHANNELS, + AVERAGE_NEIGHBOURS_FOR_BAD_CHANNELS, + FLAT_FIELD_CORRECTION, + RATE_CORRECTION, + ANGULAR_CONVERSION + } +*/ /////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1902,9 +1902,9 @@ int multiSlsDetector::getRateCorrection(double &t){ } else t=0; #ifdef VERBOSE - std::cout<< "Rate correction is disabled " << std::endl; + std::cout<< "Rate correction is disabled " << std::endl; #endif - return 0; + return 0; }; double multiSlsDetector::getRateCorrectionTau(){ @@ -2054,7 +2054,7 @@ int multiSlsDetector::setBadChannelCorrection(int nbad, int *badlist, int ff) { #ifdef VERBOSE cout << "setting " << 0 << " badchans to detector " << idet << endl; #endif - detectors[idet]->setBadChannelCorrection(nbaddet,badlist,0); + detectors[idet]->setBadChannelCorrection(nbaddet,badlist,0); } } thisMultiDetector->correctionMask&=~(1<setDAC(val, idac, im); - if (ret1==-100) - ret1=ret; - else if (ret!=ret1) - ret1=-1; - } - } - return ret1; + for (int idet=dmi; idetsetDAC(val, idac, im); + if (ret1==-100) + ret1=ret; + else if (ret!=ret1) + ret1=-1; + } + } + return ret1; } dacs_t multiSlsDetector::getADC(dacIndex idac, int imod) { @@ -2182,16 +2182,16 @@ dacs_t multiSlsDetector::getADC(dacIndex idac, int imod) { dma=dma+1; } - for (int idet=dmi; idetgetADC(idac, im); - if (ret1==-100) - ret1=ret; - else if (ret!=ret1) - ret1=-1; - } - } - return ret1; + for (int idet=dmi; idetgetADC(idac, im); + if (ret1==-100) + ret1=ret; + else if (ret!=ret1) + ret1=-1; + } + } + return ret1; } int multiSlsDetector::setChannel(long long reg, int ichan, int ichip, int imod) { @@ -2218,21 +2218,21 @@ int multiSlsDetector::setChannel(long long reg, int ichan, int ichip, int imod) - /** - sets the value of s angular conversion parameter - \param c can be ANGULAR_DIRECTION, GLOBAL_OFFSET, FINE_OFFSET, BIN_SIZE - \param v the value to be set - \returns the actual value - */ +/** + sets the value of s angular conversion parameter + \param c can be ANGULAR_DIRECTION, GLOBAL_OFFSET, FINE_OFFSET, BIN_SIZE + \param v the value to be set + \returns the actual value +*/ double multiSlsDetector::setAngularConversionParameter(angleConversionParameter c, double v) { double ret=slsDetectorUtils::setAngularConversionParameter(c,v); for (int idet=0; idetnumberOfDetectors; idet++) { - if (detectors[idet]) { + if (detectors[idet]) { - detectors[idet]->setAngularConversionParameter(c,v); - } + detectors[idet]->setAngularConversionParameter(c,v); + } } return ret; } @@ -2307,7 +2307,7 @@ int multiSlsDetector::exitServer() { } - /** returns the detector trimbit/settings directory */ +/** returns the detector trimbit/settings directory */ char* multiSlsDetector::getSettingsDir() { string s0="", s1="", s; @@ -2336,7 +2336,7 @@ char* multiSlsDetector::getSettingsDir() { - /** sets the detector trimbit/settings directory \sa sharedSlsDetector */ +/** sets the detector trimbit/settings directory \sa sharedSlsDetector */ char* multiSlsDetector::setSettingsDir(string s){ if (s.find('+')==string::npos) { @@ -2414,10 +2414,10 @@ int multiSlsDetector::getTrimEn(int *ene) { - /** - returns the location of the calibration files - \sa sharedSlsDetector - */ +/** + returns the location of the calibration files + \sa sharedSlsDetector +*/ char* multiSlsDetector::getCalDir() { string s0="", s1="", s; //char ans[1000]; @@ -2443,10 +2443,10 @@ char* multiSlsDetector::getCalDir() { } - /** - sets the location of the calibration files - \sa sharedSlsDetector - */ +/** + sets the location of the calibration files + \sa sharedSlsDetector +*/ char* multiSlsDetector::setCalDir(string s){ if (s.find('+')==string::npos) { @@ -2476,10 +2476,10 @@ char* multiSlsDetector::setCalDir(string s){ } - /** - returns the location of the calibration files - \sa sharedSlsDetector - */ +/** + returns the location of the calibration files + \sa sharedSlsDetector +*/ char* multiSlsDetector::getNetworkParameter(networkParameter p) { string s0="", s1="",s ; @@ -2506,10 +2506,10 @@ char* multiSlsDetector::getNetworkParameter(networkParameter p) { } - /** - sets the location of the calibration files - \sa sharedSlsDetector - */ +/** + sets the location of the calibration files + \sa sharedSlsDetector +*/ char* multiSlsDetector::setNetworkParameter(networkParameter p, string s){ if (s.find('+')==string::npos) { @@ -2592,7 +2592,7 @@ string multiSlsDetector::getLastClientIP() { } } if (s1=="bad") - return s0; + return s0; else return s1; } @@ -2681,7 +2681,7 @@ slsDetectorDefs::externalSignalFlag multiSlsDetector::setExternalSignalFlags(ext const char * multiSlsDetector::getSettingsFile() { - string s0="", s1="",s ; + string s0="", s1="",s ; for (int idet=0; idetnumberOfDetectors; idet++) { if (detectors[idet]) { @@ -2726,86 +2726,86 @@ int multiSlsDetector::configureMAC() { int multiSlsDetector::loadImageToDetector(imageType index,string const fname){ - int ret=-100, ret1; - short int imageVals[thisMultiDetector->numberOfChannels]; + int ret=-100, ret1; + short int imageVals[thisMultiDetector->numberOfChannels]; - ifstream infile; - infile.open(fname.c_str(), ios_base::in); - if (infile.is_open()) { + ifstream infile; + infile.open(fname.c_str(), ios_base::in); + if (infile.is_open()) { #ifdef VERBOSE - std::cout<< std::endl<< "Loading "; - if(!index) - std::cout<<"Dark"; - else - std::cout<<"Gain"; - std::cout<<" image from file " << fname << std::endl; + std::cout<< std::endl<< "Loading "; + if(!index) + std::cout<<"Dark"; + else + std::cout<<"Gain"; + std::cout<<" image from file " << fname << std::endl; #endif - for (int idet=0; idetnumberOfDetectors; idet++) { - if (detectors[idet]) { - if(detectors[idet]->readDataFile(infile,imageVals)>=0){ - ret1=detectors[idet]->sendImageToDetector(index,imageVals); - if (ret==-100) - ret=ret1; - else if (ret!=ret1) - ret=-1; - } - } - } - infile.close(); - } else { - std::cout<< "Could not open file "<< fname << std::endl; - return -1; + for (int idet=0; idetnumberOfDetectors; idet++) { + if (detectors[idet]) { + if(detectors[idet]->readDataFile(infile,imageVals)>=0){ + ret1=detectors[idet]->sendImageToDetector(index,imageVals); + if (ret==-100) + ret=ret1; + else if (ret!=ret1) + ret=-1; } - return ret; + } + } + infile.close(); + } else { + std::cout<< "Could not open file "<< fname << std::endl; + return -1; + } + return ret; } int multiSlsDetector::writeCounterBlockFile(string const fname,int startACQ){ - int ret=OK, ret1=OK; - short int arg[thisMultiDetector->numberOfChannels]; - ofstream outfile; - outfile.open(fname.c_str(), ios_base::out); - if (outfile.is_open()) { + int ret=OK, ret1=OK; + short int arg[thisMultiDetector->numberOfChannels]; + ofstream outfile; + outfile.open(fname.c_str(), ios_base::out); + if (outfile.is_open()) { #ifdef VERBOSE - std::cout<< std::endl<< "Reading Counter to \""<numberOfDetectors; idet++) { - if (detectors[idet]) { - ret1=detectors[idet]->getCounterBlock(arg,startACQ); - if(ret1!=OK) - ret=FAIL; - else{ - ret1=detectors[idet]->writeDataFile(outfile,arg); - if(ret1!=OK) - ret=FAIL; - } - } - } - outfile.close(); - } else { - std::cout<< "Could not open file "<< fname << std::endl; - return -1; + for (int idet=0; idetnumberOfDetectors; idet++) { + if (detectors[idet]) { + ret1=detectors[idet]->getCounterBlock(arg,startACQ); + if(ret1!=OK) + ret=FAIL; + else{ + ret1=detectors[idet]->writeDataFile(outfile,arg); + if(ret1!=OK) + ret=FAIL; } - return ret; + } + } + outfile.close(); + } else { + std::cout<< "Could not open file "<< fname << std::endl; + return -1; + } + return ret; } int multiSlsDetector::resetCounterBlock(int startACQ){ - int ret=-100, ret1; - for (int idet=0; idetnumberOfDetectors; idet++) { - if (detectors[idet]) { - ret1=detectors[idet]->resetCounterBlock(startACQ); - if (ret==-100) - ret=ret1; - else if (ret!=ret1) - ret=-1; - } - } - return ret; + int ret=-100, ret1; + for (int idet=0; idetnumberOfDetectors; idet++) { + if (detectors[idet]) { + ret1=detectors[idet]->resetCounterBlock(startACQ); + if (ret==-100) + ret=ret1; + else if (ret!=ret1) + ret=-1; + } + } + return ret; } @@ -2925,7 +2925,7 @@ int multiSlsDetector::decodeNMod(int i, int &id, int &im) { id=idet; im=i; #ifdef VERBOSE - cout << " B---------" <numberOfDetectors; - for (int i=0; ifreeSharedMemory(); - } + for (int i=0; ifreeSharedMemory(); } - thisMultiDetector->numberOfDetectors=0; + } + thisMultiDetector->numberOfDetectors=0; multiSlsDetectorClient *cmd; char ext[100]; - string ans; - string str; - ifstream infile; - int iargval; - int interrupt=0; - char *args[1000]; + string ans; + string str; + ifstream infile; + int iargval; + int interrupt=0; + char *args[1000]; - char myargs[1000][1000]; + char myargs[1000][1000]; - string sargname, sargval; - int iline=0; - std::cout<< "config file name "<< fname << std::endl; - infile.open(fname.c_str(), ios_base::in); - if (infile.is_open()) { + string sargname, sargval; + int iline=0; + std::cout<< "config file name "<< fname << std::endl; + infile.open(fname.c_str(), ios_base::in); + if (infile.is_open()) { while (infile.good() and interrupt==0) { - sargname="none"; - sargval="0"; - getline(infile,str); - iline++; + sargname="none"; + sargval="0"; + getline(infile,str); + iline++; #ifdef VERBOSE - std::cout<< str << std::endl; + std::cout<< str << std::endl; #endif - if (str.find('#')!=string::npos) { + if (str.find('#')!=string::npos) { #ifdef VERBOSE - std::cout<< "Line is a comment " << std::endl; - std::cout<< str << std::endl; + std::cout<< "Line is a comment " << std::endl; + std::cout<< str << std::endl; #endif - continue; - } else if (str.length()<2) { + continue; + } else if (str.length()<2) { #ifdef VERBOSE - std::cout<< "Empty line " << std::endl; + std::cout<< "Empty line " << std::endl; #endif - continue; - } else { - istringstream ssstr(str); - iargval=0; - while (ssstr.good()) { - ssstr >> sargname; - //if (ssstr.good()) { + continue; + } else { + istringstream ssstr(str); + iargval=0; + while (ssstr.good()) { + ssstr >> sargname; + //if (ssstr.good()) { #ifdef VERBOSE - std::cout<< iargval << " " << sargname << std::endl; + std::cout<< iargval << " " << sargname << std::endl; #endif - strcpy(myargs[iargval], sargname.c_str()); - args[iargval]=myargs[iargval]; + strcpy(myargs[iargval], sargname.c_str()); + args[iargval]=myargs[iargval]; #ifdef VERBOSE - std::cout<< "--" << iargval << " " << args[iargval] << std::endl; + std::cout<< "--" << iargval << " " << args[iargval] << std::endl; #endif - iargval++; - //} - } - -#ifdef VERBOSE - cout << endl; - for (int ia=0; ianumberOfDetectors; i++) { + for (int i=0; inumberOfDetectors; i++) { - if (detectors[i]) { - n=detectors[i]->getTotalNumberOfChannels(); - if (nch_leftgetTotalNumberOfChannels(); + if (nch_leftwriteDataFile(outfile,n, data+off, pe, pa, dataformat, choff); + detectors[i]->writeDataFile(outfile,n, data+off, pe, pa, dataformat, choff); - nch_left-=n; + nch_left-=n; - choff+=detectors[i]->getMaxNumberOfChannels(); + choff+=detectors[i]->getMaxNumberOfChannels(); - off+=n; + off+=n; - if (pe) - pe=err+off; + if (pe) + pe=err+off; - if (pa) - pa=ang+off; + if (pa) + pa=ang+off; - } + } - } + } - outfile.close(); - return OK; - } else { + outfile.close(); + return OK; + } else { std::cout<< "Could not open file " << fname << "for writing"<< std::endl; return FAIL; } @@ -3404,22 +3404,22 @@ int multiSlsDetector::writeDataFile(string fname, int *data) { outfile.open (fname.c_str(),ios_base::out); if (outfile.is_open()) - { - for (int i=0; inumberOfDetectors; i++) { - if (detectors[i]) { + { + for (int i=0; inumberOfDetectors; i++) { + if (detectors[i]) { #ifdef VERBOSE - cout << " write " << i << " position " << off << " offset " << choff << endl; + cout << " write " << i << " position " << off << " offset " << choff << endl; #endif - detectors[i]->writeDataFile(outfile, detectors[i]->getTotalNumberOfChannels(), data+off, choff); - choff+=detectors[i]->getMaxNumberOfChannels(); - off+=detectors[i]->getTotalNumberOfChannels(); + detectors[i]->writeDataFile(outfile, detectors[i]->getTotalNumberOfChannels(), data+off, choff); + choff+=detectors[i]->getMaxNumberOfChannels(); + off+=detectors[i]->getTotalNumberOfChannels(); + } } - } - outfile.close(); - return OK; - } else { + outfile.close(); + return OK; + } else { std::cout<< "Could not open file " << fname << "for writing"<< std::endl; return FAIL; } @@ -3450,10 +3450,10 @@ int multiSlsDetector::readDataFile(string fname, double *data, double *err, doub iline+=detectors[i]->readDataFile(detectors[i]->getTotalNumberOfChannels(), infile, data+off, pe, pa, dataformat, choff); choff+=detectors[i]->getMaxNumberOfChannels(); off+=detectors[i]->getTotalNumberOfChannels(); - if (pe) - pe=pe+off; - if (pa) - pa=pa+off; + if (pe) + pe=pe+off; + if (pa) + pa=pa+off; } } @@ -3508,35 +3508,35 @@ 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; inumberOfDetectors; i++) - if (detectors[i]){ - ret1=detectors[i]->setReceiverOnline(off); - if(ret==-100) - ret=ret1; - else if (ret!=ret1) - ret=-1; - } - thisMultiDetector->receiverOnlineFlag=ret; - } - return thisMultiDetector->receiverOnlineFlag; + if (off!=GET_ONLINE_FLAG) { + int ret=-100,ret1; + for (int i=0; inumberOfDetectors; i++) + if (detectors[i]){ + ret1=detectors[i]->setReceiverOnline(off); + if(ret==-100) + ret=ret1; + else if (ret!=ret1) + ret=-1; + } + thisMultiDetector->receiverOnlineFlag=ret; + } + return thisMultiDetector->receiverOnlineFlag; } string multiSlsDetector::checkReceiverOnline() { - string retval1 = "",retval; - for (int idet=0; idetnumberOfDetectors; idet++) { - if (detectors[idet]) { - retval=detectors[idet]->checkReceiverOnline(); - if(!retval.empty()){ - retval1.append(retval); - retval1.append("+"); - } - } - } - return retval1; + string retval1 = "",retval; + for (int idet=0; idetnumberOfDetectors; idet++) { + if (detectors[idet]) { + retval=detectors[idet]->checkReceiverOnline(); + if(!retval.empty()){ + retval1.append(retval); + retval1.append("+"); + } + } + } + return retval1; } @@ -3544,100 +3544,100 @@ string multiSlsDetector::checkReceiverOnline() { string multiSlsDetector::setReceiverFileName(string fileName) { - string ret="error", ret1; + string ret="error", ret1; - for (int idet=0; idetnumberOfDetectors; idet++) { - if (detectors[idet]) { - ret1=detectors[idet]->setReceiverFileName(fileName); - if (ret=="error") - ret=ret1; - else if (ret!=ret1) - ret=""; - } - } - return ret; + for (int idet=0; idetnumberOfDetectors; idet++) { + if (detectors[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; + string ret="error", ret1; - for (int idet=0; idetnumberOfDetectors; idet++) { - if (detectors[idet]) { - ret1=detectors[idet]->setReceiverFileDir(fileDir); - if (ret=="error") - ret=ret1; - else if (ret!=ret1) - ret=""; - } - } - return ret; + for (int idet=0; idetnumberOfDetectors; idet++) { + if (detectors[idet]) { + ret1=detectors[idet]->setReceiverFileDir(fileDir); + if (ret=="error") + ret=ret1; + else if (ret!=ret1) + ret=""; + } + } + return ret; } int multiSlsDetector::setReceiverFileIndex(int fileIndex) { - int ret=-100, ret1; + int ret=-100, ret1; - for (int idet=0; idetnumberOfDetectors; idet++) { - if (detectors[idet]) { - ret1=detectors[idet]->setReceiverFileIndex(fileIndex); - if (ret==-100) - ret=ret1; - else if (ret!=ret1) - ret=-1; - } - } - return ret; + for (int idet=0; idetnumberOfDetectors; idet++) { + if (detectors[idet]) { + ret1=detectors[idet]->setReceiverFileIndex(fileIndex); + if (ret==-100) + ret=ret1; + else if (ret!=ret1) + ret=-1; + } + } + return ret; } int multiSlsDetector::startReceiver(){ - int i=0; - int ret=OK, ret1=OK; - for (i=0; inumberOfDetectors; i++) { - if (i!=thisMultiDetector->masterPosition) - if (detectors[i]) { - ret=detectors[i]->startReceiver(); - if (ret!=OK) - ret1=FAIL; - } - } - i=thisMultiDetector->masterPosition; - if (thisMultiDetector->masterPosition>=0) { - if (detectors[i]) { - ret=detectors[i]->startReceiver(); - if (ret!=OK) - ret1=FAIL; - } - } - return ret1; + int i=0; + int ret=OK, ret1=OK; + for (i=0; inumberOfDetectors; i++) { + if (i!=thisMultiDetector->masterPosition) + if (detectors[i]) { + ret=detectors[i]->startReceiver(); + if (ret!=OK) + ret1=FAIL; + } + } + i=thisMultiDetector->masterPosition; + if (thisMultiDetector->masterPosition>=0) { + if (detectors[i]) { + ret=detectors[i]->startReceiver(); + if (ret!=OK) + ret1=FAIL; + } + } + return ret1; } int multiSlsDetector::stopReceiver(){ - int i=0; - int ret=OK, ret1=OK; + int i=0; + int ret=OK, ret1=OK; - i=thisMultiDetector->masterPosition; - if (thisMultiDetector->masterPosition>=0) { - if (detectors[i]) { - ret=detectors[i]->stopReceiver(); - if (ret!=OK) - ret1=FAIL; - } - } - for (i=0; inumberOfDetectors; i++) { - if (detectors[i]) { - ret=detectors[i]->stopReceiver(); - if (ret!=OK) - ret1=FAIL; - } - } - return ret1; + i=thisMultiDetector->masterPosition; + if (thisMultiDetector->masterPosition>=0) { + if (detectors[i]) { + ret=detectors[i]->stopReceiver(); + if (ret!=OK) + ret1=FAIL; + } + } + for (i=0; inumberOfDetectors; i++) { + if (detectors[i]) { + ret=detectors[i]->stopReceiver(); + if (ret!=OK) + ret1=FAIL; + } + } + return ret1; } @@ -3645,24 +3645,24 @@ int multiSlsDetector::stopReceiver(){ slsDetectorDefs::runStatus multiSlsDetector::getReceiverStatus(){ - runStatus s,s1; + runStatus s,s1; - if (thisMultiDetector->masterPosition>=0) - if (detectors[thisMultiDetector->masterPosition]) - return detectors[thisMultiDetector->masterPosition]->getReceiverStatus(); + if (thisMultiDetector->masterPosition>=0) + if (detectors[thisMultiDetector->masterPosition]) + return detectors[thisMultiDetector->masterPosition]->getReceiverStatus(); - if (detectors[0]) s=detectors[0]->getReceiverStatus(); + if (detectors[0]) s=detectors[0]->getReceiverStatus(); - for (int i=0; inumberOfDetectors; i++) { - s1=detectors[i]->getReceiverStatus(); - if (s1==ERROR) - s=ERROR; - if (s1==IDLE && s!=IDLE) - s=ERROR; + for (int i=0; inumberOfDetectors; i++) { + s1=detectors[i]->getReceiverStatus(); + if (s1==ERROR) + s=ERROR; + if (s1==IDLE && s!=IDLE) + s=ERROR; - } - return s; + } + return s; } @@ -3670,17 +3670,17 @@ slsDetectorDefs::runStatus multiSlsDetector::getReceiverStatus(){ int multiSlsDetector::getFramesCaughtByReciver() { - int ret=-100,ret1; - for (int i=0; inumberOfDetectors; i++) - if (detectors[i]){ - ret1=detectors[i]->getFramesCaughtByReciver(); - if(ret==-100) - ret=ret1; - else if (ret!=ret1) - ret=-1; - } + int ret=-100,ret1; + for (int i=0; inumberOfDetectors; i++) + if (detectors[i]){ + ret1=detectors[i]->getFramesCaughtByReciver(); + if(ret==-100) + ret=ret1; + else if (ret!=ret1) + ret=-1; + } - return ret; + return ret; } @@ -3694,9 +3694,9 @@ int multiSlsDetector::lockReceiver(int lock) { if (detectors[idet]) { ret1=detectors[idet]->lockReceiver(lock); if (ret==-100) - ret=ret1; + ret=ret1; else if (ret!=ret1) - ret=-1; + ret=-1; } } @@ -3726,7 +3726,7 @@ string multiSlsDetector::getReceiverLastClientIP() { } } if (s1=="bad") - return s0; + return s0; else return s1; } diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h index 5fc410763..4ec7df143 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h @@ -28,17 +28,17 @@ class slsDetector; /** * * -@libdoc The multiSlsDetector class is used to operate several slsDetectors in parallel. + @libdoc The multiSlsDetector class is used to operate several slsDetectors in parallel. * * @short This is the base class for multi detector system functionalities * @author Anna Bergamaschi * @version 0.1alpha - */ +*/ class multiSlsDetector : public slsDetectorUtils { -//public virtual slsDetectorUtils { + //public virtual slsDetectorUtils { typedef struct sharedMultiSlsDetector { @@ -107,7 +107,7 @@ class multiSlsDetector : public slsDetectorUtils { - /** current index of the output file */ + /** current index of the output file */ int fileIndex; /** path of the output files */ char filePath[MAX_STR_LENGTH]; @@ -143,13 +143,13 @@ class multiSlsDetector : public slsDetectorUtils { - /** array of angular conversion constants for each module \see ::angleConversionConstant */ + /** array of angular conversion constants for each module \see ::angleConversionConstant */ //angleConversionConstant angOff[MAXMODS]; /** angular direction (1 if it corresponds to the encoder direction i.e. channel 0 is 0, maxchan is positive high angle, 0 otherwise */ int angDirection; - /** beamline fine offset (of the order of mdeg, might be adjusted for each measurements) */ + /** beamline fine offset (of the order of mdeg, might be adjusted for each measurements) */ double fineOffset; - /** beamline offset (might be a few degrees beacuse of encoder offset - normally it is kept fixed for a long period of time) */ + /** beamline offset (might be a few degrees beacuse of encoder offset - normally it is kept fixed for a long period of time) */ double globalOffset; /** bin size for data merging */ double binSize; @@ -159,9 +159,9 @@ class multiSlsDetector : public slsDetectorUtils { //X and Y displacement double sampleDisplacement[2]; - /** number of positions at which the detector should acquire */ + /** number of positions at which the detector should acquire */ int numberOfPositions; - /** list of encoder positions at which the detector should acquire */ + /** list of encoder positions at which the detector should acquire */ double detPositions[MAXPOS]; @@ -211,23 +211,23 @@ class multiSlsDetector : public slsDetectorUtils { - using slsDetectorUtils::flatFieldCorrect; - using slsDetectorUtils::rateCorrect; - using slsDetectorUtils::setBadChannelCorrection; - using slsDetectorUtils::readAngularConversion; - using slsDetectorUtils::writeAngularConversion; + using slsDetectorUtils::flatFieldCorrect; + using slsDetectorUtils::rateCorrect; + using slsDetectorUtils::setBadChannelCorrection; + using slsDetectorUtils::readAngularConversion; + using slsDetectorUtils::writeAngularConversion; -/* - @short Structure allocated in shared memory to store detector settings and be accessed in parallel by several applications (take care of possible conflicts!) + /* + @short Structure allocated in shared memory to store detector settings and be accessed in parallel by several applications (take care of possible conflicts!) */ -/** (default) constructor - \param id is the detector index which is needed to define the shared memory id. Different physical detectors should have different IDs in order to work independently + /** (default) constructor + \param id is the detector index which is needed to define the shared memory id. Different physical detectors should have different IDs in order to work independently -*/ + */ multiSlsDetector(int id=0); //slsDetector(string const fname); /** destructor */ @@ -241,15 +241,15 @@ class multiSlsDetector : public slsDetectorUtils { int initSharedMemory(int) ; /** adds the detector with ID id in postion pos - \param id of the detector to be added (should already exist!) - \param pos position where it should be added (normally at the end of the list (default to -1) - \return the actual number of detectors or -1 if it failed*/ + \param id of the detector to be added (should already exist!) + \param pos position where it should be added (normally at the end of the list (default to -1) + \return the actual number of detectors or -1 if it failed*/ int addSlsDetector(int id, int pos=-1); /** adds the detector with ID id in postion pos - \param name of the detector to be added (should already exist in shared memory or at least be online) - \param pos position where it should be added (normally at the end of the list (default to -1) - \return the actual number of detectors or -1 if it failed*/ + \param name of the detector to be added (should already exist in shared memory or at least be online) + \param pos position where it should be added (normally at the end of the list (default to -1) + \return the actual number of detectors or -1 if it failed*/ int addSlsDetector(const char *name, int pos=-1); int addSlsDetector(detectorType type, int pos=-1); @@ -286,17 +286,17 @@ class multiSlsDetector : public slsDetectorUtils { /** adds a detector by id in position pos - \param ival detector id to be added - \param pos position to add it (-1 fails) - \returns detector ID or -1 if detector in position i is empty + \param ival detector id to be added + \param pos position to add it (-1 fails) + \returns detector ID or -1 if detector in position i is empty */ int setDetectorId(int ival, int pos=-1); /** returns the id of the detector in position i - \param i position of the detector - \returns detector ID or -1 if detector in position i is empty*/ + \param i position of the detector + \returns detector ID or -1 if detector in position i is empty*/ int getDetectorId(int i); @@ -307,10 +307,10 @@ class multiSlsDetector : public slsDetectorUtils { int getMaxMods(); - int getNMods(); - int getChansPerMod(int imod=0); + int getNMods(); + int getChansPerMod(int imod=0); - angleConversionConstant *getAngularConversionPointer(int imod=0); + angleConversionConstant *getAngularConversionPointer(int imod=0); int getTotalNumberOfChannels(){return thisMultiDetector->numberOfChannels;}; @@ -326,7 +326,7 @@ class multiSlsDetector : public slsDetectorUtils { */ int getDetectorOffset(int pos, int &ox, int &oy); - /** sets the detector offset (in number of channels) + /** sets the detector offset (in number of channels) \param pos position of the detector \param ox offset in x (-1 does not change) \param oy offset in y (-1 does not change) @@ -347,13 +347,13 @@ class multiSlsDetector : public slsDetectorUtils { \param sync syncronization mode \returns current syncronization mode */ -/* enum synchronizationMode { */ -/* GET_SYNCHRONIZATION_MODE=-1, /\**< the multidetector will return its synchronization mode *\/ */ -/* NONE, /\**< all detectors are independent (no cabling) *\/ */ -/* MASTER_GATES, /\**< the master gates the other detectors *\/ */ -/* MASTER_TRIGGERS, /\**< the master triggers the other detectors *\/ */ -/* SLAVE_STARTS_WHEN_MASTER_STOPS /\**< the slave acquires when the master finishes, to avoid deadtime *\/ */ -/* }; */ + /* enum synchronizationMode { */ + /* GET_SYNCHRONIZATION_MODE=-1, /\**< the multidetector will return its synchronization mode *\/ */ + /* NONE, /\**< all detectors are independent (no cabling) *\/ */ + /* MASTER_GATES, /\**< the master gates the other detectors *\/ */ + /* MASTER_TRIGGERS, /\**< the master triggers the other detectors *\/ */ + /* SLAVE_STARTS_WHEN_MASTER_STOPS /\**< the slave acquires when the master finishes, to avoid deadtime *\/ */ + /* }; */ synchronizationMode setSynchronization(synchronizationMode sync=GET_SYNCHRONIZATION_MODE); @@ -371,22 +371,22 @@ class multiSlsDetector : public slsDetectorUtils { /** - \returns 1 if the detector structure has already be initlialized with the given id and belongs to this multiDetector instance, 0 otherwise */ + \returns 1 if the detector structure has already be initlialized with the given id and belongs to this multiDetector instance, 0 otherwise */ int exists(); /** - Purely virtual function - Should be implemented in the specific detector class - /sa mythenDetector::readConfigurationFile + Purely virtual function + Should be implemented in the specific detector class + /sa mythenDetector::readConfigurationFile */ int readConfigurationFile(string const fname); /** - Purely virtual function - Should be implemented in the specific detector class - /sa mythenDetector::writeConfigurationFile + Purely virtual function + Should be implemented in the specific detector class + /sa mythenDetector::writeConfigurationFile */ int writeConfigurationFile(string const fname); @@ -401,45 +401,45 @@ class multiSlsDetector : public slsDetectorUtils { // Expert Initialization functions /** - get threshold energy - \param imod module number (-1 all) - \returns current threshold value for imod in ev (-1 failed) + get threshold energy + \param imod module number (-1 all) + \returns current threshold value for imod in ev (-1 failed) */ int getThresholdEnergy(int imod=-1); /** - set threshold energy - \param e_eV threshold in eV - \param imod module number (-1 all) - \param isettings ev. change settings - \returns current threshold value for imod in ev (-1 failed) + set threshold energy + \param e_eV threshold in eV + \param imod module number (-1 all) + \param isettings ev. change settings + \returns current threshold value for imod in ev (-1 failed) */ int setThresholdEnergy(int e_eV, int imod=-1, detectorSettings isettings=GET_SETTINGS); /** - get detector settings - \param imod module number (-1 all) - \returns current settings + get detector settings + \param imod module number (-1 all) + \returns current settings */ detectorSettings getSettings(int imod=-1); /** - set detector settings - \param isettings settings - \param imod module number (-1 all) - \returns current settings + set detector settings + \param isettings settings + \param imod module number (-1 all) + \returns current settings - in this function trimbits and calibration files are searched in the trimDir and calDir directories and the detector is initialized + in this function trimbits and calibration files are searched in the trimDir and calDir directories and the detector is initialized */ detectorSettings setSettings(detectorSettings isettings, int imod=-1); /** - Returns the trimbits from the detector's shared memmory - \param retval is the array with the trimbits - \param fromDetector is true if the trimbits shared memory have to be uploaded from detector - \returns the total number of channels for the detector - */ + Returns the trimbits from the detector's shared memmory + \param retval is the array with the trimbits + \param fromDetector is true if the trimbits shared memory have to be uploaded from detector + \returns the total number of channels for the detector + */ int getChanRegs(double* retval,bool fromDetector); @@ -485,81 +485,81 @@ class multiSlsDetector : public slsDetectorUtils { -// Acquisition functions + // Acquisition functions /** - start detector acquisition (master is started as last) - \returns OK if all detectors are properly started, FAIL otherwise + start detector acquisition (master is started as last) + \returns OK if all detectors are properly started, FAIL otherwise */ int startAcquisition(); /** - stop detector acquisition (master firtst) - \returns OK/FAIL + stop detector acquisition (master firtst) + \returns OK/FAIL */ int stopAcquisition(); /** - start readout (without exposure or interrupting exposure) (master first) - \returns OK/FAIL + start readout (without exposure or interrupting exposure) (master first) + \returns OK/FAIL */ int startReadOut(); /** - start detector acquisition and read all data putting them a data queue - \returns pointer to the front of the data queue - \sa startAndReadAllNoWait getDataFromDetector dataQueue + start detector acquisition and read all data putting them a data queue + \returns pointer to the front of the data queue + \sa startAndReadAllNoWait getDataFromDetector dataQueue */ int* startAndReadAll(); /** - start detector acquisition and read out, but does not read data from socket + start detector acquisition and read out, but does not read data from socket */ int startAndReadAllNoWait(); /** - receives a data frame from the detector socket - \returns pointer to the data or NULL. If NULL disconnects the socket - \sa getDataFromDetector + receives a data frame from the detector socket + \returns pointer to the data or NULL. If NULL disconnects the socket + \sa getDataFromDetector */ //int* getDataFromDetectorNoWait(); /** - receives a data frame from the detector socket - \returns pointer to the data or NULL. If NULL disconnects the socket - \sa getDataFromDetector + receives a data frame from the detector socket + \returns pointer to the data or NULL. If NULL disconnects the socket + \sa getDataFromDetector */ int* getDataFromDetector(); /** - asks and receives a data frame from the detector and puts it in the data queue - \returns pointer to the data or NULL. - \sa getDataFromDetector + asks and receives a data frame from the detector and puts it in the data queue + \returns pointer to the data or NULL. + \sa getDataFromDetector */ int* readFrame(); /** - asks and receives all data from the detector and puts them in a data queue - \returns pointer to the front of the queue or NULL. - \sa getDataFromDetector dataQueue + asks and receives all data from the detector and puts them in a data queue + \returns pointer to the front of the queue or NULL. + \sa getDataFromDetector dataQueue */ int* readAll(); /** - pops the data from the data queue - \returns pointer to the popped data or NULL if the queue is empty. - \sa dataQueue + pops the data from the data queue + \returns pointer to the popped data or NULL if the queue is empty. + \sa dataQueue */ int* popDataQueue(); /** - pops the data from thepostprocessed data queue - \returns pointer to the popped data or NULL if the queue is empty. - \sa finalDataQueue + pops the data from thepostprocessed data queue + \returns pointer to the popped data or NULL if the queue is empty. + \sa finalDataQueue */ detectorData* popFinalDataQueue(); @@ -567,14 +567,14 @@ class multiSlsDetector : public slsDetectorUtils { /** - resets the raw data queue - \sa dataQueue + resets the raw data queue + \sa dataQueue */ void resetDataQueue(); /** - resets the postprocessed data queue - \sa finalDataQueue + resets the postprocessed data queue + \sa finalDataQueue */ void resetFinalDataQueue(); @@ -602,12 +602,12 @@ class multiSlsDetector : public slsDetectorUtils { */ int64_t getTimeLeft(timerIndex index); -/* /\** */ -/* get current timer value */ -/* \param index timer index */ -/* \returns elapsed time value in ns or number of...(e.g. frames, gates, probes) */ -/* *\/ */ -/* int64_t getTimeLeft(timerIndex index); */ + /* /\** */ + /* get current timer value */ + /* \param index timer index */ + /* \returns elapsed time value in ns or number of...(e.g. frames, gates, probes) */ + /* *\/ */ + /* int64_t getTimeLeft(timerIndex index); */ @@ -737,9 +737,9 @@ class multiSlsDetector : public slsDetectorUtils { /** - decode data from the detector converting them to an array of doubles, one for each channle - \param datain data from the detector - \returns pointer to a double array with a data per channel + decode data from the detector converting them to an array of doubles, one for each channle + \param datain data from the detector + \returns pointer to a double array with a data per channel */ double* decodeData(int *datain, double *fdata=NULL); @@ -747,48 +747,48 @@ class multiSlsDetector : public slsDetectorUtils { /** - flat field correct data - \param datain data - \param errin error on data (if<=0 will default to sqrt(datain) - \param dataout corrected data - \param errout error on corrected data - \param ffcoefficient flat field correction coefficient - \param fferr erro on ffcoefficient - \returns 0 + flat field correct data + \param datain data + \param errin error on data (if<=0 will default to sqrt(datain) + \param dataout corrected data + \param errout error on corrected data + \param ffcoefficient flat field correction coefficient + \param fferr erro on ffcoefficient + \returns 0 */ // int flatFieldCorrect(double datain, double errin, double &dataout, double &errout, double ffcoefficient, double fferr); /** - flat field correct data - \param datain data array - \param errin error array on data (if NULL will default to sqrt(datain) - \param dataout array of corrected data - \param errout error on corrected data (if not NULL) - \returns 0 + flat field correct data + \param datain data array + \param errin error array on data (if NULL will default to sqrt(datain) + \param dataout array of corrected data + \param errout error on corrected data (if not NULL) + \returns 0 */ int flatFieldCorrect(double* datain, double *errin, double* dataout, double *errout); /** - rate correct data - \param datain data - \param errin error on data (if<=0 will default to sqrt(datain) - \param dataout corrected data - \param errout error on corrected data - \param tau dead time 9in ns) - \param t acquisition time (in ns) - \returns 0 + rate correct data + \param datain data + \param errin error on data (if<=0 will default to sqrt(datain) + \param dataout corrected data + \param errout error on corrected data + \param tau dead time 9in ns) + \param t acquisition time (in ns) + \returns 0 */ // int rateCorrect(double datain, double errin, double &dataout, double &errout, double tau, double t); /** - rate correct data - \param datain data array - \param errin error array on data (if NULL will default to sqrt(datain) - \param dataout array of corrected data - \param errout error on corrected data (if not NULL) - \returns 0 + rate correct data + \param datain data array + \param errin error array on data (if NULL will default to sqrt(datain) + \param dataout array of corrected data + \param errout error on corrected data (if not NULL) + \returns 0 */ int rateCorrect(double* datain, double *errin, double* dataout, double *errout); @@ -798,9 +798,9 @@ class multiSlsDetector : public slsDetectorUtils { int exitServer(); /** pure /////////////////////////////////////////////////// virtual function - function for processing data - /param delflag if 1 the data are processed, written to file and then deleted. If 0 they are added to the finalDataQueue - \sa mythenDetector::processData + function for processing data + /param delflag if 1 the data are processed, written to file and then deleted. If 0 they are added to the finalDataQueue + \sa mythenDetector::processData */ /////////////////////////////////////////////////// virtual void* processData(int delflag=1); // thread function @@ -817,29 +817,29 @@ class multiSlsDetector : public slsDetectorUtils { /** - set dacs value - \param val value (in V) - \param index DAC index - \param imod module number (if -1 alla modules) - \returns current DAC value + set dacs value + \param val value (in V) + \param index DAC index + \param imod module number (if -1 alla modules) + \returns current DAC value */ dacs_t setDAC(dacs_t val, dacIndex index, int imod=-1); /** - set dacs value - \param val value (in V) - \param index DAC index - \param imod module number (if -1 alla modules) - \returns current DAC value + set dacs value + \param val value (in V) + \param index DAC index + \param imod module number (if -1 alla modules) + \returns current DAC value */ dacs_t getADC(dacIndex index, int imod=0); - /** - configure channel - \param reg channel register - \param ichan channel number (-1 all) - \param ichip chip number (-1 all) - \param imod module number (-1 all) - \returns current register value - \sa ::sls_detector_channel + /** + configure channel + \param reg channel register + \param ichan channel number (-1 all) + \param ichip chip number (-1 all) + \param imod module number (-1 all) + \returns current register value + \sa ::sls_detector_channel */ int setChannel(int64_t reg, int ichan=-1, int ichip=-1, int imod=-1); /** @@ -856,7 +856,7 @@ class multiSlsDetector : public slsDetectorUtils { /** get run status - \returns status mask + \returns status mask */ //virtual runStatus getRunStatus()=0; runStatus getRunStatus(); @@ -869,14 +869,14 @@ class multiSlsDetector : public slsDetectorUtils { char* getSettingsDir(); /** sets the detector trimbit/settings directory \sa sharedSlsDetector */ char* setSettingsDir(string s); - /** + /** returns the location of the calibration files - \sa sharedSlsDetector + \sa sharedSlsDetector */ char* getCalDir(); - /** - sets the location of the calibration files - \sa sharedSlsDetector + /** + sets the location of the calibration files + \sa sharedSlsDetector */ char* setCalDir(string s); @@ -906,25 +906,25 @@ class multiSlsDetector : public slsDetectorUtils { - int setTrimEn(int nen, int *en=NULL); - int getTrimEn(int *en=NULL); + int setTrimEn(int nen, int *en=NULL); + int getTrimEn(int *en=NULL); - externalSignalFlag setExternalSignalFlags(externalSignalFlag pol=GET_EXTERNAL_SIGNAL_FLAG , int signalindex=0); - int setReadOutFlags(readOutFlags flag=GET_READOUT_FLAGS); + externalSignalFlag setExternalSignalFlags(externalSignalFlag pol=GET_EXTERNAL_SIGNAL_FLAG , int signalindex=0); + int setReadOutFlags(readOutFlags flag=GET_READOUT_FLAGS); - externalCommunicationMode setExternalCommunicationMode(externalCommunicationMode pol=GET_EXTERNAL_COMMUNICATION_MODE); + externalCommunicationMode setExternalCommunicationMode(externalCommunicationMode pol=GET_EXTERNAL_COMMUNICATION_MODE); - /** - Loads dark image or gain image to the detector - \param index can be DARK_IMAGE or GAIN_IMAGE - \fname file name to load data from - \returns OK or FAIL - */ + /** + Loads dark image or gain image to the detector + \param index can be DARK_IMAGE or GAIN_IMAGE + \fname file name to load data from + \returns OK or FAIL + */ int loadImageToDetector(imageType index,string const fname); - /** + /** sets the value of s angular conversion parameter \param c can be ANGULAR_DIRECTION, GLOBAL_OFFSET, FINE_OFFSET, BIN_SIZE \param v the value to be set @@ -933,153 +933,153 @@ class multiSlsDetector : public slsDetectorUtils { double setAngularConversionParameter(angleConversionParameter c, double v); - /** + /** - writes a data file - \param name of the file to be written - \param data array of data values - \param err array of arrors on the data. If NULL no errors will be written + writes a data file + \param name of the file to be written + \param data array of data values + \param err array of arrors on the data. If NULL no errors will be written - \param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' double (default) - \param nch number of channels to be written to file. if -1 defaults to the number of installed channels of the detector - \returns OK or FAIL if it could not write the file or data=NULL - \sa mythenDetector::writeDataFile + \param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err) + \param dataformat format of the data: can be 'i' integer or 'f' double (default) + \param nch number of channels to be written to file. if -1 defaults to the number of installed channels of the detector + \returns OK or FAIL if it could not write the file or data=NULL + \sa mythenDetector::writeDataFile */ - int writeDataFile(string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int nch=-1); + int writeDataFile(string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int nch=-1); /** - writes a data file - \param name of the file to be written - \param data array of data values - \returns OK or FAIL if it could not write the file or data=NULL - \sa mythenDetector::writeDataFile + writes a data file + \param name of the file to be written + \param data array of data values + \returns OK or FAIL if it could not write the file or data=NULL + \sa mythenDetector::writeDataFile */ - int writeDataFile(string fname, int *data); + int writeDataFile(string fname, int *data); /** - reads a data file - \param name of the file to be read - \param data array of data values to be filled - \param err array of arrors on the data. If NULL no errors are expected on the file + reads a data file + \param name of the file to be read + \param data array of data values to be filled + \param err array of arrors on the data. If NULL no errors are expected on the file - \param ang array of angular values. If NULL data are expected in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' double (default) - \param nch number of channels to be written to file. if <=0 defaults to the number of installed channels of the detector - \returns OK or FAIL if it could not read the file or data=NULL + \param ang array of angular values. If NULL data are expected in the form chan-val(-err) otherwise ang-val(-err) + \param dataformat format of the data: can be 'i' integer or 'f' double (default) + \param nch number of channels to be written to file. if <=0 defaults to the number of installed channels of the detector + \returns OK or FAIL if it could not read the file or data=NULL - \sa mythenDetector::readDataFile + \sa mythenDetector::readDataFile */ - int readDataFile(string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f'); + int readDataFile(string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f'); /** - reads a data file - \param name of the file to be read - \param data array of data values - \returns OK or FAIL if it could not read the file or data=NULL - \sa mythenDetector::readDataFile + reads a data file + \param name of the file to be read + \param data array of data values + \returns OK or FAIL if it could not read the file or data=NULL + \sa mythenDetector::readDataFile */ - int readDataFile(string fname, int *data); + int readDataFile(string fname, int *data); - /** - writes the counter memory block from the detector - \param startACQ is 1 to start acquisition after reading counter - \param fname file name to load data from - \returns OK or FAIL - */ - int writeCounterBlockFile(string const fname,int startACQ=0); + /** + writes the counter memory block from the detector + \param startACQ is 1 to start acquisition after reading counter + \param fname file name to load data from + \returns OK or FAIL + */ + int writeCounterBlockFile(string const fname,int startACQ=0); /** - Resets counter in detector - \param startACQ is 1 to start acquisition after resetting counter - \returns OK or FAIL - */ - int resetCounterBlock(int startACQ=0); + Resets counter in detector + \param startACQ is 1 to start acquisition after resetting counter + \returns OK or FAIL + */ + int resetCounterBlock(int startACQ=0); - int getMoveFlag(int imod); + int getMoveFlag(int imod); - slsDetector *getSlsDetector(int pos) {if (pos>=0 && pos< MAXDET) return detectors[pos]; return NULL;}; + slsDetector *getSlsDetector(int pos) {if (pos>=0 && pos< MAXDET) return detectors[pos]; return NULL;}; -//receiver + //receiver - /** - calls setReceiverTCPSocket if online and sets the flag - */ - int setReceiverOnline(int const online=GET_ONLINE_FLAG); + /** + calls setReceiverTCPSocket if online and sets the flag + */ + int setReceiverOnline(int const online=GET_ONLINE_FLAG); - /** - Checks if the receiver is really online - */ - string checkReceiverOnline(); + /** + Checks if the receiver is really online + */ + string checkReceiverOnline(); - /** - Sets up the receiver file name - @param fileName file name - \returns file name - */ - string setReceiverFileName(string fileName=""); + /** + 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 - \returns file dir - */ - string setReceiverFileDir(string fileDir=""); + /** + Sets up the receiver file directory + @param fileName fileDir file directory + \returns file dir + */ + string setReceiverFileDir(string fileDir=""); - /** - Sets up the receiver file index - @param fileIndex file index - \returns file index - */ - int setReceiverFileIndex(int fileIndex=-1); + /** + Sets up the receiver file index + @param fileIndex file index + \returns file index + */ + int setReceiverFileIndex(int fileIndex=-1); - /** Starts the listening mode of receiver - \returns OK or FAIL - */ - int startReceiver(); + /** Starts the listening mode of receiver + \returns OK or FAIL + */ + int startReceiver(); - /** Stops the listening mode of receiver - \returns OK or FAIL - */ - int stopReceiver(); + /** Stops the listening mode of receiver + \returns OK or FAIL + */ + int stopReceiver(); - /** gets the status of the listening mode of receiver - \returns status - */ - runStatus getReceiverStatus(); + /** gets the status of the listening mode of receiver + \returns status + */ + runStatus getReceiverStatus(); - /** gets the number of frames caught by receiver - \returns number of frames caught by receiver - */ - int getFramesCaughtByReciver(); + /** gets the number of frames caught by receiver + \returns number of frames caught by receiver + */ + int getFramesCaughtByReciver(); - /** Locks/Unlocks the connection to the receiver - /param lock sets (1), usets (0), gets (-1) the lock - /returns lock status of the receiver - */ - int lockReceiver(int lock=-1); + /** Locks/Unlocks the connection to the receiver + /param lock sets (1), usets (0), gets (-1) the lock + /returns lock status of the receiver + */ + int lockReceiver(int lock=-1); - /** - Returns the IP of the last client connecting to the receiver - */ - string getReceiverLastClientIP(); + /** + Returns the IP of the last client connecting to the receiver + */ + string getReceiverLastClientIP(); - int fillModuleMask(int *mM); + int fillModuleMask(int *mM); protected: diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 303299ad4..9c17aedfc 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -12,67 +12,67 @@ int slsDetector::initSharedMemory(detectorType type, int id) { - /** - the shared memory key is set to DEFAULT_SHM_KEY+id - */ - key_t mem_key=DEFAULT_SHM_KEY+id; - int shm_id; - int nch, nm, nc, nd; - int sz; + /** + the shared memory key is set to DEFAULT_SHM_KEY+id + */ + key_t mem_key=DEFAULT_SHM_KEY+id; + int shm_id; + int nch, nm, nc, nd; + int sz; - //shmId=-1; + //shmId=-1; - switch(type) { - case MYTHEN: - nch=128; // complete mythen system - nm=24; - nc=10; - nd=6; // dacs+adcs - break; - case PICASSO: - nch=128; // complete mythen system - nm=24; - nc=12; - nd=6; // dacs+adcs - break; - case GOTTHARD: - nch=128; - nm=1; - nc=10; - nd=13; // dacs+adcs - break; - case EIGER: - nch=65536; // one EIGER half module - nm=1; //modules/detector - nc=4; //chips - nd=16; //dacs+adcs - default: - nch=0; // dum! - nm=0; //modules/detector - nc=0; //chips - nd=0; //dacs+adcs + switch(type) { + case MYTHEN: + nch=128; // complete mythen system + nm=24; + nc=10; + nd=6; // dacs+adcs + break; + case PICASSO: + nch=128; // complete mythen system + nm=24; + nc=12; + nd=6; // dacs+adcs + break; + case GOTTHARD: + nch=128; + nm=1; + nc=10; + nd=13; // dacs+adcs + break; + case EIGER: + nch=65536; // one EIGER half module + nm=1; //modules/detector + nc=4; //chips + nd=16; //dacs+adcs + default: + nch=0; // dum! + nm=0; //modules/detector + nc=0; //chips + nd=0; //dacs+adcs - } - /** - The size of the shared memory is: - size of shared structure + ffcoefficents +fferrors + modules+ dacs+adcs+chips+chans - */ + } + /** + The size of the shared memory is: + size of shared structure + ffcoefficents +fferrors + modules+ dacs+adcs+chips+chans + */ - sz=sizeof(sharedSlsDetector)+nm*(2*nch*nc*sizeof(double)+sizeof(sls_detector_module)+sizeof(int)*nc+sizeof(dacs_t)*nd+sizeof(int)*nch*nc); + sz=sizeof(sharedSlsDetector)+nm*(2*nch*nc*sizeof(double)+sizeof(sls_detector_module)+sizeof(int)*nc+sizeof(dacs_t)*nd+sizeof(int)*nch*nc); #ifdef VERBOSE - std::cout<<"Size of shared memory is "<< sz << "(type " << type << " - id " << mem_key << ")"<< std::endl; + std::cout<<"Size of shared memory is "<< sz << "(type " << type << " - id " << mem_key << ")"<< std::endl; #endif - shm_id = shmget(mem_key,sz,IPC_CREAT | 0666); // allocate shared memory + shm_id = shmget(mem_key,sz,IPC_CREAT | 0666); // allocate shared memory if (shm_id < 0) { std::cout<<"*** shmget error (server) ***"<< shm_id << std::endl; return shm_id; } - /** - thisDetector pointer is set to the memory address of the shared memory - */ + /** + thisDetector pointer is set to the memory address of the shared memory + */ thisDetector = (sharedSlsDetector*) shmat(shm_id, NULL, 0); /* attach */ @@ -82,9 +82,9 @@ int slsDetector::initSharedMemory(detectorType type, int id) { } - /** - shm_id returns -1 is shared memory initialization fails - */ + /** + shm_id returns -1 is shared memory initialization fails + */ //shmId=shm_id; return shm_id; @@ -93,36 +93,36 @@ int slsDetector::initSharedMemory(detectorType type, int id) { int slsDetector::freeSharedMemory() { // Detach Memory address - if (shmdt(thisDetector) == -1) { - perror("shmdt failed\n"); - return FAIL; - } - printf("Shared memory %d detached\n", shmId); - // remove shared memory - if (shmctl(shmId, IPC_RMID, 0) == -1) { - perror("shmctl(IPC_RMID) failed\n"); - return FAIL; - } - printf("Shared memory %d deleted\n", shmId); - return OK; + if (shmdt(thisDetector) == -1) { + perror("shmdt failed\n"); + return FAIL; + } + printf("Shared memory %d detached\n", shmId); + // remove shared memory + if (shmctl(shmId, IPC_RMID, 0) == -1) { + perror("shmctl(IPC_RMID) failed\n"); + return FAIL; + } + printf("Shared memory %d deleted\n", shmId); + return OK; } slsDetector::slsDetector(int id) :slsDetectorUtils(), - thisDetector(NULL), - detId(id), - shmId(-1), - controlSocket(NULL), - stopSocket(NULL), - dataSocket(NULL), - ffcoefficients(NULL), - fferrors(NULL), - detectorModules(NULL), - dacs(NULL), - adcs(NULL), - chipregs(NULL), - chanregs(NULL) + thisDetector(NULL), + detId(id), + shmId(-1), + controlSocket(NULL), + stopSocket(NULL), + dataSocket(NULL), + ffcoefficients(NULL), + fferrors(NULL), + detectorModules(NULL), + dacs(NULL), + adcs(NULL), + chipregs(NULL), + chanregs(NULL) { @@ -131,10 +131,10 @@ slsDetector::slsDetector(int id) :slsDetectorUtils(), detectorType type=(detectorType)getDetectorType(id); while (shmId<0) { - /**Initlializes shared memory \sa initSharedMemory + /**Initlializes shared memory \sa initSharedMemory - if it fails the detector id is incremented until it succeeds - */ + if it fails the detector id is incremented until it succeeds + */ shmId=initSharedMemory(type,id); id++; } @@ -146,7 +146,7 @@ slsDetector::slsDetector(int id) :slsDetectorUtils(), /**Initializes the detector stucture \sa initializeDetectorSize - */ + */ initializeDetectorSize(type); @@ -158,38 +158,38 @@ slsDetector::slsDetector(int id) :slsDetectorUtils(), slsDetector::slsDetector(detectorType type, int id): slsDetectorUtils(), - thisDetector(NULL), - detId(id), - shmId(-1), - controlSocket(NULL), - stopSocket(NULL), - dataSocket(NULL), - ffcoefficients(NULL), - fferrors(NULL), - detectorModules(NULL), - dacs(NULL), - adcs(NULL), - chipregs(NULL), - chanregs(NULL) - { - while (shmId<0) { - /**Initlializes shared memory \sa initSharedMemory + thisDetector(NULL), + detId(id), + shmId(-1), + controlSocket(NULL), + stopSocket(NULL), + dataSocket(NULL), + ffcoefficients(NULL), + fferrors(NULL), + detectorModules(NULL), + dacs(NULL), + adcs(NULL), + chipregs(NULL), + chanregs(NULL) +{ + while (shmId<0) { + /**Initlializes shared memory \sa initSharedMemory - if it fails the detector id is incremented until it succeeds - */ - shmId=initSharedMemory(type,id); - id++; - } - id--; + if it fails the detector id is incremented until it succeeds + */ + shmId=initSharedMemory(type,id); + id++; + } + id--; #ifdef VERBOSE - std::cout<< "Detector id is " << id << " type is " << type << std::endl; + std::cout<< "Detector id is " << id << " type is " << type << std::endl; #endif - detId=id; + detId=id; - /**Initializes the detector stucture \sa initializeDetectorSize - */ - initializeDetectorSize(type); + /**Initializes the detector stucture \sa initializeDetectorSize + */ + initializeDetectorSize(type); @@ -199,38 +199,38 @@ slsDetector::slsDetector(detectorType type, int id): slsDetectorUtils(), slsDetector::~slsDetector(){ // Detach Memory address - if (shmdt(thisDetector) == -1) { - perror("shmdt failed\n"); - printf("Could not detach shared memory %d\n", shmId); - } else - printf("Shared memory %d detached\n", shmId); + if (shmdt(thisDetector) == -1) { + perror("shmdt failed\n"); + printf("Could not detach shared memory %d\n", shmId); + } else + printf("Shared memory %d detached\n", shmId); }; slsDetector::slsDetector(char *name, int id, int cport) : slsDetectorUtils(), - thisDetector(NULL), - detId(id), - shmId(-1), - controlSocket(NULL), - stopSocket(NULL), - dataSocket(NULL), - ffcoefficients(NULL), - fferrors(NULL), - detectorModules(NULL), - dacs(NULL), - adcs(NULL), - chipregs(NULL), - chanregs(NULL) + thisDetector(NULL), + detId(id), + shmId(-1), + controlSocket(NULL), + stopSocket(NULL), + dataSocket(NULL), + ffcoefficients(NULL), + fferrors(NULL), + detectorModules(NULL), + dacs(NULL), + adcs(NULL), + chipregs(NULL), + chanregs(NULL) { detectorType type=(detectorType)getDetectorType(name, cport); while (shmId<0) { - /**Initlializes shared memory \sa initSharedMemory + /**Initlializes shared memory \sa initSharedMemory - if it fails the detector id is incremented until it succeeds - */ + if it fails the detector id is incremented until it succeeds + */ shmId=initSharedMemory(type,id); id++; } @@ -242,7 +242,7 @@ slsDetector::slsDetector(char *name, int id, int cport) : slsDetectorUtils(), /**Initializes the detector stucture \sa initializeDetectorSize - */ + */ initializeDetectorSize(type); @@ -264,7 +264,7 @@ slsDetectorDefs::detectorType slsDetector::getDetectorType(const char *name, int #ifdef VERBOSE cout << "Getting detector type " << endl; #endif - if (s->Connect()>=0) { + if (s->Connect()>=0) { s->SendDataOnly(&fnum,sizeof(fnum)); s->ReceiveDataOnly(&retval,sizeof(retval)); @@ -280,12 +280,12 @@ slsDetectorDefs::detectorType slsDetector::getDetectorType(const char *name, int std::cout<< "Detector returned error: " << m << std::endl; } s->Disconnect(); - } else { - cout << "Cannot connect to server " << name << " over port " << cport << endl; - } + } else { + cout << "Cannot connect to server " << name << " over port " << cport << endl; + } - delete s; - return t; + delete s; + return t; } @@ -298,26 +298,26 @@ slsDetectorDefs::detectorType slsDetector::getDetectorType(const char *name, int int slsDetector::exists(int id) { - key_t mem_key=DEFAULT_SHM_KEY+id; - int shm_id; - int sz; + key_t mem_key=DEFAULT_SHM_KEY+id; + int shm_id; + int sz; - sz=sizeof(sharedSlsDetector); + sz=sizeof(sharedSlsDetector); #ifdef VERBOSE - cout << "getDetectorType: generic shared memory of size " << sz << endl; + cout << "getDetectorType: generic shared memory of size " << sz << endl; #endif - shm_id = shmget(mem_key,sz,IPC_CREAT | 0666); // allocate shared memory + shm_id = shmget(mem_key,sz,IPC_CREAT | 0666); // allocate shared memory if (shm_id < 0) { std::cout<<"*** shmget error (server) ***"<< shm_id << std::endl; return -1; } - /** - thisDetector pointer is set to the memory address of the shared memory - */ + /** + thisDetector pointer is set to the memory address of the shared memory + */ sharedSlsDetector* det = (sharedSlsDetector*) shmat(shm_id, NULL, 0); /* attach */ @@ -325,16 +325,16 @@ int slsDetector::exists(int id) { std::cout<<"*** shmat error (server) ***" << std::endl; return -1; } - /** - shm_id returns -1 is shared memory initialization fails - */ + /** + shm_id returns -1 is shared memory initialization fails + */ //shmId=shm_id; if (det->alreadyExisting==0) { - // Detach Memory address + // Detach Memory address if (shmdt(det) == -1) { perror("shmdt failed\n"); return 0; @@ -368,26 +368,26 @@ slsDetectorDefs::detectorType slsDetector::getDetectorType(int id) { detectorType t=GENERIC; - key_t mem_key=DEFAULT_SHM_KEY+id; - int shm_id; - int sz; + key_t mem_key=DEFAULT_SHM_KEY+id; + int shm_id; + int sz; - sz=sizeof(sharedSlsDetector); + sz=sizeof(sharedSlsDetector); #ifdef VERBOSE - cout << "getDetectorType: generic shared memory of size " << sz << endl; + cout << "getDetectorType: generic shared memory of size " << sz << endl; #endif - shm_id = shmget(mem_key,sz,IPC_CREAT | 0666); // allocate shared memory + shm_id = shmget(mem_key,sz,IPC_CREAT | 0666); // allocate shared memory if (shm_id < 0) { std::cout<<"*** shmget error (server) ***"<< shm_id << std::endl; return t; } - /** - thisDetector pointer is set to the memory address of the shared memory - */ + /** + thisDetector pointer is set to the memory address of the shared memory + */ sharedSlsDetector* det = (sharedSlsDetector*) shmat(shm_id, NULL, 0); /* attach */ @@ -395,16 +395,16 @@ slsDetectorDefs::detectorType slsDetector::getDetectorType(int id) { std::cout<<"*** shmat error (server) ***" << std::endl; return t; } - /** - shm_id returns -1 is shared memory initialization fails - */ + /** + shm_id returns -1 is shared memory initialization fails + */ //shmId=shm_id; t=det->myDetectorType; if (det->alreadyExisting==0) { - // Detach Memory address + // Detach Memory address if (shmdt(det) == -1) { perror("shmdt failed\n"); return t; @@ -439,251 +439,251 @@ int slsDetector::initializeDetectorSize(detectorType type) { // cout << "init detector size" << endl; /** if the shared memory has newly be created, initialize the detector variables */ - if (thisDetector->alreadyExisting==0) { + if (thisDetector->alreadyExisting==0) { - // cout << "detector not existing " << endl; + // cout << "detector not existing " << endl; - /** set hostname to default */ - strcpy(thisDetector->hostname,DEFAULT_HOSTNAME); + /** set hostname to default */ + strcpy(thisDetector->hostname,DEFAULT_HOSTNAME); - /** set client ip address */ - strcpy(thisDetector->receiverIP,"none"); - /** set client mac address */ - strcpy(thisDetector->receiverMAC,"none"); - /** set server mac address */ - strcpy(thisDetector->serverMAC,"00:aa:bb:cc:dd:ee"); + /** set client ip address */ + strcpy(thisDetector->receiverIP,"none"); + /** set client mac address */ + strcpy(thisDetector->receiverMAC,"none"); + /** set server mac address */ + strcpy(thisDetector->serverMAC,"00:aa:bb:cc:dd:ee"); - /** sets onlineFlag to OFFLINE_FLAG */ - thisDetector->onlineFlag=OFFLINE_FLAG; - /** set ports to defaults */ - thisDetector->controlPort=DEFAULT_PORTNO; - thisDetector->stopPort=DEFAULT_PORTNO+1; - thisDetector->dataPort=DEFAULT_PORTNO+2; - /** set thisDetector->myDetectorType to type and according to this set nChans, nChips, nDacs, nAdcs, nModMax, dynamicRange, nMod*/ - thisDetector->myDetectorType=type; - switch(thisDetector->myDetectorType) { - case MYTHEN: - thisDetector->nChans=128; - thisDetector->nChips=10; - thisDetector->nDacs=6; - thisDetector->nAdcs=0; - thisDetector->nModMax[X]=24; - thisDetector->nModMax[Y]=1; - thisDetector->dynamicRange=24; - thisDetector->moveFlag=1; + /** sets onlineFlag to OFFLINE_FLAG */ + thisDetector->onlineFlag=OFFLINE_FLAG; + /** set ports to defaults */ + thisDetector->controlPort=DEFAULT_PORTNO; + thisDetector->stopPort=DEFAULT_PORTNO+1; + thisDetector->dataPort=DEFAULT_PORTNO+2; + /** set thisDetector->myDetectorType to type and according to this set nChans, nChips, nDacs, nAdcs, nModMax, dynamicRange, nMod*/ + thisDetector->myDetectorType=type; + switch(thisDetector->myDetectorType) { + case MYTHEN: + thisDetector->nChans=128; + thisDetector->nChips=10; + thisDetector->nDacs=6; + thisDetector->nAdcs=0; + thisDetector->nModMax[X]=24; + thisDetector->nModMax[Y]=1; + thisDetector->dynamicRange=24; + thisDetector->moveFlag=1; #ifdef VERBOSE - cout << "move flag" << thisDetector->moveFlag<< endl; + cout << "move flag" << thisDetector->moveFlag<< endl; #endif - break; - case PICASSO: - thisDetector->nChans=128; - thisDetector->nChips=12; - thisDetector->nDacs=6; - thisDetector->nAdcs=0; - thisDetector->nModMax[X]=6; - thisDetector->nModMax[Y]=1; - thisDetector->dynamicRange=24; - break; - case GOTTHARD: - thisDetector->nChans=128; - thisDetector->nChips=10; - thisDetector->nDacs=8; - thisDetector->nAdcs=5; - thisDetector->nModMax[X]=1; - thisDetector->nModMax[Y]=1; - thisDetector->dynamicRange=16; - break; - default: - thisDetector->nChans=0; - thisDetector->nChips=0; - thisDetector->nDacs=0; - thisDetector->nAdcs=0; - thisDetector->nModMax[X]=0; - thisDetector->nModMax[Y]=0; - thisDetector->dynamicRange=32; - } - thisDetector->nModsMax=thisDetector->nModMax[0]*thisDetector->nModMax[1]; - /** number of modules is initally the maximum number of modules */ - thisDetector->nMod[X]=thisDetector->nModMax[X]; - thisDetector->nMod[Y]=thisDetector->nModMax[Y]; - thisDetector->nMods=thisDetector->nModsMax; - /** calculates the expected data size */ - thisDetector->timerValue[PROBES_NUMBER]=0; - thisDetector->timerValue[FRAME_NUMBER]=1; - thisDetector->timerValue[MEASUREMENTS_NUMBER]=1; - thisDetector->timerValue[CYCLES_NUMBER]=1; + break; + case PICASSO: + thisDetector->nChans=128; + thisDetector->nChips=12; + thisDetector->nDacs=6; + thisDetector->nAdcs=0; + thisDetector->nModMax[X]=6; + thisDetector->nModMax[Y]=1; + thisDetector->dynamicRange=24; + break; + case GOTTHARD: + thisDetector->nChans=128; + thisDetector->nChips=10; + thisDetector->nDacs=8; + thisDetector->nAdcs=5; + thisDetector->nModMax[X]=1; + thisDetector->nModMax[Y]=1; + thisDetector->dynamicRange=16; + break; + default: + thisDetector->nChans=0; + thisDetector->nChips=0; + thisDetector->nDacs=0; + thisDetector->nAdcs=0; + thisDetector->nModMax[X]=0; + thisDetector->nModMax[Y]=0; + thisDetector->dynamicRange=32; + } + thisDetector->nModsMax=thisDetector->nModMax[0]*thisDetector->nModMax[1]; + /** number of modules is initally the maximum number of modules */ + thisDetector->nMod[X]=thisDetector->nModMax[X]; + thisDetector->nMod[Y]=thisDetector->nModMax[Y]; + thisDetector->nMods=thisDetector->nModsMax; + /** calculates the expected data size */ + thisDetector->timerValue[PROBES_NUMBER]=0; + thisDetector->timerValue[FRAME_NUMBER]=1; + thisDetector->timerValue[MEASUREMENTS_NUMBER]=1; + thisDetector->timerValue[CYCLES_NUMBER]=1; - if (thisDetector->dynamicRange==24 || thisDetector->timerValue[PROBES_NUMBER]>0) - 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*/ - 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; + if (thisDetector->dynamicRange==24 || thisDetector->timerValue[PROBES_NUMBER]>0) + 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*/ + 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 number of trim energies to 0*/ - thisDetector->nTrimEn=0; - /** set correction mask to 0*/ - thisDetector->correctionMask=0; - /** set deat time*/ - thisDetector->tDead=0; - /** sets bad channel list file to none */ - strcpy(thisDetector->badChanFile,"none"); - /** sets flat field correction directory */ - strcpy(thisDetector->flatFieldDir,getenv("HOME")); - /** sets flat field correction file */ - strcpy(thisDetector->flatFieldFile,"none"); - /** set number of bad chans to 0*/ - thisDetector->nBadChans=0; - /** set number of bad flat field chans to 0*/ - thisDetector->nBadFF=0; - /** set angular direction to 1*/ - thisDetector->angDirection=1; - /** set fine offset to 0*/ - thisDetector->fineOffset=0; - /** set global offset to 0*/ - thisDetector->globalOffset=0; - /** set number of rois to 0*/ - thisDetector->nROI=0; - /** set readoutflags to none*/ - thisDetector->roFlags=NORMAL_READOUT; - /** set current settings to uninitialized*/ - thisDetector->currentSettings=UNINITIALIZED; - /** set threshold to -1*/ - thisDetector->currentThresholdEV=-1; - // /** set clockdivider to 1*/ - // thisDetector->clkDiv=1; - /** set number of positions to 0*/ - thisDetector->numberOfPositions=0; - /** sets angular conversion file to none */ - strcpy(thisDetector->angConvFile,"none"); - /** set binsize*/ - thisDetector->binSize=0.001; - thisDetector->stoppedFlag=0; - thisDetector->threadedProcessing=1; + /** set number of trim energies to 0*/ + thisDetector->nTrimEn=0; + /** set correction mask to 0*/ + thisDetector->correctionMask=0; + /** set deat time*/ + thisDetector->tDead=0; + /** sets bad channel list file to none */ + strcpy(thisDetector->badChanFile,"none"); + /** sets flat field correction directory */ + strcpy(thisDetector->flatFieldDir,getenv("HOME")); + /** sets flat field correction file */ + strcpy(thisDetector->flatFieldFile,"none"); + /** set number of bad chans to 0*/ + thisDetector->nBadChans=0; + /** set number of bad flat field chans to 0*/ + thisDetector->nBadFF=0; + /** set angular direction to 1*/ + thisDetector->angDirection=1; + /** set fine offset to 0*/ + thisDetector->fineOffset=0; + /** set global offset to 0*/ + thisDetector->globalOffset=0; + /** set number of rois to 0*/ + thisDetector->nROI=0; + /** set readoutflags to none*/ + thisDetector->roFlags=NORMAL_READOUT; + /** set current settings to uninitialized*/ + thisDetector->currentSettings=UNINITIALIZED; + /** set threshold to -1*/ + thisDetector->currentThresholdEV=-1; + // /** set clockdivider to 1*/ + // thisDetector->clkDiv=1; + /** set number of positions to 0*/ + thisDetector->numberOfPositions=0; + /** sets angular conversion file to none */ + strcpy(thisDetector->angConvFile,"none"); + /** set binsize*/ + thisDetector->binSize=0.001; + thisDetector->stoppedFlag=0; + thisDetector->threadedProcessing=1; - thisDetector->actionMask=0; + thisDetector->actionMask=0; - for (int ia=0; iaactionScript[ia],"none"); - strcpy(thisDetector->actionParameter[ia],"none"); - } + for (int ia=0; iaactionScript[ia],"none"); + strcpy(thisDetector->actionParameter[ia],"none"); + } - for (int iscan=0; iscanscanMode[iscan]=0; - strcpy(thisDetector->scanScript[iscan],"none"); - strcpy(thisDetector->scanParameter[iscan],"none"); - thisDetector->nScanSteps[iscan]=0; - thisDetector->scanPrecision[iscan]=0; - } + thisDetector->scanMode[iscan]=0; + strcpy(thisDetector->scanScript[iscan],"none"); + strcpy(thisDetector->scanParameter[iscan],"none"); + thisDetector->nScanSteps[iscan]=0; + thisDetector->scanPrecision[iscan]=0; + } - /* receiver*/ - /** sets receiver onlineFlag to OFFLINE_FLAG */ - thisDetector->receiverOnlineFlag=OFFLINE_FLAG; + /* receiver*/ + /** sets receiver onlineFlag to OFFLINE_FLAG */ + thisDetector->receiverOnlineFlag=OFFLINE_FLAG; - /** calculates the memory offsets for flat field coefficients and errors, module structures, dacs, adcs, chips and channels */ - thisDetector->ffoff=sizeof(sharedSlsDetector); - thisDetector->fferroff=thisDetector->ffoff+sizeof(double)*thisDetector->nChans*thisDetector->nChips*thisDetector->nModsMax; - thisDetector->modoff= thisDetector->fferroff+sizeof(double)*thisDetector->nChans*thisDetector->nChips*thisDetector->nModsMax; - thisDetector->dacoff=thisDetector->modoff+sizeof(sls_detector_module)*thisDetector->nModsMax; - thisDetector->adcoff=thisDetector->dacoff+sizeof(dacs_t)*thisDetector->nDacs*thisDetector->nModsMax; - thisDetector->chipoff=thisDetector->adcoff+sizeof(dacs_t)*thisDetector->nAdcs*thisDetector->nModsMax; - thisDetector->chanoff=thisDetector->chipoff+sizeof(int)*thisDetector->nChips*thisDetector->nModsMax; + /** calculates the memory offsets for flat field coefficients and errors, module structures, dacs, adcs, chips and channels */ + thisDetector->ffoff=sizeof(sharedSlsDetector); + thisDetector->fferroff=thisDetector->ffoff+sizeof(double)*thisDetector->nChans*thisDetector->nChips*thisDetector->nModsMax; + thisDetector->modoff= thisDetector->fferroff+sizeof(double)*thisDetector->nChans*thisDetector->nChips*thisDetector->nModsMax; + thisDetector->dacoff=thisDetector->modoff+sizeof(sls_detector_module)*thisDetector->nModsMax; + thisDetector->adcoff=thisDetector->dacoff+sizeof(dacs_t)*thisDetector->nDacs*thisDetector->nModsMax; + thisDetector->chipoff=thisDetector->adcoff+sizeof(dacs_t)*thisDetector->nAdcs*thisDetector->nModsMax; + thisDetector->chanoff=thisDetector->chipoff+sizeof(int)*thisDetector->nChips*thisDetector->nModsMax; - } + } - /** also in case thisDetector alread existed initialize the pointer for flat field coefficients and errors, module structures, dacs, adcs, chips and channels */ - ffcoefficients=(double*)(goff+thisDetector->ffoff); - fferrors=(double*)(goff+thisDetector->fferroff); - detectorModules=(sls_detector_module*)(goff+ thisDetector->modoff); + /** also in case thisDetector alread existed initialize the pointer for flat field coefficients and errors, module structures, dacs, adcs, chips and channels */ + ffcoefficients=(double*)(goff+thisDetector->ffoff); + fferrors=(double*)(goff+thisDetector->fferroff); + detectorModules=(sls_detector_module*)(goff+ thisDetector->modoff); #ifdef VERBOSE - // for (int imod=0; imod< thisDetector->nModsMax; imod++) - // std::cout<< hex << detectorModules+imod << dec <nModsMax; imod++) + // std::cout<< hex << detectorModules+imod << dec <dacoff); - adcs=(dacs_t*)(goff+thisDetector->adcoff); - chipregs=(int*)(goff+thisDetector->chipoff); - chanregs=(int*)(goff+thisDetector->chanoff); - if (thisDetector->alreadyExisting==0) { - /** if thisDetector is new, initialize its structures \sa initializeDetectorStructure(); */ - initializeDetectorStructure(); - /** set thisDetector->alreadyExisting=1 */ - thisDetector->alreadyExisting=1; - } + dacs=(dacs_t*)(goff+thisDetector->dacoff); + adcs=(dacs_t*)(goff+thisDetector->adcoff); + chipregs=(int*)(goff+thisDetector->chipoff); + chanregs=(int*)(goff+thisDetector->chanoff); + if (thisDetector->alreadyExisting==0) { + /** if thisDetector is new, initialize its structures \sa initializeDetectorStructure(); */ + initializeDetectorStructure(); + /** set thisDetector->alreadyExisting=1 */ + thisDetector->alreadyExisting=1; + } #ifdef VERBOSE - cout << "passing pointers" << endl; + cout << "passing pointers" << endl; #endif - stoppedFlag=&thisDetector->stoppedFlag; - threadedProcessing=&thisDetector->threadedProcessing; - actionMask=&thisDetector->actionMask; - actionScript=thisDetector->actionScript; - actionParameter=thisDetector->actionParameter; - nScanSteps=thisDetector->nScanSteps; - scanMode=thisDetector->scanMode; - scanScript=thisDetector->scanScript; - scanParameter=thisDetector->scanParameter; - scanSteps=thisDetector->scanSteps; - scanPrecision=thisDetector->scanPrecision; - numberOfPositions=&thisDetector->numberOfPositions; - detPositions=thisDetector->detPositions; - angConvFile=thisDetector->angConvFile; - correctionMask=&thisDetector->correctionMask; - binSize=&thisDetector->binSize; - fineOffset=&thisDetector->fineOffset; - globalOffset=&thisDetector->globalOffset; - angDirection=&thisDetector->angDirection; - flatFieldDir=thisDetector->flatFieldDir; - flatFieldFile=thisDetector->flatFieldFile; - badChanFile=thisDetector->badChanFile; - timerValue=thisDetector->timerValue; - expTime=&timerValue[ACQUISITION_TIME]; + stoppedFlag=&thisDetector->stoppedFlag; + threadedProcessing=&thisDetector->threadedProcessing; + actionMask=&thisDetector->actionMask; + actionScript=thisDetector->actionScript; + actionParameter=thisDetector->actionParameter; + nScanSteps=thisDetector->nScanSteps; + scanMode=thisDetector->scanMode; + scanScript=thisDetector->scanScript; + scanParameter=thisDetector->scanParameter; + scanSteps=thisDetector->scanSteps; + scanPrecision=thisDetector->scanPrecision; + numberOfPositions=&thisDetector->numberOfPositions; + detPositions=thisDetector->detPositions; + angConvFile=thisDetector->angConvFile; + correctionMask=&thisDetector->correctionMask; + binSize=&thisDetector->binSize; + fineOffset=&thisDetector->fineOffset; + globalOffset=&thisDetector->globalOffset; + angDirection=&thisDetector->angDirection; + flatFieldDir=thisDetector->flatFieldDir; + flatFieldFile=thisDetector->flatFieldFile; + badChanFile=thisDetector->badChanFile; + timerValue=thisDetector->timerValue; + expTime=&timerValue[ACQUISITION_TIME]; - currentSettings=&thisDetector->currentSettings; - currentThresholdEV=&thisDetector->currentThresholdEV; - filePath=thisDetector->filePath; - fileName=thisDetector->fileName; - fileIndex=&thisDetector->fileIndex; - moveFlag=&thisDetector->moveFlag; - sampleDisplacement=NULL; - settingsFile=thisDetector->settingsFile; + currentSettings=&thisDetector->currentSettings; + currentThresholdEV=&thisDetector->currentThresholdEV; + filePath=thisDetector->filePath; + fileName=thisDetector->fileName; + fileIndex=&thisDetector->fileIndex; + moveFlag=&thisDetector->moveFlag; + sampleDisplacement=NULL; + settingsFile=thisDetector->settingsFile; - // setAngularConversionPointer(thisDetector->angOff,&thisDetector->nMods, thisDetector->nChans*thisDetector->nChips); + // setAngularConversionPointer(thisDetector->angOff,&thisDetector->nMods, thisDetector->nChans*thisDetector->nChips); #ifdef VERBOSE - cout << "done" << endl; + cout << "done" << endl; #endif - /** modifies the last PID accessing the detector */ - thisDetector->lastPID=getpid(); + /** modifies the last PID accessing the detector */ + thisDetector->lastPID=getpid(); #ifdef VERBOSE - cout << "Det size initialized " << endl; + cout << "Det size initialized " << endl; #endif - return OK; + return OK; } int slsDetector::initializeDetectorStructure() { @@ -717,8 +717,8 @@ int slsDetector::initializeDetectorStructure() { /** initializes the adc values to 0 */ - for (int iadc=0; iadcnAdcs; iadc++) { - *(adcs+iadc+thisDetector->nAdcs*imod)=0.; + for (int iadc=0; iadcnAdcs; iadc++) { + *(adcs+iadc+thisDetector->nAdcs*imod)=0.; } @@ -747,39 +747,39 @@ slsDetectorDefs::sls_detector_module* slsDetector::createModule(detectorType t) int nch, nm, nc, nd, na=0; - switch(t) { - case MYTHEN: - nch=128; // complete mythen system - nm=24; - nc=10; - nd=6; // dacs - break; - case PICASSO: - nch=128; // complete mythen system - nm=24; - nc=12; - nd=6; // dacs+adcs - break; - case GOTTHARD: - nch=128; - nm=1; - nc=10; - nd=8; // dacs+adcs - na=5; - break; - case EIGER: - nch=65536; // one EIGER half module - nm=1; //modules/detector - nc=4; //chips - nd=16; //dacs - na=16; - default: - nch=0; // dum! - nm=0; //modules/detector - nc=0; //chips - nd=0; //dacs+adcs - na=0; - } + switch(t) { + case MYTHEN: + nch=128; // complete mythen system + nm=24; + nc=10; + nd=6; // dacs + break; + case PICASSO: + nch=128; // complete mythen system + nm=24; + nc=12; + nd=6; // dacs+adcs + break; + case GOTTHARD: + nch=128; + nm=1; + nc=10; + nd=8; // dacs+adcs + na=5; + break; + case EIGER: + nch=65536; // one EIGER half module + nm=1; //modules/detector + nc=4; //chips + nd=16; //dacs + na=16; + default: + nch=0; // dum! + nm=0; //modules/detector + nc=0; //chips + nd=0; //dacs+adcs + na=0; + } dacs_t *dacs=new dacs_t[nd]; dacs_t *adcs=new dacs_t[na]; @@ -923,7 +923,7 @@ int slsDetector::setOnline(int off) { string slsDetector::checkOnline() { string retval = string(""); if(!controlSocket){ - //this already sets the online/offline flag + //this already sets the online/offline flag setTCPSocket(); if(thisDetector->onlineFlag==OFFLINE_FLAG) return string(thisDetector->hostname); @@ -955,14 +955,14 @@ string slsDetector::checkOnline() { - /* - configure the socket communication and check that the server exists - enum communicationProtocol{ - TCP, - UDP - }{}; +/* + configure the socket communication and check that the server exists + enum communicationProtocol{ + TCP, + UDP + }{}; - */ +*/ int slsDetector::setTCPSocket(string const name, int const control_port, int const stop_port){ @@ -978,16 +978,12 @@ int slsDetector::setTCPSocket(string const name, int const control_port, int con strcpy(thisName,name.c_str()); strcpy(thisDetector->hostname,thisName); if (controlSocket) { - delete controlSocket; - controlSocket=NULL; + delete controlSocket; + controlSocket=NULL; } if (stopSocket) { - delete stopSocket; - stopSocket=NULL; - } - if (dataSocket){ - delete dataSocket; - dataSocket=NULL; + delete stopSocket; + stopSocket=NULL; } } else strcpy(thisName,thisDetector->hostname); @@ -999,8 +995,8 @@ int slsDetector::setTCPSocket(string const name, int const control_port, int con thisCP=control_port; thisDetector->controlPort=thisCP; if (controlSocket) { - delete controlSocket; - controlSocket=NULL; + delete controlSocket; + controlSocket=NULL; } } else thisCP=thisDetector->controlPort; @@ -1012,8 +1008,8 @@ int slsDetector::setTCPSocket(string const name, int const control_port, int con thisSP=stop_port; thisDetector->stopPort=thisSP; if (stopSocket) { - delete stopSocket; - stopSocket=NULL; + delete stopSocket; + stopSocket=NULL; } } else thisSP=thisDetector->stopPort; @@ -1038,40 +1034,22 @@ int slsDetector::setTCPSocket(string const name, int const control_port, int con stopSocket=new MySocketTCP(thisName, thisSP); if (stopSocket->getErrorStatus()){ #ifdef VERBOSE - std::cout<< "Could not connect Stop socket "<getErrorStatus()){ -#ifdef VERBOSE - std::cout<< "Could not connect Data socket "<onlineFlag=OFFLINE_FLAG; + thisDetector->onlineFlag=OFFLINE_FLAG; #ifdef VERBOSE std::cout<< "offline!" << std::endl; #endif @@ -1080,13 +1058,13 @@ int slsDetector::setTCPSocket(string const name, int const control_port, int con }; - /** connect to the control port */ +/** connect to the control port */ int slsDetector::connectControl() { if (controlSocket) return controlSocket->Connect(); return FAIL; } - /** disconnect from the control port */ +/** disconnect from the control port */ int slsDetector::disconnectControl() { if (controlSocket) controlSocket->Disconnect(); @@ -1095,28 +1073,28 @@ int slsDetector::disconnectControl() { - /** connect to the data port */ - int slsDetector::connectData() { +/** connect to the data port */ +int slsDetector::connectData() { if (dataSocket) return dataSocket->Connect(); return FAIL; }; - /** disconnect from the data port */ - int slsDetector::disconnectData(){ +/** disconnect from the data port */ +int slsDetector::disconnectData(){ if (dataSocket) dataSocket->Disconnect(); return OK; } ; - /** connect to the stop port */ - int slsDetector::connectStop() { +/** connect to the stop port */ +int slsDetector::connectStop() { if (stopSocket) return stopSocket->Connect(); return FAIL; }; - /** disconnect from the stop port */ - int slsDetector::disconnectStop(){ +/** disconnect from the stop port */ +int slsDetector::disconnectStop(){ if (stopSocket) stopSocket->Disconnect(); return OK; @@ -1139,14 +1117,14 @@ int slsDetector::disconnectControl() { - /* Communication to server */ +/* Communication to server */ - // General purpose functions +// General purpose functions - /* - executes a system command on the server - e.g. mount an nfs disk, reboot and returns answer etc. - */ +/* + executes a system command on the server + e.g. mount an nfs disk, reboot and returns answer etc. +*/ int slsDetector::execCommand(string cmd, string answer){ char arg[MAX_STR_LENGTH], retval[MAX_STR_LENGTH]; @@ -1183,20 +1161,20 @@ int slsDetector::execCommand(string cmd, string answer){ // Detector configuration functions - /* - the detector knows what type of detector it is +/* + the detector knows what type of detector it is - enum detectorType{ - GET_DETECTOR_TYPE, - GENERIC, - MYTHEN, - PILATUS, - EIGER, - GOTTHARD, - AGIPD - }; + enum detectorType{ + GET_DETECTOR_TYPE, + GENERIC, + MYTHEN, + PILATUS, + EIGER, + GOTTHARD, + AGIPD + }; - */ +*/ int slsDetector::setDetectorType(detectorType const type){ int arg, retval=FAIL; @@ -1233,7 +1211,7 @@ int slsDetector::setDetectorType(detectorType const type){ else { retType=type; thisDetector->myDetectorType=type; - } + } retval=OK; } #ifdef VERBOSE @@ -1261,7 +1239,7 @@ slsDetectorDefs::detectorType slsDetector::getDetectorsType(int pos){ - /* needed to set/get the size of the detector */ +/* needed to set/get the size of the detector */ // if n=GET_FLAG returns the number of installed modules, int slsDetector::setNumberOfModules(int n, dimension d){ @@ -1316,23 +1294,23 @@ int slsDetector::setNumberOfModules(int n, dimension d){ retval=thisDetector->nMod[d]; } #ifdef VERBOSE - std::cout<< "Number of modules in dimension "<< d <<" is " << retval << std::endl; + std::cout<< "Number of modules in dimension "<< d <<" is " << retval << std::endl; #endif - if (ret==FAIL) { - std::cout<< "Set number of modules failed " << std::endl; - } else { - thisDetector->nMod[d]=retval; - thisDetector->nMods=thisDetector->nMod[X]*thisDetector->nMod[Y]; + if (ret==FAIL) { + std::cout<< "Set number of modules failed " << std::endl; + } else { + thisDetector->nMod[d]=retval; + thisDetector->nMods=thisDetector->nMod[X]*thisDetector->nMod[Y]; - if (thisDetector->nModsMaxnMods) - thisDetector->nModsMax=thisDetector->nMods; + if (thisDetector->nModsMaxnMods) + thisDetector->nModsMax=thisDetector->nMods; - if (thisDetector->nModMax[X]nMod[X]) - thisDetector->nModMax[X]=thisDetector->nMod[X]; + if (thisDetector->nModMax[X]nMod[X]) + thisDetector->nModMax[X]=thisDetector->nMod[X]; - if (thisDetector->nModMax[Y]nMod[Y]) - thisDetector->nModMax[Y]=thisDetector->nMod[Y]; + if (thisDetector->nModMax[Y]nMod[Y]) + thisDetector->nModMax[Y]=thisDetector->nMod[Y]; @@ -1342,22 +1320,22 @@ int slsDetector::setNumberOfModules(int n, dimension d){ - int dr=thisDetector->dynamicRange; - if (dr==24) - dr=32; + int dr=thisDetector->dynamicRange; + if (dr==24) + dr=32; - if (thisDetector->timerValue[PROBES_NUMBER]==0) { - thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*dr/8; - } else { - thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*4; - } + if (thisDetector->timerValue[PROBES_NUMBER]==0) { + thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*dr/8; + } else { + thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*4; + } #ifdef VERBOSE - std::cout<< "Data size is " << thisDetector->dataBytes << std::endl; - std::cout<< "nModX " << thisDetector->nMod[X] << " nModY " << thisDetector->nMod[Y] << " nChips " << thisDetector->nChips << " nChans " << thisDetector->nChans<< " dr " << dr << std::endl; + std::cout<< "Data size is " << thisDetector->dataBytes << std::endl; + std::cout<< "nModX " << thisDetector->nMod[X] << " nModY " << thisDetector->nMod[Y] << " nChips " << thisDetector->nChips << " nChans " << thisDetector->nChans<< " dr " << dr << std::endl; #endif - } - return thisDetector->nMod[d]; + } + return thisDetector->nMod[d]; }; @@ -1400,32 +1378,32 @@ int slsDetector::getMaxNumberOfModules(dimension d){ retval=thisDetector->nModMax[d]; } #ifdef VERBOSE - std::cout<< "Max number of modules in dimension "<< d <<" is " << retval << std::endl; + std::cout<< "Max number of modules in dimension "<< d <<" is " << retval << std::endl; #endif - if (ret==FAIL) { - std::cout<< "Get max number of modules failed " << std::endl; - return retval; - } else { - thisDetector->nModMax[d]=retval; - thisDetector->nModsMax=thisDetector->nModMax[0]*thisDetector->nModMax[1]; - } - return thisDetector->nModMax[d]; + if (ret==FAIL) { + std::cout<< "Get max number of modules failed " << std::endl; + return retval; + } else { + thisDetector->nModMax[d]=retval; + thisDetector->nModsMax=thisDetector->nModMax[0]*thisDetector->nModMax[1]; + } + return thisDetector->nModMax[d]; }; - /* - This function is used to set the polarity and meaning of the digital I/O signals (signal index) +/* + This function is used to set the polarity and meaning of the digital I/O signals (signal index) -enum externalSignalFlag { + enum externalSignalFlag { GET_EXTERNAL_SIGNAL_FLAG, SIGNAL_OFF, GATE_ACTIVE_HIGH, GATE_ACTIVE_LOW, TRIGGER_RISING_EDGE, TRIGGER_FALLING_EDGE -}{}; - */ + }{}; +*/ slsDetectorDefs::externalSignalFlag slsDetector::setExternalSignalFlags(externalSignalFlag pol, int signalindex){ @@ -1483,21 +1461,21 @@ slsDetectorDefs::externalSignalFlag slsDetector::setExternalSignalFlags(external }; - /* - this function is used to select wether the detector is triggered or gated and in which mode - enum externalCommunicationMode{ - GET_EXTERNAL_COMMUNICATION_MODE, - AUTO, - TRIGGER_EXPOSURE, - TRIGGER_READOUT, - TRIGGER_COINCIDENCE_WITH_INTERNAL_ENABLE, - GATE_FIX_NUMBER, - GATE_FIX_DURATION, - GATE_WITH_START_TRIGGER, - GATE_COINCIDENCE_WITH_INTERNAL_ENABLE -}; +/* + this function is used to select wether the detector is triggered or gated and in which mode + enum externalCommunicationMode{ + GET_EXTERNAL_COMMUNICATION_MODE, + AUTO, + TRIGGER_EXPOSURE, + TRIGGER_READOUT, + TRIGGER_COINCIDENCE_WITH_INTERNAL_ENABLE, + GATE_FIX_NUMBER, + GATE_FIX_DURATION, + GATE_WITH_START_TRIGGER, + GATE_COINCIDENCE_WITH_INTERNAL_ENABLE + }; - */ +*/ slsDetectorDefs::externalCommunicationMode slsDetector::setExternalCommunicationMode( externalCommunicationMode pol){ @@ -1550,19 +1528,19 @@ slsDetectorDefs::externalCommunicationMode slsDetector::setExternalCommunication }; - // Tests and identification - /* - Gets versions +// Tests and identification +/* + Gets versions - enum idMode{ - MODULE_SERIAL_NUMBER, - MODULE_FIRMWARE_VERSION, - DETECTOR_SERIAL_NUMBER, - DETECTOR_FIRMWARE_VERSION, - DETECTOR_SOFTWARE_VERSION - }{}; + enum idMode{ + MODULE_SERIAL_NUMBER, + MODULE_FIRMWARE_VERSION, + DETECTOR_SERIAL_NUMBER, + DETECTOR_FIRMWARE_VERSION, + DETECTOR_SOFTWARE_VERSION + }{}; - */ +*/ @@ -1582,7 +1560,7 @@ int64_t slsDetector::getId( idMode mode, int imod){ if (mode==MODULE_SERIAL_NUMBER) std::cout<< "Getting id of "<< imod << std::endl; else - std::cout<< "Getting id type "<< mode << std::endl; + std::cout<< "Getting id type "<< mode << std::endl; #endif if (mode==THIS_SOFTWARE_VERSION) { ret=OK; @@ -1628,19 +1606,19 @@ int64_t slsDetector::getId( idMode mode, int imod){ - /* - Digital test of the modules +/* + Digital test of the modules - enum digitalTestMode { - CHIP_TEST, - MODULE_FIRMWARE_TEST, - DETECTOR_FIRMWARE_TEST, - DETECTOR_MEMORY_TEST, - DETECTOR_BUS_TEST, - DETECTOR_SOFTWARE_TEST - }{}; - returns ok or error mask - */ + enum digitalTestMode { + CHIP_TEST, + MODULE_FIRMWARE_TEST, + DETECTOR_FIRMWARE_TEST, + DETECTOR_MEMORY_TEST, + DETECTOR_BUS_TEST, + DETECTOR_SOFTWARE_TEST + }{}; + returns ok or error mask +*/ int slsDetector::digitalTest( digitalTestMode mode, int imod){ @@ -1661,7 +1639,7 @@ int slsDetector::digitalTest( digitalTestMode mode, int imod){ controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&mode,sizeof(mode)); if ((mode==CHIP_TEST)|| (mode==DIGITAL_BIT_TEST)) - controlSocket->SendDataOnly(&imod,sizeof(imod)); + controlSocket->SendDataOnly(&imod,sizeof(imod)); controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret!=FAIL) controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); @@ -1678,7 +1656,7 @@ int slsDetector::digitalTest( digitalTestMode mode, int imod){ ret=FAIL; } #ifdef VERBOSE - std::cout<< "Id "<< mode <<" is " << retval << std::endl; + std::cout<< "Id "<< mode <<" is " << retval << std::endl; #endif if (ret==FAIL) { std::cout<< "Get id failed " << std::endl; @@ -1689,48 +1667,48 @@ int slsDetector::digitalTest( digitalTestMode mode, int imod){ - /* - analog test of the modules - enum analogTestMode { - COUNT_CALIBRATION_PULSES, - I_DON_T_KNOW - }{}; +/* + analog test of the modules + enum analogTestMode { + COUNT_CALIBRATION_PULSES, + I_DON_T_KNOW + }{}; - */ -/* -int* slsDetector::analogTest(analogTestMode mode){ - std::cout<< "function not yet implemented " << std::endl; -}; */ - /* - enable analog output of channel - */ /* -int slsDetector::enableAnalogOutput(int ichan){ + int* slsDetector::analogTest(analogTestMode mode){ + std::cout<< "function not yet implemented " << std::endl; + }; +*/ +/* + enable analog output of channel +*/ +/* + int slsDetector::enableAnalogOutput(int ichan){ int imod=ichan/(nChans*nChips); ichan-=imod*(nChans*nChips); int ichip=ichan/nChans; ichan-=ichip*(nChans); enableAnalogOutput(imod,ichip,ichan); -}; -int slsDetector::enableAnalogOutput(int imod, int ichip, int ichan){ + }; + int slsDetector::enableAnalogOutput(int imod, int ichip, int ichan){ std::cout<< "function not yet implemented " << std::endl; -}; + }; */ - /* - give a train of calibration pulses - */ +/* + give a train of calibration pulses +*/ /* -int slsDetector::giveCalibrationPulse(double vcal, int npulses){ + int slsDetector::giveCalibrationPulse(double vcal, int npulses){ std::cout<< "function not yet implemented " << std::endl; -}; + }; */ - // Expert low level functions +// Expert low level functions - /* write or read register */ +/* write or read register */ int slsDetector::writeRegister(int addr, int val){ @@ -1827,20 +1805,20 @@ int slsDetector::readRegister(int addr){ }; - // Expert initialization functions - /* - set dacs or read ADC for the module - enum dacIndex { - TRIMBIT_SIZE, - THRESHOLD, - SHAPER1, - SHAPER2, - CALIBRATION_PULSE, - PREAMP, - TEMPERATURE, - HUMIDITY, -}{}; - */ +// Expert initialization functions +/* + set dacs or read ADC for the module + enum dacIndex { + TRIMBIT_SIZE, + THRESHOLD, + SHAPER1, + SHAPER2, + CALIBRATION_PULSE, + PREAMP, + TEMPERATURE, + HUMIDITY, + }{}; +*/ dacs_t slsDetector::setDAC(dacs_t val, dacIndex index, int imod){ @@ -1925,12 +1903,12 @@ dacs_t slsDetector::getADC(dacIndex index, int imod){ if (ret!=FAIL) { controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); if (adcs) { - *(adcs+index+imod*thisDetector->nAdcs)=retval; + *(adcs+index+imod*thisDetector->nAdcs)=retval; } } else { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); std::cout<< "Detector returned error: " << mess << std::endl; - } + } controlSocket->Disconnect(); if (ret==FORCE_UPDATE) updateDetector(); @@ -1949,16 +1927,16 @@ dacs_t slsDetector::getADC(dacIndex index, int imod){ }; - /* - configure single channel - enum channelRegisterBit { - COMPARATOR_ENABLE_OFF, - ANALOG_SIGNAL_ENABLE_OFF, - CALIBRATION_ENABLE_OFF, - TRIMBIT_OFF // should always be the last! - } +/* + configure single channel + enum channelRegisterBit { + COMPARATOR_ENABLE_OFF, + ANALOG_SIGNAL_ENABLE_OFF, + CALIBRATION_ENABLE_OFF, + TRIMBIT_OFF // should always be the last! + } - */ +*/ int slsDetector::setChannel(int64_t reg, int ichan, int ichip, int imod){ sls_detector_channel myChan; @@ -1970,19 +1948,19 @@ int slsDetector::setChannel(int64_t reg, int ichan, int ichip, int imod){ int ret; /* if (imod==-1) { - mmin=0; - mmax=thisDetector->nModsMax; - } + mmin=0; + mmax=thisDetector->nModsMax; + } - if (ichip==-1) { - chimin=0; - chimax=thisDetector->nChips; - } + if (ichip==-1) { + chimin=0; + chimax=thisDetector->nChips; + } - if (ichan==-1) { - chamin=0; - chamax=thisDetector->nChans; - }*/ + if (ichan==-1) { + chamin=0; + chamax=thisDetector->nChans; + }*/ // for (int im=mmin; imonlineFlag==ONLINE_FLAG) { if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - sendChannel(&chan); + if (controlSocket->Connect()>=0) { + controlSocket->SendDataOnly(&fnum,sizeof(fnum)); + sendChannel(&chan); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - } else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); + if (ret!=FAIL) { + controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); + } else { + controlSocket->ReceiveDataOnly(mess,sizeof(mess)); + std::cout<< "Detector returned error: " << mess << std::endl; + } + controlSocket->Disconnect(); + if (ret==FORCE_UPDATE) + updateDetector(); } - controlSocket->Disconnect(); - if (ret==FORCE_UPDATE) - updateDetector(); - } } } @@ -2105,21 +2083,21 @@ slsDetectorDefs::sls_detector_channel slsDetector::getChannel(int ichan, int ic arg[2]=imod; if (thisDetector->onlineFlag==ONLINE_FLAG) { if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(arg,sizeof(arg)); + if (controlSocket->Connect()>=0) { + controlSocket->SendDataOnly(&fnum,sizeof(fnum)); + controlSocket->SendDataOnly(arg,sizeof(arg)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) { - receiveChannel(&myChan); - } else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); - if (ret==FORCE_UPDATE) + controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); + if (ret!=FAIL) { + receiveChannel(&myChan); + } else { + controlSocket->ReceiveDataOnly(mess,sizeof(mess)); + std::cout<< "Detector returned error: " << mess << std::endl; + } + controlSocket->Disconnect(); + if (ret==FORCE_UPDATE) updateDetector(); - } + } } } @@ -2136,15 +2114,15 @@ slsDetectorDefs::sls_detector_channel slsDetector::getChannel(int ichan, int ic return myChan; } - /* - configure chip - enum chipRegisterBit { - ENABLE_ANALOG_OUTPUT, - OUTPUT_WIDTH // should always be the last - }{}; - */ +/* + configure chip + enum chipRegisterBit { + ENABLE_ANALOG_OUTPUT, + OUTPUT_WIDTH // should always be the last + }{}; +*/ int slsDetector::setChip(int reg, int ichip, int imod){ - sls_detector_chip myChip; + sls_detector_chip myChip; #ifdef VERBOSE std::cout<< "Setting chip "<< ichip << " " << imod << " to " << reg << std::endl; @@ -2199,20 +2177,20 @@ int slsDetector::setChip(sls_detector_chip chip){ if (thisDetector->onlineFlag==ONLINE_FLAG) { if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - sendChip(&chip); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - } else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); - if (ret==FORCE_UPDATE) + if (controlSocket->Connect()>=0) { + controlSocket->SendDataOnly(&fnum,sizeof(fnum)); + sendChip(&chip); + controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); + if (ret!=FAIL) { + controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); + } else { + controlSocket->ReceiveDataOnly(mess,sizeof(mess)); + std::cout<< "Detector returned error: " << mess << std::endl; + } + controlSocket->Disconnect(); + if (ret==FORCE_UPDATE) updateDetector(); - } + } } } @@ -2229,7 +2207,7 @@ int slsDetector::setChip(sls_detector_chip chip){ }; - slsDetectorDefs::sls_detector_chip slsDetector::getChip(int ichip, int imod){ +slsDetectorDefs::sls_detector_chip slsDetector::getChip(int ichip, int imod){ int fnum=F_GET_CHIP; sls_detector_chip myChip; @@ -2253,21 +2231,21 @@ int slsDetector::setChip(sls_detector_chip chip){ if (thisDetector->onlineFlag==ONLINE_FLAG) { if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(arg,sizeof(arg)); + if (controlSocket->Connect()>=0) { + controlSocket->SendDataOnly(&fnum,sizeof(fnum)); + controlSocket->SendDataOnly(arg,sizeof(arg)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) { - receiveChip(&myChip); - } else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); + controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); + if (ret!=FAIL) { + receiveChip(&myChip); + } else { + controlSocket->ReceiveDataOnly(mess,sizeof(mess)); + std::cout<< "Detector returned error: " << mess << std::endl; + } + controlSocket->Disconnect(); if (ret==FORCE_UPDATE) updateDetector(); - } + } } } @@ -2287,19 +2265,19 @@ int slsDetector::setChip(sls_detector_chip chip){ return myChip; }; - /* - configure module - enum moduleRegisterBit { - I_DON_T_KNOW, - OUTPUT_WIDTH // should always be the last - }{}; - */ +/* + configure module + enum moduleRegisterBit { + I_DON_T_KNOW, + OUTPUT_WIDTH // should always be the last + }{}; +*/ int slsDetector::setModule(int reg, int imod){ sls_detector_module myModule; #ifdef VERBOSE - std::cout << "slsDetector set module " << std::endl; + std::cout << "slsDetector set module " << std::endl; #endif int charegs[thisDetector->nChans*thisDetector->nChips]; int chiregs[thisDetector->nChips]; @@ -2385,26 +2363,26 @@ int slsDetector::setModule(sls_detector_module module){ #ifdef VERBOSE - std::cout << "slsDetector set module " << std::endl; + std::cout << "slsDetector set module " << std::endl; #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - sendModule(&module); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - } else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); + if (controlSocket->Connect()>=0) { + controlSocket->SendDataOnly(&fnum,sizeof(fnum)); + sendModule(&module); + controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); + if (ret!=FAIL) { + controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); + } else { + controlSocket->ReceiveDataOnly(mess,sizeof(mess)); + std::cout<< "Detector returned error: " << mess << std::endl; + } + controlSocket->Disconnect(); if (ret==FORCE_UPDATE) updateDetector(); - } + } } } @@ -2496,21 +2474,21 @@ slsDetectorDefs::sls_detector_module *slsDetector::getModule(int imod){ if (thisDetector->onlineFlag==ONLINE_FLAG) { if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&imod,sizeof(imod)); + if (controlSocket->Connect()>=0) { + controlSocket->SendDataOnly(&fnum,sizeof(fnum)); + controlSocket->SendDataOnly(&imod,sizeof(imod)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) { - receiveModule(myMod); - } else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); + controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); + if (ret!=FAIL) { + receiveModule(myMod); + } else { + controlSocket->ReceiveDataOnly(mess,sizeof(mess)); + std::cout<< "Detector returned error: " << mess << std::endl; + } + controlSocket->Disconnect(); if (ret==FORCE_UPDATE) updateDetector(); - } + } } } @@ -2563,30 +2541,30 @@ slsDetectorDefs::sls_detector_module *slsDetector::getModule(int imod){ - // calibration functions +// calibration functions /* really needed? -int slsDetector::setCalibration(int imod, detectorSettings isettings, double gain, double offset){ + int slsDetector::setCalibration(int imod, detectorSettings isettings, double gain, double offset){ std::cout<< "function not yet implemented " << std::endl; return OK; -} -int slsDetector::getCalibration(int imod, detectorSettings isettings, double &gain, double &offset){ + } + int slsDetector::getCalibration(int imod, detectorSettings isettings, double &gain, double &offset){ std::cout<< "function not yet implemented " << std::endl; -} + } */ - /* - calibrated setup of the threshold - */ +/* + calibrated setup of the threshold +*/ int slsDetector::getThresholdEnergy(int imod){ @@ -2660,10 +2638,10 @@ int slsDetector::setThresholdEnergy(int e_eV, int imod, detectorSettings isetti return thisDetector->currentThresholdEV; }; - /* - select detector settings - */ - slsDetectorDefs::detectorSettings slsDetector::getSettings(int imod){ +/* + select detector settings +*/ +slsDetectorDefs::detectorSettings slsDetector::getSettings(int imod){ int fnum=F_SET_SETTINGS; @@ -2691,7 +2669,7 @@ int slsDetector::setThresholdEnergy(int e_eV, int imod, detectorSettings isetti #ifdef VERBOSE std::cout<< "Settings are "<< retval << std::endl; #endif - } + } controlSocket->Disconnect(); if (ret==FORCE_UPDATE) updateDetector(); @@ -2850,84 +2828,84 @@ int slsDetector::getChanRegs(double* retval,bool fromDetector){ int slsDetector::updateDetectorNoWait() { - // int ret=OK; - enum detectorSettings t; - int thr, n, nm; - // int it; - int64_t retval;// tns=-1; - char lastClientIP[INET_ADDRSTRLEN]; + // int ret=OK; + enum detectorSettings t; + int thr, n, nm; + // int it; + int64_t retval;// tns=-1; + char lastClientIP[INET_ADDRSTRLEN]; - n = controlSocket->ReceiveDataOnly(lastClientIP,sizeof(lastClientIP)); + n = controlSocket->ReceiveDataOnly(lastClientIP,sizeof(lastClientIP)); #ifdef VERBOSE - cout << "Updating detector last modified by " << lastClientIP << std::endl; + cout << "Updating detector last modified by " << lastClientIP << std::endl; #endif - n = controlSocket->ReceiveDataOnly(&nm,sizeof(nm)); - thisDetector->nMod[X]=nm; - n = controlSocket->ReceiveDataOnly( &nm,sizeof(nm)); - /// Should be overcome at a certain point! + n = controlSocket->ReceiveDataOnly(&nm,sizeof(nm)); + thisDetector->nMod[X]=nm; + n = controlSocket->ReceiveDataOnly( &nm,sizeof(nm)); + /// Should be overcome at a certain point! - if (thisDetector->myDetectorType==MYTHEN) { - thisDetector->nModMax[X]=nm; - thisDetector->nModMax[Y]=1; - thisDetector->nModsMax=thisDetector->nModMax[Y]*thisDetector->nModMax[X]; - thisDetector->nMod[Y]=1; - } else { - thisDetector->nMod[Y]=nm; - } + if (thisDetector->myDetectorType==MYTHEN) { + thisDetector->nModMax[X]=nm; + thisDetector->nModMax[Y]=1; + thisDetector->nModsMax=thisDetector->nModMax[Y]*thisDetector->nModMax[X]; + thisDetector->nMod[Y]=1; + } else { + thisDetector->nMod[Y]=nm; + } - thisDetector->nMods=thisDetector->nMod[Y]*thisDetector->nMod[X]; - if (thisDetector->nModsMaxnMods) - thisDetector->nModsMax=thisDetector->nMods; + thisDetector->nMods=thisDetector->nMod[Y]*thisDetector->nMod[X]; + if (thisDetector->nModsMaxnMods) + thisDetector->nModsMax=thisDetector->nMods; - if (thisDetector->nModMax[X]nMod[X]) - thisDetector->nModMax[X]=thisDetector->nMod[X]; + if (thisDetector->nModMax[X]nMod[X]) + thisDetector->nModMax[X]=thisDetector->nMod[X]; - if (thisDetector->nModMax[Y]nMod[Y]) - thisDetector->nModMax[Y]=thisDetector->nMod[Y]; + if (thisDetector->nModMax[Y]nMod[Y]) + thisDetector->nModMax[Y]=thisDetector->nMod[Y]; - n = controlSocket->ReceiveDataOnly( &nm,sizeof(nm)); - thisDetector->dynamicRange=nm; + n = controlSocket->ReceiveDataOnly( &nm,sizeof(nm)); + thisDetector->dynamicRange=nm; - n = controlSocket->ReceiveDataOnly( &nm,sizeof(nm)); - thisDetector->dataBytes=nm; - //t=setSettings(GET_SETTINGS); - n = controlSocket->ReceiveDataOnly( &t,sizeof(t)); - thisDetector->currentSettings=t; + n = controlSocket->ReceiveDataOnly( &nm,sizeof(nm)); + thisDetector->dataBytes=nm; + //t=setSettings(GET_SETTINGS); + n = controlSocket->ReceiveDataOnly( &t,sizeof(t)); + thisDetector->currentSettings=t; - if(thisDetector->myDetectorType!= GOTTHARD){ - //thr=getThresholdEnergy(); - n = controlSocket->ReceiveDataOnly( &thr,sizeof(thr)); - thisDetector->currentThresholdEV=thr; - } + if(thisDetector->myDetectorType!= GOTTHARD){ + //thr=getThresholdEnergy(); + n = controlSocket->ReceiveDataOnly( &thr,sizeof(thr)); + thisDetector->currentThresholdEV=thr; + } - //retval=setFrames(tns); - n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); - thisDetector->timerValue[FRAME_NUMBER]=retval; - // retval=setExposureTime(tns); - n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); - thisDetector->timerValue[ACQUISITION_TIME]=retval; + //retval=setFrames(tns); + n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); + thisDetector->timerValue[FRAME_NUMBER]=retval; + // retval=setExposureTime(tns); + n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); + thisDetector->timerValue[ACQUISITION_TIME]=retval; - //retval=setPeriod(tns); - n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); - thisDetector->timerValue[FRAME_PERIOD]=retval; - //retval=setDelay(tns); - n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); - thisDetector->timerValue[DELAY_AFTER_TRIGGER]=retval; - // retval=setGates(tns); - n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); - thisDetector->timerValue[GATES_NUMBER]=retval; + //retval=setPeriod(tns); + n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); + thisDetector->timerValue[FRAME_PERIOD]=retval; + //retval=setDelay(tns); + n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); + thisDetector->timerValue[DELAY_AFTER_TRIGGER]=retval; + // retval=setGates(tns); + n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); + thisDetector->timerValue[GATES_NUMBER]=retval; - //retval=setProbes(tns); - if(thisDetector->myDetectorType!= GOTTHARD){ - n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); - thisDetector->timerValue[PROBES_NUMBER]=retval; - } + //retval=setProbes(tns); + if(thisDetector->myDetectorType!= GOTTHARD){ + n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); + thisDetector->timerValue[PROBES_NUMBER]=retval; + } - //retval=setTrains(tns); - n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); - thisDetector->timerValue[CYCLES_NUMBER]=retval; + //retval=setTrains(tns); + n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); + thisDetector->timerValue[CYCLES_NUMBER]=retval; - return OK; + return OK; } @@ -3004,15 +2982,15 @@ int slsDetector::stopAcquisition(){ #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { if (stopSocket) { - if (stopSocket->Connect()>=0) { - stopSocket->SendDataOnly(&fnum,sizeof(fnum)); - stopSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - stopSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - stopSocket->Disconnect(); - } + if (stopSocket->Connect()>=0) { + stopSocket->SendDataOnly(&fnum,sizeof(fnum)); + stopSocket->ReceiveDataOnly(&ret,sizeof(ret)); + if (ret==FAIL) { + stopSocket->ReceiveDataOnly(mess,sizeof(mess)); + std::cout<< "Detector returned error: " << mess << std::endl; + } + stopSocket->Disconnect(); + } } } thisDetector->stoppedFlag=1; @@ -3032,17 +3010,17 @@ int slsDetector::startReadOut(){ #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); - if (ret==FORCE_UPDATE) - updateDetector(); - } + if (controlSocket->Connect()>=0) { + controlSocket->SendDataOnly(&fnum,sizeof(fnum)); + controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); + if (ret==FAIL) { + controlSocket->ReceiveDataOnly(mess,sizeof(mess)); + std::cout<< "Detector returned error: " << mess << std::endl; + } + controlSocket->Disconnect(); + if (ret==FORCE_UPDATE) + updateDetector(); + } } } return ret; @@ -3105,61 +3083,61 @@ int* slsDetector::readFrame(){ int* slsDetector::getDataFromDetector(int *retval){ - int nel=thisDetector->dataBytes/sizeof(int); - int n; + int nel=thisDetector->dataBytes/sizeof(int); + int n; - int *r=retval; + int *r=retval; - // int* retval=new int[nel]; + // int* retval=new int[nel]; - if (retval==NULL) - retval=new int[nel]; + if (retval==NULL) + retval=new int[nel]; - int ret=FAIL; - char mess[100]="Nothing"; + int ret=FAIL; + char mess[100]="Nothing"; #ifdef VERBOSE - std::cout<< "getting data "<< thisDetector->dataBytes << " " << nel<< std::endl; + std::cout<< "getting data "<< thisDetector->dataBytes << " " << nel<< std::endl; #endif - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); + controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); #ifdef VERBOSE - cout << "ret=" << ret << endl; + cout << "ret=" << ret << endl; #endif - if (ret!=OK) { - n= controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - if (ret==FAIL) { - thisDetector->stoppedFlag=1; - std::cout<< "Detector returned: " << mess << " " << n << std::endl; - } else { - ; + if (ret!=OK) { + n= controlSocket->ReceiveDataOnly(mess,sizeof(mess)); + if (ret==FAIL) { + thisDetector->stoppedFlag=1; + std::cout<< "Detector returned: " << mess << " " << n << std::endl; + } else { + ; #ifdef VERBOSE - std::cout<< "Detector successfully returned: " << mess << " " << n << std::endl; + std::cout<< "Detector successfully returned: " << mess << " " << n << std::endl; #endif - } - if (r==NULL) { - delete [] retval; - } - return NULL; - } else { - n=controlSocket->ReceiveDataOnly(retval,thisDetector->dataBytes); + } + if (r==NULL) { + delete [] retval; + } + return NULL; + } else { + n=controlSocket->ReceiveDataOnly(retval,thisDetector->dataBytes); #ifdef VERBOSE - std::cout<< "Received "<< n << " data bytes" << std::endl; + std::cout<< "Received "<< n << " data bytes" << std::endl; #endif - if (n!=thisDetector->dataBytes) { - std::cout<< "wrong data size received: received " << n << " but expected " << thisDetector->dataBytes << std::endl; - thisDetector->stoppedFlag=1; - ret=FAIL; - if (r==NULL) { - delete [] retval; - } - return NULL; - } - } + if (n!=thisDetector->dataBytes) { + std::cout<< "wrong data size received: received " << n << " but expected " << thisDetector->dataBytes << std::endl; + thisDetector->stoppedFlag=1; + ret=FAIL; + if (r==NULL) { + delete [] retval; + } + return NULL; + } + } - return retval; + return retval; }; @@ -3185,14 +3163,14 @@ int* slsDetector::readAll(){ while ((retval=getDataFromDetector())){ i++; #ifdef VERBOSE - std::cout<< i << std::endl; - //#else - //std::cout << "-" << flush ; + std::cout<< i << std::endl; + //#else + //std::cout << "-" << flush ; #endif - dataQueue.push(retval); - } - controlSocket->Disconnect(); - } + dataQueue.push(retval); + } + controlSocket->Disconnect(); + } } } #ifdef VERBOSE @@ -3244,15 +3222,15 @@ int* slsDetector::startAndReadAll(){ startAndReadAllNoWait(); //#ifdef VERBOSE // std::cout<< "started" << std::endl; -//#endif + //#endif while ((retval=getDataFromDetector())){ #ifdef VERBOSE - i++; - std::cout<< i << std::endl; - //#else - //std::cout<< "-" << flush; + i++; + std::cout<< i << std::endl; + //#else + //std::cout<< "-" << flush; #endif - dataQueue.push(retval); + dataQueue.push(retval); } controlSocket->Disconnect(); @@ -3262,12 +3240,12 @@ int* slsDetector::startAndReadAll(){ // std::cout << std::endl; #endif return dataQueue.front(); // check what we return! -/* while ((retval=getDataFromDetectorNoWait())) - i++; - #ifdef VERBOSE - std::cout<< "Received " << i << " frames"<< std::endl; -#endif - return dataQueue.front(); // check what we return! + /* while ((retval=getDataFromDetectorNoWait())) + i++; + #ifdef VERBOSE + std::cout<< "Received " << i << " frames"<< std::endl; + #endif + return dataQueue.front(); // check what we return! */ }; @@ -3317,19 +3295,19 @@ int slsDetector::startAndReadAllNoWait(){ - /* - set or read the acquisition timers - enum timerIndex { - FRAME_NUMBER, - ACQUISITION_TIME, - FRAME_PERIOD, - DELAY_AFTER_TRIGGER, - GATES_NUMBER, - PROBES_NUMBER - CYCLES_NUMBER, - GATE_INTEGRATED_TIME - } - */ +/* + set or read the acquisition timers + enum timerIndex { + FRAME_NUMBER, + ACQUISITION_TIME, + FRAME_PERIOD, + DELAY_AFTER_TRIGGER, + GATES_NUMBER, + PROBES_NUMBER + CYCLES_NUMBER, + GATE_INTEGRATED_TIME + } +*/ int64_t slsDetector::setTimer(timerIndex index, int64_t t){ @@ -3340,46 +3318,46 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){ int ret=OK; int n=0; - if (index!=MEASUREMENTS_NUMBER) { + if (index!=MEASUREMENTS_NUMBER) { #ifdef VERBOSE - std::cout<< "Setting timer "<< index << " to " << t << "ns" << std::endl; + std::cout<< "Setting timer "<< index << " to " << t << "ns" << std::endl; #endif - ut=t; - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&index,sizeof(index)); - n=controlSocket->SendDataOnly(&t,sizeof(t)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } else { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - thisDetector->timerValue[index]=retval; - } - controlSocket->Disconnect(); - if (ret==FORCE_UPDATE) { - updateDetector(); + ut=t; + if (thisDetector->onlineFlag==ONLINE_FLAG) { + if (controlSocket) { + if (controlSocket->Connect()>=0) { + controlSocket->SendDataOnly(&fnum,sizeof(fnum)); + controlSocket->SendDataOnly(&index,sizeof(index)); + n=controlSocket->SendDataOnly(&t,sizeof(t)); + controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); + if (ret==FAIL) { + controlSocket->ReceiveDataOnly(mess,sizeof(mess)); + std::cout<< "Detector returned error: " << mess << std::endl; + } else { + controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); + thisDetector->timerValue[index]=retval; + } + controlSocket->Disconnect(); + if (ret==FORCE_UPDATE) { + updateDetector(); #ifdef VERBOSE - std::cout<< "Updated!" << std::endl; + std::cout<< "Updated!" << std::endl; #endif + } } } + } else { + //std::cout<< "offline " << std::endl; + if (t>=0) + thisDetector->timerValue[index]=t; } } else { - //std::cout<< "offline " << std::endl; if (t>=0) thisDetector->timerValue[index]=t; - } -} else { - if (t>=0) - thisDetector->timerValue[index]=t; -} + } #ifdef VERBOSE std::cout<< "Timer " << index << " set to "<< thisDetector->timerValue[index] << "ns" << std::endl; #endif @@ -3475,71 +3453,71 @@ int slsDetector::setPort(portType index, int num){ if (num>1024) { - switch(index) { - case CONTROL_PORT: - s=controlSocket; - retval=thisDetector->controlPort; + switch(index) { + case CONTROL_PORT: + s=controlSocket; + retval=thisDetector->controlPort; #ifdef VERBOSE - cout << "s="<< s<< endl; + cout << "s="<< s<< endl; cout << thisDetector->controlPort<< " " << " " << thisDetector->stopPort << endl; #endif - if (s==NULL) { + if (s==NULL) { #ifdef VERBOSE - cout << "s=NULL"<< endl; - cout << thisDetector->controlPort<< " " << " " << thisDetector->stopPort << endl; + cout << "s=NULL"<< endl; + cout << thisDetector->controlPort<< " " << " " << thisDetector->stopPort << endl; #endif - setTCPSocket("",DEFAULT_PORTNO); - } - if (controlSocket) { - s=controlSocket; - } else { + setTCPSocket("",DEFAULT_PORTNO); + } + if (controlSocket) { + s=controlSocket; + } else { #ifdef VERBOSE - cout << "still cannot connect!"<< endl; - cout << thisDetector->controlPort<< " " << " " << thisDetector->stopPort << endl; + cout << "still cannot connect!"<< endl; + cout << thisDetector->controlPort<< " " << " " << thisDetector->stopPort << endl; #endif - setTCPSocket("",retval); + setTCPSocket("",retval); + } + break; + case DATA_PORT: + s=dataSocket; + retval=thisDetector->dataPort; + if (s==NULL) setReceiverTCPSocket("",DEFAULT_PORTNO+2); + if (dataSocket) s=dataSocket; + else setReceiverTCPSocket("",retval); + break; + case STOP_PORT: + s=stopSocket; + retval=thisDetector->stopPort; + if (s==NULL) setTCPSocket("",-1,DEFAULT_PORTNO+1); + if (stopSocket) s=stopSocket; + else setTCPSocket("",-1,retval); + break; + default: + s=NULL; } - break; - case DATA_PORT: - s=dataSocket; - retval=thisDetector->dataPort; - if (s==NULL) setReceiverTCPSocket("",DEFAULT_PORTNO+2); - if (dataSocket) s=dataSocket; - else setReceiverTCPSocket("",retval); - break; - case STOP_PORT: - s=stopSocket; - retval=thisDetector->stopPort; - if (s==NULL) setTCPSocket("",-1,DEFAULT_PORTNO+1); - if (stopSocket) s=stopSocket; - else setTCPSocket("",-1,retval); - break; - default: - s=NULL; - } if (thisDetector->onlineFlag==ONLINE_FLAG) { if (s) { if (s->Connect()>=0) { s->SendDataOnly(&fnum,sizeof(fnum)); - s->SendDataOnly(&index,sizeof(index)); - n=s->SendDataOnly(&num,sizeof(num)); - s->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - s->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } else { - s->ReceiveDataOnly(&retval,sizeof(retval)); - } - s->Disconnect(); + s->SendDataOnly(&index,sizeof(index)); + n=s->SendDataOnly(&num,sizeof(num)); + s->ReceiveDataOnly(&ret,sizeof(ret)); + if (ret==FAIL) { + s->ReceiveDataOnly(mess,sizeof(mess)); + std::cout<< "Detector returned error: " << mess << std::endl; + } else { + s->ReceiveDataOnly(&retval,sizeof(retval)); + } + s->Disconnect(); } } - } + } if (ret!=FAIL) { switch(index) { @@ -3551,7 +3529,7 @@ int slsDetector::setPort(portType index, int num){ break; case STOP_PORT: thisDetector->stopPort=retval; - break; + break; default: ; } @@ -3577,25 +3555,25 @@ int slsDetector::setPort(portType index, int num){ } } } - switch(index) { - case CONTROL_PORT: - retval=thisDetector->controlPort; - break; - case DATA_PORT: - retval=thisDetector->dataPort; - break; - case STOP_PORT: - retval=thisDetector->stopPort; + switch(index) { + case CONTROL_PORT: + retval=thisDetector->controlPort; break; - default: - retval=-1; - } + case DATA_PORT: + retval=thisDetector->dataPort; + break; + case STOP_PORT: + retval=thisDetector->stopPort; + break; + default: + retval=-1; + } - // setTCPSocket(); + // setTCPSocket(); #ifdef VERBOSE - cout << thisDetector->controlPort<< " " << thisDetector->dataPort << " " << thisDetector->stopPort << endl; + cout << thisDetector->controlPort<< " " << thisDetector->dataPort << " " << thisDetector->stopPort << endl; #endif @@ -3619,40 +3597,40 @@ int slsDetector::setPort(portType index, int num){ int slsDetector::setTotalProgress() { - int nf=1, npos=1, nscan[MAX_SCAN_LEVELS]={1,1}, nc=1, nm=1; + int nf=1, npos=1, nscan[MAX_SCAN_LEVELS]={1,1}, nc=1, nm=1; - if (thisDetector->timerValue[FRAME_NUMBER]) - nf=thisDetector->timerValue[FRAME_NUMBER]; + if (thisDetector->timerValue[FRAME_NUMBER]) + nf=thisDetector->timerValue[FRAME_NUMBER]; - if (thisDetector->timerValue[CYCLES_NUMBER]>0) - nc=thisDetector->timerValue[CYCLES_NUMBER]; + if (thisDetector->timerValue[CYCLES_NUMBER]>0) + nc=thisDetector->timerValue[CYCLES_NUMBER]; - if (thisDetector->numberOfPositions>0) - npos=thisDetector->numberOfPositions; + if (thisDetector->numberOfPositions>0) + npos=thisDetector->numberOfPositions; - if (timerValue[MEASUREMENTS_NUMBER]>0) - nc=timerValue[MEASUREMENTS_NUMBER]; + if (timerValue[MEASUREMENTS_NUMBER]>0) + nc=timerValue[MEASUREMENTS_NUMBER]; - if ((thisDetector->nScanSteps[0]>0) && (thisDetector->actionMask & (1 << MAX_ACTIONS))) - nscan[0]=thisDetector->nScanSteps[0]; + if ((thisDetector->nScanSteps[0]>0) && (thisDetector->actionMask & (1 << MAX_ACTIONS))) + nscan[0]=thisDetector->nScanSteps[0]; - if ((thisDetector->nScanSteps[1]>0) && (thisDetector->actionMask & (1 << (MAX_ACTIONS+1)))) - nscan[1]=thisDetector->nScanSteps[1]; + 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*nscan[0]*nscan[1]; #ifdef VERBOSE - cout << "nc " << nc << endl; - cout << "nm " << nm << endl; - cout << "nf " << nf << endl; - cout << "npos " << npos << endl; - cout << "nscan[0] " << nscan[0] << endl; - cout << "nscan[1] " << nscan[1] << endl; + cout << "nc " << nc << endl; + cout << "nm " << nm << endl; + cout << "nf " << nf << endl; + cout << "npos " << npos << endl; + cout << "nscan[0] " << nscan[0] << endl; + cout << "nscan[1] " << nscan[1] << endl; - cout << "Set total progress " << thisDetector->totalProgress << endl; + cout << "Set total progress " << thisDetector->totalProgress << endl; #endif - return thisDetector->totalProgress; + return thisDetector->totalProgress; } @@ -3678,11 +3656,11 @@ double slsDetector::getCurrentProgress() { /* important speed parameters -enum speedVariable { + enum speedVariable { CLOCK_DIVIDER, WAIT_STATES, SET_SIGNAL_LENGTH -}; + }; */ int slsDetector::setSpeed(speedVariable sp, int value) { @@ -3775,7 +3753,7 @@ int64_t slsDetector::getTimeLeft(timerIndex index){ }; - // Flags +// Flags int slsDetector::setDynamicRange(int n){ // cout << "single " << endl; @@ -3798,7 +3776,7 @@ int slsDetector::setDynamicRange(int n){ if (ret==FAIL) { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); std::cout<< "Detector returned error: " << mess << std::endl; - } else { + } else { controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); } controlSocket->Disconnect(); @@ -3843,17 +3821,17 @@ int slsDetector::setROI(int nroi, int *xmin, int *xmax, int *ymin, int *ymax){ }; */ - /* +/* enum readOutFlags { - NORMAL_READOUT, - setReadOutFlags(STORE_IN_RAM, - READ_HITS, - ZERO_COMPRESSION, - BACKGROUND_CORRECTION +NORMAL_READOUT, +setReadOutFlags(STORE_IN_RAM, +READ_HITS, +ZERO_COMPRESSION, +BACKGROUND_CORRECTION }{}; - */ +*/ int slsDetector::setReadOutFlags(readOutFlags flag){ @@ -3896,16 +3874,16 @@ int slsDetector::setReadOutFlags(readOutFlags flag){ return thisDetector->roFlags; }; - //Trimming - /* -enum trimMode { +//Trimming +/* + enum trimMode { NOISE_TRIMMING, BEAM_TRIMMING, IMPROVE_TRIMMING, FIXEDSETTINGS_TRIMMING, OFFLINE_TRIMMING -}{}; - */ + }{}; +*/ int slsDetector::executeTrimming(trimMode mode, int par1, int par2, int imod){ int fnum= F_EXECUTE_TRIMMING; @@ -3924,32 +3902,32 @@ int slsDetector::executeTrimming(trimMode mode, int par1, int par2, int imod){ if (thisDetector->onlineFlag==ONLINE_FLAG) { if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); + if (controlSocket->Connect()>=0) { + controlSocket->SendDataOnly(&fnum,sizeof(fnum)); #ifdef VERBOSE - std::cout<< "sending mode bytes= "<< controlSocket->SendDataOnly(&mode,sizeof(mode)) << std::endl; + std::cout<< "sending mode bytes= "<< controlSocket->SendDataOnly(&mode,sizeof(mode)) << std::endl; #endif - controlSocket->SendDataOnly(&mode,sizeof(mode)); - controlSocket->SendDataOnly(arg,sizeof(arg)); + controlSocket->SendDataOnly(&mode,sizeof(mode)); + controlSocket->SendDataOnly(arg,sizeof(arg)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } else { + controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); + if (ret==FAIL) { + controlSocket->ReceiveDataOnly(mess,sizeof(mess)); + std::cout<< "Detector returned error: " << mess << std::endl; + } else { #ifdef VERBOSE - std::cout<< "Detector trimmed "<< ret << std::endl; + std::cout<< "Detector trimmed "<< ret << std::endl; #endif - /* - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - thisDetector->roFlags=retval; - */ - retval=ret; - } - controlSocket->Disconnect(); - if (ret==FORCE_UPDATE) - updateDetector(); - } + /* + controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); + thisDetector->roFlags=retval; + */ + retval=ret; + } + controlSocket->Disconnect(); + if (ret==FORCE_UPDATE) + updateDetector(); + } } } return retval; @@ -3981,11 +3959,11 @@ double* slsDetector::decodeData(int *datain, double *fdata) { iptr=ptr[ibyte]&0x1; for (ipos=0; ipos<8; ipos++) { // dataout[ibyte*2+ichan]=((iptr&((0xf)<>ichan)&0xf; - ival=(iptr>>(ipos))&0x1; - dataout[ichan]=ival; - ichan++; + ival=(iptr>>(ipos))&0x1; + dataout[ichan]=ival; + ichan++; } - } + } break; case 4: for (ibyte=0; ibytedataBytes; ibyte++) { @@ -4037,76 +4015,76 @@ double* slsDetector::decodeData(int *datain, double *fdata) { } //Correction - /* - enum correctionFlags { - DISCARD_BAD_CHANNELS, - AVERAGE_NEIGHBOURS_FOR_BAD_CHANNELS, - FLAT_FIELD_CORRECTION, - RATE_CORRECTION, - ANGULAR_CONVERSION - } - */ +/* + enum correctionFlags { + DISCARD_BAD_CHANNELS, + AVERAGE_NEIGHBOURS_FOR_BAD_CHANNELS, + FLAT_FIELD_CORRECTION, + RATE_CORRECTION, + ANGULAR_CONVERSION + } +*/ 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; - int im=0; - int nch; - thisDetector->nBadFF=0; + double xmed[thisDetector->nModMax[X]*thisDetector->nModMax[Y]*thisDetector->nChans*thisDetector->nChips]; + int nmed=0; + int im=0; + int nch; + thisDetector->nBadFF=0; - char ffffname[MAX_STR_LENGTH*2]; - if (fname=="default") { - fname=string(thisDetector->flatFieldFile); - } + char ffffname[MAX_STR_LENGTH*2]; + if (fname=="default") { + fname=string(thisDetector->flatFieldFile); + } - if (fname=="") { + if (fname=="") { #ifdef VERBOSE - std::cout<< "disabling flat field correction" << std::endl; + std::cout<< "disabling flat field correction" << std::endl; #endif - thisDetector->correctionMask&=~(1<correctionMask&=~(1<flatFieldDir,fname.c_str()); - nch=readDataFile(string(ffffname),data); - if (nch>0) { + sprintf(ffffname,"%s/%s",thisDetector->flatFieldDir,fname.c_str()); + nch=readDataFile(string(ffffname),data); + if (nch>0) { - //???? bad ff chans? - int nm=getNMods(); - int chpm[nm]; - int mMask[nm]; - for (int i=0; i=0) { - strcpy(thisDetector->flatFieldFile,fname.c_str()); + if ((postProcessingFuncs::calculateFlatField(&nm, chpm, mMask, badChannelMask, data, ffcoefficients, fferrors))>=0) { + strcpy(thisDetector->flatFieldFile,fname.c_str()); - thisDetector->correctionMask|=(1<correctionMask|=(1<correctionMask&(1<correctionMask&(1<nMod[X]*thisDetector->nChans*thisDetector->nChips; ichan++) { -// #ifdef VERBOSE -// std::cout<< ichan << " "<< corr[ichan] << std::endl; -// #endif + // #ifdef VERBOSE + // std::cout<< ichan << " "<< corr[ichan] << std::endl; + // #endif ffcoefficients[ichan]=corr[ichan]; if (ecorr!=NULL) fferrors[ichan]=ecorr[ichan]; @@ -4133,7 +4111,7 @@ int slsDetector::setFlatFieldCorrection(double *corr, double *ecorr) { } thisDetector->correctionMask|=(1<correctionMask&=~(1<correctionMask&=~(1<correctionMask)&(1<correctionMask & (1<correctionMask&(1<< DISCARD_BAD_CHANNELS)) { return thisDetector->nBadChans+thisDetector->nBadFF; } else - return 0; + return 0; } @@ -4390,7 +4368,7 @@ int slsDetector::getBadChannelCorrection(int *bad) { } return thisDetector->nBadChans+thisDetector->nBadFF; } else - return 0; + return 0; } @@ -4408,12 +4386,12 @@ int slsDetector::exitServer(){ int fnum=F_EXIT_SERVER; if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (controlSocket) { - controlSocket->Connect(); - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - controlSocket->Disconnect(); - } + if (controlSocket) { + controlSocket->Connect(); + controlSocket->SendDataOnly(&fnum,sizeof(fnum)); + controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); + controlSocket->Disconnect(); + } } if (retval!=OK) { std::cout<< std::endl; @@ -4467,26 +4445,26 @@ char* slsDetector::getNetworkParameter(networkParameter index) { char* slsDetector::setReceiverIP(string receiverIP){ - int wrongFormat=1; + int wrongFormat=1; - struct sockaddr_in sa; - if(receiverIP.length()<16){ - if((receiverIP[3]=='.')&&(receiverIP[7]=='.')&&(receiverIP[11]=='.')){ - int result = inet_pton(AF_INET, receiverIP.c_str(), &(sa.sin_addr)); - if(result!=0){ - sprintf(thisDetector->receiverIP,receiverIP.c_str()); - wrongFormat=0; - } - } - } + struct sockaddr_in sa; + if(receiverIP.length()<16){ + if((receiverIP[3]=='.')&&(receiverIP[7]=='.')&&(receiverIP[11]=='.')){ + int result = inet_pton(AF_INET, receiverIP.c_str(), &(sa.sin_addr)); + if(result!=0){ + sprintf(thisDetector->receiverIP,receiverIP.c_str()); + wrongFormat=0; + } + } + } - if(wrongFormat) - return ("IP Address should be VALID and in xxx.xxx.xxx.xxx format"); + if(wrongFormat) + return ("IP Address should be VALID and in xxx.xxx.xxx.xxx format"); - if(setReceiverTCPSocket()==FAIL) - return("Connection to Receiver failed."); + if(setReceiverTCPSocket()==FAIL) + return("Connection to Receiver failed."); - return thisDetector->receiverIP; + return thisDetector->receiverIP; } @@ -4534,9 +4512,9 @@ int slsDetector::configureMAC(){ strcpy(arg[2],getServerMAC()); -#ifdef VERBOSE + //#ifdef VERBOSE std::cout<< "slsDetector configureMAC "<< std::endl; -#endif + //#endif for(i=0;i<3;i++){ if(!strcmp(arg[i],"none")) @@ -4555,24 +4533,27 @@ int slsDetector::configureMAC(){ pcword = strtok (NULL, "."); } strcpy(arg[0],cword); - std::cout<<"arg0:"<onlineFlag==ONLINE_FLAG) { if (controlSocket) { @@ -4613,16 +4594,16 @@ int slsDetector::configureMAC(){ int slsDetector::getAngularConversion(int &direction, angleConversionConstant *angconv) { direction=thisDetector->angDirection; - if (angconv) { - for (int imod=0; imodnMods; imod++) { - (angconv+imod)->center=thisDetector->angOff[imod].center; - (angconv+imod)->r_conversion=thisDetector->angOff[imod].r_conversion; - (angconv+imod)->offset=thisDetector->angOff[imod].offset; - (angconv+imod)->ecenter=thisDetector->angOff[imod].ecenter; - (angconv+imod)->er_conversion=thisDetector->angOff[imod].er_conversion; - (angconv+imod)->eoffset=thisDetector->angOff[imod].eoffset; - } + if (angconv) { + for (int imod=0; imodnMods; imod++) { + (angconv+imod)->center=thisDetector->angOff[imod].center; + (angconv+imod)->r_conversion=thisDetector->angOff[imod].r_conversion; + (angconv+imod)->offset=thisDetector->angOff[imod].offset; + (angconv+imod)->ecenter=thisDetector->angOff[imod].ecenter; + (angconv+imod)->er_conversion=thisDetector->angOff[imod].er_conversion; + (angconv+imod)->eoffset=thisDetector->angOff[imod].eoffset; } + } if (thisDetector->correctionMask&(1<< ANGULAR_CONVERSION)) { return 1; } else { @@ -4632,17 +4613,17 @@ int slsDetector::getAngularConversion(int &direction, angleConversionConstant * - int slsDetector::readAngularConversionFile(string fname) { +int slsDetector::readAngularConversionFile(string fname) { - return readAngularConversion(fname,thisDetector->nModsMax, thisDetector->angOff); + return readAngularConversion(fname,thisDetector->nModsMax, thisDetector->angOff); - } +} - int slsDetector::readAngularConversion(ifstream& ifs) { +int slsDetector::readAngularConversion(ifstream& ifs) { - return readAngularConversion(ifs,thisDetector->nModsMax, thisDetector->angOff); + return readAngularConversion(ifs,thisDetector->nModsMax, thisDetector->angOff); - } +} int slsDetector:: writeAngularConversion(string fname) { @@ -4664,141 +4645,141 @@ int slsDetector:: writeAngularConversion(ofstream &ofs) { int slsDetector::loadImageToDetector(imageType index,string const fname){ - int ret=FAIL; - short int arg[thisDetector->nChans*thisDetector->nChips]; + int ret=FAIL; + short int arg[thisDetector->nChans*thisDetector->nChips]; #ifdef VERBOSE - std::cout<< std::endl<< "Loading "; - if(!index) - std::cout<<"Dark"; - else - std::cout<<"Gain"; - std::cout<<" image from file " << fname << std::endl; + std::cout<< std::endl<< "Loading "; + if(!index) + std::cout<<"Dark"; + else + std::cout<<"Gain"; + std::cout<<" image from file " << fname << std::endl; #endif - if(readDataFile(fname,arg)){ - ret = sendImageToDetector(index,arg); - return ret; - } - std::cout<< "Could not open file "<< fname << std::endl; - return ret; + if(readDataFile(fname,arg)){ + ret = sendImageToDetector(index,arg); + return ret; + } + std::cout<< "Could not open file "<< fname << std::endl; + return ret; } int slsDetector::sendImageToDetector(imageType index,short int imageVals[]){ - int ret=FAIL; - int retval; - int fnum=F_LOAD_IMAGE; - char mess[100]; + int ret=FAIL; + int retval; + int fnum=F_LOAD_IMAGE; + char mess[100]; #ifdef VERBOSE - std::cout<<"Sending image to detector " <onlineFlag==ONLINE_FLAG) { - if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&index,sizeof(index)); - controlSocket->SendDataOnly(imageVals,thisDetector->dataBytes); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); - if (ret==FORCE_UPDATE) - updateDetector(); - } - - } + if (thisDetector->onlineFlag==ONLINE_FLAG) { + if (controlSocket) { + if (controlSocket->Connect()>=0) { + controlSocket->SendDataOnly(&fnum,sizeof(fnum)); + controlSocket->SendDataOnly(&index,sizeof(index)); + controlSocket->SendDataOnly(imageVals,thisDetector->dataBytes); + controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); + if (ret!=FAIL) + controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); + else { + controlSocket->ReceiveDataOnly(mess,sizeof(mess)); + std::cout<< "Detector returned error: " << mess << std::endl; } + controlSocket->Disconnect(); + if (ret==FORCE_UPDATE) + updateDetector(); + } - return ret; + } + } + + return ret; } int slsDetector::getCounterBlock(short int arg[],int startACQ){ - int ret=FAIL; - int fnum=F_READ_COUNTER_BLOCK; - char mess[100]; + int ret=FAIL; + int fnum=F_READ_COUNTER_BLOCK; + char mess[100]; - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&startACQ,sizeof(startACQ)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) - controlSocket->ReceiveDataOnly(arg,thisDetector->dataBytes); - else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); - if (ret==FORCE_UPDATE) - updateDetector(); - } - } + if (thisDetector->onlineFlag==ONLINE_FLAG) { + if (controlSocket) { + if (controlSocket->Connect()>=0) { + controlSocket->SendDataOnly(&fnum,sizeof(fnum)); + controlSocket->SendDataOnly(&startACQ,sizeof(startACQ)); + controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); + if (ret!=FAIL) + controlSocket->ReceiveDataOnly(arg,thisDetector->dataBytes); + else { + controlSocket->ReceiveDataOnly(mess,sizeof(mess)); + std::cout<< "Detector returned error: " << mess << std::endl; } + controlSocket->Disconnect(); + if (ret==FORCE_UPDATE) + updateDetector(); + } + } + } - return ret; + return ret; } int slsDetector::writeCounterBlockFile(string const fname,int startACQ){ - int ret=FAIL; - short int counterVals[thisDetector->nChans*thisDetector->nChips]; + int ret=FAIL; + short int counterVals[thisDetector->nChans*thisDetector->nChips]; #ifdef VERBOSE - std::cout<< std::endl<< "Reading Counter to \""<onlineFlag==ONLINE_FLAG) { - if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&startACQ,sizeof(startACQ)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL){ - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); - if (ret==FORCE_UPDATE) - updateDetector(); - } - } + if (thisDetector->onlineFlag==ONLINE_FLAG) { + if (controlSocket) { + if (controlSocket->Connect()>=0) { + controlSocket->SendDataOnly(&fnum,sizeof(fnum)); + controlSocket->SendDataOnly(&startACQ,sizeof(startACQ)); + controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); + if (ret==FAIL){ + controlSocket->ReceiveDataOnly(mess,sizeof(mess)); + std::cout<< "Detector returned error: " << mess << std::endl; } + controlSocket->Disconnect(); + if (ret==FORCE_UPDATE) + updateDetector(); + } + } + } - return ret; + return ret; } @@ -4815,28 +4796,28 @@ int slsDetector::readConfigurationFile(string const fname){ - string ans; - string str; - ifstream infile; - char *args[1000]; + string ans; + string str; + ifstream infile; + char *args[1000]; - string sargname, sargval; - int iline=0; + string sargname, sargval; + int iline=0; #ifdef VERBOSE - std::cout<< "config file name "<< fname << std::endl; + std::cout<< "config file name "<< fname << std::endl; #endif - infile.open(fname.c_str(), ios_base::in); - if (infile.is_open()) { - iline=readConfigurationFile(infile); - infile.close(); - } else { - std::cout<< "Error opening configuration file " << fname << " for reading" << std::endl; - return FAIL; - } + infile.open(fname.c_str(), ios_base::in); + if (infile.is_open()) { + iline=readConfigurationFile(infile); + infile.close(); + } else { + std::cout<< "Error opening configuration file " << fname << " for reading" << std::endl; + return FAIL; + } #ifdef VERBOSE - std::cout<< "Read configuration file of " << iline << " lines" << std::endl; + std::cout<< "Read configuration file of " << iline << " lines" << std::endl; #endif - return iline; + return iline; } @@ -4848,57 +4829,57 @@ int slsDetector::readConfigurationFile(ifstream &infile){ slsDetectorCommand *cmd=new slsDetectorCommand(this); - string ans; - string str; - int iargval; - int interrupt=0; - char *args[100]; - char myargs[1000][1000]; + string ans; + string str; + int iargval; + int interrupt=0; + char *args[100]; + char myargs[1000][1000]; - string sargname, sargval; - int iline=0; - while (infile.good() and interrupt==0) { - sargname="none"; - sargval="0"; - getline(infile,str); - iline++; + string sargname, sargval; + int iline=0; + while (infile.good() and interrupt==0) { + sargname="none"; + sargval="0"; + getline(infile,str); + iline++; #ifdef VERBOSE - std::cout<< str << std::endl; + std::cout<< str << std::endl; #endif - if (str.find('#')!=string::npos) { + if (str.find('#')!=string::npos) { #ifdef VERBOSE - std::cout<< "Line is a comment " << std::endl; - std::cout<< str << std::endl; + std::cout<< "Line is a comment " << std::endl; + std::cout<< str << std::endl; #endif - continue; - } else if (str.length()<2) { + continue; + } else if (str.length()<2) { #ifdef VERBOSE - std::cout<< "Empty line " << std::endl; + std::cout<< "Empty line " << std::endl; #endif - continue; - } else { - istringstream ssstr(str); - iargval=0; - while (ssstr.good()) { - ssstr >> sargname; - //if (ssstr.good()) { + continue; + } else { + istringstream ssstr(str); + iargval=0; + while (ssstr.good()) { + ssstr >> sargname; + //if (ssstr.good()) { #ifdef VERBOSE - std::cout<< iargval << " " << sargname << std::endl; + std::cout<< iargval << " " << sargname << std::endl; #endif - strcpy(myargs[iargval],sargname.c_str()); - args[iargval]=myargs[iargval]; - iargval++; - //} - } - ans=cmd->executeLine(iargval,args,PUT_ACTION); -#ifdef VERBOSE - std::cout<< ans << std::endl; -#endif - } - iline++; + strcpy(myargs[iargval],sargname.c_str()); + args[iargval]=myargs[iargval]; + iargval++; + //} } - delete cmd; - return iline; + ans=cmd->executeLine(iargval,args,PUT_ACTION); +#ifdef VERBOSE + std::cout<< ans << std::endl; +#endif + } + iline++; + } + delete cmd; + return iline; } @@ -4988,22 +4969,22 @@ int slsDetector::writeConfigurationFile(ofstream &outfile, int id){ for (iv=0; iv=0) - outfile << id << ":"; + if (id>=0) + outfile << id << ":"; - outfile << args[0] << " " << cmd->executeLine(1,args,GET_ACTION) << std::endl; - } - } else { - strcpy(args[0],names[iv].c_str()); - if (id>=0) - outfile << id << ":"; - outfile << names[iv] << " " << cmd->executeLine(1,args,GET_ACTION) << std::endl; - } + outfile << args[0] << " " << cmd->executeLine(1,args,GET_ACTION) << std::endl; + } + } else { + strcpy(args[0],names[iv].c_str()); + if (id>=0) + outfile << id << ":"; + outfile << names[iv] << " " << cmd->executeLine(1,args,GET_ACTION) << std::endl; + } } delete cmd; return iv; @@ -5103,7 +5084,7 @@ int slsDetector::loadSettingsFile(string fname, int imod) { myMod->module=im; //settings is saved in myMod.reg for gotthard if(thisDetector->myDetectorType==GOTTHARD) - myMod->reg=thisDetector->currentSettings; + myMod->reg=thisDetector->currentSettings; setModule(*myMod); deleteModule(myMod); } else @@ -5158,7 +5139,7 @@ int slsDetector::loadCalibrationFile(string fname, int imod) { fn=ostfn.str(); if(myMod=getModule(im)){ if(readCalibrationFile(fn, myMod->gain, myMod->offset)==FAIL) - return FAIL; + return FAIL; setModule(*myMod); deleteModule(myMod); } else @@ -5186,7 +5167,7 @@ int slsDetector::saveCalibrationFile(string fname, int imod) { ret=writeCalibrationFile(ostfn.str(), myMod->gain, myMod->offset); deleteModule(myMod); }else - return FAIL; + return FAIL; } return ret; } @@ -5194,10 +5175,10 @@ int slsDetector::saveCalibrationFile(string fname, int imod) { - /* returns if the detector is Master, slave or nothing - \param flag can be GET_MASTER, NO_MASTER, IS_MASTER, IS_SLAVE - \returns master flag of the detector - */ +/* returns if the detector is Master, slave or nothing + \param flag can be GET_MASTER, NO_MASTER, IS_MASTER, IS_SLAVE + \returns master flag of the detector +*/ slsDetectorDefs::masterFlags slsDetector::setMaster(masterFlags flag) { @@ -5238,11 +5219,11 @@ slsDetectorDefs::masterFlags slsDetector::setMaster(masterFlags flag) { - /* - Sets/gets the synchronization mode of the various detectors - \param sync syncronization mode can be GET_SYNCHRONIZATION_MODE, NO_SYNCHRONIZATION, MASTER_GATES, MASTER_TRIGGERS, SLAVE_STARTS_WHEN_MASTER_STOPS - \returns current syncronization mode - */ +/* + Sets/gets the synchronization mode of the various detectors + \param sync syncronization mode can be GET_SYNCHRONIZATION_MODE, NO_SYNCHRONIZATION, MASTER_GATES, MASTER_TRIGGERS, SLAVE_STARTS_WHEN_MASTER_STOPS + \returns current syncronization mode +*/ slsDetectorDefs::synchronizationMode slsDetector::setSynchronization(synchronizationMode flag) { @@ -5307,8 +5288,8 @@ string slsDetector::checkReceiverOnline() { string retval = ""; //if it doesnt exits, create data socket if(!dataSocket){ - //this already sets the online/offline flag - setReceiverTCPSocket(); + //this already sets the online/offline flag + setReceiverTCPSocket(); if(thisDetector->receiverOnlineFlag==OFFLINE_FLAG) return string(thisDetector->receiverIP); else @@ -5339,76 +5320,76 @@ string slsDetector::checkReceiverOnline() { - /* - configure the socket communication and check that the receiver exists - enum communicationProtocol{ - TCP, - UDP - }{}; +/* + configure the socket communication and check that the receiver exists + enum communicationProtocol{ + TCP, + UDP + }{}; - */ +*/ int slsDetector::setReceiverTCPSocket(string const name, int const data_port){ - char thisName[MAX_STR_LENGTH]; - int thisDP; - int retval=OK; + char thisName[MAX_STR_LENGTH]; + int thisDP; + int retval=OK; - //if receiver ip given - if (strcmp(name.c_str(),"")!=0) { + //if receiver ip given + if (strcmp(name.c_str(),"")!=0) { #ifdef VERBOSE - std::cout<< "setting receiver" << std::endl; + std::cout<< "setting receiver" << std::endl; #endif - strcpy(thisName,name.c_str()); - strcpy(thisDetector->receiverIP,thisName); - if (dataSocket){ - delete dataSocket; - dataSocket=NULL; - } - } else - strcpy(thisName,thisDetector->receiverIP); + strcpy(thisName,name.c_str()); + strcpy(thisDetector->receiverIP,thisName); + if (dataSocket){ + delete dataSocket; + dataSocket=NULL; + } + } else + strcpy(thisName,thisDetector->receiverIP); - //if dataport given - if (data_port>0) { + //if dataport given + if (data_port>0) { #ifdef VERBOSE - std::cout<< "setting data port" << std::endl; + std::cout<< "setting data port" << std::endl; #endif - thisDP=data_port; - thisDetector->dataPort=thisDP; - if (dataSocket){ - delete dataSocket; - dataSocket=NULL; - } - } else - thisDP=thisDetector->dataPort; + thisDP=data_port; + thisDetector->dataPort=thisDP; + if (dataSocket){ + delete dataSocket; + dataSocket=NULL; + } + } else + thisDP=thisDetector->dataPort; - //create data socket - if (!dataSocket) { - dataSocket=new MySocketTCP(thisName, thisDP); - if (dataSocket->getErrorStatus()){ + //create data socket + if (!dataSocket) { + dataSocket=new MySocketTCP(thisName, thisDP); + if (dataSocket->getErrorStatus()){ #ifdef VERBOSE - std::cout<< "Could not connect Data socket "<receiverOnlineFlag=OFFLINE_FLAG; + } + //check if it connects + if (retval!=FAIL) { + if(checkReceiverOnline().empty()) + retval=FAIL; + } else { + thisDetector->receiverOnlineFlag=OFFLINE_FLAG; #ifdef VERBOSE - std::cout<< "offline!" << std::endl; + std::cout<< "offline!" << std::endl; #endif - } - return retval; + } + return retval; }; @@ -5416,36 +5397,36 @@ int slsDetector::setReceiverTCPSocket(string const name, int const data_port){ string slsDetector::setReceiverFileName(string fileName) { - int fnum=F_SET_RECEIVER_FILE_NAME; - int ret = FAIL; - char mess[100]; + int fnum=F_SET_RECEIVER_FILE_NAME; + int ret = FAIL; + char mess[100]; - char arg[MAX_STR_LENGTH],retval[MAX_STR_LENGTH]=""; - strcpy(arg,fileName.c_str()); + char arg[MAX_STR_LENGTH],retval[MAX_STR_LENGTH]=""; + strcpy(arg,fileName.c_str()); #ifdef VERBOSE - std::cout << "Sending file name to receiver " << arg << std::endl; + 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)); - 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); - } - dataSocket->Disconnect(); - if (ret==FORCE_UPDATE) - updateReceiver(); - } - } + 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); + } + dataSocket->Disconnect(); + if (ret==FORCE_UPDATE) + updateReceiver(); + } + } - return string(retval); + return string(retval); } @@ -5453,280 +5434,280 @@ string slsDetector::setReceiverFileName(string fileName) { string slsDetector::setReceiverFileDir(string fileDir) { - int fnum=F_SET_RECEIVER_FILE_DIR; - int ret = FAIL; - char mess[100]; + int fnum=F_SET_RECEIVER_FILE_DIR; + int ret = FAIL; + char mess[100]; - char arg[MAX_STR_LENGTH],retval[MAX_STR_LENGTH]=""; - strcpy(arg,fileDir.c_str()); + 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; + 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); - } - dataSocket->Disconnect(); - if (ret==FORCE_UPDATE) - updateReceiver(); - } - } - return string(retval); + 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); + } + 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 fnum=F_SET_RECEIVER_FILE_INDEX; + int ret = FAIL; + char mess[100]; + int retval=-1; - int arg = fileIndex; + int arg = fileIndex; #ifdef VERBOSE - std::cout << "Sending file dir to receiver " << arg << std::endl; + 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,sizeof(arg)); - 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,sizeof(retval)); - } - dataSocket->Disconnect(); - if (ret==FORCE_UPDATE) - updateReceiver(); - } - } + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { + if (dataSocket) { + if (dataSocket->Connect()>=0) { + dataSocket->SendDataOnly(&fnum,sizeof(fnum)); + dataSocket->SendDataOnly(&arg,sizeof(arg)); + 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,sizeof(retval)); + } + dataSocket->Disconnect(); + if (ret==FORCE_UPDATE) + updateReceiver(); + } + } - return retval; + return retval; } int slsDetector::startReceiver(){ - int fnum=F_START_RECEIVER; - int ret = FAIL; - char mess[100]; + int fnum=F_START_RECEIVER; + int ret = FAIL; + char mess[100]; #ifdef VERBOSE - std::cout << "Starting Receiver " << std::endl; + std::cout << "Starting Receiver " << std::endl; #endif - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { - if (dataSocket) { - if (dataSocket->Connect()>=0) { - dataSocket->SendDataOnly(&fnum,sizeof(fnum)); - dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL){ - dataSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Receiver returned error: " << mess << std::endl; - } - dataSocket->Disconnect(); - if (ret==FORCE_UPDATE) - ret=updateReceiver(); - } - } + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { + if (dataSocket) { + if (dataSocket->Connect()>=0) { + dataSocket->SendDataOnly(&fnum,sizeof(fnum)); + dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); + if (ret==FAIL){ + dataSocket->ReceiveDataOnly(mess,sizeof(mess)); + std::cout<< "Receiver returned error: " << mess << std::endl; } + dataSocket->Disconnect(); + if (ret==FORCE_UPDATE) + ret=updateReceiver(); + } + } + } - //configuremac for gotthard - if(ret==OK) - if(thisDetector->myDetectorType==GOTTHARD) - ret=configureMAC(); + //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) { - if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL){ - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); - if (ret==FORCE_UPDATE) - ret=updateDetector(); - } - } - } + //tell the server to send to receiver and not CPU + if(ret==OK){ + if (thisDetector->onlineFlag==ONLINE_FLAG) { + if (controlSocket) { + if (controlSocket->Connect()>=0) { + controlSocket->SendDataOnly(&fnum,sizeof(fnum)); + controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); + if (ret==FAIL){ + controlSocket->ReceiveDataOnly(mess,sizeof(mess)); + std::cout<< "Detector returned error: " << mess << std::endl; + } + controlSocket->Disconnect(); + if (ret==FORCE_UPDATE) + ret=updateDetector(); } + } + } + } - return ret; + return ret; } int slsDetector::stopReceiver(){ - int fnum=F_STOP_RECEIVER; - int ret = FAIL; - char mess[100]; + int fnum=F_STOP_RECEIVER; + int ret = FAIL; + char mess[100]; #ifdef VERBOSE - std::cout << "Stopping Receiver " << std::endl; + std::cout << "Stopping Receiver " << std::endl; #endif - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { - if (dataSocket) { - if (dataSocket->Connect()>=0) { - dataSocket->SendDataOnly(&fnum,sizeof(fnum)); - dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL){ - dataSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Receiver returned error: " << mess << std::endl; - } - - dataSocket->Disconnect(); - if (ret==FORCE_UPDATE) - ret=updateReceiver(); - } - } + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { + if (dataSocket) { + if (dataSocket->Connect()>=0) { + dataSocket->SendDataOnly(&fnum,sizeof(fnum)); + dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); + if (ret==FAIL){ + dataSocket->ReceiveDataOnly(mess,sizeof(mess)); + std::cout<< "Receiver returned error: " << mess << std::endl; } - //tell the server to NOT send to receiver and instead to CPU - if(ret==OK){ - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL){ - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); - if (ret==FORCE_UPDATE) - ret=updateDetector(); - } - } - } - } + dataSocket->Disconnect(); + if (ret==FORCE_UPDATE) + ret=updateReceiver(); + } + } + } - return ret; + //tell the server to NOT send to receiver and instead to CPU + if(ret==OK){ + if (thisDetector->onlineFlag==ONLINE_FLAG) { + if (controlSocket) { + if (controlSocket->Connect()>=0) { + controlSocket->SendDataOnly(&fnum,sizeof(fnum)); + controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); + if (ret==FAIL){ + controlSocket->ReceiveDataOnly(mess,sizeof(mess)); + std::cout<< "Detector returned error: " << mess << std::endl; + } + controlSocket->Disconnect(); + if (ret==FORCE_UPDATE) + ret=updateDetector(); + } + } + } + } + + return ret; } slsDetectorDefs::runStatus slsDetector::getReceiverStatus(){ - int fnum=F_GET_RECEIVER_STATUS; - int ret = FAIL; - char mess[100]; - runStatus retval=ERROR; + int fnum=F_GET_RECEIVER_STATUS; + int ret = FAIL; + char mess[100]; + runStatus retval=ERROR; #ifdef VERBOSE - std::cout << "Getting Receiver Status" << std::endl; + std::cout << "Getting Receiver Status" << std::endl; #endif - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { - if (dataSocket) { - if (dataSocket->Connect()>=0) { - dataSocket->SendDataOnly(&fnum,sizeof(fnum)); - 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,sizeof(retval)); + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { + if (dataSocket) { + if (dataSocket->Connect()>=0) { + dataSocket->SendDataOnly(&fnum,sizeof(fnum)); + 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,sizeof(retval)); - dataSocket->Disconnect(); - if (ret==FORCE_UPDATE) - updateReceiver(); - } - } - } - return retval; + dataSocket->Disconnect(); + if (ret==FORCE_UPDATE) + updateReceiver(); + } + } + } + return retval; } int slsDetector::getFramesCaughtByReciver(){ - int fnum=F_GET_FRAMES_CAUGHT; - int ret = FAIL; - char mess[100]; - int retval=-1; + int fnum=F_GET_FRAMES_CAUGHT; + int ret = FAIL; + char mess[100]; + int retval=-1; #ifdef VERBOSE - std::cout << "Getting Frames Caught by Receiver " << std::endl; + 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)); - dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) - dataSocket->ReceiveDataOnly(&retval,sizeof(retval)); - else{ - dataSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Receiver returned error: " << mess << std::endl; - } - dataSocket->Disconnect(); - if (ret==FORCE_UPDATE) - updateReceiver(); - } - } + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { + if (dataSocket) { + if (dataSocket->Connect()>=0) { + dataSocket->SendDataOnly(&fnum,sizeof(fnum)); + dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); + if (ret!=FAIL) + dataSocket->ReceiveDataOnly(&retval,sizeof(retval)); + else{ + dataSocket->ReceiveDataOnly(mess,sizeof(mess)); + std::cout<< "Receiver returned error: " << mess << std::endl; } - return retval; + dataSocket->Disconnect(); + if (ret==FORCE_UPDATE) + updateReceiver(); + } + } + } + return retval; } int slsDetector::lockReceiver(int lock){ - int fnum=F_LOCK_RECEIVER; - int ret = FAIL; - int retval=-1; - char mess[100]; + int fnum=F_LOCK_RECEIVER; + int ret = FAIL; + int retval=-1; + char mess[100]; - int arg= lock; + int arg= lock; #ifdef VERBOSE - std::cout << "Locking or Unlocking Receiver " << std::endl; + 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)); - dataSocket->SendDataOnly(&arg,sizeof(arg)); - dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) - dataSocket->ReceiveDataOnly(&retval,sizeof(retval)); - else{ - dataSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Receiver returned error: " << mess << std::endl; - } - - dataSocket->Disconnect(); - if (ret==FORCE_UPDATE) - updateReceiver(); - } - } + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { + if (dataSocket) { + if (dataSocket->Connect()>=0) { + dataSocket->SendDataOnly(&fnum,sizeof(fnum)); + dataSocket->SendDataOnly(&arg,sizeof(arg)); + dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); + if (ret!=FAIL) + dataSocket->ReceiveDataOnly(&retval,sizeof(retval)); + else{ + dataSocket->ReceiveDataOnly(mess,sizeof(mess)); + std::cout<< "Receiver returned error: " << mess << std::endl; } - return retval; + + dataSocket->Disconnect(); + if (ret==FORCE_UPDATE) + updateReceiver(); + } + } + } + return retval; } @@ -5735,35 +5716,35 @@ int slsDetector::lockReceiver(int lock){ string slsDetector::getReceiverLastClientIP(){ - int fnum=F_GET_LAST_CLIENT_IP; - int ret = FAIL; - char retval[INET_ADDRSTRLEN]; - char mess[100]; + int fnum=F_GET_LAST_CLIENT_IP; + int ret = FAIL; + char retval[INET_ADDRSTRLEN]; + char mess[100]; #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 - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { - if (dataSocket) { - if (dataSocket->Connect()>=0) { - dataSocket->SendDataOnly(&fnum,sizeof(fnum)); - dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) - dataSocket->ReceiveDataOnly(retval,sizeof(retval)); - else{ - dataSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Receiver returned error: " << mess << std::endl; - } - - dataSocket->Disconnect(); - if (ret==FORCE_UPDATE) - updateReceiver(); - } - } + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { + if (dataSocket) { + if (dataSocket->Connect()>=0) { + dataSocket->SendDataOnly(&fnum,sizeof(fnum)); + dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); + if (ret!=FAIL) + dataSocket->ReceiveDataOnly(retval,sizeof(retval)); + else{ + dataSocket->ReceiveDataOnly(mess,sizeof(mess)); + std::cout<< "Receiver returned error: " << mess << std::endl; } - return string(retval); + + dataSocket->Disconnect(); + if (ret==FORCE_UPDATE) + updateReceiver(); + } + } + } + return string(retval); } @@ -5772,22 +5753,22 @@ string slsDetector::getReceiverLastClientIP(){ int slsDetector::updateReceiverNoWait() { - int n,ind; - char path[MAX_STR_LENGTH]; - char lastClientIP[INET_ADDRSTRLEN]; + int n,ind; + char path[MAX_STR_LENGTH]; + char lastClientIP[INET_ADDRSTRLEN]; - n = dataSocket->ReceiveDataOnly(lastClientIP,sizeof(lastClientIP)); -#ifdef VERBOSE - cout << "Updating receiver last modified by " << lastClientIP << std::endl; -#endif + n = dataSocket->ReceiveDataOnly(lastClientIP,sizeof(lastClientIP)); + //#ifdef VERBOSE + cout << "Updating receiver last modified by " << lastClientIP << std::endl; + //#endif - n = dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); cout<<"index:"<xx=xx;update file index how? - n = dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH); cout<<"path:"<xx=xx;update file index how? - n = dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH); cout<<"name:"<xx=xx;update file index how? - return OK; + n = dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); cout<<"index:"<xx=xx;update file index how? + n = dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH); cout<<"path:"<xx=xx;update file index how? + n = dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH); cout<<"name:"<xx=xx;update file index how? + return OK; } @@ -5796,27 +5777,27 @@ int slsDetector::updateReceiverNoWait() { int slsDetector::updateReceiver() { - int fnum=F_UPDATE_CLIENT; - int ret=OK; - char mess[100]; + int fnum=F_UPDATE_CLIENT; + int ret=OK; + char mess[100]; - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { - if (dataSocket) { - if (dataSocket->Connect()>=0) { - dataSocket->SendDataOnly(&fnum,sizeof(fnum)); - dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) - updateReceiverNoWait(); - else{ - dataSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Receiver returned error: " << mess << std::endl; - } - - dataSocket->Disconnect(); - } - } + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { + if (dataSocket) { + if (dataSocket->Connect()>=0) { + dataSocket->SendDataOnly(&fnum,sizeof(fnum)); + dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); + if (ret!=FAIL) + updateReceiverNoWait(); + else{ + dataSocket->ReceiveDataOnly(mess,sizeof(mess)); + std::cout<< "Receiver returned error: " << mess << std::endl; } + dataSocket->Disconnect(); + } + } + } + return ret; } diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index b2a0bab78..0d2bfd386 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -37,22 +37,22 @@ class slsDetector : public slsDetectorUtils, public energyConversion { public: -/* /\** online flags enum \sa setOnline*\/ */ -/* enum {GET_ONLINE_FLAG=-1, /\**< returns wether the detector is in online or offline state *\/ */ -/* OFFLINE_FLAG=0, /\**< detector in offline state (i.e. no communication to the detector - using only local structure - no data acquisition possible!) *\/ */ -/* ONLINE_FLAG =1/\**< detector in online state (i.e. communication to the detector updating the local structure) *\/ */ -/* }; */ + /* /\** online flags enum \sa setOnline*\/ */ + /* enum {GET_ONLINE_FLAG=-1, /\**< returns wether the detector is in online or offline state *\/ */ + /* OFFLINE_FLAG=0, /\**< detector in offline state (i.e. no communication to the detector - using only local structure - no data acquisition possible!) *\/ */ + /* ONLINE_FLAG =1/\**< detector in online state (i.e. communication to the detector updating the local structure) *\/ */ + /* }; */ /** @short Structure allocated in shared memory to store detector settings. -Structure allocated in shared memory to store detector settings and be accessed in parallel by several applications on the same machine (take care of possible conflicts, particularly if things are run on different machines!) + Structure allocated in shared memory to store detector settings and be accessed in parallel by several applications on the same machine (take care of possible conflicts, particularly if things are run on different machines!) */ -typedef struct sharedSlsDetector { - /** already existing flag. If the detector does not yet exist (alreadyExisting=0) the sharedMemory will be created, otherwise it will simly be linked */ + typedef struct sharedSlsDetector { + /** already existing flag. If the detector does not yet exist (alreadyExisting=0) the sharedMemory will be created, otherwise it will simly be linked */ int alreadyExisting; @@ -60,54 +60,54 @@ typedef struct sharedSlsDetector { /** last process id accessing the shared memory */ - pid_t lastPID; + pid_t lastPID; - /** online flag - is set if the detector is connected, unset if socket connection is not possible */ - int onlineFlag; + /** online flag - is set if the detector is connected, unset if socket connection is not possible */ + int onlineFlag; - /** stopped flag - is set if an acquisition error occurs or the detector is stopped manually. Is reset to 0 at the start of the acquisition */ - int stoppedFlag; + /** stopped flag - is set if an acquisition error occurs or the detector is stopped manually. Is reset to 0 at the start of the acquisition */ + int stoppedFlag; /** is the hostname (or IP address) of the detector. needs to be set before startin the communication */ char hostname[MAX_STR_LENGTH]; /** is the port used for control functions normally it should not be changed*/ int controlPort; - /** is the port used to stop the acquisition normally it should not be changed*/ + /** is the port used to stop the acquisition normally it should not be changed*/ int stopPort; - /** is the port used to acquire the data normally it should not be changed*/ + /** is the port used to acquire the data normally it should not be changed*/ int dataPort; - /** detector type \ see :: detectorType*/ + /** detector type \ see :: detectorType*/ detectorType myDetectorType; - /** path of the trimbits/settings files */ + /** path of the trimbits/settings files */ char settingsDir[MAX_STR_LENGTH]; - /** path of the calibration files */ + /** path of the calibration files */ char calDir[MAX_STR_LENGTH]; - /** number of energies at which the detector has been trimmed (unused) */ + /** number of energies at which the detector has been trimmed (unused) */ int nTrimEn; - /** list of the energies at which the detector has been trimmed (unused) */ + /** list of the energies at which the detector has been trimmed (unused) */ int trimEnergies[100]; - /** indicator for the acquisition progress - set to 0 at the beginning of the acquisition and incremented every time that the data are written to file */ + /** indicator for the acquisition progress - set to 0 at the beginning of the acquisition and incremented every time that the data are written to file */ int progressIndex; - /** total number of frames to be acquired */ + /** total number of frames to be acquired */ int totalProgress; - /** current index of the output file */ + /** current index of the output file */ int fileIndex; - /** path of the output files */ + /** 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]; - /* size of the detector */ + /* size of the detector */ /** number of installed modules of the detector (x and y directions) */ int nMod[2]; @@ -132,89 +132,89 @@ typedef struct sharedSlsDetector { /** corrections to be applied to the data \see ::correctionFlags */ int correctionMask; - /** threaded processing flag (i.e. if data are processed and written to file in a separate thread) */ - int threadedProcessing; + /** threaded processing flag (i.e. if data are processed and written to file in a separate thread) */ + int threadedProcessing; /** dead time (in ns) for rate corrections */ double tDead; - /** directory where the flat field files are stored */ - char flatFieldDir[MAX_STR_LENGTH]; - /** file used for flat field corrections */ - char flatFieldFile[MAX_STR_LENGTH]; + /** directory where the flat field files are stored */ + char flatFieldDir[MAX_STR_LENGTH]; + /** file used for flat field corrections */ + char flatFieldFile[MAX_STR_LENGTH]; /** number of bad channels from bad channel list */ int nBadChans; - /** file with the bad channels */ - char badChanFile[MAX_STR_LENGTH]; + /** file with the bad channels */ + char badChanFile[MAX_STR_LENGTH]; /** list of bad channels */ int badChansList[MAX_BADCHANS]; /** number of bad channels from flat field i.e. channels which read 0 in the flat field file */ int nBadFF; /** list of bad channels from flat field i.e. channels which read 0 in the flat field file */ - int badFFList[MAX_BADCHANS]; + int badFFList[MAX_BADCHANS]; - /** file with the angular conversion factors */ - char angConvFile[MAX_STR_LENGTH]; + /** file with the angular conversion factors */ + char angConvFile[MAX_STR_LENGTH]; /** array of angular conversion constants for each module \see ::angleConversionConstant */ - angleConversionConstant angOff[MAXMODS]; + angleConversionConstant angOff[MAXMODS]; /** angular direction (1 if it corresponds to the encoder direction i.e. channel 0 is 0, maxchan is positive high angle, 0 otherwise */ - int angDirection; - /** beamline fine offset (of the order of mdeg, might be adjusted for each measurements) */ - double fineOffset; - /** beamline offset (might be a few degrees beacuse of encoder offset - normally it is kept fixed for a long period of time) */ - double globalOffset; - /** number of positions at which the detector should acquire */ - int numberOfPositions; - /** list of encoder positions at which the detector should acquire */ - double detPositions[MAXPOS]; - /** bin size for data merging */ - double binSize; - /** add encoder value flag (i.e. wether the detector is moving - 1 - or stationary - 0) */ - int moveFlag; + int angDirection; + /** beamline fine offset (of the order of mdeg, might be adjusted for each measurements) */ + double fineOffset; + /** beamline offset (might be a few degrees beacuse of encoder offset - normally it is kept fixed for a long period of time) */ + double globalOffset; + /** number of positions at which the detector should acquire */ + int numberOfPositions; + /** list of encoder positions at which the detector should acquire */ + double detPositions[MAXPOS]; + /** bin size for data merging */ + double binSize; + /** add encoder value flag (i.e. wether the detector is moving - 1 - or stationary - 0) */ + int moveFlag; - /* infos necessary for the readout to determine the size of the data */ + /* infos necessary for the readout to determine the size of the data */ - /** number of rois defined */ - int nROI; - /** list of rois */ - ROI roiLimits[MAX_ROIS]; + /** number of rois defined */ + int nROI; + /** list of rois */ + ROI roiLimits[MAX_ROIS]; - /** readout flags */ - readOutFlags roFlags; + /** readout flags */ + readOutFlags roFlags; - /* detector setup - not needed */ - /** name root of the output files */ - char settingsFile[MAX_STR_LENGTH]; - /** detector settings (standard, fast, etc.) */ - detectorSettings currentSettings; - /** detector threshold (eV) */ - int currentThresholdEV; - /** timer values */ - int64_t timerValue[MAX_TIMERS]; - /** clock divider */ - //int clkDiv; + /* detector setup - not needed */ + /** name root of the output files */ + char settingsFile[MAX_STR_LENGTH]; + /** detector settings (standard, fast, etc.) */ + detectorSettings currentSettings; + /** detector threshold (eV) */ + int currentThresholdEV; + /** timer values */ + int64_t timerValue[MAX_TIMERS]; + /** clock divider */ + //int clkDiv; - /** Scans and scripts */ - ////////////////////////// only in the multi detector class?!?!?!? additional shared memory class?!?!?!? - int actionMask; + /** Scans and scripts */ + ////////////////////////// only in the multi detector class?!?!?!? additional shared memory class?!?!?!? + int actionMask; - mystring actionScript[MAX_ACTIONS]; + mystring actionScript[MAX_ACTIONS]; - mystring actionParameter[MAX_ACTIONS]; + mystring actionParameter[MAX_ACTIONS]; - int scanMode[MAX_SCAN_LEVELS]; - mystring scanScript[MAX_SCAN_LEVELS]; - mystring scanParameter[MAX_SCAN_LEVELS]; - int nScanSteps[MAX_SCAN_LEVELS]; - mysteps scanSteps[MAX_SCAN_LEVELS]; - int scanPrecision[MAX_SCAN_LEVELS]; + int scanMode[MAX_SCAN_LEVELS]; + mystring scanScript[MAX_SCAN_LEVELS]; + mystring scanParameter[MAX_SCAN_LEVELS]; + int nScanSteps[MAX_SCAN_LEVELS]; + mysteps scanSteps[MAX_SCAN_LEVELS]; + int scanPrecision[MAX_SCAN_LEVELS]; - //////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////// - /*offsets*/ + /*offsets*/ /** memory offsets for the flat field coefficients */ int ffoff; /** memory offsets for the flat filed coefficient errors */ @@ -245,7 +245,7 @@ typedef struct sharedSlsDetector { int receiverOnlineFlag; -} sharedSlsDetector; + } sharedSlsDetector; @@ -253,33 +253,33 @@ typedef struct sharedSlsDetector { - using slsDetectorUtils::getDetectorType; + using slsDetectorUtils::getDetectorType; - using postProcessing::flatFieldCorrect; - using postProcessing::rateCorrect; - using postProcessing::setBadChannelCorrection; + using postProcessing::flatFieldCorrect; + using postProcessing::rateCorrect; + using postProcessing::setBadChannelCorrection; - using angularConversion::readAngularConversion; - using angularConversion::writeAngularConversion; + using angularConversion::readAngularConversion; + using angularConversion::writeAngularConversion; - using slsDetectorUtils::getAngularConversion; + using slsDetectorUtils::getAngularConversion; - string getDetectorType(){return sgetDetectorsType();}; + string getDetectorType(){return sgetDetectorsType();}; -/** (default) constructor - \param type is needed to define the size of the detector shared memory 9defaults to GENERIC i.e. the largest shared memory needed by any slsDetector is allocated - \param id is the detector index which is needed to define the shared memory id. Different physical detectors should have different IDs in order to work independently + /** (default) constructor + \param type is needed to define the size of the detector shared memory 9defaults to GENERIC i.e. the largest shared memory needed by any slsDetector is allocated + \param id is the detector index which is needed to define the shared memory id. Different physical detectors should have different IDs in order to work independently -*/ + */ slsDetector(detectorType type=GENERIC, int id=0); -/** constructor - \param id is the detector index which is needed to define the shared memory id. Different physical detectors should have different IDs in order to work independently -*/ + /** constructor + \param id is the detector index which is needed to define the shared memory id. Different physical detectors should have different IDs in order to work independently + */ slsDetector(int id); @@ -303,7 +303,7 @@ typedef struct sharedSlsDetector { static int exists(int id); /** - configures mac for gotthard readout + configures mac for gotthard readout */ int configureMAC(); @@ -321,9 +321,9 @@ typedef struct sharedSlsDetector { /** - Writes the configuration file fname - \param fname file name - \returns OK or FAIL + Writes the configuration file fname + \param fname file name + \returns OK or FAIL */ int writeConfigurationFile(string const fname); @@ -337,14 +337,14 @@ typedef struct sharedSlsDetector { /** - configure the socket communication and initializes the socket instances + configure the socket communication and initializes the socket instances - \param name hostname - if "" the current hostname is used - \param control_port port for control commands - if -1 the current is used - \param stop_port port for stop command - if -1 the current is used + \param name hostname - if "" the current hostname is used + \param control_port port for control commands - if -1 the current is used + \param stop_port port for stop command - if -1 the current is used - \returns OK is connection succeded, FAIL otherwise - \sa sharedSlsDetector + \returns OK is connection succeded, FAIL otherwise + \sa sharedSlsDetector */ int setTCPSocket(string const name="", int const control_port=-1, int const stop_port=-1); @@ -393,7 +393,7 @@ typedef struct sharedSlsDetector { /** disconnect from the stop port */ int disconnectStop(); - /** + /** sets the network parameters \param i network parameter type can be RECEIVER_IP, RECEIVER_MAC, SERVER_MAC \param s value to be set @@ -419,39 +419,39 @@ typedef struct sharedSlsDetector { - /** + /** returns the location of the calibration files - \sa sharedSlsDetector + \sa sharedSlsDetector */ char* getCalDir() {return thisDetector->calDir;}; - /** - sets the location of the calibration files - \sa sharedSlsDetector + /** + sets the location of the calibration files + \sa sharedSlsDetector */ char* setCalDir(string s) {sprintf(thisDetector->calDir, s.c_str()); return thisDetector->calDir;}; /** returns the number of trim energies and their value \sa sharedSlsDetector - \param point to the array that will contain the trim energies (in ev) - \returns number of trim energies + \param point to the array that will contain the trim energies (in ev) + \returns number of trim energies - unused! + unused! - \sa sharedSlsDetector + \sa sharedSlsDetector */ int getTrimEn(int *en=NULL) {if (en) {for (int ien=0; iennTrimEn; ien++) en[ien]=thisDetector->trimEnergies[ien];} return (thisDetector->nTrimEn);}; /** sets the number of trim energies and their value \sa sharedSlsDetector - \param nen number of energies - \param en array of energies - \returns number of trim energies + \param nen number of energies + \param en array of energies + \returns number of trim energies - unused! + unused! - \sa sharedSlsDetector + \sa sharedSlsDetector */ int setTrimEn(int nen, int *en=NULL) {if (en) {for (int ien=0; ientrimEnergies[ien]=en[ien]; thisDetector->nTrimEn=nen;} return (thisDetector->nTrimEn);}; @@ -466,7 +466,7 @@ typedef struct sharedSlsDetector { \sa ::sls_detector_module sharedSlsDetector mythenDetector::writeSettingsFile(string, int) */ using energyConversion::writeSettingsFile; - int writeSettingsFile(string fname, int imod); + int writeSettingsFile(string fname, int imod); /** @@ -487,7 +487,7 @@ typedef struct sharedSlsDetector { \param fname file name . If not specified, extension is automatically generated! \param imod module number, -1 means all modules \returns OK or FAIL - */ + */ int loadSettingsFile(string fname, int imod=-1); @@ -495,7 +495,7 @@ typedef struct sharedSlsDetector { \param fname file name . Axtension is automatically generated! \param imod module number, -1 means all modules \returns OK or FAIL - */ + */ int saveSettingsFile(string fname, int imod=-1); @@ -503,7 +503,7 @@ typedef struct sharedSlsDetector { \param fname file name . If not specified, extension is automatically generated! \param imod module number, -1 means all modules \returns OK or FAIL - */ + */ int loadCalibrationFile(string fname, int imod=-1); @@ -511,14 +511,14 @@ typedef struct sharedSlsDetector { \param fname file name . Axtension is automatically generated! \param imod module number, -1 means all modules \returns OK or FAIL - */ + */ int saveCalibrationFile(string fname, int imod=-1); /** - reads an angular conversion file - \param fname file to be read + reads an angular conversion file + \param fname file to be read \sa angleConversionConstant mythenDetector::readAngularConversion */ int readAngularConversionFile(string fname=""); @@ -526,8 +526,8 @@ typedef struct sharedSlsDetector { /** - reads an angular conversion file - \param fname file to be read + reads an angular conversion file + \param fname file to be read \sa angleConversionConstant mythenDetector::readAngularConversion */ int readAngularConversion(ifstream& ifs); @@ -537,8 +537,8 @@ typedef struct sharedSlsDetector { /** Pure virtual function writes an angular conversion file - \param fname file to be written - \sa angleConversionConstant mythenDetector::writeAngularConversion + \param fname file to be written + \sa angleConversionConstant mythenDetector::writeAngularConversion */ int writeAngularConversion(string fname=""); @@ -547,8 +547,8 @@ typedef struct sharedSlsDetector { /** Pure virtual function writes an angular conversion file - \param fname file to be written - \sa angleConversionConstant mythenDetector::writeAngularConversion + \param fname file to be written + \sa angleConversionConstant mythenDetector::writeAngularConversion */ int writeAngularConversion(ofstream &ofs); @@ -597,17 +597,17 @@ typedef struct sharedSlsDetector { int setDetectorType(detectorType type=GET_DETECTOR_TYPE); /** - sets/gets detector type - normally the detector knows what type of detector it is - \param type is the detector type ("Mythen", "Pilatus", "XFS", "Gotthard", Agipd") - \returns returns detector type index (1 GENERIC, 2 MYTHEN, 3 PILATUS, 4 XFS, 5 GOTTHARD, 6 AGIPD, -1 command failed) + sets/gets detector type + normally the detector knows what type of detector it is + \param type is the detector type ("Mythen", "Pilatus", "XFS", "Gotthard", Agipd") + \returns returns detector type index (1 GENERIC, 2 MYTHEN, 3 PILATUS, 4 XFS, 5 GOTTHARD, 6 AGIPD, -1 command failed) */ int setDetectorType(string type); /** - gets detector type - normally the detector knows what type of detector it is - \returns returns detector type index (1 GENERIC, 2 MYTHEN, 3 PILATUS, 4 XFS, 5 GOTTHARD, 6 AGIPD, -1 command failed) + gets detector type + normally the detector knows what type of detector it is + \returns returns detector type index (1 GENERIC, 2 MYTHEN, 3 PILATUS, 4 XFS, 5 GOTTHARD, 6 AGIPD, -1 command failed) */ detectorType getDetectorsType(int pos=-1); @@ -656,7 +656,7 @@ typedef struct sharedSlsDetector { /** - set/get the use of an external signal + set/get the use of an external signal \param pol meaning of the signal \sa externalSignalFlag \param signalIndex index of the signal \returns current meaning of signal signalIndex @@ -665,9 +665,9 @@ typedef struct sharedSlsDetector { /** - set/get the external communication mode + set/get the external communication mode - obsolete \sa setExternalSignalFlags + obsolete \sa setExternalSignalFlags \param pol value to be set \sa externalCommunicationMode \returns current external communication mode */ @@ -684,10 +684,10 @@ typedef struct sharedSlsDetector { */ int64_t getId(idMode mode, int imod=0); /** - Digital test of the modules - \param mode test mode - \param imod module number for chip test or module firmware test - \returns OK or error mask + Digital test of the modules + \param mode test mode + \param imod module number for chip test or module firmware test + \returns OK or error mask */ int digitalTest(digitalTestMode mode, int imod=0); /** @@ -701,16 +701,16 @@ typedef struct sharedSlsDetector { int* analogTest(analogTestMode mode); /** - enable analog output of channel ichan + enable analog output of channel ichan - not yet implemented + not yet implemented */ int enableAnalogOutput(int ichan); /** - enable analog output of channel ichan, chip ichip, module imod + enable analog output of channel ichan, chip ichip, module imod - not yet implemented + not yet implemented */ int enableAnalogOutput(int imod, int ichip, int ichan); @@ -745,102 +745,102 @@ typedef struct sharedSlsDetector { int readRegister(int addr); /** - set dacs value - \param val value (in V) - \param index DAC index - \param imod module number (if -1 alla modules) - \returns current DAC value + set dacs value + \param val value (in V) + \param index DAC index + \param imod module number (if -1 alla modules) + \returns current DAC value */ dacs_t setDAC(dacs_t val, dacIndex index, int imod=-1); /** - set dacs value - \param index ADC index - \param imod module number - \returns current ADC value + set dacs value + \param index ADC index + \param imod module number + \returns current ADC value */ dacs_t getADC(dacIndex index, int imod=0); /** - configure channel - \param reg channel register - \param ichan channel number (-1 all) - \param ichip chip number (-1 all) - \param imod module number (-1 all) - \returns current register value - \sa ::sls_detector_channel + configure channel + \param reg channel register + \param ichan channel number (-1 all) + \param ichip chip number (-1 all) + \param imod module number (-1 all) + \returns current register value + \sa ::sls_detector_channel */ int setChannel(int64_t reg, int ichan=-1, int ichip=-1, int imod=-1); /** - configure channel - \param chan channel to be set - must contain correct channel, module and chip number - \returns current register value + configure channel + \param chan channel to be set - must contain correct channel, module and chip number + \returns current register value */ int setChannel(sls_detector_channel chan); /** - get channel - \param ichan channel number - \param ichip chip number - \param imod module number - \returns current channel structure for channel + get channel + \param ichan channel number + \param ichip chip number + \param imod module number + \returns current channel structure for channel */ sls_detector_channel getChannel(int ichan, int ichip, int imod); /** - configure chip - \param reg chip register - \param ichip chip number (-1 all) - \param imod module number (-1 all) - \returns current register value - \sa ::sls_detector_chip + configure chip + \param reg chip register + \param ichip chip number (-1 all) + \param imod module number (-1 all) + \returns current register value + \sa ::sls_detector_chip */ int setChip(int reg, int ichip=-1, int imod=-1); /** - configure chip - \param chip chip to be set - must contain correct module and chip number and also channel registers - \returns current register value - \sa ::sls_detector_chip + configure chip + \param chip chip to be set - must contain correct module and chip number and also channel registers + \returns current register value + \sa ::sls_detector_chip */ int setChip(sls_detector_chip chip); /** - get chip - \param ichip chip number - \param imod module number - \returns current chip structure for channel + get chip + \param ichip chip number + \param imod module number + \returns current chip structure for channel - \bug probably does not return corretly! + \bug probably does not return corretly! */ sls_detector_chip getChip(int ichip, int imod); /** - configure module - \param imod module number (-1 all) - \returns current register value - \sa ::sls_detector_module + configure module + \param imod module number (-1 all) + \returns current register value + \sa ::sls_detector_module */ int setModule(int reg, int imod=-1); //virtual int setModule(int reg, int imod=-1); /** - configure chip - \param module module to be set - must contain correct module number and also channel and chip registers - \returns current register value - \sa ::sls_detector_module + configure chip + \param module module to be set - must contain correct module number and also channel and chip registers + \returns current register value + \sa ::sls_detector_module */ int setModule(sls_detector_module module); //virtual int setModule(sls_detector_module module); /** - get module - \param imod module number - \returns pointer to module structure (which has bee created and must then be deleted) + get module + \param imod module number + \returns pointer to module structure (which has bee created and must then be deleted) */ sls_detector_module *getModule(int imod); //virtual sls_detector_module *getModule(int imod); @@ -854,46 +854,46 @@ typedef struct sharedSlsDetector { calibrated setup of the threshold */ /** - get threshold energy - \param imod module number (-1 all) - \returns current threshold value for imod in ev (-1 failed) + get threshold energy + \param imod module number (-1 all) + \returns current threshold value for imod in ev (-1 failed) */ int getThresholdEnergy(int imod=-1); /** - set threshold energy - \param e_eV threshold in eV - \param imod module number (-1 all) - \param isettings ev. change settings - \returns current threshold value for imod in ev (-1 failed) + set threshold energy + \param e_eV threshold in eV + \param imod module number (-1 all) + \param isettings ev. change settings + \returns current threshold value for imod in ev (-1 failed) */ int setThresholdEnergy(int e_eV, int imod=-1, detectorSettings isettings=GET_SETTINGS); /** - get detector settings - \param imod module number (-1 all) - \returns current settings + get detector settings + \param imod module number (-1 all) + \returns current settings */ detectorSettings getSettings(int imod=-1); /** - set detector settings - \param isettings settings - \param imod module number (-1 all) - \returns current settings + set detector settings + \param isettings settings + \param imod module number (-1 all) + \returns current settings - in this function trimbits/settings and calibration files are searched in the settingsDir and calDir directories and the detector is initialized + in this function trimbits/settings and calibration files are searched in the settingsDir and calDir directories and the detector is initialized */ detectorSettings setSettings(detectorSettings isettings, int imod=-1); //virtual detectorSettings setSettings(detectorSettings isettings, int imod=-1); /** - gets the trimbits from shared memory *chanRegs - \param retval is the array with the trimbits - \param fromDetector is true if the trimbits shared memory have to be uploaded from detector - \returns the total number of channels for the detector - \sa ::sls_detector_module - */ + gets the trimbits from shared memory *chanRegs + \param retval is the array with the trimbits + \param fromDetector is true if the trimbits shared memory have to be uploaded from detector + \returns the total number of channels for the detector + \sa ::sls_detector_module + */ int getChanRegs(double* retval,bool fromDetector); /** @@ -915,72 +915,72 @@ typedef struct sharedSlsDetector { int updateDetector(); -// Acquisition functions + // Acquisition functions /** - start detector acquisition - \returns OK/FAIL + start detector acquisition + \returns OK/FAIL */ int startAcquisition(); /** - stop detector acquisition - \returns OK/FAIL + stop detector acquisition + \returns OK/FAIL */ int stopAcquisition(); /** - start readout (without exposure or interrupting exposure) - \returns OK/FAIL + start readout (without exposure or interrupting exposure) + \returns OK/FAIL */ int startReadOut(); /** get run status - \returns status mask + \returns status mask */ //virtual runStatus getRunStatus()=0; runStatus getRunStatus(); /** - start detector acquisition and read all data putting them a data queue - \returns pointer to the front of the data queue - \sa startAndReadAllNoWait getDataFromDetector dataQueue + start detector acquisition and read all data putting them a data queue + \returns pointer to the front of the data queue + \sa startAndReadAllNoWait getDataFromDetector dataQueue */ int* startAndReadAll(); /** - start detector acquisition and read out, but does not read data from socket leaving socket opened - \returns OK or FAIL + start detector acquisition and read out, but does not read data from socket leaving socket opened + \returns OK or FAIL */ int startAndReadAllNoWait(); -/* /\** */ -/* receives a data frame from the detector socket */ -/* \returns pointer to the data or NULL. If NULL disconnects the socket */ -/* \sa getDataFromDetector */ -/* *\/ */ -/* int* getDataFromDetectorNoWait(); */ + /* /\** */ + /* receives a data frame from the detector socket */ + /* \returns pointer to the data or NULL. If NULL disconnects the socket */ + /* \sa getDataFromDetector */ + /* *\/ */ + /* int* getDataFromDetectorNoWait(); */ /** - asks and receives a data frame from the detector and puts it in the data queue - \returns pointer to the data or NULL. - \sa getDataFromDetector + asks and receives a data frame from the detector and puts it in the data queue + \returns pointer to the data or NULL. + \sa getDataFromDetector */ int* readFrame(); /** - asks and receives all data from the detector and puts them in a data queue - \returns pointer to the front of the queue or NULL. - \sa getDataFromDetector dataQueue + asks and receives all data from the detector and puts them in a data queue + \returns pointer to the front of the queue or NULL. + \sa getDataFromDetector dataQueue */ int* readAll(); /** - asks and receives all data from the detector and leaves the socket opened - \returns OK or FAIL + asks and receives all data from the detector and leaves the socket opened + \returns OK or FAIL */ int readAllNoWait(); @@ -1011,7 +1011,7 @@ typedef struct sharedSlsDetector { \param value is the value to be set, if -1 get value \returns current value for the specified parameter \sa speedVariable - */ + */ int setSpeed(speedVariable sp, int value=-1); // Flags @@ -1050,8 +1050,8 @@ typedef struct sharedSlsDetector { */ int setReadOutFlags(readOutFlags flag=GET_READOUT_FLAGS); - /** - execute trimming + /** + execute trimming \param mode trim mode \param par1 if noise, beam or fixed setting trimming it is count limit, if improve maximum number of iterations \param par2 if noise or beam nsigma, if improve par2!=means vthreshold will be optimized, if fixed settings par2<0 trimwith median, par2>=0 trim with level @@ -1155,9 +1155,9 @@ typedef struct sharedSlsDetector { /** - decode data from the detector converting them to an array of doubles, one for each channle - \param datain data from the detector - \returns pointer to a double array with a data per channel + decode data from the detector converting them to an array of doubles, one for each channle + \param datain data from the detector + \returns pointer to a double array with a data per channel */ double* decodeData(int *datain, double *fdata=NULL); @@ -1166,12 +1166,12 @@ typedef struct sharedSlsDetector { /** - flat field correct data - \param datain data array - \param errin error array on data (if NULL will default to sqrt(datain) - \param dataout array of corrected data - \param errout error on corrected data (if not NULL) - \returns 0 + flat field correct data + \param datain data array + \param errin error array on data (if NULL will default to sqrt(datain) + \param dataout array of corrected data + \param errout error on corrected data (if not NULL) + \returns 0 */ int flatFieldCorrect(double* datain, double *errin, double* dataout, double *errout); @@ -1179,53 +1179,53 @@ typedef struct sharedSlsDetector { /** - rate correct data - \param datain data array - \param errin error array on data (if NULL will default to sqrt(datain) - \param dataout array of corrected data - \param errout error on corrected data (if not NULL) - \returns 0 + rate correct data + \param datain data array + \param errin error array on data (if NULL will default to sqrt(datain) + \param dataout array of corrected data + \param errout error on corrected data (if not NULL) + \returns 0 */ int rateCorrect(double* datain, double *errin, double* dataout, double *errout); -/* /\** */ -/* pure virtual function */ -/* sets the arrays of the merged data to 0. NB The array should be created with size >= 360./getBinSize(); */ -/* \param mp already merged postions */ -/* \param mv already merged data */ -/* \param me already merged errors (squared sum) */ -/* \param mm multiplicity of merged arrays */ -/* \returns OK or FAIL */ -/* \sa mythenDetector::resetMerging */ -/* *\/ */ + /* /\** */ + /* pure virtual function */ + /* sets the arrays of the merged data to 0. NB The array should be created with size >= 360./getBinSize(); */ + /* \param mp already merged postions */ + /* \param mv already merged data */ + /* \param me already merged errors (squared sum) */ + /* \param mm multiplicity of merged arrays */ + /* \returns OK or FAIL */ + /* \sa mythenDetector::resetMerging */ + /* *\/ */ -/* int resetMerging(double *mp, double *mv,double *me, int *mm); */ + /* int resetMerging(double *mp, double *mv,double *me, int *mm); */ -/* /\** */ -/* pure virtual function */ -/* merge dataset */ -/* \param p1 angular positions of dataset */ -/* \param v1 data */ -/* \param e1 errors */ -/* \param mp already merged postions */ -/* \param mv already merged data */ -/* \param me already merged errors (squared sum) */ -/* \param mm multiplicity of merged arrays */ -/* \sa mythenDetector::addToMerging */ -/* *\/ */ -/* int addToMerging(double *p1, double *v1, double *e1, double *mp, double *mv,double *me, int *mm); */ + /* /\** */ + /* pure virtual function */ + /* merge dataset */ + /* \param p1 angular positions of dataset */ + /* \param v1 data */ + /* \param e1 errors */ + /* \param mp already merged postions */ + /* \param mv already merged data */ + /* \param me already merged errors (squared sum) */ + /* \param mm multiplicity of merged arrays */ + /* \sa mythenDetector::addToMerging */ + /* *\/ */ + /* int addToMerging(double *p1, double *v1, double *e1, double *mp, double *mv,double *me, int *mm); */ -/* /\** pure virtual function */ -/* calculates the "final" positions, data value and errors for the emrged data */ -/* \param mp already merged postions */ -/* \param mv already merged data */ -/* \param me already merged errors (squared sum) */ -/* \param mm multiplicity of merged arrays */ -/* \returns FAIL or the number of non empty bins (i.e. points belonging to the pattern) */ -/* \sa mythenDetector::finalizeMerging */ -/* *\/ */ -/* int finalizeMerging(double *mp, double *mv,double *me, int *mm); */ + /* /\** pure virtual function */ + /* calculates the "final" positions, data value and errors for the emrged data */ + /* \param mp already merged postions */ + /* \param mv already merged data */ + /* \param me already merged errors (squared sum) */ + /* \param mm multiplicity of merged arrays */ + /* \returns FAIL or the number of non empty bins (i.e. points belonging to the pattern) */ + /* \sa mythenDetector::finalizeMerging */ + /* *\/ */ + /* int finalizeMerging(double *mp, double *mv,double *me, int *mm); */ /** turns off server @@ -1274,22 +1274,22 @@ typedef struct sharedSlsDetector { \param \param action can be PUT_ACTION or GET_ACTION (from text client even READOUT_ACTION for acquisition) */ - static detectorType getDetectorType(const char *name, int cport=DEFAULT_PORTNO); + static detectorType getDetectorType(const char *name, int cport=DEFAULT_PORTNO); /** returns the detector type from hostname and controlport \param \param action can be PUT_ACTION or GET_ACTION (from text client even READOUT_ACTION for acquisition) */ - static detectorType getDetectorType(int id); + static detectorType getDetectorType(int id); - /** + /** Returns detector id \returns detector id */ - int getDetectorId(int i=-1) {return detId;}; + int getDetectorId(int i=-1) {return detId;}; /** Receives a data frame from the detector socket \returns pointer to the data (or NULL if failed) @@ -1307,17 +1307,17 @@ typedef struct sharedSlsDetector { masterFlags setMaster(masterFlags flag); /** - Loads dark image or gain image from a file and sends it to the detector - \param index is 0 for dark image and 1 for gain image - \param fname file name to load data from + Loads dark image or gain image from a file and sends it to the detector + \param index is 0 for dark image and 1 for gain image + \param fname file name to load data from */ int loadImageToDetector(imageType index,string const fname); /** - Called from loadImageToDetector to send the image to detector - \param index is 0 for dark image and 1 for gain image - \param arg image + Called from loadImageToDetector to send the image to detector + \param index is 0 for dark image and 1 for gain image + \param arg image */ int sendImageToDetector(imageType index,short int imageVals[]); @@ -1330,27 +1330,27 @@ typedef struct sharedSlsDetector { synchronizationMode setSynchronization(synchronizationMode sync=GET_SYNCHRONIZATION_MODE); /** - writes the counter memory block from the detector - \param startACQ is 1 to start acquisition after reading counter - \param fname file name to load data from - \returns OK or FAIL + writes the counter memory block from the detector + \param startACQ is 1 to start acquisition after reading counter + \param fname file name to load data from + \returns OK or FAIL */ int writeCounterBlockFile(string const fname,int startACQ=0); /** - gets counter memory block in detector - \param startACQ is 1 to start acquisition after reading counter - \param arg counter memory block from detector - \returns OK or FAIL + gets counter memory block in detector + \param startACQ is 1 to start acquisition after reading counter + \param arg counter memory block from detector + \returns OK or FAIL */ int getCounterBlock(short int arg[],int startACQ=0); /** - Resets counter in detector - \param startACQ is 1 to start acquisition after resetting counter - \returns OK or FAIL + Resets counter in detector + \param startACQ is 1 to start acquisition after resetting counter + \returns OK or FAIL */ int resetCounterBlock(int startACQ=0); @@ -1364,17 +1364,17 @@ typedef struct sharedSlsDetector { -//receiver + //receiver /** - calls setReceiverTCPSocket if online and sets the flag - */ + calls setReceiverTCPSocket if online and sets the flag + */ int setReceiverOnline(int const online=GET_ONLINE_FLAG); /** Checks if the receiver is really online - */ + */ string checkReceiverOnline(); /** @@ -1389,45 +1389,45 @@ typedef struct sharedSlsDetector { int setReceiverTCPSocket(string const name="", int const data_port=-1); /** - Sets up the receiver file name - @param fileName file name - \returns file name - */ + 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 - \returns file dir - */ + Sets up the receiver file directory + @param fileName fileDir file directory + \returns file dir + */ string setReceiverFileDir(string fileDir=""); /** - Sets up the receiver file index - @param fileIndex file index - \returns file index - */ + Sets up the receiver file index + @param fileIndex file index + \returns file index + */ int setReceiverFileIndex(int fileIndex=-1); /** Starts the listening mode of receiver \returns OK or FAIL - */ + */ int startReceiver(); /** Stops the listening mode of receiver \returns OK or FAIL - */ + */ int stopReceiver(); /** gets the status of the listening mode of receiver \returns status - */ + */ runStatus getReceiverStatus(); /** gets the number of frames caught by receiver \returns number of frames caught by receiver - */ + */ int getFramesCaughtByReciver(); /** Locks/Unlocks the connection to the receiver @@ -1437,19 +1437,19 @@ typedef struct sharedSlsDetector { int lockReceiver(int lock=-1); /** - Returns the IP of the last client connecting to the receiver + Returns the IP of the last client connecting to the receiver */ string getReceiverLastClientIP(); /** - updates the shared memory receiving the data from the detector (without asking and closing the connection - /returns OK + updates the shared memory receiving the data from the detector (without asking and closing the connection + /returns OK */ int updateReceiverNoWait(); /** - updates the shared memory receiving the data from the detector - /returns OK + updates the shared memory receiving the data from the detector + /returns OK */ int updateReceiver(); int fillModuleMask(int *mM); @@ -1457,7 +1457,7 @@ typedef struct sharedSlsDetector { /** - address of the detector structure in shared memory + address of the detector structure in shared memory */ sharedSlsDetector *thisDetector; diff --git a/slsDetectorSoftware/slsDetector/slsDetectorBase.h b/slsDetectorSoftware/slsDetector/slsDetectorBase.h index 6f6c15f9b..b26a6ee00 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorBase.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorBase.h @@ -2,37 +2,37 @@ #ifndef SLS_DETECTOR_BASE_H #define SLS_DETECTOR_BASE_H /** - \mainpage Common C++ library for SLS detectors data acquisition - * - * \section intro_sec Introduction + \mainpage Common C++ library for SLS detectors data acquisition + * + * \section intro_sec Introduction - * \subsection mot_sec Motivation - Although the SLS detectors group delvelops several types of detectors (1/2D, counting/integrating etc.) it is common interest of the group to use a common platfor for data acquisition - \subsection arch_sec System Architecture - The architecture of the acquisitions system is intended as follows: - \li A socket server running on the detector (or more than one in some special cases) - \li C++ classes common to all detectors for client-server communication. These can be supplied to users as libraries and embedded also in acquisition systems which are not developed by the SLS - \li the possibility of using a Qt-based graphical user interface (with eventually root analisys capabilities) - \li the possibility of running all commands from command line. In order to ensure a fast operation of this so called "text client" the detector parameters should not be re-initialized everytime. For this reason a shared memory block is allocated where the main detector flags and parameters are stored - \li a Root library for data postprocessing and detector calibration (energy, angle). + * \subsection mot_sec Motivation + Although the SLS detectors group delvelops several types of detectors (1/2D, counting/integrating etc.) it is common interest of the group to use a common platfor for data acquisition + \subsection arch_sec System Architecture + The architecture of the acquisitions system is intended as follows: + \li A socket server running on the detector (or more than one in some special cases) + \li C++ classes common to all detectors for client-server communication. These can be supplied to users as libraries and embedded also in acquisition systems which are not developed by the SLS + \li the possibility of using a Qt-based graphical user interface (with eventually root analisys capabilities) + \li the possibility of running all commands from command line. In order to ensure a fast operation of this so called "text client" the detector parameters should not be re-initialized everytime. For this reason a shared memory block is allocated where the main detector flags and parameters are stored + \li a Root library for data postprocessing and detector calibration (energy, angle). - \section howto_sec How to use it + \section howto_sec How to use it - The detectors can be simply operated by using the provided GUi or command line executable.
-In case you need to embed the detector control e.g in the beamline control software, compile these classes using -
-make package -
-and link the shared library created to your software slsDetectorSoftware/bin/libSlsDetector.so -
-The software can also be installed (with super-user rights)
-make install -
-
-Most methods of interest for the user are implemented in the ::slsDetectorBase interface class, but the classes to be implemented in the main program are either ::slsDetector (for single controller detectors) or ::multiSlsDetector (for multiple controllers, but can work also for single controllers). + The detectors can be simply operated by using the provided GUi or command line executable.
+ In case you need to embed the detector control e.g in the beamline control software, compile these classes using +
+ make package +
+ and link the shared library created to your software slsDetectorSoftware/bin/libSlsDetector.so +
+ The software can also be installed (with super-user rights)
+ make install +
+
+ Most methods of interest for the user are implemented in the ::slsDetectorBase interface class, but the classes to be implemented in the main program are either ::slsDetector (for single controller detectors) or ::multiSlsDetector (for multiple controllers, but can work also for single controllers). -@author Anna Bergamaschi -@version 0.1alpha + @author Anna Bergamaschi + @version 0.1alpha */ @@ -58,7 +58,7 @@ using namespace std; @libdoc The slsDetectorBase contains also a set of purely virtual functions useful for the implementation of the derived classes - * @short This is the base class for all detector functionalities +* @short This is the base class for all detector functionalities */ @@ -68,119 +68,119 @@ class slsDetectorBase : public virtual slsDetectorDefs { public: /** default constructor */ - slsDetectorBase(){}; + slsDetectorBase(){}; - /** virtual destructor */ - virtual ~slsDetectorBase(){}; + /** virtual destructor */ + virtual ~slsDetectorBase(){}; - string getDetectorDeveloper(){return string("PSI");}; - // protected: + string getDetectorDeveloper(){return string("PSI");}; + // protected: /** - set angular conversion - \param fname file with angular conversion constants ("" disable) - \returns 0 if angular conversion disabled, >0 otherwise + set angular conversion + \param fname file with angular conversion constants ("" disable) + \returns 0 if angular conversion disabled, >0 otherwise */ virtual int setAngularConversionFile(string fname="")=0; /** pure virtual function - returns the angular conversion file + returns the angular conversion file */ virtual string getAngularConversionFile()=0; - /** - set action - \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS} - \param fname for script ("" disable) - \returns 0 if action disabled, >0 otherwise + /** + set action + \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS} + \param fname for script ("" disable) + \returns 0 if action disabled, >0 otherwise */ virtual int setActionScript(int iaction, string fname="")=0; /** - set action - \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS} - \param par for script ("" disable) - \returns 0 if action disabled, >0 otherwise + set action + \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS} + \param par for script ("" disable) + \returns 0 if action disabled, >0 otherwise */ virtual int setActionParameter(int iaction, string par="")=0; /** - returns action script - \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript} - \returns action script + returns action script + \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript} + \returns action script */ virtual string getActionScript(int iaction)=0; /** - returns action parameter - \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript} - \returns action parameter - */ + returns action parameter + \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript} + \returns action parameter + */ virtual string getActionParameter(int iaction)=0; - /** - set scan script - \param index is the scan index (0 or 1) - \param script fname for script ("" disable, "none" disables and overwrites current, "threshold" makes threshold scan, "trimbits" make trimbits scan, "energy" makes energy scan) - \returns 0 if scan disabled, >0 otherwise + /** + set scan script + \param index is the scan index (0 or 1) + \param script fname for script ("" disable, "none" disables and overwrites current, "threshold" makes threshold scan, "trimbits" make trimbits scan, "energy" makes energy scan) + \returns 0 if scan disabled, >0 otherwise */ virtual int setScanScript(int index, string script="")=0; - /** - set scan script parameter - \param index is the scan index (0 or 1) - \param spar parameter to be passed to the scan script with syntax par=spar - \returns 0 if scan disabled, >0 otherwise + /** + set scan script parameter + \param index is the scan index (0 or 1) + \param spar parameter to be passed to the scan script with syntax par=spar + \returns 0 if scan disabled, >0 otherwise */ virtual int setScanParameter(int index, string spar="")=0; /** set scan precision - \param index is the scan index (0 or 1) - \param precision number of decimals to use for the scan variable in the file name - \returns 0 if scan disabled, >0 otherwise */ + \param index is the scan index (0 or 1) + \param precision number of decimals to use for the scan variable in the file name + \returns 0 if scan disabled, >0 otherwise */ virtual int setScanPrecision(int index, int precision=-1)=0; /** - set scan steps (passed to the scan script as var=step) - \param index is the scan index (0 or 1) - \param nvalues is the number of steps - \param values array of steps - \returns 0 if scan disabled, >0 otherwise*/ + set scan steps (passed to the scan script as var=step) + \param index is the scan index (0 or 1) + \param nvalues is the number of steps + \param values array of steps + \returns 0 if scan disabled, >0 otherwise*/ virtual int setScanSteps(int index, int nvalues=-1, double *values=NULL)=0; - /** - get scan script - \param index is the scan index (0 or 1) - \returns "none" if disables, "threshold" threshold scan, "trimbits" trimbits scan, "energy" energy scan or scan script name + /** + get scan script + \param index is the scan index (0 or 1) + \returns "none" if disables, "threshold" threshold scan, "trimbits" trimbits scan, "energy" energy scan or scan script name */ virtual string getScanScript(int index)=0; - /** - get scan script - \param index is the scan index (0 or 1) - \returns scan script parameter + /** + get scan script + \param index is the scan index (0 or 1) + \returns scan script parameter */ virtual string getScanParameter(int index)=0; - /** - get scan precision - \param index is the scan index (0 or 1) - \returns precision i.e. number of decimals to use for the scan variable in the file name + /** + get scan precision + \param index is the scan index (0 or 1) + \returns precision i.e. number of decimals to use for the scan variable in the file name */ virtual int getScanPrecision(int index)=0; - /** - get scan steps - \param index is the scan index (0 or 1) - \param values pointer to array of values (must be allocated in advance) - \returns number of steps + /** + get scan steps + \param index is the scan index (0 or 1) + \param values pointer to array of values (must be allocated in advance) + \returns number of steps */ virtual int getScanSteps(int index, double *values=NULL)=0; @@ -193,64 +193,64 @@ class slsDetectorBase : public virtual slsDetectorDefs { virtual int writeConfigurationFile(string const fname)=0; - /** - Loads dark image or gain image to the detector - \param index can be DARK_IMAGE or GAIN_IMAGE - \param fname file name to load data from - \returns OK or FAIL - */ + /** + Loads dark image or gain image to the detector + \param index can be DARK_IMAGE or GAIN_IMAGE + \param fname file name to load data from + \returns OK or FAIL + */ virtual int loadImageToDetector(imageType index,string const fname)=0; /** - \returns number of positions - */ - virtual int getNumberOfPositions()=0;// {return 0;}; + \returns number of positions + */ + virtual int getNumberOfPositions()=0;// {return 0;}; - /** - \returns action mask - */ - virtual int getActionMask()=0;// {return 0;}; - /** - \param index scan level index - \returns current scan variable - */ - virtual double getCurrentScanVariable(int index)=0;// {return 0;}; + /** + \returns action mask + */ + virtual int getActionMask()=0;// {return 0;}; + /** + \param index scan level index + \returns current scan variable + */ + virtual double getCurrentScanVariable(int index)=0;// {return 0;}; - /** - \returns current position index - */ - virtual int getCurrentPositionIndex()=0;// {return 0;}; + /** + \returns current position index + */ + virtual int getCurrentPositionIndex()=0;// {return 0;}; - /** - \returns total number of channels - */ - virtual int getTotalNumberOfChannels()=0; + /** + \returns total number of channels + */ + virtual int getTotalNumberOfChannels()=0; /** generates file name without extension */ - virtual string createFileName()=0; + virtual string createFileName()=0; - virtual void incrementProgress()=0; - virtual double getCurrentProgress()=0; - virtual void incrementFileIndex()=0; - virtual int setTotalProgress()=0; + virtual void incrementProgress()=0; + virtual double getCurrentProgress()=0; + virtual void incrementFileIndex()=0; + virtual int setTotalProgress()=0; - virtual double* decodeData(int *datain, double *fdata=NULL)=0; + virtual double* decodeData(int *datain, double *fdata=NULL)=0; - virtual string getCurrentFileName()=0; + virtual string getCurrentFileName()=0; - virtual int getFileIndexFromFileName(string fname)=0; + virtual int getFileIndexFromFileName(string fname)=0; - virtual double *convertAngles()=0; + virtual double *convertAngles()=0; /** set rate correction \param t dead time in ns - if 0 disable correction, if >0 set dead time to t, if <0 set deadtime to default dead time for current settings @@ -275,7 +275,7 @@ class slsDetectorBase : public virtual slsDetectorDefs { int setFlatFieldCorrectionFile(string fname=""){return setFlatFieldCorrection(fname);}; - /** + /** set/get dynamic range \param i dynamic range (-1 get) \returns current dynamic range @@ -308,11 +308,11 @@ class slsDetectorBase : public virtual slsDetectorDefs { /** performs a complete acquisition including scansand data processing - moves the detector to next position
- starts and reads the detector
- reads the IC (if required)
- reads the encoder (iof required for angualr conversion)
- processes the data (flat field, rate, angular conversion and merging ::processData()) + moves the detector to next position
+ starts and reads the detector
+ reads the IC (if required)
+ reads the encoder (iof required for angualr conversion)
+ processes the data (flat field, rate, angular conversion and merging ::processData()) \param delflag 0 leaves the data in the final data queue (default is 1) \returns nothing */ @@ -321,74 +321,74 @@ class slsDetectorBase : public virtual slsDetectorDefs { int startMeasurement(){acquire(0); return OK;}; /** - asks and receives a data frame from the detector, writes it to disk and processes the data - \returns pointer to the data or NULL (unused!!!). + asks and receives a data frame from the detector, writes it to disk and processes the data + \returns pointer to the data or NULL (unused!!!). */ virtual int* readFrame()=0; /** - start detector acquisition - \returns OK/FAIL + start detector acquisition + \returns OK/FAIL */ virtual int startAcquisition()=0; /** - stop detector acquisition - \returns OK/FAIL + stop detector acquisition + \returns OK/FAIL */ virtual int stopAcquisition()=0; int stopMeasurement(){return stopAcquisition();}; virtual int getChansPerMod(int imod=0)=0; /** - set/get timer value - \param index timer index - \param t time in ns or number of...(e.g. frames, gates, probes) - \returns timer set value in ns or number of...(e.g. frames, gates, probes) + set/get timer value + \param index timer index + \param t time in ns or number of...(e.g. frames, gates, probes) + \returns timer set value in ns or number of...(e.g. frames, gates, probes) */ virtual int64_t setTimer(timerIndex index, int64_t t=-1)=0; int64_t setExposureTime(int64_t t=-1){return setTimer(ACQUISITION_TIME,t);}; -int64_t setExposurePeriod(int64_t t=-1){return setTimer(FRAME_PERIOD,t);}; -int64_t setDelayAfterTrigger(int64_t t=-1){return setTimer(DELAY_AFTER_TRIGGER,t);}; -int64_t setNumberOfGates(int64_t t=-1){return setTimer(GATES_NUMBER,t);}; -int64_t setNumberOfFrames(int64_t t=-1){return setTimer(FRAME_NUMBER,t);}; -int64_t setNumberOfCycles(int64_t t=-1){return setTimer(CYCLES_NUMBER,t);}; + int64_t setExposurePeriod(int64_t t=-1){return setTimer(FRAME_PERIOD,t);}; + int64_t setDelayAfterTrigger(int64_t t=-1){return setTimer(DELAY_AFTER_TRIGGER,t);}; + int64_t setNumberOfGates(int64_t t=-1){return setTimer(GATES_NUMBER,t);}; + int64_t setNumberOfFrames(int64_t t=-1){return setTimer(FRAME_NUMBER,t);}; + int64_t setNumberOfCycles(int64_t t=-1){return setTimer(CYCLES_NUMBER,t);}; /////////////////////////////////////////////////////////////////////////////////////////// /** - @short get run status - \returns status mask + @short get run status + \returns status mask */ virtual runStatus getRunStatus()=0; int getDetectorStatus() {return (int)getRunStatus();}; /** @short sets the onlineFlag - \param online can be: -1 returns wether the detector is in online (1) or offline (0) state; 0 detector in offline state; 1 detector in online state - \returns 0 (offline) or 1 (online) + \param online can be: -1 returns wether the detector is in online (1) or offline (0) state; 0 detector in offline state; 1 detector in online state + \returns 0 (offline) or 1 (online) */ virtual int setOnline(int const online=-1)=0; /** - @short set detector settings - \param isettings settings index (-1 gets) - \returns current settings + @short set detector settings + \param isettings settings index (-1 gets) + \returns current settings */ virtual detectorSettings setSettings(detectorSettings isettings, int imod=-1)=0; int setSettings(int isettings){return (int)setSettings((detectorSettings)isettings,-1);}; virtual detectorSettings getSettings(int imod=-1)=0; /** - get threshold energy - \param imod module number (-1 all) - \returns current threshold value for imod in ev (-1 failed) + get threshold energy + \param imod module number (-1 all) + \returns current threshold value for imod in ev (-1 failed) */ virtual int getThresholdEnergy(int imod)=0; int getThresholdEnergy(){return getThresholdEnergy(-1);}; /** - set/get the external communication mode + set/get the external communication mode - obsolete \sa setExternalSignalFlags + obsolete \sa setExternalSignalFlags \param pol value to be set \sa externalCommunicationMode \returns current external communication mode */ @@ -417,12 +417,12 @@ int64_t setNumberOfCycles(int64_t t=-1){return setTimer(CYCLES_NUMBER,t);}; int retrieveDetectorSetup(string const fname){return retrieveDetectorSetup(fname,0);}; /** @short - \returns the default output file index + \returns the default output file index */ virtual int getFileIndex()=0; /** - @short sets the default output file index + @short sets the default output file index \param i file index \returns the default output file index */ @@ -431,50 +431,50 @@ int64_t setNumberOfCycles(int64_t t=-1){return setTimer(CYCLES_NUMBER,t);}; //receiver /** - calls setReceiverTCPSocket if online and sets the flag - */ + calls setReceiverTCPSocket if online and sets the flag + */ virtual int setReceiverOnline(int const online=GET_ONLINE_FLAG)=0; /** - Sets up the receiver file name - @param fileName file name - \returns file name - */ + 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 - */ + 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 - */ + 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 - */ + */ virtual int startReceiver()=0; /** Stops the listening mode of receiver \returns OK or FAIL - */ + */ virtual int stopReceiver()=0; /** gets the status of the listening mode of receiver \returns status - */ + */ virtual runStatus getReceiverStatus()=0; /** gets the number of frames caught by receiver \returns number of frames caught by receiver - */ + */ virtual int getFramesCaughtByReciver()=0; /** Locks/Unlocks the connection to the receiver @@ -496,7 +496,7 @@ int64_t setNumberOfCycles(int64_t t=-1){return setTimer(CYCLES_NUMBER,t);}; case GOTTHARD: return string("Gotthard"); \ case AGIPD: return string("Agipd"); \ default: return string("Unknown"); \ - }}; + }}; /** returns detector type index from detector type string \param type can be MYTHEN, PILATUS, EIGER, GOTTHARD, AGIPD, GENERIC @@ -573,23 +573,23 @@ int64_t setNumberOfCycles(int64_t t=-1){return setTimer(CYCLES_NUMBER,t);}; */ static externalSignalFlag externalSignalType(string sval){\ - if (sval=="off") return SIGNAL_OFF;\ - if (sval=="gate_in_active_high") return GATE_IN_ACTIVE_HIGH; \ - if (sval=="gate_in_active_low") return GATE_IN_ACTIVE_LOW;\ - if (sval=="trigger_in_rising_edge") return TRIGGER_IN_RISING_EDGE;\ - if (sval=="trigger_in_falling_edge") return TRIGGER_IN_FALLING_EDGE;\ - if (sval=="ro_trigger_in_rising_edge") return RO_TRIGGER_IN_RISING_EDGE;\ - if (sval=="ro_trigger_in_falling_edge") return RO_TRIGGER_IN_FALLING_EDGE;\ - if (sval=="gate_out_active_high") return GATE_OUT_ACTIVE_HIGH;\ - if (sval=="gate_out_active_low") return GATE_OUT_ACTIVE_LOW;\ - if (sval=="trigger_out_rising_edge") return TRIGGER_OUT_RISING_EDGE;\ - if (sval=="trigger_out_falling_edge") return TRIGGER_OUT_FALLING_EDGE;\ - if (sval=="ro_trigger_out_rising_edge") return RO_TRIGGER_OUT_RISING_EDGE;\ - if (sval=="ro_trigger_out_falling_edge") return RO_TRIGGER_OUT_FALLING_EDGE;\ - if (sval=="sync") return MASTER_SLAVE_SYNCHRONIZATION;\ - if (sval=="gnd") return OUTPUT_LOW;\ - if (sval=="vcc") return OUTPUT_HIGH;\ - return GET_EXTERNAL_SIGNAL_FLAG ;}; + if (sval=="off") return SIGNAL_OFF;\ + if (sval=="gate_in_active_high") return GATE_IN_ACTIVE_HIGH; \ + if (sval=="gate_in_active_low") return GATE_IN_ACTIVE_LOW;\ + if (sval=="trigger_in_rising_edge") return TRIGGER_IN_RISING_EDGE;\ + if (sval=="trigger_in_falling_edge") return TRIGGER_IN_FALLING_EDGE;\ + if (sval=="ro_trigger_in_rising_edge") return RO_TRIGGER_IN_RISING_EDGE;\ + if (sval=="ro_trigger_in_falling_edge") return RO_TRIGGER_IN_FALLING_EDGE;\ + if (sval=="gate_out_active_high") return GATE_OUT_ACTIVE_HIGH;\ + if (sval=="gate_out_active_low") return GATE_OUT_ACTIVE_LOW;\ + if (sval=="trigger_out_rising_edge") return TRIGGER_OUT_RISING_EDGE;\ + if (sval=="trigger_out_falling_edge") return TRIGGER_OUT_FALLING_EDGE;\ + if (sval=="ro_trigger_out_rising_edge") return RO_TRIGGER_OUT_RISING_EDGE;\ + if (sval=="ro_trigger_out_falling_edge") return RO_TRIGGER_OUT_FALLING_EDGE;\ + if (sval=="sync") return MASTER_SLAVE_SYNCHRONIZATION;\ + if (sval=="gnd") return OUTPUT_LOW;\ + if (sval=="vcc") return OUTPUT_HIGH;\ + return GET_EXTERNAL_SIGNAL_FLAG ;}; /** returns detector settings string from index \param s can be STANDARD, FAST, HIGHGAIN, DYNAMICGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN, GET_SETTINGS @@ -651,14 +651,14 @@ int64_t setNumberOfCycles(int64_t t=-1){return setTimer(CYCLES_NUMBER,t);}; */ static externalCommunicationMode externalCommunicationType(string sval){\ - if (sval=="auto") return AUTO_TIMING;\ - if (sval=="trigger") return TRIGGER_EXPOSURE; \ - if (sval=="trigger_frame") return TRIGGER_FRAME; \ - if (sval=="ro_trigger") return TRIGGER_READOUT;\ - if (sval=="gating") return GATE_FIX_NUMBER;\ - if (sval=="triggered_gating") return GATE_WITH_START_TRIGGER;\ - if (sval=="trigger_window") return TRIGGER_WINDOW; \ - return GET_EXTERNAL_COMMUNICATION_MODE; \ + if (sval=="auto") return AUTO_TIMING;\ + if (sval=="trigger") return TRIGGER_EXPOSURE; \ + if (sval=="trigger_frame") return TRIGGER_FRAME; \ + if (sval=="ro_trigger") return TRIGGER_READOUT;\ + if (sval=="gating") return GATE_FIX_NUMBER;\ + if (sval=="triggered_gating") return GATE_WITH_START_TRIGGER;\ + if (sval=="trigger_window") return TRIGGER_WINDOW; \ + return GET_EXTERNAL_COMMUNICATION_MODE; \ }; /** returns string from run status index diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index 1ab4a5731..058a37405 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -598,9 +598,9 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimeLeft; i++; -// descrToFuncMap[i].m_pFuncName="progress"; -// descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimer; -// i++; + // descrToFuncMap[i].m_pFuncName="progress"; + // descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimer; + // i++; descrToFuncMap[i].m_pFuncName="now"; // descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimeLeft; @@ -675,9 +675,9 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { numberOfCommands=i; -// #ifdef VERBOSE -// cout << "Number of commands is " << numberOfCommands << endl; -// #endif + // #ifdef VERBOSE + // cout << "Number of commands is " << numberOfCommands << endl; + // #endif } @@ -706,12 +706,12 @@ string slsDetectorCommand::executeLine(int narg, char *args[], int action) { /* otherwise one could try if truncated key is unique */ - // size_t p=(descrToFuncMap[i].m_pFuncName).find(); - // if (p==0) { + // size_t p=(descrToFuncMap[i].m_pFuncName).find(); + // if (p==0) { - if(key==descrToFuncMap[i].m_pFuncName){ + if(key==descrToFuncMap[i].m_pFuncName){ #ifdef VERBOSE - std::cout<setOnline(ONLINE_FLAG); + + //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(); + usleep(2000000); + if(myDet->getReceiverStatus()!=RUNNING) + return string("could not start receiver"); + } + } + + myDet->acquire(); return string(""); @@ -822,7 +841,7 @@ string slsDetectorCommand::helpData(int narg, char *args[], int action){ if (action==PUT_ACTION) return string(""); else - return string("data \t gets all data from the detector (if any) processes them and writes them to file according to the preferences already setup\n"); + return string("data \t gets all data from the detector (if any) processes them and writes them to file according to the preferences already setup\n"); } @@ -832,19 +851,19 @@ string slsDetectorCommand::cmdFrame(int narg, char *args[], int action) { #ifdef VERBOSE cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n"); #endif - if (action==PUT_ACTION) { - return string("cannot set"); - } else if (action==HELP_ACTION) { - return helpFrame(narg,args,HELP_ACTION); - } else { - b=myDet->setThreadedProcessing(-1); - myDet->setThreadedProcessing(0); - myDet->setOnline(ONLINE_FLAG); - myDet->readFrame(); - myDet->processData(1); - myDet->setThreadedProcessing(b); - return string("ok"); - } + if (action==PUT_ACTION) { + return string("cannot set"); + } else if (action==HELP_ACTION) { + return helpFrame(narg,args,HELP_ACTION); + } else { + b=myDet->setThreadedProcessing(-1); + myDet->setThreadedProcessing(0); + myDet->setOnline(ONLINE_FLAG); + myDet->readFrame(); + myDet->processData(1); + myDet->setThreadedProcessing(b); + return string("ok"); + } } @@ -864,8 +883,24 @@ string slsDetectorCommand::cmdStatus(int narg, char *args[], int action) { myDet->setOnline(ONLINE_FLAG); if (action==PUT_ACTION) { //myDet->setThreadedProcessing(0); - if (string(args[1])=="start") + if (string(args[1])=="start"){ + //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(); + usleep(2000000); + if(myDet->getReceiverStatus()!=RUNNING) + return string("could not start receiver"); + } + } myDet->startAcquisition(); + } else if (string(args[1])=="stop") myDet->stopAcquisition(); else @@ -891,17 +926,17 @@ string slsDetectorCommand::helpStatus(int narg, char *args[], int action) { } - string slsDetectorCommand::cmdFree(int narg, char *args[], int action) { +string slsDetectorCommand::cmdFree(int narg, char *args[], int action) { #ifdef VERBOSE - cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n"); + cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n"); #endif if (action==HELP_ACTION) { return helpFree(narg,args,HELP_ACTION); } myDet->freeSharedMemory(); return("freed"); - } +} string slsDetectorCommand::helpFree(int narg, char *args[], int action) { @@ -1317,34 +1352,34 @@ string slsDetectorCommand::helpTrimEn(int narg, char *args[], int action) { string slsDetectorCommand::cmdOutDir(int narg, char *args[], int action){ - bool receiver = false; + bool receiver = false; - if (action==HELP_ACTION) { - return helpOutDir(narg, args, action); - } + if (action==HELP_ACTION) { + return helpOutDir(narg, args, action); + } - if(myDet->setReceiverOnline()==ONLINE_FLAG) - if(myDet->setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) - receiver = true; + if(myDet->setReceiverOnline()==ONLINE_FLAG) + if(myDet->setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) + receiver = true; - if (action==PUT_ACTION) { - if(receiver){ - if(myDet->setReceiverFileDir(string(args[1]))==string(args[1])) - myDet->setFilePath(string(args[1])); - }else{ - //check if the outdir really exists in localhost - struct stat st; - if(stat(args[1],&st)) - return string("path does not exist"); - else - myDet->setFilePath(string(args[1])); - } - } + if (action==PUT_ACTION) { + if(receiver){ + if(myDet->setReceiverFileDir(string(args[1]))==string(args[1])) + myDet->setFilePath(string(args[1])); + }else{ + //check if the outdir really exists in localhost + struct stat st; + if(stat(args[1],&st)) + return string("path does not exist"); + else + myDet->setFilePath(string(args[1])); + } + } - if(receiver) - return myDet->setReceiverFileDir(); - else - return string(myDet->getFilePath()); + if(receiver) + return myDet->setReceiverFileDir(); + else + return string(myDet->getFilePath()); } @@ -1362,28 +1397,28 @@ string slsDetectorCommand::helpOutDir(int narg, char *args[], int action){ string slsDetectorCommand::cmdFileName(int narg, char *args[], int action){ - bool receiver = false; + bool receiver = false; - if (action==HELP_ACTION) { - return helpFileName(narg, args, action); - } + if (action==HELP_ACTION) { + return helpFileName(narg, args, action); + } - if(myDet->setReceiverOnline()==ONLINE_FLAG) - if(myDet->setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) - receiver = true; + if(myDet->setReceiverOnline()==ONLINE_FLAG) + if(myDet->setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) + receiver = true; - if (action==PUT_ACTION) { - if(receiver){ - if(myDet->setReceiverFileName(string(args[1]))==string(args[1])) - myDet->setFileName(string(args[1])); - }else - myDet->setFileName(string(args[1])); - } + if (action==PUT_ACTION) { + if(receiver){ + if(myDet->setReceiverFileName(string(args[1]))==string(args[1])) + myDet->setFileName(string(args[1])); + }else + myDet->setFileName(string(args[1])); + } - if(receiver) - return myDet->setReceiverFileName(); - else - return string(myDet->getFileName()); + if(receiver) + return myDet->setReceiverFileName(); + else + return string(myDet->getFileName()); } @@ -1431,37 +1466,37 @@ string slsDetectorCommand::helpEnablefwrite(int narg, char *args[], int action){ } string slsDetectorCommand::cmdFileIndex(int narg, char *args[], int action){ - bool receiver = false; - int i; - char ans[100]; + bool receiver = false; + int i; + char ans[100]; - if (action==HELP_ACTION) { - return helpFileName(narg, args, action); - } + if (action==HELP_ACTION) { + return helpFileName(narg, args, action); + } - if(myDet->setReceiverOnline()==ONLINE_FLAG) - if(myDet->setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) - receiver = true; + if(myDet->setReceiverOnline()==ONLINE_FLAG) + if(myDet->setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) + receiver = true; - if (action==PUT_ACTION) { - if (sscanf(args[1],"%d",&i)){ - if(receiver){ - if(myDet->setReceiverFileIndex(i)==i) - myDet->setFileIndex(i); - }else - myDet->setFileIndex(i); - } - } + if (action==PUT_ACTION) { + if (sscanf(args[1],"%d",&i)){ + if(receiver){ + if(myDet->setReceiverFileIndex(i)==i) + myDet->setFileIndex(i); + }else + myDet->setFileIndex(i); + } + } - if(receiver){ - //int ret=myDet->setReceiverFileIndex(); - //myDet->setFileIndex(ret); - sprintf(ans,"%d", myDet->setReceiverFileIndex()); - } - else - sprintf(ans,"%d", myDet->getFileIndex()); + if(receiver){ + //int ret=myDet->setReceiverFileIndex(); + //myDet->setFileIndex(ret); + sprintf(ans,"%d", myDet->setReceiverFileIndex()); + } + else + sprintf(ans,"%d", myDet->getFileIndex()); - return string(ans); + return string(ans); } @@ -1537,14 +1572,14 @@ string slsDetectorCommand::helpFlatField(int narg, char *args[], int action){ if (action==GET_ACTION || action==HELP_ACTION) { os << string("flatfield [fn]\t gets the flat field file name. the coorection values and errors can be dumped to fn if specified. \n"); } if (action==PUT_ACTION || action==HELP_ACTION) - os << string("flatfield s \t sets the flat field file name\n"); + os << string("flatfield s \t sets the flat field file name\n"); } if (t!=2) { if (action==GET_ACTION || action==HELP_ACTION) os << string("ffdir \t gets the path for the flat field files \n"); if (action==PUT_ACTION || action==HELP_ACTION) - os << string("ffdir s \t sets the path for flat field files\n"); + os << string("ffdir s \t sets the path for flat field files\n"); } return os.str(); @@ -1597,41 +1632,41 @@ string slsDetectorCommand::cmdBadChannels(int narg, char *args[], int action){ return helpBadChannels(narg, args, action); } if (action==PUT_ACTION) { + sval=string(args[1]); + if (sval=="none") + sval=""; + myDet->setBadChannelCorrection(sval); + } else if (action==GET_ACTION) { + if (narg>1) sval=string(args[1]); - if (sval=="none") - sval=""; - myDet->setBadChannelCorrection(sval); - } else if (action==GET_ACTION) { - if (narg>1) - sval=string(args[1]); - else - sval="none"; - int bch[24*1280], nbch; - if ((nbch=myDet->getBadChannelCorrection(bch))) { - if (sval!="none") { - ofstream outfile; - outfile.open (sval.c_str(),ios_base::out); - if (outfile.is_open()) { - for (int ich=0; ichgetBadChannelCorrectionFile()); + else + sval="none"; + int bch[24*1280], nbch; + if ((nbch=myDet->getBadChannelCorrection(bch))) { + if (sval!="none") { + ofstream outfile; + outfile.open (sval.c_str(),ios_base::out); + if (outfile.is_open()) { + for (int ich=0; ichgetBadChannelCorrectionFile()); } string slsDetectorCommand::helpBadChannels(int narg, char *args[], int action){ - ostringstream os; - if (action==GET_ACTION || action==HELP_ACTION) - os << string("badchannels [fn]\t returns the badchannels file. Prints the list of bad channels in fn, if specified. \n"); - if (action==PUT_ACTION || action==HELP_ACTION) + ostringstream os; + if (action==GET_ACTION || action==HELP_ACTION) + os << string("badchannels [fn]\t returns the badchannels file. Prints the list of bad channels in fn, if specified. \n"); + if (action==PUT_ACTION || action==HELP_ACTION) os << string("badchannels \t sets the bad channels list\n"); return os.str(); @@ -1703,12 +1738,12 @@ string slsDetectorCommand::cmdAngConv(int narg, char *args[], int action){ - if (action==PUT_ACTION) { - if (sscanf(args[1],"%lf",&fval)) - myDet->setAngularConversionParameter(c,fval); - } - sprintf(answer,"%f",myDet->getAngularConversionParameter(c)); - return string(answer); + if (action==PUT_ACTION) { + if (sscanf(args[1],"%lf",&fval)) + myDet->setAngularConversionParameter(c,fval); + } + sprintf(answer,"%f",myDet->getAngularConversionParameter(c)); + return string(answer); } @@ -1766,7 +1801,7 @@ string slsDetectorCommand::helpAngConv(int narg, char *args[], int action){ if (action==PUT_ACTION || action==HELP_ACTION) os << string("samplex f\t sets the sample displacement in th direction parallel to the beam \n"); } - if (t&32) { + if (t&32) { if (action==GET_ACTION || action==HELP_ACTION) os << string("sampley \t gets the sample displacement in the direction orthogonal to the beam \n"); if (action==PUT_ACTION || action==HELP_ACTION) @@ -1795,10 +1830,10 @@ string slsDetectorCommand::cmdThreaded(int narg, char *args[], int action){ string slsDetectorCommand::helpThreaded(int narg, char *args[], int action){ - ostringstream os; - if (action==GET_ACTION || action==HELP_ACTION) - os << string("threaded \t returns wether the data processing is threaded. \n"); - if (action==PUT_ACTION || action==HELP_ACTION) + ostringstream os; + if (action==GET_ACTION || action==HELP_ACTION) + os << string("threaded \t returns wether the data processing is threaded. \n"); + if (action==PUT_ACTION || action==HELP_ACTION) os << string("threaded t \t sets the threading flag ( 1sets, 0 unsets).\n"); return os.str(); @@ -1812,16 +1847,16 @@ string slsDetectorCommand::cmdImage(int narg, char *args[], int action){ if (action==HELP_ACTION) return helpImage(narg,args,HELP_ACTION); else if (action==GET_ACTION) - return string("Cannot get"); + return string("Cannot get"); sval=string(args[1]); myDet->setOnline(ONLINE_FLAG); if (string(args[0])==string("darkimage")) - retval=myDet->loadImageToDetector(DARK_IMAGE,sval); + retval=myDet->loadImageToDetector(DARK_IMAGE,sval); else if (string(args[0])==string("gainimage")) - retval=myDet->loadImageToDetector(GAIN_IMAGE,sval); + retval=myDet->loadImageToDetector(GAIN_IMAGE,sval); if(retval==OK) @@ -1832,16 +1867,16 @@ string slsDetectorCommand::cmdImage(int narg, char *args[], int action){ string slsDetectorCommand::helpImage(int narg, char *args[], int action){ - ostringstream os; - if (action==PUT_ACTION || action==HELP_ACTION){ - os << "darkimage f \t loads the image to detector from file f"<< std::endl; - os << "gainimage f \t loads the image to detector from file f"<< std::endl; - } - if (action==GET_ACTION || action==HELP_ACTION){ - os << "darkimage \t Cannot get"<< std::endl; - os << "gainimage \t Cannot get"<< std::endl; - } - return os.str(); + ostringstream os; + if (action==PUT_ACTION || action==HELP_ACTION){ + os << "darkimage f \t loads the image to detector from file f"<< std::endl; + os << "gainimage f \t loads the image to detector from file f"<< std::endl; + } + if (action==GET_ACTION || action==HELP_ACTION){ + os << "darkimage \t Cannot get"<< std::endl; + os << "gainimage \t Cannot get"<< std::endl; + } + return os.str(); } @@ -1852,25 +1887,25 @@ string slsDetectorCommand::cmdCounter(int narg, char *args[], int action){ if (action==HELP_ACTION) return helpCounter(narg,args,HELP_ACTION); else if (action==PUT_ACTION) - ival=atoi(args[1]); + ival=atoi(args[1]); myDet->setOnline(ONLINE_FLAG); - if (string(args[0])==string("readctr")){ - if (action==PUT_ACTION) - return string("Cannot put"); - else{ - if (narg<3) - return string("should specify I/O file"); - sval=string(args[2]); - retval=myDet->writeCounterBlockFile(sval,ival); - } + if (string(args[0])==string("readctr")){ + if (action==PUT_ACTION) + return string("Cannot put"); + else{ + if (narg<3) + return string("should specify I/O file"); + sval=string(args[2]); + retval=myDet->writeCounterBlockFile(sval,ival); + } } else if (string(args[0])==string("resetctr")){ - if (action==GET_ACTION) - return string("Cannot get"); - else - retval=myDet->resetCounterBlock(ival); + if (action==GET_ACTION) + return string("Cannot get"); + else + retval=myDet->resetCounterBlock(ival); } @@ -1882,16 +1917,16 @@ string slsDetectorCommand::cmdCounter(int narg, char *args[], int action){ string slsDetectorCommand::helpCounter(int narg, char *args[], int action){ - ostringstream os; - os << std::endl; - if (action==PUT_ACTION || action==HELP_ACTION){ - os << "readctr \t Cannot put"<< std::endl; - os << "resetctr i \t resets counter in detector, restarts acquisition if i=1"<< std::endl; - } - if (action==GET_ACTION || action==HELP_ACTION) - os << "readctr i fname\t reads counter in detector to file fname, restarts acquisition if i=1"<< std::endl; - os << "resetctr \t Cannot get"<< std::endl; - return os.str(); + ostringstream os; + os << std::endl; + if (action==PUT_ACTION || action==HELP_ACTION){ + os << "readctr \t Cannot put"<< std::endl; + os << "resetctr i \t resets counter in detector, restarts acquisition if i=1"<< std::endl; + } + if (action==GET_ACTION || action==HELP_ACTION) + os << "readctr i fname\t reads counter in detector to file fname, restarts acquisition if i=1"<< std::endl; + os << "resetctr \t Cannot get"<< std::endl; + return os.str(); } @@ -2198,7 +2233,7 @@ string slsDetectorCommand::cmdNetworkParameter(int narg, char *args[], int actio if(!strcmp(myDet->setNetworkParameter(t, args[1]),args[1])){ if(t==RECEIVER_IP){ if(myDet->setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG) - return string("receiver not online"); + return string("receiver not online"); //outdir if(myDet->setReceiverFileDir(myDet->getFilePath()).compare(myDet->getFilePath())) return string("could not set up receiver file outdir"); @@ -2301,35 +2336,35 @@ string slsDetectorCommand::cmdLock(int narg, char *args[], int action) { char ans[1000]; if(cmd=="lock"){ - myDet->setOnline(ONLINE_FLAG); - if (action==PUT_ACTION) { - if (sscanf(args[1],"%d",&val)) - myDet->lockServer(val); - else - return string("could not lock status")+string(args[1]); - } + myDet->setOnline(ONLINE_FLAG); + if (action==PUT_ACTION) { + if (sscanf(args[1],"%d",&val)) + myDet->lockServer(val); + else + return string("could not lock status")+string(args[1]); + } - sprintf(ans,"%d",myDet->lockServer()); + sprintf(ans,"%d",myDet->lockServer()); } else if(cmd=="r_lock"){ - if(myDet->setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG) - return string("could not connect to receiver"); + if(myDet->setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG) + return string("could not connect to receiver"); - if (action==PUT_ACTION) { - if (!sscanf(args[1],"%d",&val)) - return string("could not decode lock status")+string(args[1]); + if (action==PUT_ACTION) { + if (!sscanf(args[1],"%d",&val)) + 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()); + if(myDet->lockReceiver(val)!=val) + return string("could not lock/unlock receiver"); + } + sprintf(ans,"%d",myDet->lockReceiver()); } else - return string("could not decode command"); + return string("could not decode command"); return string(ans); } @@ -2360,19 +2395,19 @@ string slsDetectorCommand::cmdLastClient(int narg, char *args[], int action) { return helpLastClient(narg,args,action); if (action==PUT_ACTION) - return string("cannot set"); + return string("cannot set"); if(cmd=="lastclient"){ - myDet->setOnline(ONLINE_FLAG); + myDet->setOnline(ONLINE_FLAG); - return myDet->getLastClientIP(); + return myDet->getLastClientIP(); } else if(cmd=="r_lastclient"){ - if(myDet->setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG) - return string("could not connect to receiver"); + if(myDet->setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG) + return string("could not connect to receiver"); - return myDet->getReceiverLastClientIP(); + return myDet->getReceiverLastClientIP(); } } @@ -2391,50 +2426,50 @@ string slsDetectorCommand::helpLastClient(int narg, char *args[], int action) { string slsDetectorCommand::cmdOnline(int narg, char *args[], int action) { - if (action==HELP_ACTION) { - return helpOnline(narg,args,action); - } - int ival; - char ans[1000]; + if (action==HELP_ACTION) { + return helpOnline(narg,args,action); + } + int ival; + char ans[1000]; - if(cmd=="online"){ - if (action==PUT_ACTION) { - if (sscanf(args[1],"%d",&ival)) - myDet->setOnline(ival); - else - return string("Could not scan online mode ")+string(args[1]); - } - sprintf(ans,"%d",myDet->setOnline()); - } - else if(cmd=="checkonline"){ - if (action==PUT_ACTION) - return string("cannot set"); - strcpy(ans,myDet->checkOnline().c_str()); - if(!strlen(ans)) - strcpy(ans,"All online"); - else - strcat(ans," :Not online"); - } - else if(cmd=="r_online"){ - if (action==PUT_ACTION) { - if (sscanf(args[1],"%d",&ival)) - myDet->setReceiverOnline(ival); - else - return string("Could not scan online mode ")+string(args[1]); - } - sprintf(ans,"%d",myDet->setReceiverOnline()); - } - else{ - if (action==PUT_ACTION) - return string("cannot set"); - strcpy(ans,myDet->checkReceiverOnline().c_str()); - if(!strlen(ans)) - strcpy(ans,"All receiver online"); - else - strcat(ans," :Not receiver online"); - } + if(cmd=="online"){ + if (action==PUT_ACTION) { + if (sscanf(args[1],"%d",&ival)) + myDet->setOnline(ival); + else + return string("Could not scan online mode ")+string(args[1]); + } + sprintf(ans,"%d",myDet->setOnline()); + } + else if(cmd=="checkonline"){ + if (action==PUT_ACTION) + return string("cannot set"); + strcpy(ans,myDet->checkOnline().c_str()); + if(!strlen(ans)) + strcpy(ans,"All online"); + else + strcat(ans," :Not online"); + } + else if(cmd=="r_online"){ + if (action==PUT_ACTION) { + if (sscanf(args[1],"%d",&ival)) + myDet->setReceiverOnline(ival); + else + return string("Could not scan online mode ")+string(args[1]); + } + sprintf(ans,"%d",myDet->setReceiverOnline()); + } + else{ + if (action==PUT_ACTION) + return string("cannot set"); + strcpy(ans,myDet->checkReceiverOnline().c_str()); + if(!strlen(ans)) + strcpy(ans,"All receiver online"); + else + strcat(ans," :Not receiver online"); + } - return ans; + return ans; } string slsDetectorCommand::helpOnline(int narg, char *args[], int action) { @@ -2562,11 +2597,11 @@ string slsDetectorCommand::cmdSettings(int narg, char *args[], int action) { -// if (sscanf(args[1],"%d",&val)) -// ; -// else -// return string("could not scan port number")+string(args[1]); -// } + // if (sscanf(args[1],"%d",&val)) + // ; + // else + // return string("could not scan port number")+string(args[1]); + // } myDet->setOnline(ONLINE_FLAG); @@ -2601,39 +2636,39 @@ string slsDetectorCommand::cmdSettings(int narg, char *args[], int action) { if (action==GET_ACTION) return string("cannot get!"); - trimMode mode=NOISE_TRIMMING; - int par1=0, par2=0; - if (string(args[0]).find("trim:")==string::npos) - return helpSettings(narg,args,action); - else if (string(args[0]).find("noise")!=string::npos) { - // par1 is countlim; par2 is nsigma - mode=NOISE_TRIMMING; - par1=500; - par2=4; - } else if (string(args[0]).find("beam")!=string::npos){ - // par1 is countlim; par2 is nsigma - mode=BEAM_TRIMMING; - par1=1000; - par2=4; - } else if (string(args[0]).find("improve")!=string::npos) { - // par1 is maxit; if par2!=0 vthresh will be optimized - mode=IMPROVE_TRIMMING; - par1=5; - par2=0; - } else if (string(args[0]).find("fix")!=string::npos) { - // par1 is countlim; if par2<0 then trimwithlevel else trim with median - mode=FIXEDSETTINGS_TRIMMING; - par1=1000; - par2=1; - // }else if (string(args[0]).find("fix")!=string::npos) { - //mode=OFFLINE_TRIMMING; - } else { - return string("Unknown trim mode ")+cmd; - } - myDet->executeTrimming(mode, par1, par2); - string sval=string(args[1]); - myDet->saveSettingsFile(sval, -1); - return string("done"); + trimMode mode=NOISE_TRIMMING; + int par1=0, par2=0; + if (string(args[0]).find("trim:")==string::npos) + return helpSettings(narg,args,action); + else if (string(args[0]).find("noise")!=string::npos) { + // par1 is countlim; par2 is nsigma + mode=NOISE_TRIMMING; + par1=500; + par2=4; + } else if (string(args[0]).find("beam")!=string::npos){ + // par1 is countlim; par2 is nsigma + mode=BEAM_TRIMMING; + par1=1000; + par2=4; + } else if (string(args[0]).find("improve")!=string::npos) { + // par1 is maxit; if par2!=0 vthresh will be optimized + mode=IMPROVE_TRIMMING; + par1=5; + par2=0; + } else if (string(args[0]).find("fix")!=string::npos) { + // par1 is countlim; if par2<0 then trimwithlevel else trim with median + mode=FIXEDSETTINGS_TRIMMING; + par1=1000; + par2=1; + // }else if (string(args[0]).find("fix")!=string::npos) { + //mode=OFFLINE_TRIMMING; + } else { + return string("Unknown trim mode ")+cmd; + } + myDet->executeTrimming(mode, par1, par2); + string sval=string(args[1]); + myDet->saveSettingsFile(sval, -1); + return string("done"); } return string("unknown settings command ")+cmd; @@ -2752,7 +2787,7 @@ string slsDetectorCommand::cmdDigiTest(int narg, char *args[], int action) { char answer[1000]; if (action==HELP_ACTION) - return helpSN(narg, args, action); + return helpSN(narg, args, action); myDet->setOnline(ONLINE_FLAG); @@ -2852,15 +2887,15 @@ string slsDetectorCommand::cmdRegister(int narg, char *args[], int action) { sprintf(answer,"%x",myDet->writeRegister(addr,val)); } else { - if (narg<2) - return string("wrong usage: should specify address (hexadecimal fomat) "); - if (sscanf(args[1],"%x",&addr)) - ; - else - return string("Could not scan address (hexadecimal fomat) ")+string(args[1]); + if (narg<2) + return string("wrong usage: should specify address (hexadecimal fomat) "); + if (sscanf(args[1],"%x",&addr)) + ; + else + return string("Could not scan address (hexadecimal fomat) ")+string(args[1]); - sprintf(answer,"%x",myDet->readRegister(addr)); + sprintf(answer,"%x",myDet->readRegister(addr)); } @@ -2947,11 +2982,11 @@ string slsDetectorCommand::cmdDAC(int narg, char *args[], int action) { #ifdef DACS_INT if (sscanf(args[1],"%d", &val)) #else - if (sscanf(args[1],"%f", &val)) + if (sscanf(args[1],"%f", &val)) #endif - ; - else - return string("cannot scan DAC value ")+string(args[1]); + ; + else + return string("cannot scan DAC value ")+string(args[1]); } myDet->setOnline(ONLINE_FLAG); @@ -2967,80 +3002,80 @@ string slsDetectorCommand::cmdDAC(int narg, char *args[], int action) { string slsDetectorCommand::helpDAC(int narg, char *args[], int action) { - ostringstream os; - if (action==PUT_ACTION || action==HELP_ACTION) { - os << "vthreshold dacu\t sets the detector threshold in dac units (0-1024). The energy is approx 800-15*keV" << std::endl; - os << std::endl; + ostringstream os; + if (action==PUT_ACTION || action==HELP_ACTION) { + os << "vthreshold dacu\t sets the detector threshold in dac units (0-1024). The energy is approx 800-15*keV" << std::endl; + os << std::endl; - os << "vcalibration " << "dacu\t sets the calibration pulse amplitude in dac units (0-1024)." << std::endl; - os << std::endl; - os << "vtrimbit " << "dacu\t sets the trimbit amplitude in dac units (0-1024)." << std::endl; - os << std::endl; - os << "vpreamp " << "dacu\t sets the preamp feedback voltage in dac units (0-1024)." << std::endl; - os << std::endl; - os << "vshaper1 " << "dacu\t sets the shaper1 feedback voltage in dac units (0-1024)." << std::endl; - os << std::endl; - os << "vshaper2 " << "dacu\t sets the shaper2 feedback voltage in dac units (0-1024)." << std::endl; - os << std::endl; - os << "vhighvoltage " << "dacu\t CHIPTEST BOARD ONLY - sets the detector HV in dac units (0-1024)." << std::endl; - os << std::endl; - os << "vapower " << "dacu\t CHIPTEST BOARD ONLY - sets the analog power supply in dac units (0-1024)." << std::endl; - os << std::endl; - os << "vddpower " << "dacu\t CHIPTEST BOARD ONLY - sets the digital power supply in dac units (0-1024)." << std::endl; - os << std::endl; - os << "vshpower " << "dacu\t CHIPTEST BOARD ONLY - sets the comparator power supply in dac units (0-1024)." << std::endl; - os << std::endl; - os << "viopower " << "dacu\t CHIPTEST BOARD ONLY - sets the FPGA I/O power supply in dac units (0-1024)." << std::endl; + os << "vcalibration " << "dacu\t sets the calibration pulse amplitude in dac units (0-1024)." << std::endl; + os << std::endl; + os << "vtrimbit " << "dacu\t sets the trimbit amplitude in dac units (0-1024)." << std::endl; + os << std::endl; + os << "vpreamp " << "dacu\t sets the preamp feedback voltage in dac units (0-1024)." << std::endl; + os << std::endl; + os << "vshaper1 " << "dacu\t sets the shaper1 feedback voltage in dac units (0-1024)." << std::endl; + os << std::endl; + os << "vshaper2 " << "dacu\t sets the shaper2 feedback voltage in dac units (0-1024)." << std::endl; + os << std::endl; + os << "vhighvoltage " << "dacu\t CHIPTEST BOARD ONLY - sets the detector HV in dac units (0-1024)." << std::endl; + os << std::endl; + os << "vapower " << "dacu\t CHIPTEST BOARD ONLY - sets the analog power supply in dac units (0-1024)." << std::endl; + os << std::endl; + os << "vddpower " << "dacu\t CHIPTEST BOARD ONLY - sets the digital power supply in dac units (0-1024)." << std::endl; + os << std::endl; + os << "vshpower " << "dacu\t CHIPTEST BOARD ONLY - sets the comparator power supply in dac units (0-1024)." << std::endl; + os << std::endl; + os << "viopower " << "dacu\t CHIPTEST BOARD ONLY - sets the FPGA I/O power supply in dac units (0-1024)." << std::endl; - os << "vrefds " << "dacu\t sets vrefds" << std::endl; - os << "vcascn_pb " << "dacu\t sets vcascn_pb" << std::endl; - os << "vcascp_pb " << "dacu\t sets vcascp_pb" << std::endl; - os << "vout_cm " << "dacu\t sets vout_cm" << std::endl; - os << "vin_cm " << "dacu\t sets vin_cm" << std::endl; - os << "vcasc_out " << "dacu\t sets vcasc_out" << std::endl; - os << "vref_comp " << "dacu\t sets vref_comp" << std::endl; - os << "ib_test_c " << "dacu\t sets ib_test_c" << std::endl; + os << "vrefds " << "dacu\t sets vrefds" << std::endl; + os << "vcascn_pb " << "dacu\t sets vcascn_pb" << std::endl; + os << "vcascp_pb " << "dacu\t sets vcascp_pb" << std::endl; + os << "vout_cm " << "dacu\t sets vout_cm" << std::endl; + os << "vin_cm " << "dacu\t sets vin_cm" << std::endl; + os << "vcasc_out " << "dacu\t sets vcasc_out" << std::endl; + os << "vref_comp " << "dacu\t sets vref_comp" << std::endl; + os << "ib_test_c " << "dacu\t sets ib_test_c" << std::endl; - } - if (action==GET_ACTION || action==HELP_ACTION) { + } + if (action==GET_ACTION || action==HELP_ACTION) { - os << "vthreshold \t Gets the detector threshold in dac units (0-1024). The energy is approx 800-15*keV" << std::endl; - os << std::endl; + os << "vthreshold \t Gets the detector threshold in dac units (0-1024). The energy is approx 800-15*keV" << std::endl; + os << std::endl; - os << "vcalibration " << "dacu\t gets the calibration pulse amplitude in dac units (0-1024)." << std::endl; - os << std::endl; - os << "vtrimbit " << "dacu\t gets the trimbit amplitude in dac units (0-1024)." << std::endl; - os << std::endl; - os << "vpreamp " << "dacu\t gets the preamp feedback voltage in dac units (0-1024)." << std::endl; - os << std::endl; - os << "vshaper1 " << "dacu\t gets the shaper1 feedback voltage in dac units (0-1024)." << std::endl; - os << std::endl; - os << "vshaper2 " << "dacu\t gets the shaper2 feedback voltage in dac units (0-1024)." << std::endl; - os << std::endl; - os << "vhighvoltage " << "dacu\t CHIPTEST BOARD ONLY - gets the detector HV in dac units (0-1024)." << std::endl; - os << std::endl; - os << "vapower " << "dacu\t CHIPTEST BOARD ONLY - gets the analog power supply in dac units (0-1024)." << std::endl; - os << std::endl; - os << "vddpower " << "dacu\t CHIPTEST BOARD ONLY - gets the digital power supply in dac units (0-1024)." << std::endl; - os << std::endl; - os << "vshpower " << "dacu\t CHIPTEST BOARD ONLY - gets the comparator power supply in dac units (0-1024)." << std::endl; - os << std::endl; - os << "viopower " << "dacu\t CHIPTEST BOARD ONLY - gets the FPGA I/O power supply in dac units (0-1024)." << std::endl; - os << std::endl; + os << "vcalibration " << "dacu\t gets the calibration pulse amplitude in dac units (0-1024)." << std::endl; + os << std::endl; + os << "vtrimbit " << "dacu\t gets the trimbit amplitude in dac units (0-1024)." << std::endl; + os << std::endl; + os << "vpreamp " << "dacu\t gets the preamp feedback voltage in dac units (0-1024)." << std::endl; + os << std::endl; + os << "vshaper1 " << "dacu\t gets the shaper1 feedback voltage in dac units (0-1024)." << std::endl; + os << std::endl; + os << "vshaper2 " << "dacu\t gets the shaper2 feedback voltage in dac units (0-1024)." << std::endl; + os << std::endl; + os << "vhighvoltage " << "dacu\t CHIPTEST BOARD ONLY - gets the detector HV in dac units (0-1024)." << std::endl; + os << std::endl; + os << "vapower " << "dacu\t CHIPTEST BOARD ONLY - gets the analog power supply in dac units (0-1024)." << std::endl; + os << std::endl; + os << "vddpower " << "dacu\t CHIPTEST BOARD ONLY - gets the digital power supply in dac units (0-1024)." << std::endl; + os << std::endl; + os << "vshpower " << "dacu\t CHIPTEST BOARD ONLY - gets the comparator power supply in dac units (0-1024)." << std::endl; + os << std::endl; + os << "viopower " << "dacu\t CHIPTEST BOARD ONLY - gets the FPGA I/O power supply in dac units (0-1024)." << std::endl; + os << std::endl; - os << "vrefds " << "\t gets vrefds" << std::endl; - os << "vcascn_pb " << "\t gets vcascn_pb" << std::endl; - os << "vcascp_pb " << "\t gets vcascp_pb" << std::endl; - os << "vout_cm " << "\t gets vout_cm" << std::endl; - os << "vin_cm " << "\t gets vin_cm" << std::endl; - os << "vcasc_out " << "\t gets vcasc_out" << std::endl; - os << "vref_comp " << "\t gets vref_comp" << std::endl; - os << "ib_test_c " << "\t gets ib_test_c" << std::endl; - } - return os.str(); + os << "vrefds " << "\t gets vrefds" << std::endl; + os << "vcascn_pb " << "\t gets vcascn_pb" << std::endl; + os << "vcascp_pb " << "\t gets vcascp_pb" << std::endl; + os << "vout_cm " << "\t gets vout_cm" << std::endl; + os << "vin_cm " << "\t gets vin_cm" << std::endl; + os << "vcasc_out " << "\t gets vcasc_out" << std::endl; + os << "vref_comp " << "\t gets vref_comp" << std::endl; + os << "ib_test_c " << "\t gets ib_test_c" << std::endl; + } + return os.str(); } @@ -3245,7 +3280,7 @@ string slsDetectorCommand::cmdTimeLeft(int narg, char *args[], int action) { if (action==PUT_ACTION) { - return string("cannot set ")+string(args[1]); + return string("cannot set ")+string(args[1]); } @@ -3492,8 +3527,8 @@ string slsDetectorCommand::cmdConfiguration(int narg, char *args[], int action) if (cmd=="config") { if (action==PUT_ACTION) { - sval=string(args[1]); - myDet->readConfigurationFile(sval); + sval=string(args[1]); + myDet->readConfigurationFile(sval); } else if (action==GET_ACTION) { sval=string(args[1]); myDet->writeConfigurationFile(sval); @@ -3501,20 +3536,20 @@ string slsDetectorCommand::cmdConfiguration(int narg, char *args[], int action) return sval; } else if (cmd=="parameters") { if (action==PUT_ACTION) { - sval=string(args[1]); - myDet->retrieveDetectorSetup(sval); + sval=string(args[1]); + myDet->retrieveDetectorSetup(sval); } else if (action==GET_ACTION) { - sval=string(args[1]); - myDet->dumpDetectorSetup(sval); + sval=string(args[1]); + myDet->dumpDetectorSetup(sval); } return sval; } else if (cmd=="setup") { if (action==PUT_ACTION) { - sval=string(args[1]); - myDet->retrieveDetectorSetup(sval,2); + sval=string(args[1]); + myDet->retrieveDetectorSetup(sval,2); } else if (action==GET_ACTION) { - sval=string(args[1]); - myDet->dumpDetectorSetup(sval,2); + sval=string(args[1]); + myDet->dumpDetectorSetup(sval,2); } return sval; } @@ -3555,54 +3590,54 @@ string slsDetectorCommand::helpConfiguration(int narg, char *args[], int action) string slsDetectorCommand::cmdReceiver(int narg, char *args[], int action) { - char answer[100]; + char answer[100]; - if (action==HELP_ACTION) - return helpReceiver(narg, args, action); + if (action==HELP_ACTION) + return helpReceiver(narg, args, action); - if(myDet->setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG) - return string("receiver not online"); + if(myDet->setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG) + return string("receiver not online"); - if(cmd=="receiver"){ - if (action==PUT_ACTION) { - if(!strcasecmp(args[1],"start")){ - 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->setOnline(ONLINE_FLAG); - myDet->startReceiver(); - } - } - - else if(!strcasecmp(args[1],"stop")){ - if(myDet->getReceiverStatus()==RUNNING){ - myDet->setOnline(ONLINE_FLAG); - if(myDet->stopReceiver()!=FAIL){ - //update index - int index = myDet->setReceiverFileIndex(); - if(index==-1) - return string("could not get receiver file index"); - myDet->setFileIndex(index); - } - } - }else - return helpReceiver(narg, args, action); - } - return myDet->runStatusType(myDet->getReceiverStatus()); + if(cmd=="receiver"){ + if (action==PUT_ACTION) { + if(!strcasecmp(args[1],"start")){ + 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->setOnline(ONLINE_FLAG); + myDet->startReceiver(); } + } - else if(cmd=="framescaught"){ - if (action==PUT_ACTION) - return string("cannot put"); - else{ - sprintf(answer,"%d",myDet->getFramesCaughtByReciver()); - return string(answer); - } + else if(!strcasecmp(args[1],"stop")){ + if(myDet->getReceiverStatus()==RUNNING){ + myDet->setOnline(ONLINE_FLAG); + if(myDet->stopReceiver()!=FAIL){ + //update index + int index = myDet->setReceiverFileIndex(); + if(index==-1) + return string("could not get receiver file index"); + myDet->setFileIndex(index); + } } - else - return string("could not decode command"); + }else + return helpReceiver(narg, args, action); + } + return myDet->runStatusType(myDet->getReceiverStatus()); + } + + else if(cmd=="framescaught"){ + if (action==PUT_ACTION) + return string("cannot put"); + else{ + sprintf(answer,"%d",myDet->getFramesCaughtByReciver()); + return string(answer); + } + } + else + return string("could not decode command"); } @@ -3614,7 +3649,7 @@ string slsDetectorCommand::helpReceiver(int narg, char *args[], int action) { if (action==PUT_ACTION || action==HELP_ACTION) os << "receiver [status] \t starts/stops the receiver to listen to detector packets. - can be start or stop" << std::endl; if (action==GET_ACTION || action==HELP_ACTION){ - os << "receiver \t returns the status of receiver - can be running or idle" << std::endl; + os << "receiver \t returns the status of receiver - can be running or idle" << std::endl; os << "framescaught \t returns the number of frames caught by receiver" << std::endl; } return os.str(); diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.h b/slsDetectorSoftware/slsDetector/slsDetectorCommand.h index d852bdd46..9e7a57d52 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.h @@ -16,73 +16,73 @@ class slsDetectorCommand : public virtual slsDetectorDefs { public: - slsDetectorCommand(slsDetectorUtils *det); + slsDetectorCommand(slsDetectorUtils *det); /* /\** */ -/* executes a set of string arguments according to a given format. It is used to read/write configuration file, dump and retrieve detector settings and for the command line interface command parsing */ -/* \param narg number of arguments */ -/* \param args array of string arguments */ -/* \param action can be PUT_ACTION or GET_ACTION (from text client even READOUT_ACTION for acquisition) */ -/* \returns answer string */ -/* *\/ */ - virtual string executeLine(int narg, char *args[], int action); + /* executes a set of string arguments according to a given format. It is used to read/write configuration file, dump and retrieve detector settings and for the command line interface command parsing */ + /* \param narg number of arguments */ + /* \param args array of string arguments */ + /* \param action can be PUT_ACTION or GET_ACTION (from text client even READOUT_ACTION for acquisition) */ + /* \returns answer string */ + /* *\/ */ + virtual string executeLine(int narg, char *args[], int action); -/* /\** */ -/* returns the help for the executeLine command */ -/* \param os output stream to return the help to */ -/* \param action can be PUT_ACTION or GET_ACTION (from text client even READOUT_ACTION for acquisition) */ -/* *\/ */ - string helpLine(int narg, char *args[], int action=HELP_ACTION); - static string helpAcquire(int narg, char *args[], int action); - static string helpData(int narg, char *args[], int action); - static string helpFrame(int narg, char *args[], int action); - static string helpStatus(int narg, char *args[], int action); - static string helpFree(int narg, char *args[], int action); - static string helpAdd(int narg, char *args[], int action); - static string helpRemove(int narg, char *args[], int action); - static string helpHostname(int narg, char *args[], int action); - static string helpId(int narg, char *args[], int action); - static string helpMaster(int narg, char *args[], int action); - static string helpSync(int narg, char *args[], int action); - static string helpExitServer(int narg, char *args[], int action); - static string helpSettingsDir(int narg, char *args[], int action); - static string helpCalDir(int narg, char *args[], int action); - static string helpTrimEn(int narg, char *args[], int action); - static string helpOutDir(int narg, char *args[], int action); - static string helpFileName(int narg, char *args[], int action); - static string helpFileIndex(int narg, char *args[], int action); - static string helpFlatField(int narg, char *args[], int action); - static string helpRateCorr(int narg, char *args[], int action); - static string helpBadChannels(int narg, char *args[], int action); - static string helpAngConv(int narg, char *args[], int action); - static string helpThreaded(int narg, char *args[], int action); - static string helpPositions(int narg, char *args[], int action); - static string helpScripts(int narg, char *args[], int action); - static string helpScans(int narg, char *args[], int action); - static string helpNetworkParameter(int narg, char *args[], int action); - static string helpPort(int narg, char *args[], int action); - static string helpLock(int narg, char *args[], int action); - static string helpLastClient(int narg, char *args[], int action); - static string helpOnline(int narg, char *args[], int action); - static string helpConfigureMac(int narg, char *args[], int action); - static string helpDetectorSize(int narg, char *args[], int action); - static string helpSettings(int narg, char *args[], int action); - static string helpSN(int narg, char *args[], int action); - static string helpDigiTest(int narg, char *args[], int action); - static string helpRegister(int narg, char *args[], int action); - static string helpDAC(int narg, char *args[], int action); - static string helpTimer(int narg, char *args[], int action); - static string helpTiming(int narg, char *args[], int action); - static string helpTimeLeft(int narg, char *args[], int action); - static string helpSpeed(int narg, char *args[], int action); - static string helpAdvanced(int narg, char *args[], int action); - static string helpConfiguration(int narg, char *args[], int action); - static string helpImage(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 helpEnablefwrite(int narg, char *args[], int action); - static string helpReceiver(int narg, char *args[], int action); + /* /\** */ + /* returns the help for the executeLine command */ + /* \param os output stream to return the help to */ + /* \param action can be PUT_ACTION or GET_ACTION (from text client even READOUT_ACTION for acquisition) */ + /* *\/ */ + string helpLine(int narg, char *args[], int action=HELP_ACTION); + static string helpAcquire(int narg, char *args[], int action); + static string helpData(int narg, char *args[], int action); + static string helpFrame(int narg, char *args[], int action); + static string helpStatus(int narg, char *args[], int action); + static string helpFree(int narg, char *args[], int action); + static string helpAdd(int narg, char *args[], int action); + static string helpRemove(int narg, char *args[], int action); + static string helpHostname(int narg, char *args[], int action); + static string helpId(int narg, char *args[], int action); + static string helpMaster(int narg, char *args[], int action); + static string helpSync(int narg, char *args[], int action); + static string helpExitServer(int narg, char *args[], int action); + static string helpSettingsDir(int narg, char *args[], int action); + static string helpCalDir(int narg, char *args[], int action); + static string helpTrimEn(int narg, char *args[], int action); + static string helpOutDir(int narg, char *args[], int action); + static string helpFileName(int narg, char *args[], int action); + static string helpFileIndex(int narg, char *args[], int action); + static string helpFlatField(int narg, char *args[], int action); + static string helpRateCorr(int narg, char *args[], int action); + static string helpBadChannels(int narg, char *args[], int action); + static string helpAngConv(int narg, char *args[], int action); + static string helpThreaded(int narg, char *args[], int action); + static string helpPositions(int narg, char *args[], int action); + static string helpScripts(int narg, char *args[], int action); + static string helpScans(int narg, char *args[], int action); + static string helpNetworkParameter(int narg, char *args[], int action); + static string helpPort(int narg, char *args[], int action); + static string helpLock(int narg, char *args[], int action); + static string helpLastClient(int narg, char *args[], int action); + static string helpOnline(int narg, char *args[], int action); + static string helpConfigureMac(int narg, char *args[], int action); + static string helpDetectorSize(int narg, char *args[], int action); + static string helpSettings(int narg, char *args[], int action); + static string helpSN(int narg, char *args[], int action); + static string helpDigiTest(int narg, char *args[], int action); + static string helpRegister(int narg, char *args[], int action); + static string helpDAC(int narg, char *args[], int action); + static string helpTimer(int narg, char *args[], int action); + static string helpTiming(int narg, char *args[], int action); + static string helpTimeLeft(int narg, char *args[], int action); + static string helpSpeed(int narg, char *args[], int action); + static string helpAdvanced(int narg, char *args[], int action); + static string helpConfiguration(int narg, char *args[], int action); + static string helpImage(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 helpEnablefwrite(int narg, char *args[], int action); + static string helpReceiver(int narg, char *args[], int action); @@ -101,76 +101,76 @@ class slsDetectorCommand : public virtual slsDetectorDefs { slsDetectorUtils *myDet; - string cmdUnderDevelopment(int narg, char *args[], int action); - string cmdUnknown(int narg, char *args[], int action); - string cmdAcquire(int narg, char *args[], int action); - string cmdData(int narg, char *args[], int action); - string cmdFrame(int narg, char *args[], int action); - string cmdStatus(int narg, char *args[], int action); - string cmdFree(int narg, char *args[], int action); - string cmdAdd(int narg, char *args[], int action); - string cmdRemove(int narg, char *args[], int action); - string cmdHostname(int narg, char *args[], int action); - string cmdId(int narg, char *args[], int action); - string cmdMaster(int narg, char *args[], int action); - string cmdSync(int narg, char *args[], int action); - string cmdHelp(int narg, char *args[], int action); - string cmdExitServer(int narg, char *args[], int action); - string cmdSettingsDir(int narg, char *args[], int action); - string cmdCalDir(int narg, char *args[], int action); - string cmdTrimEn(int narg, char *args[], int action); - string cmdOutDir(int narg, char *args[], int action); - string cmdFileName(int narg, char *args[], int action); - string cmdFileIndex(int narg, char *args[], int action); - string cmdFlatField(int narg, char *args[], int action); - string cmdRateCorr(int narg, char *args[], int action); - string cmdBadChannels(int narg, char *args[], int action); - string cmdAngConv(int narg, char *args[], int action); - string cmdThreaded(int narg, char *args[], int action); - string cmdPositions(int narg, char *args[], int action); - string cmdScripts(int narg, char *args[], int action); - string cmdScans(int narg, char *args[], int action); - string cmdNetworkParameter(int narg, char *args[], int action); - string cmdPort(int narg, char *args[], int action); - string cmdLock(int narg, char *args[], int action); - string cmdLastClient(int narg, char *args[], int action); - string cmdOnline(int narg, char *args[], int action); - string cmdConfigureMac(int narg, char *args[], int action); - string cmdDetectorSize(int narg, char *args[], int action); - string cmdSettings(int narg, char *args[], int action); - string cmdSN(int narg, char *args[], int action); - string cmdDigiTest(int narg, char *args[], int action); - string cmdRegister(int narg, char *args[], int action); - string cmdDAC(int narg, char *args[], int action); - string cmdTiming(int narg, char *args[], int action); - string cmdTimer(int narg, char *args[], int action); - string cmdTimeLeft(int narg, char *args[], int action); - string cmdSpeed(int narg, char *args[], int action); - string cmdAdvanced(int narg, char *args[], int action); - string cmdConfiguration(int narg, char *args[], int action); - string cmdImage(int narg, char *args[], int action); - string cmdCounter(int narg, char *args[], int action); - string cmdADC(int narg, char *args[], int action); - string cmdEnablefwrite(int narg, char *args[], int action); - string cmdReceiver(int narg, char *args[], int action); + string cmdUnderDevelopment(int narg, char *args[], int action); + string cmdUnknown(int narg, char *args[], int action); + string cmdAcquire(int narg, char *args[], int action); + string cmdData(int narg, char *args[], int action); + string cmdFrame(int narg, char *args[], int action); + string cmdStatus(int narg, char *args[], int action); + string cmdFree(int narg, char *args[], int action); + string cmdAdd(int narg, char *args[], int action); + string cmdRemove(int narg, char *args[], int action); + string cmdHostname(int narg, char *args[], int action); + string cmdId(int narg, char *args[], int action); + string cmdMaster(int narg, char *args[], int action); + string cmdSync(int narg, char *args[], int action); + string cmdHelp(int narg, char *args[], int action); + string cmdExitServer(int narg, char *args[], int action); + string cmdSettingsDir(int narg, char *args[], int action); + string cmdCalDir(int narg, char *args[], int action); + string cmdTrimEn(int narg, char *args[], int action); + string cmdOutDir(int narg, char *args[], int action); + string cmdFileName(int narg, char *args[], int action); + string cmdFileIndex(int narg, char *args[], int action); + string cmdFlatField(int narg, char *args[], int action); + string cmdRateCorr(int narg, char *args[], int action); + string cmdBadChannels(int narg, char *args[], int action); + string cmdAngConv(int narg, char *args[], int action); + string cmdThreaded(int narg, char *args[], int action); + string cmdPositions(int narg, char *args[], int action); + string cmdScripts(int narg, char *args[], int action); + string cmdScans(int narg, char *args[], int action); + string cmdNetworkParameter(int narg, char *args[], int action); + string cmdPort(int narg, char *args[], int action); + string cmdLock(int narg, char *args[], int action); + string cmdLastClient(int narg, char *args[], int action); + string cmdOnline(int narg, char *args[], int action); + string cmdConfigureMac(int narg, char *args[], int action); + string cmdDetectorSize(int narg, char *args[], int action); + string cmdSettings(int narg, char *args[], int action); + string cmdSN(int narg, char *args[], int action); + string cmdDigiTest(int narg, char *args[], int action); + string cmdRegister(int narg, char *args[], int action); + string cmdDAC(int narg, char *args[], int action); + string cmdTiming(int narg, char *args[], int action); + string cmdTimer(int narg, char *args[], int action); + string cmdTimeLeft(int narg, char *args[], int action); + string cmdSpeed(int narg, char *args[], int action); + string cmdAdvanced(int narg, char *args[], int action); + string cmdConfiguration(int narg, char *args[], int action); + string cmdImage(int narg, char *args[], int action); + string cmdCounter(int narg, char *args[], int action); + string cmdADC(int narg, char *args[], int action); + string cmdEnablefwrite(int narg, char *args[], int action); + string cmdReceiver(int narg, char *args[], int action); - int numberOfCommands; - string cmd; + int numberOfCommands; + string cmd; - typedef string (slsDetectorCommand::*MemFuncGetter)(int narg, char *args[], int action); + typedef string (slsDetectorCommand::*MemFuncGetter)(int narg, char *args[], int action); - struct FuncTable - { - string m_pFuncName; - //const char* m_pFuncName; - MemFuncGetter m_pFuncPtr; - }; + struct FuncTable + { + string m_pFuncName; + //const char* m_pFuncName; + MemFuncGetter m_pFuncPtr; + }; - FuncTable descrToFuncMap[1000]; + FuncTable descrToFuncMap[1000]; diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp b/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp index 14d59e8a5..c0ceb9cc8 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp @@ -48,7 +48,7 @@ void slsDetectorUtils::acquire(int delflag){ angCalLogClass *aclog=NULL; enCalLogClass *eclog=NULL; - // int lastindex=startindex, nowindex=startindex; + // int lastindex=startindex, nowindex=startindex; int connectChannels=0; #ifdef VERBOSE @@ -124,217 +124,217 @@ void slsDetectorUtils::acquire(int delflag){ cout << " starting measurement "<< im << " of " << nm << endl; #endif - //cout << "data thread started " << endl; + //cout << "data thread started " << endl; - //loop measurements + //loop measurements - pthread_mutex_lock(&mp); - setStartIndex(*fileIndex); - pthread_mutex_unlock(&mp); + pthread_mutex_lock(&mp); + setStartIndex(*fileIndex); + pthread_mutex_unlock(&mp); - //cout << "action at start" << endl; - if (*stoppedFlag==0) { - executeAction(startScript); - } + //cout << "action at start" << endl; + if (*stoppedFlag==0) { + executeAction(startScript); + } - for (int is0=0; is00) { - moveDetector(detPositions[ip]); - IncrementPositionIndex(); + for (int ip=0; ip0) { + moveDetector(detPositions[ip]); + IncrementPositionIndex(); #ifdef VERBOSE - std::cout<< "moving to position" << std::endl; + std::cout<< "moving to position" << std::endl; #endif - } - } else - break; + } + } else + break; - pthread_mutex_lock(&mp); - createFileName(); - pthread_mutex_unlock(&mp); + pthread_mutex_lock(&mp); + createFileName(); + pthread_mutex_unlock(&mp); - if (*stoppedFlag==0) { - executeAction(scriptBefore); - } else - break; + if (*stoppedFlag==0) { + executeAction(scriptBefore); + } else + break; - if (*stoppedFlag==0) { + if (*stoppedFlag==0) { - executeAction(headerBefore); + executeAction(headerBefore); - if (*correctionMask&(1<< ANGULAR_CONVERSION) || aclog || eclog) { - positionFinished(0); - setCurrentPosition(getDetectorPosition()); - } + if (*correctionMask&(1<< ANGULAR_CONVERSION) || aclog || eclog) { + positionFinished(0); + setCurrentPosition(getDetectorPosition()); + } - if (aclog) - aclog->addStep(getCurrentPosition(), getCurrentFileName()); + if (aclog) + aclog->addStep(getCurrentPosition(), getCurrentFileName()); - if (eclog) - eclog->addStep(setDAC(-1,THRESHOLD), getCurrentFileName()); + if (eclog) + eclog->addStep(setDAC(-1,THRESHOLD), getCurrentFileName()); - if (*correctionMask&(1<< I0_NORMALIZATION)) { - if (get_i0) - get_i0(0, IOarg); - } + if (*correctionMask&(1<< I0_NORMALIZATION)) { + if (get_i0) + get_i0(0, IOarg); + } - startAndReadAll(); + startAndReadAll(); #ifdef VERBOSE - cout << "returned! " << endl; + cout << "returned! " << endl; #endif - if (*correctionMask&(1<< I0_NORMALIZATION)) { - if (get_i0) - currentI0=get_i0(1,IOarg); // this is the correct i0!!!!! - } + if (*correctionMask&(1<< I0_NORMALIZATION)) { + if (get_i0) + currentI0=get_i0(1,IOarg); // this is the correct i0!!!!! + } #ifdef VERBOSE - cout << "pos finished? " << endl; + cout << "pos finished? " << endl; #endif - positionFinished(1); + positionFinished(1); #ifdef VERBOSE - cout << "done! " << endl; + cout << "done! " << endl; #endif - if (*threadedProcessing==0){ + if (*threadedProcessing==0){ #ifdef VERBOSE - cout << "start unthreaded process data " << endl; + cout << "start unthreaded process data " << endl; #endif - processData(delflag); - } + processData(delflag); + } - } else - break; + } else + break; - // wait until data processing thread has finished the data + // wait until data processing thread has finished the data #ifdef VERBOSE - cout << "check data queue size " << endl; + cout << "check data queue size " << endl; #endif - while (dataQueueSize()){ + while (dataQueueSize()){ #ifdef VERBOSE - cout << "AAAAAAAAA check data queue size " << endl; + cout << "AAAAAAAAA check data queue size " << endl; #endif - usleep(100000); - } + usleep(100000); + } - pthread_mutex_lock(&mp); - if (*stoppedFlag==0) { - executeAction(headerAfter); - setLastIndex(*fileIndex); - } else { - setLastIndex(*fileIndex); - break; - } - pthread_mutex_unlock(&mp); + pthread_mutex_lock(&mp); + if (*stoppedFlag==0) { + executeAction(headerAfter); + setLastIndex(*fileIndex); + } else { + setLastIndex(*fileIndex); + break; + } + pthread_mutex_unlock(&mp); - if (*stoppedFlag) { + if (*stoppedFlag) { #ifdef VERBOSE - std::cout<< "exiting since the detector has been stopped" << std::endl; + std::cout<< "exiting since the detector has been stopped" << std::endl; #endif - break; - } else if (ip<(np-1)) { - pthread_mutex_lock(&mp); - *fileIndex=setStartIndex(); - pthread_mutex_unlock(&mp); - } - } // loop on position finished + break; + } else if (ip<(np-1)) { + pthread_mutex_lock(&mp); + *fileIndex=setStartIndex(); + pthread_mutex_unlock(&mp); + } + } // loop on position finished - //script after - if (*stoppedFlag==0) { - executeAction(scriptAfter); - } else - break; + //script after + if (*stoppedFlag==0) { + executeAction(scriptAfter); + } else + break; - if (*stoppedFlag) { + if (*stoppedFlag) { #ifdef VERBOSE - std::cout<< "exiting since the detector has been stopped" << std::endl; + std::cout<< "exiting since the detector has been stopped" << std::endl; #endif - break; - } else if (is1<(ns1-1)) { - pthread_mutex_lock(&mp); - *fileIndex=setStartIndex(); - pthread_mutex_unlock(&mp); - } - } + break; + } else if (is1<(ns1-1)) { + pthread_mutex_lock(&mp); + *fileIndex=setStartIndex(); + pthread_mutex_unlock(&mp); + } + } - //end scan1 loop is1 + //end scan1 loop is1 - if (*stoppedFlag) { + if (*stoppedFlag) { #ifdef VERBOSE - std::cout<< "exiting since the detector has been stopped" << std::endl; + std::cout<< "exiting since the detector has been stopped" << std::endl; #endif - break; - } else if (is0<(ns0-1)) { + break; + } else if (is0<(ns0-1)) { + pthread_mutex_lock(&mp); + *fileIndex=setStartIndex(); + pthread_mutex_unlock(&mp); + } + + } //end scan0 loop is0 + pthread_mutex_lock(&mp); - *fileIndex=setStartIndex(); + *fileIndex=setLastIndex(); pthread_mutex_unlock(&mp); - } + if (*stoppedFlag==0) { + executeAction(stopScript); + } else + break; - } //end scan0 loop is0 - - pthread_mutex_lock(&mp); - *fileIndex=setLastIndex(); - pthread_mutex_unlock(&mp); - if (*stoppedFlag==0) { - executeAction(stopScript); - } else - break; - -// loop measurements + // loop measurements - if (measurement_finished) - measurement_finished(im,*fileIndex,measFinished_p); + if (measurement_finished) + measurement_finished(im,*fileIndex,measFinished_p); - if (*stoppedFlag) { - break; - } + if (*stoppedFlag) { + break; + } } @@ -346,21 +346,21 @@ void slsDetectorUtils::acquire(int delflag){ } - if (connectChannels) { - if (disconnect_channels) - disconnect_channels(DCarg); - } + if (connectChannels) { + if (disconnect_channels) + disconnect_channels(DCarg); + } - if (aclog) - delete aclog; + if (aclog) + delete aclog; - if (eclog) - delete eclog; + if (eclog) + delete eclog; - if (acquisition_finished) - acquisition_finished(getCurrentProgress(),getDetectorStatus(),acqFinished_p); + if (acquisition_finished) + acquisition_finished(getCurrentProgress(),getDetectorStatus(),acqFinished_p); } @@ -378,33 +378,33 @@ int slsDetectorUtils::setTotalProgress() { nf=timerValue[FRAME_NUMBER]; if (timerValue[CYCLES_NUMBER]>0) - nc=timerValue[CYCLES_NUMBER]; + nc=timerValue[CYCLES_NUMBER]; if (timerValue[MEASUREMENTS_NUMBER]>0) - nm=timerValue[MEASUREMENTS_NUMBER]; + nm=timerValue[MEASUREMENTS_NUMBER]; if (*numberOfPositions>0) - npos=*numberOfPositions; + npos=*numberOfPositions; if ((nScanSteps[0]>0) && (*actionMask & (1 << MAX_ACTIONS))) - nscan[0]=nScanSteps[0]; + nscan[0]=nScanSteps[0]; - if ((nScanSteps[1]>0) && (*actionMask & (1 << (MAX_ACTIONS+1)))) - nscan[1]=nScanSteps[1]; + if ((nScanSteps[1]>0) && (*actionMask & (1 << (MAX_ACTIONS+1)))) + nscan[1]=nScanSteps[1]; - totalProgress=nm*nf*nc*npos*nscan[0]*nscan[1]; + totalProgress=nm*nf*nc*npos*nscan[0]*nscan[1]; #ifdef VERBOSE - cout << "nc " << nc << endl; - cout << "nm " << nm << endl; - cout << "nf " << nf << endl; - cout << "npos " << npos << endl; - cout << "nscan[0] " << nscan[0] << endl; - cout << "nscan[1] " << nscan[1] << endl; + cout << "nc " << nc << endl; + cout << "nm " << nm << endl; + cout << "nf " << nf << endl; + cout << "npos " << npos << endl; + cout << "nscan[0] " << nscan[0] << endl; + cout << "nscan[1] " << nscan[1] << endl; - cout << "Set total progress " << totalProgress << endl; + cout << "Set total progress " << totalProgress << endl; #endif - return totalProgress; + return totalProgress; } @@ -460,26 +460,26 @@ int slsDetectorUtils::setBadChannelCorrection(string fname, int &nbadtot, int *b - infile.open(fn.c_str(), ios_base::in); - if (infile.is_open()==0) { - std::cout << "could not open file " << fname <0 && nbadtot> sargname; // if (ssstr.good()) { - strcpy(myargs[iargval],sargname.c_str()); - args[iargval]=myargs[iargval]; + strcpy(myargs[iargval],sargname.c_str()); + args[iargval]=myargs[iargval]; #ifdef VERBOSE - std::cout<< args[iargval] << std::endl; + std::cout<< args[iargval] << std::endl; #endif - iargval++; - // } - skip=0; + iargval++; + // } + skip=0; } if (level!=2) { @@ -749,7 +749,7 @@ int slsDetectorUtils::dumpDetectorSetup(string const fname, int level){ - char ext[100]; + char ext[100]; int iv=0; string fname1; @@ -809,26 +809,26 @@ int slsDetectorUtils::dumpDetectorSetup(string const fname, int level){ - if (level==2) { - strcpy(args[0],names[iv].c_str()); - size_t c=fname.rfind('/'); - if (cexecuteLine(nargs,args,GET_ACTION) << std::endl; - iv++; + outfile << names[iv] << " " << cmd->executeLine(nargs,args,GET_ACTION) << std::endl; + iv++; - } + } - delete cmd; + delete cmd; outfile.close(); } diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h index 5980fecb3..db9a90f6c 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h @@ -56,7 +56,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { public: - slsDetectorUtils(); + slsDetectorUtils(); virtual ~slsDetectorUtils(){}; @@ -84,14 +84,14 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { // int getFileIndex(){return fileIO::getFileIndex();}; // int setFileIndex(int s){return fileIO::setFileIndex(s);}; -/* - int getScanPrecision(int i){return slsDetectorActions::getScanPrecision(i);}; + /* + int getScanPrecision(int i){return slsDetectorActions::getScanPrecision(i);}; - int getActionMask() {return slsDetectorActions::getActionMask();}; - float getCurrentScanVariable(int i) {return slsDetectorActions::getCurrentScanVariable(i);}; - int getCurrentPositionIndex(){return angularConversion::getCurrentPositionIndex();}; - int getNumberOfPositions(){return angularConversion::getNumberOfPositions();}; -*/ + int getActionMask() {return slsDetectorActions::getActionMask();}; + float getCurrentScanVariable(int i) {return slsDetectorActions::getCurrentScanVariable(i);}; + int getCurrentPositionIndex(){return angularConversion::getCurrentPositionIndex();}; + int getNumberOfPositions(){return angularConversion::getNumberOfPositions();}; + */ // int getActionMask() {return slsDetectorActions::getActionMask();}; // double getCurrentScanVariable(int i) {return slsDetectorActions::getCurrentScanVariable(i);}; @@ -175,7 +175,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { */ virtual char *setNetworkParameter(networkParameter i, string s)=0; -/** + /** changes/gets the port number \param t type port type can be CONTROL_PORT, DATA_PORT, STOP_PORT \param i new port number (<1024 gets) @@ -183,7 +183,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { */ virtual int setPort(portType t, int i=-1)=0; - /** + /** get detector ids/versions for module=0 \param mode which id/version has to be read \param imod module number for module serial number @@ -192,21 +192,21 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { virtual int64_t getId(idMode mode, int imod=0)=0; /** - checks if the detector(s) are online/offline - \returns hostname if offline - */ - virtual string checkOnline()=0; + checks if the detector(s) are online/offline + \returns hostname if offline + */ + virtual string checkOnline()=0; - /** - Digital test of the modules - \param mode test mode - \param imod module number for chip test or module firmware test - \returns OK or error mask + /** + Digital test of the modules + \param mode test mode + \param imod module number for chip test or module firmware test + \returns OK or error mask */ virtual int digitalTest(digitalTestMode mode, int imod=0)=0; - /** - execute trimming + /** + execute trimming \param mode trim mode \param par1 if noise, beam or fixed setting trimming it is count limit, if improve maximum number of iterations \param par2 if noise or beam nsigma, if improve par2!=means vthreshold will be optimized, if fixed settings par2<0 trimwith median, par2>=0 trim with level @@ -222,7 +222,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { virtual const char *getSettingsFile()=0; - /** + /** get current timer value \param index timer index \returns elapsed time value in ns or number of...(e.g. frames, gates, probes) @@ -232,11 +232,11 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { /** sets the number of trim energies and their value \sa sharedSlsDetector - \param nen number of energies - \param en array of energies - \returns number of trim energies + \param nen number of energies + \param en array of energies + \returns number of trim energies - unused! + unused! */ virtual int setTrimEn(int nen, int *en=NULL)=0; @@ -252,7 +252,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { /** - set/get the use of an external signal + set/get the use of an external signal \param pol meaning of the signal \sa externalSignalFlag \param signalindex index of the signal \returns current meaning of signal signalIndex @@ -267,7 +267,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { \param value is the value to be set, if -1 get value \returns current value for the specified parameter \sa speedVariable - */ + */ virtual int setSpeed(speedVariable sp, int value=-1)=0; @@ -292,7 +292,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { - /** sets/gets position of the master in a multi detector structure + /** sets/gets position of the master in a multi detector structure \param i position of the detector in the multidetector structure \returns position of the master in a multi detector structure (-1 no master or always in slsDetector) */ @@ -320,7 +320,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { virtual char* getCalDir()=0; /** - sets the location of the calibration files + sets the location of the calibration files */ virtual char* setCalDir(string s)=0; @@ -329,17 +329,17 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { /** adds the detector with ID id in postion pos - \param id of the detector to be added (should already exist!) - \param pos position where it should be added (normally at the end of the list (default to -1) - \returns the actual number of detectors or -1 if it failed (always for slsDetector) + \param id of the detector to be added (should already exist!) + \param pos position where it should be added (normally at the end of the list (default to -1) + \returns the actual number of detectors or -1 if it failed (always for slsDetector) */ virtual int addSlsDetector(int id, int pos=-1){return -1;}; /** adds the detector name in position pos - \param name of the detector to be added (should already exist in shared memory or at least be online) - \param pos position where it should be added (normally at the end of the list (default to -1) - \return the actual number of detectors or -1 if it failed (always for slsDetector) + \param name of the detector to be added (should already exist in shared memory or at least be online) + \param pos position where it should be added (normally at the end of the list (default to -1) + \return the actual number of detectors or -1 if it failed (always for slsDetector) */ virtual int addSlsDetector(char* name, int pos=-1){return -1;}; @@ -351,13 +351,13 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { */ virtual int removeSlsDetector(int pos=-1){return -1;}; - /**removes the detector in position pos from the multidetector - \param name is the name of the detector - \returns the actual number of detectors or -1 if it failed (always for slsDetector) - */ + /**removes the detector in position pos from the multidetector + \param name is the name of the detector + \returns the actual number of detectors or -1 if it failed (always for slsDetector) + */ virtual int removeSlsDetector(char* name){return -1;}; - /** + /** Turns off the server - do not use except for debugging! */ virtual int exitServer()=0; @@ -365,28 +365,28 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { -/** - Loads dark image or gain image to the detector - \param index can be DARK_IMAGE or GAIN_IMAGE - \fname file name to load data from - \returns OK or FAIL - */ + /** + Loads dark image or gain image to the detector + \param index can be DARK_IMAGE or GAIN_IMAGE + \fname file name to load data from + \returns OK or FAIL + */ virtual int loadImageToDetector(imageType index,string const fname)=0; /** - writes the counter memory block from the detector - \param startACQ is 1 to start acquisition after reading counter - \fname file fname to load data from - \returns OK or FAIL + writes the counter memory block from the detector + \param startACQ is 1 to start acquisition after reading counter + \fname file fname to load data from + \returns OK or FAIL */ virtual int writeCounterBlockFile(string const fname,int startACQ=0)=0; /** - Resets counter memory block in detector - \param startACQ is 1 to start acquisition after resetting counter - \returns OK or FAIL + Resets counter memory block in detector + \param startACQ is 1 to start acquisition after resetting counter + \returns OK or FAIL */ virtual int resetCounterBlock(int startACQ=0)=0; @@ -395,8 +395,8 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { /** - asks and receives all data from the detector and puts them in a data queue - \returns pointer to the front of the queue or NULL. + asks and receives all data from the detector and puts them in a data queue + \returns pointer to the front of the queue or NULL. */ virtual int* readAll()=0; @@ -404,11 +404,11 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { /** performs a complete acquisition including scansand data processing - moves the detector to next position
- starts and reads the detector
- reads the IC (if required)
- reads the encoder (iof required for angualr conversion)
- processes the data (flat field, rate, angular conversion and merging ::processData()) + moves the detector to next position
+ starts and reads the detector
+ reads the IC (if required)
+ reads the encoder (iof required for angualr conversion)
+ processes the data (flat field, rate, angular conversion and merging ::processData()) \param delflag 0 leaves the data in the final data queue \returns nothing */ @@ -420,7 +420,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { // virtual double* convertAngles(double pos)=0; virtual int setThresholdEnergy(int, int im=-1, detectorSettings isettings=GET_SETTINGS)=0; - virtual int setChannel(int64_t, int ich=-1, int ichip=-1, int imod=-1)=0; + virtual int setChannel(int64_t, int ich=-1, int ichip=-1, int imod=-1)=0; virtual double getRateCorrectionTau()=0; virtual int* startAndReadAll()=0; @@ -465,7 +465,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { */ virtual int readRegister(int addr)=0; /** - Returns the IP of the last client connecting to the detector + Returns the IP of the last client connecting to the detector */ virtual string getLastClientIP()=0; @@ -483,7 +483,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { \param fname file name . If not specified, extension is automatically generated! \param imod module number, -1 means all modules \returns OK or FAIL - */ + */ virtual int loadSettingsFile(string fname, int imod=-1)=0; @@ -492,17 +492,17 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { \param fname file name . Axtension is automatically generated! \param imod module number, -1 means all modules \returns OK or FAIL - */ + */ virtual int saveSettingsFile(string fname, int imod=-1)=0; /** - set dacs value - \param val value (in V) - \param index DAC index - \param imod module number (if -1 alla modules) - \returns current DAC value + set dacs value + \param val value (in V) + \param index DAC index + \param imod module number (if -1 alla modules) + \returns current DAC value */ virtual dacs_t setDAC(dacs_t val, dacIndex index , int imod=-1)=0; @@ -516,9 +516,9 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { virtual dacs_t getADC(dacIndex index, int imod=0)=0; /** - get the maximum size of the detector - \param d dimension - \returns maximum number of modules that can be installed in direction d + get the maximum size of the detector + \param d dimension + \returns maximum number of modules that can be installed in direction d */ virtual int getMaxNumberOfModules(dimension d=X)=0; @@ -547,7 +547,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { /** - Saves the detector setup to file + Saves the detector setup to file \param fname file to write to \param level if 2 reads also trimbits, flat field, angular correction etc. and writes them to files with automatically added extension \returns OK or FAIL @@ -557,7 +557,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { /** - Loads the detector setup from file + Loads the detector setup from file \param fname file to read from \param level if 2 reads also reads trimbits, angular conversion coefficients etc. from files with default extensions as generated by dumpDetectorSetup \returns OK or FAIL @@ -571,26 +571,26 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { -//receiver + //receiver /** Checks if the receiver is really online - */ + */ virtual string checkReceiverOnline()=0; /** - Returns the IP of the last client connecting to the receiver + Returns the IP of the last client connecting to the receiver */ virtual string getReceiverLastClientIP()=0; protected: - static const int64_t thisSoftwareVersion=0x20120124; + static const int64_t thisSoftwareVersion=0x20120124; - //protected: + //protected: int *stoppedFlag; int64_t *timerValue; diff --git a/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.cpp b/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.cpp index 67de642f2..ae8ab41db 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.cpp +++ b/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.cpp @@ -70,20 +70,20 @@ int energyConversion::writeCalibrationFile(string fname, double gain, double off #ifndef MYROOT - /* I/O */ +/* I/O */ slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string fname, detectorType myDetectorType, sls_detector_module *myMod){ - int nflag=0; + int nflag=0; - if (myMod==NULL) { - myMod=createModule(myDetectorType); - nflag=1; - } + if (myMod==NULL) { + myMod=createModule(myDetectorType); + nflag=1; + } - string myfname; + string myfname; string str; ifstream infile; ostringstream oss; @@ -97,101 +97,101 @@ slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string #ifdef VERBOSE std::cout<< "reading settings file for module number "<< myMod->module << std::endl; #endif - myfname=fname; + myfname=fname; #ifdef VERBOSE - std::cout<< "file name is "<< myfname << std::endl; + std::cout<< "file name is "<< myfname << std::endl; #endif - infile.open(myfname.c_str(), ios_base::in); - if (infile.is_open()) { + infile.open(myfname.c_str(), ios_base::in); + if (infile.is_open()) { - switch (myDetectorType) { + switch (myDetectorType) { - case MYTHEN: + case MYTHEN: - for (int iarg=0; iargndac; iarg++) { - getline(infile,str); - iline++; - istringstream ssstr(str); - ssstr >> sargname >> ival; + for (int iarg=0; iargndac; iarg++) { + getline(infile,str); + iline++; + istringstream ssstr(str); + ssstr >> sargname >> ival; #ifdef VERBOSE - std::cout<< sargname << " dac nr. " << idac << " is " << ival << std::endl; + std::cout<< sargname << " dac nr. " << idac << " is " << ival << std::endl; #endif - myMod->dacs[idac]=ival; - idac++; - } - for (ichip=0; ichipnchip; ichip++) { - getline(infile,str); - iline++; + myMod->dacs[idac]=ival; + idac++; + } + for (ichip=0; ichipnchip; ichip++) { + getline(infile,str); + iline++; #ifdef VERBOSE - // std::cout<< str << std::endl; + // std::cout<< str << std::endl; #endif - istringstream ssstr(str); - ssstr >> sargname >> ival; + istringstream ssstr(str); + ssstr >> sargname >> ival; #ifdef VERBOSE - // std::cout<< "chip " << ichip << " " << sargname << " is " << ival << std::endl; + // std::cout<< "chip " << ichip << " " << sargname << " is " << ival << std::endl; #endif - myMod->chipregs[ichip]=ival; - for (ichan=0; ichanchipregs[ichip]=ival; + for (ichan=0; ichannChans <<" iline " << iline<< std::endl; + // std::cout<< "channel " << ichan+ichip*thisDetector->nChans <<" iline " << iline<< std::endl; #endif - iline++; - myMod->chanregs[ichip*nch+ichan]=0; - for (int iarg=0; iarg<6 ; iarg++) { - ssstr >> ival; - //if (ssstr.good()) { - switch (iarg) { - case 0: + iline++; + myMod->chanregs[ichip*nch+ichan]=0; + for (int iarg=0; iarg<6 ; iarg++) { + ssstr >> ival; + //if (ssstr.good()) { + switch (iarg) { + case 0: #ifdef VERBOSE - // std::cout<< "trimbits " << ival ; + // std::cout<< "trimbits " << ival ; #endif - myMod->chanregs[ichip*nch+ichan]|=ival&TRIMBITMASK; - break; - case 1: + myMod->chanregs[ichip*nch+ichan]|=ival&TRIMBITMASK; + break; + case 1: #ifdef VERBOSE - //std::cout<< " compen " << ival ; + //std::cout<< " compen " << ival ; #endif - myMod->chanregs[ichip*nch+ichan]|=ival<<9; - break; - case 2: + myMod->chanregs[ichip*nch+ichan]|=ival<<9; + break; + case 2: #ifdef VERBOSE - //std::cout<< " anen " << ival ; + //std::cout<< " anen " << ival ; #endif - myMod->chanregs[ichip*nch+ichan]|=ival<<8; - break; - case 3: + myMod->chanregs[ichip*nch+ichan]|=ival<<8; + break; + case 3: #ifdef VERBOSE - //std::cout<< " calen " << ival ; + //std::cout<< " calen " << ival ; #endif - myMod->chanregs[ichip*nch+ichan]|=ival<<7; - break; - case 4: + myMod->chanregs[ichip*nch+ichan]|=ival<<7; + break; + case 4: #ifdef VERBOSE - //std::cout<< " outcomp " << ival ; + //std::cout<< " outcomp " << ival ; #endif - myMod->chanregs[ichip*nch+ichan]|=ival<<10; - break; - case 5: + myMod->chanregs[ichip*nch+ichan]|=ival<<10; + break; + case 5: #ifdef VERBOSE - //std::cout<< " counts " << ival << std::endl; + //std::cout<< " counts " << ival << std::endl; #endif - myMod->chanregs[ichip*nch+ichan]|=ival<<11; - break; - default: - std::cout<< " too many columns" << std::endl; - break; - } + myMod->chanregs[ichip*nch+ichan]|=ival<<11; + break; + default: + std::cout<< " too many columns" << std::endl; + break; } } - // } + } + // } } #ifdef VERBOSE std::cout<< "read " << ichan*ichip << " channels" <ndac; iarg++) { - getline(infile,str); - iline++; + case GOTTHARD: + //---------------dacs--------------- + for (int iarg=0; iargndac; iarg++) { + getline(infile,str); + iline++; #ifdef VERBOSE - std::cout<< str << std::endl; + std::cout<< str << std::endl; #endif - istringstream ssstr(str); - ssstr >> sargname >> ival; + istringstream ssstr(str); + ssstr >> sargname >> ival; #ifdef VERBOSE - std::cout<< sargname << " dac nr. " << idac << " is " << ival << std::endl; + std::cout<< sargname << " dac nr. " << idac << " is " << ival << std::endl; #endif - myMod->dacs[idac]=ival; - idac++; - } - break; + myMod->dacs[idac]=ival; + idac++; + } + break; - default: - std::cout<< "Unknown detector type - don't know how to read file" << myfname << std::endl; - infile.close(); - deleteModule(myMod); - return NULL; - - } - + default: + std::cout<< "Unknown detector type - don't know how to read file" << myfname << std::endl; infile.close(); - strcpy(settingsFile,fname.c_str()); - return myMod; - - } else { - std::cout<< "could not open settings file " << myfname << std::endl; - - if (nflag) - deleteModule(myMod); - + deleteModule(myMod); return NULL; + } + + infile.close(); + strcpy(settingsFile,fname.c_str()); + return myMod; + + } else { + std::cout<< "could not open settings file " << myfname << std::endl; + + if (nflag) + deleteModule(myMod); + + return NULL; + } };