From 025c6ae10f0d917b217a069c90c34c02acba90b3 Mon Sep 17 00:00:00 2001 From: bergamaschi Date: Fri, 11 Nov 2011 15:51:34 +0000 Subject: [PATCH] File name functions made (also) static git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@48 951219d9-93cf-4727-9268-0efd64621fa3 --- slsDetectorSoftware/doxy.config | 2 +- .../multiSlsDetector/multiSlsDetector.cpp | 2381 +++-------------- .../multiSlsDetector/multiSlsDetector.h | 790 +++--- .../slsDetector/slsDetector.cpp | 29 +- slsDetectorSoftware/slsDetector/slsDetector.h | 56 +- 5 files changed, 777 insertions(+), 2481 deletions(-) diff --git a/slsDetectorSoftware/doxy.config b/slsDetectorSoftware/doxy.config index 884bdc547..394cccd65 100644 --- a/slsDetectorSoftware/doxy.config +++ b/slsDetectorSoftware/doxy.config @@ -58,7 +58,7 @@ HIDE_UNDOC_CLASSES = NO HIDE_FRIEND_COMPOUNDS = NO -INPUT = slsDetector/slsDetector.h mythenDetector/mythenDetector.h eigerDetector/eigerDetector.h MySocketTCP/MySocketTCP.h usersFunctions/usersFunctions.h commonFiles/sls_detector_defs.h slsDetector/slsDetector.cpp MySocketTCP/MySocketTCP.cxx usersFunctions/usersFunctions.c +INPUT = slsDetector/slsDetector.h mythenDetector/mythenDetector.h eigerDetector/eigerDetector.h gotthardDetector/gotthardDetector.h MySocketTCP/MySocketTCP.h usersFunctions/usersFunctions.h multiSlsDetector/multiSlsDetector.h commonFiles/sls_detector_defs.h slsDetector/slsDetector.cpp MySocketTCP/MySocketTCP.cxx usersFunctions/usersFunctions.c multiSlsDetector/multiSlsDetector.cpp gotthardDetector/gotthardDetector.cpp OUTPUT_DIRECTORY = docs diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index aaaf990e6..90b893e7c 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -1,3 +1,15 @@ +/******************************************************************* + +Date: $Date$ +Revision: $Rev$ +Author: $Author$ +URL: $URL$ +ID: $Id$ + +********************************************************************/ + + + #include "multiSlsDetector.h" #include "usersFunctions.h" #include @@ -7,96 +19,153 @@ -int multiSlsDetector::freeSharedMemory(int i) { - int nd=nDetectors; - for (int id=0; idfreeSharedMemory(); - delete detectors[id]; - detectors[id]=NULL; - nDetectors--; - } - return OK; +int multiSlsDetector::freeSharedMemory() { + // Detach Memory address + 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; + } -multiSlsDetector::multiSlsDetector(detectorType type, int ndet, int id): nDetectors(0) -{ - for (int i=0; ialreadyExisting==0) { + + + thisMultiDetector->onlineFlag=ONLINE; + thisMultiDetector->numberOfDetectors=0; + for (int id=0; iddetectorIds[id]=-1; + } + thisMultiDetector->masterId=-1; + thisMultiDetector->dataBytes=0; + + thisMultiDetector->alreadyExisting=1; + } + + + for (int i=0; inumberOfDetectors; i++) { + detectors[i]=new slsDetector(thisMultiDetector->detectorIds[i]); + } + for (int i=thisMultiDetector->numberOfDetectors; inumberOfDetectors; - detectors[nDetectors]=new slsDetector(type,id); - if (detectors[nDetectors]) - nDetectors++; - return nDetectors; -} + if (pos<0) + pos=j; + if (pos>j) + return thisMultiDetector->numberOfDetectors; - -int multiSlsDetector::removeSlsDetector(int i) { - int imin=0, imax=nDetectors; - if (i>=0) { - imin=i; - imax=i; + for (int ip=thisMultiDetector->numberOfDetectors-1; ip>pos; ip--) { + thisMultiDetector->detectorIds[ip+1]=thisMultiDetector->detectorIds[ip]; + detectors[ip+1]=detectors[ip]; } - for (int j=imin; jnumberOfDetectors++; + thisMultiDetector->dataBytes+=detectors[pos]->getDataBytes(); - if (nDetectors<1) - return GET_ONLINE_FLAG; - if (i>=0) { - imin=i; - imax=i; - } + return thisMultiDetector->numberOfDetectors; - for (int j=imin; jsetOnline(off); - if (ret==GET_ONLINE_FLAG && err==0) - ret=ans; - if (ret!=ans) { - err=1; - ret=GET_ONLINE_FLAG; - } +} + + + +int multiSlsDetector::removeSlsDetector(int pos) { + int j, found=0; + + if (pos<0 ) + pos=thisMultiDetector->numberOfDetectors-1; + + if (pos>=thisMultiDetector->numberOfDetectors) + return thisMultiDetector->numberOfDetectors; + + j=pos; + + if (detectors[j]) { + delete detectors[j]; + thisMultiDetector->numberOfDetectors--; + + + + + for (int i=j+1; inumberOfDetectors+1; i++) { + detectors[i-1]=detectors[i]; + thisMultiDetector->detectorIds[i-1]=thisMultiDetector->detectorIds[i]; } + detectors[thisMultiDetector->numberOfDetectors]=NULL; + thisMultiDetector->detectorIds[thisMultiDetector->numberOfDetectors]=-1; } - return ret; -}; - - -int multiSlsDetector::exists(int id) { - - for (int i=0; igetId())==id) - return 1; - } - } - return 0; - + return thisMultiDetector->numberOfDetectors; } @@ -105,127 +174,196 @@ int multiSlsDetector::exists(int id) { + + int setMaster(int i=-1) { + if (i>=0 && inumberOfDetectors) + if (detectors[i]) + thisMultiDetector->masterPosition=i; + + switch (thisMultiDetector->syncMode) { + case MASTER_GATES: + for (int i=0; inumberOfDetectors; i++) { + if (i!=thisMultiDetector->masterPosition) { + if (detector[i]) { + detector[i]->setExternalSignalFlags(GATE_IN_ACTIVE_HIGH, 0); + detector[i]->setTimer(NUMBER_OF_GATES, 1); + detector[i]->setExternalSignalFlags(OFF, 1); + } + } else { + detector[i]->setExternalSignalFlags(GATE_OUT_ACTIVE_HIGH, 2); + } + } + break; + + case MASTER_TRIGGERS: + for (int i=0; inumberOfDetectors; i++) { + if (i!=thisMultiDetector->masterPosition) { + if (detector[i]) { + detector[i]->setExternalSignalFlags(OFF, 0); + detector[i]->setExternalSignalFlags(TRIGGER_IN_RISING_EDGE, 1); + } + } else { + detector[i]->setExternalSignalFlags(GATE_OUT_ACTIVE_HIGH, 2); + } + } + break; + + case SLAVE_STARTS_WHEN_MASTER_STOPS: + for (int i=0; inumberOfDetectors; i++) { + if (detector[i]) { + detector[i]->setExternalSignalFlags(OFF, 0); + detector[i]->setExternalSignalFlags(TRIGGER_IN_FALLING_EDGE, 1); + } + } else { + detector[i]->setExternalSignalFlags(GATE_OUT_ACTIVE_HIGH, 2); + } + } + break; + + + default: + for (int i=0; inumberOfDetectors; i++) { + if (detector[i]) { + detector[i]->setExternalSignalFlags(OFF, 0); + detector[i]->setExternalSignalFlags(OFF, 1); + } + } + + } + + + + return thisMultiDetector->masterPosition; + } + +// enum synchronyzationMode { +// GET_SYNHRONIZATION_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 */ +// } - - - - - - - - - - /* - configure the socket communication and check that the server exists - enum communicationProtocol{ - TCP, - UDP - }{}; - + + /** + Sets/gets the synchronization mode of the various detectors + \param sync syncronization mode + \returns current syncronization mode */ +synchronizationMode setSyncronization(synchronizationMode sync=GET_SYNHRONIZATION_MODE) { + if (sync>GET_SYNHRONIZATION_MODE) { + + + switch (sync) { + case MASTER_GATES: -int multiSlsDetector::setTCPSocket(int i, string const name, int const control_port, int const stop_port, int const data_port){ + if (thisMultiDetector->masterPosition>=0 && thisMultiDetector->masterPositionnumberOfDetectors) { + for (int i=0; inumberOfDetectors; i++) { + if (i!=thisMultiDetector->masterPosition) { + if (detector[i]) { + detector[i]->setExternalSignalFlags(GATE_IN_ACTIVE_HIGH, 0); + detector[i]->setTimer(NUMBER_OF_GATES, 1); + detector[i]->setExternalSignalFlags(OFF, 1); + } + } else { + detector[i]->setExternalSignalFlags(GATE_OUT_ACTIVE_HIGH, 2); + } + } + thisMultiDetector->syncMode=sync; + } + break; + + case MASTER_TRIGGERS: + if (thisMultiDetector->masterPosition>=0 && thisMultiDetector->masterPositionnumberOfDetectors) { + for (int i=0; inumberOfDetectors; i++) { + if (i!=thisMultiDetector->masterPosition) { + if (detector[i]) { + detector[i]->setExternalSignalFlags(OFF, 0); + detector[i]->setExternalSignalFlags(TRIGGER_IN_RISING_EDGE, 1); + } + } else { + detector[i]->setExternalSignalFlags(GATE_OUT_ACTIVE_HIGH, 2); + } + } + thisMultiDetector->syncMode=sync; + } + break; + + case SLAVE_STARTS_WHEN_MASTER_STOPS: + if (thisMultiDetector->masterPosition>=0 && thisMultiDetector->masterPositionnumberOfDetectors) { + for (int i=0; inumberOfDetectors; i++) { + if (detector[i]) { + detector[i]->setExternalSignalFlags(OFF, 0); + detector[i]->setExternalSignalFlags(TRIGGER_IN_FALLING_EDGE, 1); + } + } else { + detector[i]->setExternalSignalFlags(GATE_OUT_ACTIVE_HIGH, 2); + } + } + thisMultiDetector->syncMode=sync; + } + break; + + + default: + for (int i=0; inumberOfDetectors; i++) { + if (detector[i]) { + detector[i]->setExternalSignalFlags(OFF, 0); + detector[i]->setExternalSignalFlags(OFF, 1); + } + } + thisMultiDetector->syncMode=sync; + } + + return thisMultiDetector->syncMode; + +} + + + + + + + + + + + + + + + + + + + + + + + + + + + +int multiSlsDetector::setOnline(int off) { + + if (off!=GET_ONLINE_FLAG) { + thisMultiDetector->onlineFlag=off; + for (int i=0; inumberOfDetectors+1; i++) { + if (detectors[i]) + detectors[i]->setOnlineFlag(off); + } + return thisMultiDetector->onlineFlag; - if (i<0) - return FAIL; - if (detectors[i]) - return detectors[i]->setTCPSocket(name, control_port, stop_port, data_port); - else - return FAIL; }; - - -char* multiSlsDetector::getHostname(int i) { - if (i<0) - return NULL; - if (detectors[i]) - return detectors[i]->getHostname(); - else - return NULL; +int multiSlsDetector::exists() { + return thisMultiDetector->alreadyExisting; } -int multiSlsDetector::getControlPort(int i) { - - - int imin=0, imax=nDetectors; - int ret=-1, err=0; - if (i>=0) { - imin=i; - imax=i; - } - for (int j=imin; jgetControlPort(); - else if (detectors[j]->getControlPort()!=ret) { - ret=-1; - err=1; - } - } else { - ret=-1; - err=1; - } - } - return ret; -} - -int multiSlsDetector::getDataPort(int i) { - - int imin=0, imax=nDetectors; - int ret=-1, err=0; - if (i>=0) { - imin=i; - imax=i; - } - for (int j=imin; jgetDataPort(); - else if (detectors[j]->getDataPort()!=ret) { - ret=-1; - err=1; - } - } else { - ret=-1; - err=1; - } - } - return ret; - - - - -} - - -int multiSlsDetector::getStopPort(int i) { - - int imin=0, imax=nDetectors; - int ret=-1, err=0; - if (i>=0) { - imin=i; - imax=i; - } - for (int j=imin; jgetStopPort(); - else if (detectors[j]->getStopPort()!=ret) { - ret=-1; - err=1; - } - } else { - ret=-1; - err=1; - } - } - return ret; - -} /* I/O */ @@ -233,28 +371,24 @@ int multiSlsDetector::getStopPort(int i) { /* generates file name without extension*/ string multiSlsDetector::createFileName() { + return slsDetector::createFileName(thisMultiDetector->filePath, thisMultiDetector->fileName, thisMultiDetector->actionMask, currentScanVariable[0], thisMultiDetector->scanPrecision[0], currentScanVariable[1], thisMultiDetector->scanPrecision[1], currentPositionIndex, thisMultiDetector->numberOfPositions, thisMultiDetector->fileIndex); - string ret=string("error"), ans; - int err=0; - - for (int i=0; icreateFileName(); - else { - ans=string("error"); - err=1; - } - if (ret==string("error") && err==0) - ret=ans; - else if (ans!=ret) { - ret=string("error"); - err=1; - } - } - return ret; - } +/* I/O */ + + + +int multiSlsDetector::getFileIndexFromFileName(string fname) { + return slsDetector::getFileIndexFromFileName(fname); +} + +int multiSlsDetector::getVariablesFromFileName(string fname, int &index, int &p_index, float &sv0, float &sv1) { + return slsDetector::getVariablesFromFileName(fname, index, p_index, sv0, sv1); +} + + + @@ -284,1728 +418,90 @@ string multiSlsDetector::createFileName() { /* Communication to server */ - // General purpose functions - /* - executes a system command on the server - e.g. mount an nfs disk, reboot and returns answer etc. - */ -int multiSlsDetector::execCommand(string cmd, string answer){ - - char arg[MAX_STR_LENGTH], retval[MAX_STR_LENGTH]; - int fnum=F_EXEC_COMMAND; - - int ret=FAIL; - - strcpy(arg,cmd.c_str()); - -#ifdef VERBOSE - std::cout<< std::endl; - std::cout<< "Sending command " << arg << std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (controlSocket) { - if (controlSocket->Connect()>=0) { - if (controlSocket->SendDataOnly(&fnum,sizeof(fnum))>=0) { - if (controlSocket->SendDataOnly(arg,MAX_STR_LENGTH)>=0) { - if (controlSocket->ReceiveDataOnly(retval,MAX_STR_LENGTH)>=0) { - ret=OK; - answer=retval; - } - } - } - controlSocket->Disconnect(); - } - } -#ifdef VERBOSE - std::cout<< "Detector answer is " << answer << std::endl; -#endif - } - return ret; -}; - -// Detector configuration functions - - /* - the detector knows what type of detector it is - - enum detectorType{ - GET_DETECTOR_TYPE, - GENERIC, - MYTHEN, - PILATUS, - EIGER, - GOTTHARD, - AGIPD - }; - - */ -int multiSlsDetector::setDetectorType(detectorType const type){ - - int arg, retval=FAIL; - int fnum=F_GET_DETECTOR_TYPE; - arg=int(type); - detectorType retType=type; - char mess[100]; - strcpy(mess,"dummy"); - - -#ifdef VERBOSE - std::cout<< std::endl; - std::cout<< "Setting detector type to " << arg << std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - if (retval==OK) - controlSocket->ReceiveDataOnly(&retType,sizeof(retType)); - else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); - } - } - } else { - if (type==GET_DETECTOR_TYPE) - retType=thisDetector->myDetectorType; - else { - retType=type; - thisDetector->myDetectorType=type; - } - retval=OK; - } -#ifdef VERBOSE - std::cout<< "Detector type set to " << retType << std::endl; -#endif - if (retval==FAIL) { - std::cout<< "Set detector type failed " << std::endl; - retType=GENERIC; - } - else - thisDetector->myDetectorType=retType; - - - return retType; -}; - -int multiSlsDetector::setDetectorType(string const type){ - detectorType dtype=GENERIC; - if (type=="Mythen") - dtype=MYTHEN; - else if (type=="Pilatus") - dtype=PILATUS; - else if (type=="Eiger") - dtype=EIGER; - else if (type=="Gotthard") - dtype=GOTTHARD; - else if (type=="Agipd") - dtype=AGIPD; - return setDetectorType(dtype); -}; - -void multiSlsDetector::getDetectorType(char *type){ - - switch (thisDetector->myDetectorType) { - case MYTHEN: - strcpy(type,"Mythen"); - break; - case PILATUS: - strcpy(type,"Pilatus"); - break; - case EIGER: - strcpy(type,"Eiger"); - break; - case GOTTHARD: - strcpy(type,"Gotthard"); - break; - case AGIPD: - strcpy(type,"Agipd"); - break; - default: - strcpy(type,"Unknown"); - break; - } -}; - - - - - /* needed to set/get the size of the detector */ -// if n=GET_FLAG returns the number of installed modules, -int multiSlsDetector::setNumberOfModules(int n, dimension d){ - - int arg[2], retval; - int fnum=F_SET_NUMBER_OF_MODULES; - int ret=FAIL; - char mess[100]; - - - arg[0]=d; - arg[1]=n; - - - if (dY) { - std::cout<< "Set number of modules in wrong dimension " << d << std::endl; - return ret; - } - - -#ifdef VERBOSE - std::cout<< std::endl; - std::cout<< "Setting number of modules of dimension "<< d << " to " << n << std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&arg,sizeof(arg)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==OK) - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Deterctor returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); - } - } - } else { - ret=OK; - if (n==GET_FLAG) - ; - else { - if (n<=0 || n>thisDetector->nModMax[d]) { - ret=FAIL; - } else { - thisDetector->nMod[d]=n; - } - } - retval=thisDetector->nMod[d]; - } -#ifdef VERBOSE - 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]; - 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; - } - -#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; -#endif - } - return thisDetector->nMod[d]; -}; - - - - -int multiSlsDetector::getMaxNumberOfModules(dimension d){ - - int retval; - int fnum=F_GET_MAX_NUMBER_OF_MODULES; - int ret=FAIL; - char mess[100]; - - if (dY) { - std::cout<< "Get max number of modules in wrong dimension " << d << std::endl; - return ret; - } -#ifdef VERBOSE - std::cout<< std::endl; - std::cout<< "Getting max number of modules in dimension "<< d <onlineFlag==ONLINE_FLAG) { - if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&d,sizeof(d)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==OK) - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Deterctor returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); - } - } - } else { - ret=OK; - retval=thisDetector->nModMax[d]; - } -#ifdef VERBOSE - 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]; -}; - - - - /* - This function is used to set the polarity and meaning of the digital I/O signals (signal index) - -enum externalSignalFlag { - GET_EXTERNAL_SIGNAL_FLAG, - SIGNAL_OFF, - GATE_ACTIVE_HIGH, - GATE_ACTIVE_LOW, - TRIGGER_RISING_EDGE, - TRIGGER_FALLING_EDGE -}{}; - */ - - externalSignalFlag multiSlsDetector::setExternalSignalFlags(externalSignalFlag pol, int signalindex){ - - - - - int arg[2]; - externalSignalFlag retval; - int ret=FAIL; - int fnum=F_SET_EXTERNAL_SIGNAL_FLAG; - char mess[100]; - - arg[0]=signalindex; - arg[1]=pol; - - retval=GET_EXTERNAL_SIGNAL_FLAG; - -#ifdef VERBOSE - std::cout<< std::endl; - std::cout<< "Setting signal "<< signalindex << " to flag" << pol << std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&arg,sizeof(arg)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==OK) - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); - } - } - } else { - retval=GET_EXTERNAL_SIGNAL_FLAG; - ret=FAIL; - } -#ifdef VERBOSE - std::cout<< "Signal "<< signalindex << " flag set to" << retval << std::endl; - if (ret==FAIL) { - std::cout<< "Set signal flag failed " << std::endl; - } -#endif - return retval; - - - - - - -}; - - /* - 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 -}; - - */ - - externalCommunicationMode multiSlsDetector::setExternalCommunicationMode( externalCommunicationMode pol){ - - - - - int arg[1]; - externalCommunicationMode retval; - int fnum=F_SET_EXTERNAL_COMMUNICATION_MODE; - char mess[100]; - - arg[0]=pol; - - int ret=FAIL; - retval=GET_EXTERNAL_COMMUNICATION_MODE; - -#ifdef VERBOSE - std::cout<< std::endl; - std::cout<< "Setting communication to mode " << pol << std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&arg,sizeof(arg)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==OK) - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); - } - } - } else { - retval=GET_EXTERNAL_COMMUNICATION_MODE; - ret=FAIL; - } -#ifdef VERBOSE - std::cout<< "Communication mode "<< " set to" << retval << std::endl; -#endif - if (ret==FAIL) { - std::cout<< "Setting communication mode failed" << std::endl; - } - return retval; - -}; - - - // Tests and identification - /* - Gets versions - - enum idMode{ - MODULE_SERIAL_NUMBER, - MODULE_FIRMWARE_VERSION, - DETECTOR_SERIAL_NUMBER, - DETECTOR_FIRMWARE_VERSION, - DETECTOR_SOFTWARE_VERSION - }{}; - - */ - - - - - -int64_t multiSlsDetector::getId( idMode mode, int imod){ - - - int64_t retval=-1; - int fnum=F_GET_ID; - int ret=FAIL; - - char mess[100]; - -#ifdef VERBOSE - std::cout<< std::endl; - if (mode==MODULE_SERIAL_NUMBER) - std::cout<< "Getting id of "<< imod << std::endl; - else - std::cout<< "Getting id type "<< mode << std::endl; -#endif - if (mode==THIS_SOFTWARE_VERSION) { - ret=OK; - retval=thisSoftwareVersion; - } else { - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&mode,sizeof(mode)); - if (mode==MODULE_SERIAL_NUMBER) - controlSocket->SendDataOnly(&imod,sizeof(imod)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==OK) - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); - } else - ret=FAIL; - } else { - ret=FAIL; - } - } - } - if (ret==FAIL) { - std::cout<< "Get id failed " << std::endl; - return ret; - } else { -#ifdef VERBOSE - if (mode==MODULE_SERIAL_NUMBER) - std::cout<< "Id of "<< imod <<" is " << hex <onlineFlag==ONLINE_FLAG) { - - - if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&mode,sizeof(mode)); - if (mode==CHIP_TEST) - controlSocket->SendDataOnly(&imod,sizeof(imod)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==OK) - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); - } - } - } else { - ret=FAIL; - } -#ifdef VERBOSE - std::cout<< "Id "<< mode <<" is " << retval << std::endl; -#endif - if (ret==FAIL) { - std::cout<< "Get id failed " << std::endl; - return ret; - } else - return retval; -}; - - - - /* - analog test of the modules - enum analogTestMode { - COUNT_CALIBRATION_PULSES, - I_DON_T_KNOW - }{}; - - */ -/* -int* multiSlsDetector::analogTest(analogTestMode mode){ - std::cout<< "function not yet implemented " << std::endl; -}; -*/ - /* - enable analog output of channel - */ -/* -int multiSlsDetector::enableAnalogOutput(int ichan){ - int imod=ichan/(nChans*nChips); - ichan-=imod*(nChans*nChips); - int ichip=ichan/nChans; - ichan-=ichip*(nChans); - enableAnalogOutput(imod,ichip,ichan); - -}; -int multiSlsDetector::enableAnalogOutput(int imod, int ichip, int ichan){ - std::cout<< "function not yet implemented " << std::endl; -}; -*/ - /* - give a train of calibration pulses - */ -/* -int multiSlsDetector::giveCalibrationPulse(float vcal, int npulses){ - std::cout<< "function not yet implemented " << std::endl; -}; -*/ - // Expert low level functions - - - - /* write or read register */ - -int multiSlsDetector::writeRegister(int addr, int val){ - - - int retval; - int fnum=F_WRITE_REGISTER; - int ret=FAIL; - - char mess[100]; - - int arg[2]; - arg[0]=addr; - arg[1]=val; - - -#ifdef VERBOSE - std::cout<< std::endl; - std::cout<< "Writing to register "<< addr << " data " << val << std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(arg,sizeof(arg)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==OK) - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); - } - } - } -#ifdef VERBOSE - std::cout<< "Register returned "<< retval << std::endl; -#endif - if (ret==FAIL) { - std::cout<< "Write to register failed " << std::endl; - } - return retval; - -}; - - - - -int multiSlsDetector::readRegister(int addr){ - - - int retval; - int fnum=F_READ_REGISTER; - int ret=FAIL; - - char mess[100]; - - int arg; - arg=addr; - - -#ifdef VERBOSE - std::cout<< std::endl; - std::cout<< "Reding register "<< addr << std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&arg,sizeof(arg)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==OK) - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); - } - } - } -#ifdef VERBOSE - std::cout<< "Register returned "<< retval << std::endl; -#endif - if (ret==FAIL) { - std::cout<< "Read register failed " << std::endl; - } - return retval; - -}; - - - // Expert initialization functions - /* - set dacs or read ADC for the module - enum dacIndex { - TRIMBIT_SIZE, - THRESHOLD, - SHAPER1, - SHAPER2, - CALIBRATION_PULSE, - PREAMP, - TEMPERATURE, - HUMIDITY, - DETECTOR_BIAS -}{}; - */ - - -float multiSlsDetector::setDAC(float val, dacIndex index, int imod){ - - - float retval; - int fnum=F_SET_DAC; - int ret=FAIL; - char mess[100]; - int arg[2]; - arg[0]=index; - arg[1]=imod; - -#ifdef VERBOSE - std::cout<< std::endl; - std::cout<< "Setting DAC/POT "<< index << "of module " << imod << " to " << val << std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(arg,sizeof(arg)); - controlSocket->SendDataOnly(&val,sizeof(val)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==OK) { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - if (index < thisDetector->nDacs){ - - if (dacs) { - if (imod>=0) { - *(dacs+index+imod*thisDetector->nDacs)=retval; - } - else { - for (imod=0; imodnModsMax; imod++) - *(dacs+index+imod*thisDetector->nDacs)=retval; - } - } - } - } else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); - } - - } - } -#ifdef VERBOSE - std::cout<< "Dac/Pot set to "<< retval << std::endl; -#endif - if (ret==FAIL) { - std::cout<< "Set dac/pot failed " << std::endl; - } - return retval; - - - -}; - - -float multiSlsDetector::getADC(dacIndex index, int imod){ - - float retval; - int fnum=F_GET_ADC; - int ret=FAIL; - char mess[100]; - - int arg[2]; - arg[0]=index; - arg[1]=imod; - - - -#ifdef VERBOSE - std::cout<< std::endl; - std::cout<< "Getting ADC "<< index << "of module " << imod << std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(arg,sizeof(arg)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==OK) { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - if (adcs) { - *(adcs+index+imod*thisDetector->nAdcs)=retval; - } - } else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); - } - } - } -#ifdef VERBOSE - std::cout<< "ADC returned "<< retval << std::endl; -#endif - if (ret==FAIL) { - std::cout<< "Get ADC failed " << std::endl; - } - return retval; - - - -}; - - /* - configure single channel - enum channelRegisterBit { - COMPARATOR_ENABLE_OFF, - ANALOG_SIGNAL_ENABLE_OFF, - CALIBRATION_ENABLE_OFF, - TRIMBIT_OFF // should always be the last! - } - - */ - -int multiSlsDetector::setChannel(int64_t reg, int ichan, int ichip, int imod){ - sls_detector_channel myChan; -#ifdef VERBOSE - std::cout<< "Setting channel "<< ichan << " " << ichip << " " << imod << " to " << reg << std::endl; -#endif - //int mmin=imod, mmax=imod+1, chimin=ichip, chimax=ichip+1, chamin=ichan, chamax=ichan+1; - - int ret; - - /* if (imod==-1) { - mmin=0; - mmax=thisDetector->nModsMax; - } - - if (ichip==-1) { - chimin=0; - chimax=thisDetector->nChips; - } - - 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); - - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==OK) { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - } else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); - } - } - } - - - if (ret==OK) { - if (chanregs) { - -int mmin=imod, mmax=imod+1, chimin=ichip, chimax=ichip+1, chamin=ichan, chamax=ichan+1; - - if (imod==-1) { - mmin=0; - mmax=thisDetector->nModsMax; - } - - if (ichip==-1) { - chimin=0; - chimax=thisDetector->nChips; - } - - if (ichan==-1) { - chamin=0; - chamax=thisDetector->nChans; - } - - - - - - - for (int im=mmin; imnChans*thisDetector->nChips+ichi*thisDetector->nChips+icha)=retval; - - } - } -} - - } - } -#ifdef VERBOSE - std::cout<< "Channel register returned "<< retval << std::endl; -#endif - return retval; - -} - - sls_detector_channel multiSlsDetector::getChannel(int ichan, int ichip, int imod){ - - - int fnum=F_GET_CHANNEL; - sls_detector_channel myChan; - int arg[3]; - int ret=FAIL; - char mess[100]; - arg[0]=ichan; - arg[1]=ichip; - arg[2]=imod; - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(arg,sizeof(arg)); - - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==OK) { - receiveChannel(&myChan); - } else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); - } - } - } - - - if (ret==OK) { - if (chanregs) { - *(chanregs+imod*thisDetector->nChans*thisDetector->nChips+ichip*thisDetector->nChips+ichan)=myChan.reg; - } - } - -#ifdef VERBOSE - std::cout<< "Returned channel "<< ichan << " " << ichip << " " << imod << " " << myChan.reg << std::endl; -#endif - return myChan; -} - - /* - configure chip - enum chipRegisterBit { - ENABLE_ANALOG_OUTPUT, - OUTPUT_WIDTH // should always be the last - }{}; - */ -int multiSlsDetector::setChip(int reg, int ichip, int imod){ - sls_detector_chip myChip; - -#ifdef VERBOSE - std::cout<< "Setting chip "<< ichip << " " << imod << " to " << reg << std::endl; -#endif - - - int chregs[thisDetector->nChans]; - int mmin=imod, mmax=imod+1, chimin=ichip, chimax=ichip+1; - int ret=FAIL; - if (imod==-1) { - mmin=0; - mmax=thisDetector->nModsMax; - } - - if (ichip==-1) { - chimin=0; - chimax=thisDetector->nChips; - } - - myChip.nchan=thisDetector->nChans; - myChip.reg=reg; - for (int im=mmin; imnChans+im*thisDetector->nChans*thisDetector->nChips); - else { - for (int i=0; inChans; i++) - chregs[i]=-1; - myChip.chanregs=chregs; - } - ret=setChip(myChip); - } - } - return ret; -} - -int multiSlsDetector::setChip(sls_detector_chip chip){ - - int fnum=F_SET_CHIP; - int retval; - int ret=FAIL; - char mess[100]; - - int ichi=chip.chip; - int im=chip.module; - - - - - - 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==OK) { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - } else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); - } - } - } - - - if (ret==OK) { - if (chipregs) - *(chipregs+ichi+im*thisDetector->nChips)=retval; - } - -#ifdef VERBOSE - std::cout<< "Chip register returned "<< retval << std::endl; -#endif - return retval; -}; - - - sls_detector_chip multiSlsDetector::getChip(int ichip, int imod){ - - int fnum=F_GET_CHIP; - sls_detector_chip myChip; - int chanreg[thisDetector->nChans]; - - int ret=FAIL; - char mess[100]; - - - myChip.chip=ichip; - myChip.module=imod; - myChip.nchan=thisDetector->nChans; - myChip.chanregs=chanreg; - - int arg[2]; - arg[0]=ichip; - arg[1]=imod; - - - - - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(arg,sizeof(arg)); - - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==OK) { - receiveChip(&myChip); - } else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); - } - } - } - - - if (ret==OK) { - if (chipregs) - *(chipregs+ichip+imod*thisDetector->nChips)=myChip.reg; - if (chanregs) { - for (int ichan=0; ichannChans; ichan++) - *(chanregs+imod*thisDetector->nChans*thisDetector->nChips+ichip*thisDetector->nChans+ichan)=*((myChip.chanregs)+ichan); - } - } -#ifdef VERBOSE - std::cout<< "Returned chip "<< ichip << " " << imod << " " << myChip.reg << std::endl; -#endif - - return myChip; -}; - - /* - configure module - enum moduleRegisterBit { - I_DON_T_KNOW, - OUTPUT_WIDTH // should always be the last - }{}; - */ - -int multiSlsDetector::setModule(int reg, int imod){ - sls_detector_module myModule; - -#ifdef VERBOSE - std::cout << "slsDetector set module " << std::endl; -#endif - int charegs[thisDetector->nChans*thisDetector->nChips]; - int chiregs[thisDetector->nChips]; - float das[thisDetector->nDacs], ads[thisDetector->nAdcs]; - int mmin=imod, mmax=imod+1; - int ret=FAIL; - - if (imod==-1) { - mmin=0; - mmax=thisDetector->nModsMax; - } - - - - for (int im=mmin; imnChans; - myModule.nchip=thisDetector->nChips; - myModule.ndac=thisDetector->nDacs; - myModule.nadc=thisDetector->nAdcs; - - myModule.reg=reg; - if (detectorModules) { - myModule.gain=(detectorModules+im)->gain; - myModule.offset=(detectorModules+im)->offset; - myModule.serialnumber=(detectorModules+im)->serialnumber; - } else { - myModule.gain=-1; - myModule.offset=-1; - myModule.serialnumber=-1; - } - - - for (int i=0; inAdcs; i++) - ads[i]=-1; - - if (chanregs) - myModule.chanregs=chanregs+im*thisDetector->nChips*thisDetector->nChans; - else { - for (int i=0; inChans*thisDetector->nChips; i++) - charegs[i]=-1; - myModule.chanregs=charegs; - } - if (chipregs) - myModule.chipregs=chanregs+im*thisDetector->nChips; - else { - for (int ichip=0; ichipnChips; ichip++) - chiregs[ichip]=-1; - myModule.chipregs=chiregs; - } - if (dacs) - myModule.dacs=dacs+im*thisDetector->nDacs; - else { - for (int i=0; inDacs; i++) - das[i]=-1; - myModule.dacs=das; - } - if (adcs) - myModule.adcs=adcs+im*thisDetector->nAdcs; - else { - for (int i=0; inAdcs; i++) - ads[i]=-1; - myModule.adcs=ads; - } - ret=setModule(myModule); - } - return ret; - - -}; - - - -int multiSlsDetector::setModule(sls_detector_module module){ - - - int fnum=F_SET_MODULE; - int retval; - int ret=FAIL; - char mess[100]; - - int imod=module.module; - - - -#ifdef VERBOSE - 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==OK) { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - } else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); - } - } - } - - - if (ret==OK) { - if (detectorModules) { - if (imod>=0 && imodnMod[X]*thisDetector->nMod[Y]) { - (detectorModules+imod)->nchan=module.nchan; - (detectorModules+imod)->nchip=module.nchip; - (detectorModules+imod)->ndac=module.ndac; - (detectorModules+imod)->nadc=module.nadc; - thisDetector->nChips=module.nchip; - thisDetector->nChans=module.nchan/module.nchip; - thisDetector->nDacs=module.ndac; - thisDetector->nAdcs=module.nadc; - - for (int ichip=0; ichipnChips; ichip++) { - if (chipregs) - chipregs[ichip+thisDetector->nChips*imod]=module.chipregs[ichip]; - - if (chanregs) { - for (int i=0; inChans; i++) { - chanregs[i+ichip*thisDetector->nChans+thisDetector->nChips*thisDetector->nChans*imod]=module.chanregs[ichip*thisDetector->nChans+i]; - } - } - } - if (dacs) { - for (int i=0; inDacs; i++) - dacs[i+imod*thisDetector->nDacs]=module.dacs[i]; - } - if (adcs) { - for (int i=0; inAdcs; i++) - adcs[i+imod*thisDetector->nAdcs]=module.adcs[i]; - } - - (detectorModules+imod)->gain=module.gain; - (detectorModules+imod)->offset=module.offset; - (detectorModules+imod)->serialnumber=module.serialnumber; - (detectorModules+imod)->reg=module.reg; - } - } - } - -#ifdef VERBOSE - std::cout<< "Module register returned "<< retval << std::endl; -#endif - - return retval; -}; - -sls_detector_module *multiSlsDetector::getModule(int imod){ - -#ifdef VERBOSE - std::cout << "slsDetector get module " << std::endl; -#endif - - int fnum=F_GET_MODULE; - sls_detector_module *myMod=createModule(); - - - //char *ptr, *goff=(char*)thisDetector; - - // int chanreg[thisDetector->nChans*thisDetector->nChips]; - //int chipreg[thisDetector->nChips]; - //float dac[thisDetector->nDacs], adc[thisDetector->nAdcs]; - - int ret=FAIL; - char mess[100]; - // int n; - -#ifdef VERBOSE - std::cout<< "getting module " << imod << std::endl; -#endif - - myMod->module=imod; - // myMod.nchan=thisDetector->nChans*thisDetector->nChips; - //myMod.chanregs=chanreg; - //myMod.nchip=thisDetector->nChips; - //myMod.chipregs=chipreg; - //myMod.ndac=thisDetector->nDacs; - //myMod.dacs=dac; - //myMod.ndac=thisDetector->nAdcs; - //myMod.dacs=adc; - - - - - - - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&imod,sizeof(imod)); - - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==OK) { - receiveModule(myMod); - } else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); - } - } - } - - - if (ret==OK) { - if (detectorModules) { - if (imod>=0 && imodnMod[X]*thisDetector->nMod[Y]) { - (detectorModules+imod)->nchan=myMod->nchan; - (detectorModules+imod)->nchip=myMod->nchip; - (detectorModules+imod)->ndac=myMod->ndac; - (detectorModules+imod)->nadc=myMod->nadc; - thisDetector->nChips=myMod->nchip; - thisDetector->nChans=myMod->nchan/myMod->nchip; - thisDetector->nDacs=myMod->ndac; - thisDetector->nAdcs=myMod->nadc; - - for (int ichip=0; ichipnChips; ichip++) { - if (chipregs) - chipregs[ichip+thisDetector->nChips*imod]=myMod->chipregs[ichip]; - - if (chanregs) { - for (int i=0; inChans; i++) { - chanregs[i+ichip*thisDetector->nChans+thisDetector->nChips*thisDetector->nChans*imod]=myMod->chanregs[ichip*thisDetector->nChans+i]; - } - } - } - if (dacs) { - for (int i=0; inDacs; i++) - dacs[i+imod*thisDetector->nDacs]=myMod->dacs[i]; - } - if (adcs) { - for (int i=0; inAdcs; i++) - adcs[i+imod*thisDetector->nAdcs]=myMod->adcs[i]; - } - - (detectorModules+imod)->gain=myMod->gain; - (detectorModules+imod)->offset=myMod->offset; - (detectorModules+imod)->serialnumber=myMod->serialnumber; - (detectorModules+imod)->reg=myMod->reg; - } - } - } else { - deleteModule(myMod); - myMod=NULL; - } - - return myMod; -} - - - - - // calibration functions -/* - really needed? - -int multiSlsDetector::setCalibration(int imod, detectorSettings isettings, float gain, float offset){ - std::cout<< "function not yet implemented " << std::endl; - - - - return OK; - -} -int multiSlsDetector::getCalibration(int imod, detectorSettings isettings, float &gain, float &offset){ - - std::cout<< "function not yet implemented " << std::endl; - - - -} -*/ - - /* - calibrated setup of the threshold - */ - -int multiSlsDetector::getThresholdEnergy(int imod){ - - int fnum= F_GET_THRESHOLD_ENERGY; - int retval; - int ret=FAIL; - char mess[100]; -#ifdef VERBOSE - std::cout<< "Getting threshold energy "<< std::endl; -#endif - - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&imod,sizeof(imod)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=OK) { - std::cout<< "Detector returned error: "<< std::endl; - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< mess << std::endl; - } else { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - thisDetector->currentThresholdEV=retval; - } - controlSocket->Disconnect(); - } - } - } - return thisDetector->currentThresholdEV; -}; - -int multiSlsDetector::setThresholdEnergy(int e_eV, int imod, detectorSettings isettings){ - - int fnum= F_SET_THRESHOLD_ENERGY; - int retval; - int ret=FAIL; - char mess[100]; -#ifdef VERBOSE - std::cout<< "Getting threshold energy "<< std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&e_eV,sizeof(e_eV)); - controlSocket->SendDataOnly(&imod,sizeof(imod)); - controlSocket->SendDataOnly(&isettings,sizeof(isettings)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=OK) { - std::cout<< "Detector returned error: "<< std::endl; - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< mess << std::endl; - } else { -#ifdef VERBOSE - std::cout<< "Detector returned OK "<< std::endl; -#endif - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - thisDetector->currentThresholdEV=retval; - } - controlSocket->Disconnect(); - } - } - } else { - thisDetector->currentThresholdEV=e_eV; - } - return thisDetector->currentThresholdEV; -}; - - /* - select detector settings - */ - detectorSettings multiSlsDetector::getSettings(int imod){ - - - int fnum=F_SET_SETTINGS; - int ret=FAIL; - char mess[100]; - int retval; - int arg[2]; - arg[0]=GET_SETTINGS; - arg[1]=imod; -#ifdef VERBOSE - std::cout<< "Getting settings "<< std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(arg,sizeof(arg)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=OK) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } else{ - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - thisDetector->currentSettings=(detectorSettings)retval; -#ifdef VERBOSE - std::cout<< "Settings are "<< retval << std::endl; -#endif - } - controlSocket->Disconnect(); - } - } - } - return thisDetector->currentSettings; - -}; - - detectorSettings multiSlsDetector::setSettings( detectorSettings isettings, int imod){ -#ifdef VERBOSE - std::cout<< "slsDetector setSettings "<< std::endl; -#endif - sls_detector_module *myMod=createModule(); - int modmi=imod, modma=imod+1, im=imod; - string trimfname, calfname; - string ssettings; - - if (isettings>=STANDARD && isettings<=HIGHGAIN) { - switch (isettings) { - case STANDARD: - ssettings="/standard"; - thisDetector->currentSettings=STANDARD; - break; - case FAST: - ssettings="/fast"; - thisDetector->currentSettings=FAST; - break; - case HIGHGAIN: - ssettings="/highgain"; - thisDetector->currentSettings=HIGHGAIN; - break; - default: - std::cout<< "Unknown settings!" << std::endl; - } - - if (imod<0) { - modmi=0; - // modma=thisDetector->nModMax[X]*thisDetector->nModMax[Y]; - modma=thisDetector->nMod[X]*thisDetector->nMod[Y]; - } - - for (im=modmi; immodule=im; - //create file names - ostfn << thisDetector->trimDir << ssettings <<"/noise.sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10); - oscfn << thisDetector->calDir << ssettings << "/calibration.sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10); - // - trimfname=ostfn.str(); -#ifdef VERBOSE - cout << trimfname << endl; -#endif - if (readTrimFile(trimfname,myMod)) { - calfname=oscfn.str(); -#ifdef VERBOSE - cout << calfname << endl; -#endif - readCalibrationFile(calfname,myMod->gain, myMod->offset); - setModule(*myMod); - } else { - ostringstream ostfn,oscfn; - ostfn << thisDetector->trimDir << ssettings << ssettings << ".trim"; - oscfn << thisDetector->calDir << ssettings << ssettings << ".cal"; - calfname=oscfn.str(); - trimfname=ostfn.str(); -#ifdef VERBOSE - cout << trimfname << endl; - cout << calfname << endl; -#endif - if (readTrimFile(trimfname,myMod)) { - calfname=oscfn.str(); - readCalibrationFile(calfname,myMod->gain, myMod->offset); - setModule(*myMod); - } - } - } - } - deleteModule(myMod); - if (thisDetector->correctionMask&(1<-1 && isett<3) { - thisDetector->tDead=t[isett]; - } - } - - - return getSettings(imod); -}; // Acquisition functions /* change these funcs accepting also ok/fail */ int multiSlsDetector::startAcquisition(){ - - - int fnum=F_START_ACQUISITION; - int ret=FAIL; - char mess[100]; - -#ifdef VERBOSE - std::cout<< "Starting acquisition "<< std::endl; -#endif - thisDetector->stoppedFlag=0; - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=OK) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); + + int i=0; + int ret=OK, ret1=OK; + for (i=0; inumberOfDetectors; i++) { + if (i!=thisMultiDetector->masterPosition) + if (detectors[i]) { + ret=detectors[i]->startAcquisition(); + if (ret!=OK) + ret1=FAIL; } + } + i=thisMultiDetector->masterPosition; + if (thisMultiDetector->masterPosition>=0) { + if (detectors[i]) { + ret=detectors[i]->startAcquisition(); + if (ret!=OK) + ret1=FAIL; } } - return ret; - - - + return ret1; + }; + + + + int multiSlsDetector::stopAcquisition(){ - - int fnum=F_STOP_ACQUISITION; - int ret=FAIL; - char mess[100]; - -#ifdef VERBOSE - std::cout<< "Stopping acquisition "<< std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (stopSocket) { - if (stopSocket->Connect()>=0) { - stopSocket->SendDataOnly(&fnum,sizeof(fnum)); - stopSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=OK) { - stopSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - stopSocket->Disconnect(); - } + int i=0; + int ret=OK, ret1=OK; + + i=thisMultiDetector->masterPosition; + if (thisMultiDetector->masterPosition>=0) { + if (detectors[i]) { + ret=detectors[i]->stopAcquisition(); + if (ret!=OK) + ret1=FAIL; } } - thisDetector->stoppedFlag=1; - return ret; + for (i=0; inumberOfDetectors; i++) { + if (detectors[i]) { + ret=detectors[i]->startAcquisition(); + if (ret!=OK) + ret1=FAIL; + } + } + return ret1; }; int multiSlsDetector::startReadOut(){ - int fnum=F_START_READOUT; - int ret=FAIL; - char mess[100]; + int i=0; + int ret=OK, ret1=OK; + i=thisMultiDetector->masterPosition; + if (i>=0) + if (detectors[i]) { + ret=detectors[i]->startReadOut(); + if (ret!=OK) + ret1=FAIL; + } + } + for (i=0; inumberOfDetectors; i++) { + if (detectors[i]) { + ret=detectors[i]->startReadOut(); + if (ret!=OK) + ret1=FAIL; + } + } + + return ret1; + -#ifdef VERBOSE - std::cout<< "Starting readout "<< std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=OK) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - controlSocket->Disconnect(); - } - } - } - return ret; }; -/*int multiSlsDetector::getRunStatus(){ - int fnum=F_GET_RUN_STATUS; - int retval; - int ret=FAIL; - char mess[100]; -#ifdef VERBOSE - std::cout<< "Getting status "<< std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=OK) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } else - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - controlSocket->Disconnect(); - } - } - } - return retval; - - -}; -*/ int* multiSlsDetector::readFrame(){ @@ -2298,44 +794,6 @@ int64_t multiSlsDetector::setTimer(timerIndex index, int64_t t){ -int multiSlsDetector::setTotalProgress() { - - int nf=1, npos=1, nscan[MAX_SCAN_LEVELS]={1,1}, nc=1; - - if (thisDetector->timerValue[FRAME_NUMBER]) - nf=thisDetector->timerValue[FRAME_NUMBER]; - - if (thisDetector->timerValue[CYCLES_NUMBER]>0) - nc=thisDetector->timerValue[CYCLES_NUMBER]; - - if (thisDetector->numberOfPositions>0) - npos=thisDetector->numberOfPositions; - - 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]; - - thisDetector->totalProgress=nf*nc*npos*nscan[0]*nscan[1]; - -#ifdef VERBOSE - cout << "nc " << nc << 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; -#endif - return thisDetector->totalProgress; -} - - -float multiSlsDetector::getCurrentProgress() { - - return 100.*((float)thisDetector->progressIndex)/((float)thisDetector->totalProgress); -} @@ -2351,61 +809,6 @@ float multiSlsDetector::getCurrentProgress() { -/* - important speed parameters - -enum speedVariable { - CLOCK_DIVIDER, - WAIT_STATES, - SET_SIGNAL_LENGTH -}; -*/ - -int multiSlsDetector::setSpeed(speedVariable sp, int value) { - - - int fnum=F_SET_SPEED; - int retval=-1; - char mess[100]; - int ret=OK; - int n=0; -#ifdef VERBOSE - std::cout<< "Setting speed variable"<< sp << " to " << value << std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (controlSocket) { - if (controlSocket->Connect()>=0) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&sp,sizeof(sp)); - n=controlSocket->SendDataOnly(&value,sizeof(value)); -#ifdef VERBOSE - std::cout<< "Sent "<< n << " bytes " << std::endl; -#endif - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=OK) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } else { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - } - controlSocket->Disconnect(); - } - } - } -#ifdef VERBOSE - std::cout<< "Speed set to "<< retval << std::endl; -#endif - return retval; - -} - - - - - - - - diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h index e8e65e511..b4cb412b5 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h @@ -1,3 +1,12 @@ +/******************************************************************* + +Date: $Date$ +Revision: $Rev$ +Author: $Author$ +URL: $URL$ +ID: $Id$ + +********************************************************************/ @@ -10,46 +19,120 @@ //using namespace std; -/** - \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 \sa MySocketTCP slsDetector - \li the possibility of using a Qt-based graphical user interface (with eventually root analisys capabilities) - \li the possibility of runnin alla 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 \sa slsDetector::sharedSlsDetector - \section howto_sec How to use it - The best way to operate the slsDetectors is to use the software (text client or GUI) developed by the sls detectors group. -In case you need to embed the detector control in a previously existing software, compile these classes using
-make package -
-and link the shared library created to your software bin/libSlsDetector.so.1.0.1 -Then in your software you should use the class related to the detector you want to control (mythenDetector or eigerDetector). - - @author Anna Bergamaschi - -*/ /** * * -@libdoc The slsDetector class is expected to become the interface class for all SLS Detectors acquisition (and analysis) software. +@libdoc The multiSlsDetector class is used to operate several slsDetectors in parallel. * - * @short This is the base class for all SLS detector functionalities + * @short This is the base class for multi detector system functionalities * @author Anna Bergamaschi * @version 0.1alpha - */ -class multiSlsDetector : public slsDetector { +class multiSlsDetector { + + + + typedef struct sharedMultiSlsDetector { + /** 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; + /** 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; + + + /** Number of detectors operated at once */ + int numberOfDetectors; + + /** Ids of the detectors to be operated at once */ + int detectorIds[MAXDET]; + + /** id of the master detector */ + int masterPosition; + + /** type of synchronization between detectors */ + synchronizationMode syncMode; + + /** size of the data that are transfered from all detectors */ + int dataBytes; + + + + + + /** 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 */ + int totalProgress; + /** current index of the output file */ + int fileIndex; + /** path of the output files */ + char filePath[MAX_STR_LENGTH]; + /** name root of the output files */ + char fileName[MAX_STR_LENGTH]; + + + /** 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; + /** dead time (in ns) for rate corrections */ + float 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]; + /** number of bad channels from bad channel list */ + int nBadChans; + /** 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]; + + + /** Scans and scripts */ + + int actionMask; + + int actionMode[MAX_ACTIONS]; + char actionScript[MAX_ACTIONS][MAX_STR_LENGTH]; + char actionParameter[MAX_ACTIONS][MAX_STR_LENGTH]; + + + int scanMode[MAX_SCAN_LEVELS]; + char scanScript[MAX_SCAN_LEVELS][MAX_STR_LENGTH]; + char scanParameter[MAX_SCAN_LEVELS][MAX_STR_LENGTH]; + int nScanSteps[MAX_SCAN_LEVELS]; + float scanSteps[MAX_SCAN_LEVELS][MAX_SCAN_STEPS]; + int scanPrecision[MAX_SCAN_LEVELS]; + + + +} + + + + + + + + + + + + + @@ -63,32 +146,78 @@ class multiSlsDetector : public slsDetector { /** (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 - - + \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(detectorType type=GENERIC, int ndet=1, int id=0); + multiSlsDetector(int id=0); //slsDetector(string const fname); /** destructor */ virtual ~multiSlsDetector(); + /** frees the shared memory occpied by the sharedMultiSlsDetector structure */ + int freeSharedMemory() ; + + /** allocates the shared memory occpied for the sharedMultiSlsDetector structure */ + int initSharedMemory() ; + + /** 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*/ + int addSlsDetector(int id, int pos=-1); + + /**removes the detector in position pos from the multidetector + \param pos position of the detector to be removed from the multidetector system (defaults to -1 i.e. last detector) + \returns the actual number of detectors + */ + int removeSlsDetector(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*/ + int getDetectorId(int i) {if (i>=0) if (detectors[i]) return detectors[i]->getDetectorId(); else return -1;}; - int addSlsDetector(detectorType type=GENERIC, int id=0); - int removeSlsDetector(int i=-1); + /** returns the number of detectors in the multidetector structure + \returns number of detectors */ + int getNumberOfDetectors() {return thisMultiDetector->numberOfDetectors;}; + + /** sets the detector in position i as master of the structure (e.g. it gates the other detectors and therefore must be started as last.
Assumes that signal 0 is gate in, signal 1 is trigger in, signal 2 is gate out + \param i position of master (-1 gets) + \return master's position (-1 none) + */ + int setMaster(int i=-1); + + /** + Sets/gets the synchronization mode of the various detectors + \param sync syncronization mode + \returns current syncronization mode + */ + synchronizationMode setSyncronization(synchronizationMode sync=GET_SYNHRONIZATION_MODE); + + /** synchronization of the various detectors (should be set for each detector individually?!?!?) */ + + enum synchronyzationMode { + GET_SYNHRONIZATION_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 */ + } - int getDetectorId(int i) {if (detectors[i]) return detectors[i]->getDetectorId();}; /** sets the onlineFlag - \param off can be:
GET_ONLINE_FLAG, returns wether the detector is in online or offline state;
OFFLINE_FLAG, detector in offline state (i.e. no communication to the detector - using only local structure - no data acquisition possible!);
ONLINE_FLAG detector in online state (i.e. communication to the detector updating the local structure) */ - int setOnline(int const online=GET_ONLINE_FLAG, int i=-1); + \param off can be: GET_ONLINE_FLAG, returns wether the detector is in online or offline state; OFFLINE_FLAG, detector in offline state (i.e. no communication to the detector - using only local structure - no data acquisition possible!); ONLINE_FLAG detector in online state (i.e. communication to the detector updating the local structure) + \returns online/offline status + */ + int setOnline(int const online=GET_ONLINE_FLAG); /** sets the onlineFlag \returns 1 if the detector structure has already be initlialized with the given idand belongs to this multiDetector instance, 0 otherwise */ - int exists(int id) ; + int exists() ; /** Purely virtual function @@ -96,13 +225,13 @@ class multiSlsDetector : public slsDetector { /sa mythenDetector::readConfigurationFile */ - virtual int readConfigurationFile(string const fname)=0; + int readConfigurationFile(string const fname); /** Purely virtual function Should be implemented in the specific detector class /sa mythenDetector::writeConfigurationFile */ - virtual int writeConfigurationFile(string const fname)=0; + int writeConfigurationFile(string const fname); /* @@ -115,36 +244,15 @@ class multiSlsDetector : public slsDetector { Should be implemented in the specific detector class /sa mythenDetector::dumpDetectorSetup */ - virtual int dumpDetectorSetup(string const fname, int level)=0; + int dumpMultiDetectorSetup(string const fname, int level); /** Purely virtual function Should be implemented in the specific detector class /sa mythenDetector::retrieveDetectorSetup */ - virtual int retrieveDetectorSetup(string const fname, int level)=0; + int retrieveMultiDetectorSetup(string const fname, int level); - /** - 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 data_port port for receiving data - if -1 the current is used - - \returns OK is connection succeded, FAIL otherwise - \sa sharedSlsDetector - */ - int setTCPSocket(int i, string const name="", int const control_port=-1, int const stop_port=-1, int const data_port=-1); - - /** returns the detector hostname \sa sharedSlsDetector */ - char* getHostname(int i) ; - /** returns the detector control port \sa sharedSlsDetector */ - int getControlPort(int i=-1); - /** returns the detector stop port \sa sharedSlsDetector */ - int getStopPort(int i=-1); - /** returns the detector data port \sa sharedSlsDetector */ - int getDataPort(int i=-1); - /** generates file name without extension always appends to file path and file name the run index. @@ -152,11 +260,35 @@ class multiSlsDetector : public slsDetector { in case also appends the position index Filenames will be of the form: filepath/filename(_px)_i - where x is the position index and i is the run index + where x is the position index and i is the run index + \returns file name without extension + \sa slsDetector::createFileName */ string createFileName(); + /** + function that returns the file index from the file name + \param fname file name + \returns file index + \sa slsDetector::getFileIndexFromFileName + + */ + int multiSlsDetector::getFileIndexFromFileName(string fname) ; + + /** + + function that returns the variables from the file name + \param fname file name + \param index reference to index + \param p_index reference to position index + \param sv0 reference to scan variable 0 + \param sv1 reference to scan variable 1 + \returns file index + \sa slsDetector::getVariablesFromFileName + + */ + int multiSlsDetector::getVariablesFromFileName(string fname, int &index, int &p_index, float &sv0, float &sv1) ; @@ -171,108 +303,47 @@ class multiSlsDetector : public slsDetector { /* I/O */ - /** returns the detector trimbit directory \sa sharedSlsDetector */ - char* getSettingsDir(int i=-1); - /** sets the detector trimbit directory \sa sharedSlsDetector */ - char* setSettingsDir(string s, int i=-1); - /** 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 - - unused! - - \sa sharedSlsDetector - */ - int getTrimEn(int *en=NULL, int i=-1); - /** 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 - - unused! - - \sa sharedSlsDetector - */ - int setTrimEn(int nen, int *en=NULL, int i=-1); - - /** - Pure virtual function - reads a trim file - \param fname name of the file to be read - \param myMod pointer to the module structure which has to be set.
If it is NULL a new module structure will be created - \returns the pointer to myMod or NULL if reading the file failed - \sa mythenDetector::readTrimFile - */ - - virtual sls_detector_module* readTrimFile(string fname, sls_detector_module* myMod=NULL)=0; - - /** - Pure virtual function - writes a trim file - \param fname name of the file to be written - \param mod module structure which has to be written to file - \returns OK or FAIL if the file could not be written - - \sa ::sls_detector_module mythenDetector::writeTrimFile(string, sls_detector_module) - */ - virtual int writeTrimFile(string fname, sls_detector_module mod)=0; - - /** - returns currently the loaded trimfile name - */ - - const char *getTrimFile(int i=-1); - - /** - Pure virtual function - writes a trim file for module number imod - the values will be read from the current detector structure - \param fname name of the file to be written - \param imod module number - \returns OK or FAIL if the file could not be written - \sa ::sls_detector_module sharedSlsDetector mythenDetector::writeTrimFile(string, int) - */ - virtual int writeTrimFile(string fname, int imod, int i)=0; /** sets the default output files path - \sa sharedSlsDetector + \sa sharedMultiSlsDetector */ - char* setFilePath(string s, int i=-1); + char* setFilePath(string s, int i=-1) {sprintf(thisMultiDetector->filePath, s.c_str()); return thisMultiDetector->filePath;};; /** sets the default output files root name - \sa sharedSlsDetector + \sa sharedMultiSlsDetector */ - char* setFileName(string s, int i=-1); + char* setFileName(string s, int i=-1){sprintf(thisMultiDetector->fileName, s.c_str()); return thisMultiDetector->fileName;}; /** sets the default output file index - \sa sharedSlsDetector + \sa sharedMultiSlsDetector */ - int setFileIndex(int i, int id=-1); + int setFileIndex(int i, int id=-1){thisMultiDetector->fileIndex=i; return thisMultiDetector->fileIndex;}; /** returns the default output files path - \sa sharedSlsDetector + \sa sharedMultiSlsDetector */ - char* getFilePath(int id=-1); + char* getFilePath(int id=-1) {return thisMultiDetector->filePath;}; /** returns the default output files root name - \sa sharedSlsDetector + \sa sharedMultiSlsDetector */ - char* getFileName(int id=-1) ; + char* getFileName(int id=-1) {return thisMultiDetector->fileName;}; /** returns the default output file index - \sa sharedSlsDetector + \sa sharedMultiSlsDetector */ - int getFileIndex(int id=-1) ; + int getFileIndex(int id=-1) {return thisMultiDetector->fileIndex;}; /** - Pure virtual function + writes a data file \param name of the file to be written \param data array of data values @@ -285,20 +356,20 @@ class multiSlsDetector : public slsDetector { \sa mythenDetector::writeDataFile */ - virtual int writeDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=-1)=0; + int writeDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=-1); /** - Pure virtual function + 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 */ - virtual int writeDataFile(string fname, int *data)=0; + int writeDataFile(string fname, int *data); /** - Pure virtual function + reads a data file \param name of the file to be read \param data array of data values to be filled @@ -311,334 +382,67 @@ class multiSlsDetector : public slsDetector { \sa mythenDetector::readDataFile */ - virtual int readDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=0)=0; + int readDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=0); /** - Pure virtual function + 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 */ - virtual int readDataFile(string fname, int *data)=0; - - /** - returns the location of the calibration files - \sa sharedSlsDetector - */ - char* getCalDir(int id=-1); - - - /** - sets the location of the calibration files - \sa sharedSlsDetector - */ - char* setCalDir(string s, int id=-1) - /** - Pure virtual function - reads a calibration file - \param fname file to be read - \param gain reference to the gain variable - \offset reference to the offset variable - \sa sharedSlsDetector mythenDetector::readCalibrationFile - */ - virtual int readCalibrationFile(string fname, float &gain, float &offset)=0; - /** - Pure virtual function - writes a calibration file - \param fname file to be written - \param gain - \param offset - \sa sharedSlsDetector mythenDetector::writeCalibrationFile - */ - virtual int writeCalibrationFile(string fname, float gain, float offset)=0; + int readDataFile(string fname, int *data); /** - Pure virtual function - reads an angular conversion file + + reads an angular conversion file for all detectors \param fname file to be read \sa angleConversionConstant mythenDetector::readAngularConversion */ - virtual int readAngularConversion(string fname="", int id=-1)=0; + virtual int readAngularConversion(string fname="", int id=-1); + + + /** - Pure virtual function - writes an angular conversion file + + writes an angular conversion file for all detectors \param fname file to be written \sa angleConversionConstant mythenDetector::writeAngularConversion */ - virtual int writeAngularConversion(string fname="", int id=-1)=0; + virtual int writeAngularConversion(string fname="", int id=-1); + + + + + + + - /** Returns the number of channels per chip */ - int getNChans(int id=-1); // - /** Returns the number of chips per module */ - int getNChips(int id=-1); // /* Communication to server */ - /** - executes a system command on the server - e.g. mount an nfs disk, reboot and returns answer etc. - \param cmd is the command to be executed - \param answer is the answer from the detector - \returns OK or FAIL depending on the command outcome - */ - int execCommand(string cmd, string answer, int id=-1); - - /** - sets/gets detector type - normally the detector knows what type of detector it is - \param type is the detector type (defaults to GET_DETECTOR_TYPE) - \returns returns detector type index (1 GENERIC, 2 MYTHEN, 3 PILATUS, 4 XFS, 5 GOTTHARD, 6 AGIPD, -1 command failed) - */ - int setDetectorType(detectorType type=GET_DETECTOR_TYPE, int id=-1); - - /** - 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, int id=-1); - - /** - gets detector type - normally the detector knows what type of detector it is - \param type is the string where the detector type will be written ("Mythen", "Pilatus", "XFS", "Gotthard", Agipd") - */ - void getDetectorType(char *type, int id=-1); - // Detector configuration functions - /** - set/get the size of the detector - \param n number of modules - \param d dimension - \returns current number of modules in direction d - */ - - // Detector configuration functions - /** - set/get the size of the detector - \param n number of modules - \param d dimension - \returns current number of modules in direction d - */ - int setNumberOfModules(int n=GET_FLAG, dimension d=X, int id=-1); // if n=GET_FLAG returns the number of installed modules - - /* - returns the instrinsic size of the detector (maxmodx, maxmody, nchans, nchips, ndacs - enum numberOf { - MAXMODX, - MAXMODY, - CHANNELS, - CHIPS, - DACS - } - */ - /** - get the maximum size of the detector - \param d dimension - \returns maximum number of modules that can be installed in direction d - */ - int getMaxNumberOfModules(dimension d=X, int id=-1); // - - - /** - 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 - */ - externalSignalFlag setExternalSignalFlags(externalSignalFlag pol=GET_EXTERNAL_SIGNAL_FLAG , int signalindex=0, int id=-1); - - - /** - set/get the external communication mode - - obsolete \sa setExternalSignalFlags - \param pol value to be set \sa externalCommunicationMode - \returns current external communication mode - */ - externalCommunicationMode setExternalCommunicationMode(externalCommunicationMode pol=GET_EXTERNAL_COMMUNICATION_MODE, int id=-1); - // Tests and identification - - /** - get detector ids/versions for module - \param mode which id/version has to be read - \param imod module number for module serial number - \returns id - */ - int64_t getId(idMode mode, int imod=0, int id=0); - 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 - */ - int digitalTest(digitalTestMode mode, int imod=0); - int digitalTest(digitalTestMode mode, int imod=0, int id=0); - /** - analog test - \param modte test mode - \return pointer to acquired data - - not yet implemented - */ - int* analogTest(analogTestMode mode); - - /** - enable analog output of channel ichan - - not yet implemented - */ - int enableAnalogOutput(int ichan); - - /** - enable analog output of channel ichan, chip ichip, module imod - - not yet implemented - */ - int enableAnalogOutput(int imod, int ichip, int ichan); - /** - give a train of calibration pulses - \param vcal pulse amplitude - \param npulses number of pulses - - not yet implemented - - */ - int giveCalibrationPulse(float vcal, int npulses); + + + + // Expert Initialization functions - /** - write register - \param addr address - \val value - \returns current register value - */ - int writeRegister(int addr, int val); - - /** - read register - \param addr address - \returns current register value - - */ - 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 - */ - float setDAC(float val, dacIndex index, int imod=-1); - - /** - set dacs value - \param index ADC index - \param imod module number - \returns current ADC value - */ - float 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 - */ - 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 - */ - 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 - */ - 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 - */ - 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 - */ - int setChip(sls_detector_chip chip); - - /** - get chip - \param ichip chip number - \param imod module number - \returns current chip structure for channel - - \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 - */ - 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 - */ - 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) - */ - virtual sls_detector_module *getModule(int imod); - // calibration functions // int setCalibration(int imod, detectorSettings isettings, float gain, float offset); //int getCalibration(int imod, detectorSettings isettings, float &gain, float &offset); @@ -681,32 +485,59 @@ class multiSlsDetector : public slsDetector { virtual detectorSettings setSettings(detectorSettings isettings, int imod=-1); + + + + + + + + + + + + + + + + + + + + + + + + + + + // Acquisition functions /** - start detector acquisition - \returns OK/FAIL + start detector acquisition (master is started as last) + \returns OK if all detectors are properly started, FAIL otherwise */ int startAcquisition(); /** - stop detector acquisition + stop detector acquisition (master firtst) \returns OK/FAIL */ int stopAcquisition(); /** - start readout (without exposure or interrupting exposure) + start readout (without exposure or interrupting exposure) (master first) \returns OK/FAIL */ int startReadOut(); /** - get run status + get run status
Does it make sense to ask the status for all detectors?!?!?! \returns status mask */ - virtual runStatus getRunStatus()=0; + runStatus getRunStatus(); /** start detector acquisition and read all data putting them a data queue @@ -797,15 +628,6 @@ class multiSlsDetector : public slsDetector { - - /** sets/gets the value of important readout speed parameters - \param sp is the parameter to be set/get - \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 /** set/get dynamic range @@ -1225,29 +1047,7 @@ s \sa mythenDetector::processData */ virtual void* processData(int delflag=1)=0; // thread function - /** Allocates the memory for a sls_detector_module structure and initializes it - \returns myMod the pointer to the allocate dmemory location - */ - sls_detector_module* createModule(); - /** frees the memory for a sls_detector_module structure - \param myMod the pointer to the memory to be freed - - */ - - void deleteModule(sls_detector_module *myMod); - - - /** pure virtual function - performs the complete acquisition and 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()) - /param delflag if 1 the data are processed, written to file and then deleted. If 0 they are added to the finalDataQueue - \sa mythenDetector::acquire() - */ virtual void acquire(int delflag=1)=0; @@ -1264,13 +1064,57 @@ s - - int nDetectors; - + int shmId; slsDetector *detectors[MAXDET]; + sharedMultiSlsDetector *thisMultiDetector; + + /** + current position of the detector + */ + float currentPosition; + + /** + current position index of the detector + */ + int currentPositionIndex; + + /** + I0 measured + */ + float currentI0; + + + + + /** + current scan variable of the detector + */ + float currentScanVariable[MAX_SCAN_LEVELS]; + + /** + current scan variable index of the detector + */ + int currentScanIndex[MAX_SCAN_LEVELS]; + + + + + /** merging bins */ + float *mergingBins; + + /** merging counts */ + float *mergingCounts; + + /** merging errors */ + float *mergingErrors; + + /** merging multiplicity */ + int *mergingMultiplicity; + + }; diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 1cbe96ef0..4d1c34a11 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -844,27 +844,30 @@ int slsDetector::setTCPSocket(string const name, int const control_port, int con /* generates file name without extension*/ string slsDetector::createFileName() { + createFileName(thisDetector->filePath, thisDetector->fileName, thisDetector->actionMask, currentScanVariable[0], thisDetector->scanPrecision[0], currentScanVariable[1], thisDetector->scanPrecision[1], currentPositionIndex, thisDetector->numberOfPositions, thisDetector->fileIndex); +} +string slsDetector::createFileName(char *filepath, char *filename, int aMask, float sv0, int prec0, float sv1, int prec1, int pindex, int npos, int findex) { ostringstream osfn; /*directory name +root file name */ - osfn << thisDetector->filePath << "/" << thisDetector->fileName; + osfn << filepath << "/" << filename; // scan level 0 - if (thisDetector->actionMask & (1 << (MAX_ACTIONS))) - osfn << "_S" << fixed << setprecision(thisDetector->scanPrecision[0]) << currentScanVariable[0]; + if ( aMask& (1 << (MAX_ACTIONS))) + osfn << "_S" << fixed << setprecision(prec0) << sv0; //scan level 1 - if (thisDetector->actionMask & (1 << (MAX_ACTIONS+1))) - osfn << "_s" << fixed << setprecision(thisDetector->scanPrecision[1]) << currentScanVariable[1]; + if (aMask & (1 << (MAX_ACTIONS+1))) + osfn << "_s" << fixed << setprecision(prec1) << sv1; //position - if (currentPositionIndex>0 && currentPositionIndex<=thisDetector->numberOfPositions) - osfn << "_p" << currentPositionIndex; + if (pindex>0 && pindex<=npos) + osfn << "_p" << pindex; // file index - osfn << "_" << thisDetector->fileIndex; + osfn << "_" << findex; #ifdef VERBOSE @@ -876,6 +879,16 @@ string slsDetector::createFileName() { } + + + + + + + + + + int slsDetector::getFileIndexFromFileName(string fname) { int i; size_t dot=fname.rfind("."); diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index bc3933ecc..e0f882f7b 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -487,6 +487,7 @@ typedef struct sharedSlsDetector { */ int getFileIndex() {return thisDetector->fileIndex;}; + /** generates file name without extension always appends to file path and file name the run index. @@ -495,13 +496,51 @@ typedef struct sharedSlsDetector { Filenames will be of the form: filepath/filename(_px)_i where x is the position index and i is the run index + \param filepath outdir + \param filename file root name + \param aMask action mask (scans, positions) + \param sv0 scan variable 0 + \param prec0 scan precision 0 + \param sv1 scan variable 1 + \param prec1 scan precision 1 + \param pindex position index + \param number of positions + \param findex file index + \returns file name without extension + */ + static string createFileName(char *filepath, char *filename, int aMask, float sv0, int prec0, float sv1, int prec1, int pindex, int npos, int findex); + /** generates file name without extension + always appends to file path and file name the run index. + + in case also appends the position index + + Filenames will be of the form: filepath/filename(_px)_i + where x is the position index and i is the run index + \returns file name without extension */ string createFileName(); + + + /** static function that returns the file index from the file name + \param fname file name + \returns file index*/ + static int getFileIndexFromFileName(string fname); + + /** static function that returns the variables from the file name + \param fname file name + \param index reference to index + \param p_index reference to position index + \param sv0 reference to scan variable 0 + \param sv1 reference to scan variable 1 + \returns file index + */ + static int getVariablesFromFileName(string fname, int &index, int &p_index, float &sv0, float &sv1); + /** - Pure virtual function + writes a data file \param name of the file to be written \param data array of data values @@ -517,7 +556,7 @@ typedef struct sharedSlsDetector { virtual int writeDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=-1){}; /** - Pure virtual function + writes a data file \param name of the file to be written \param data array of data values @@ -527,7 +566,7 @@ typedef struct sharedSlsDetector { virtual int writeDataFile(string fname, int *data){}; /** - Pure virtual function + reads a data file \param name of the file to be read \param data array of data values to be filled @@ -543,7 +582,7 @@ typedef struct sharedSlsDetector { virtual int readDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=0){}; /** - Pure virtual function + reads a data file \param name of the file to be read \param data array of data values @@ -565,7 +604,7 @@ typedef struct sharedSlsDetector { */ char* setCalDir(string s) {sprintf(thisDetector->calDir, s.c_str()); return thisDetector->calDir;}; /** - Pure virtual function + reads a calibration file \param fname file to be read \param gain reference to the gain variable @@ -574,7 +613,7 @@ typedef struct sharedSlsDetector { */ virtual int readCalibrationFile(string fname, float &gain, float &offset){}; /** - Pure virtual function + writes a calibration file \param fname file to be written \param gain @@ -585,7 +624,7 @@ typedef struct sharedSlsDetector { /** - Pure virtual function + reads an angular conversion file \param fname file to be read \sa angleConversionConstant mythenDetector::readAngularConversion @@ -1546,9 +1585,6 @@ enum {GET_ACTION, PUT_ACTION, READOUT_ACTION}; protected: - int getFileIndexFromFileName(string fname); - int getVariablesFromFileName(string fname, int &index, int &p_index, float &sv0, float &sv1); - static const int64_t thisSoftwareVersion=0x20110113;