From 2463c9841c028f461cf9afc990d6661fccf5ca43 Mon Sep 17 00:00:00 2001 From: bergamaschi Date: Fri, 23 Mar 2012 15:58:03 +0000 Subject: [PATCH] really merged after the mess... git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@163 951219d9-93cf-4727-9268-0efd64621fa3 --- .../commonFiles/sls_detector_defs.h | 2 +- .../commonFiles/sls_detector_funcs.h | 5 +- .../multiSlsDetector/multiSlsDetector.cpp | 113 +++++------ .../slsDetector/slsDetector.cpp | 177 ++++++++---------- .../slsDetector/slsDetectorBase.h | 14 +- .../slsDetector/slsDetectorCommand.cpp | 6 +- .../slsDetector/slsDetectorUtils.h | 32 ++++ 7 files changed, 187 insertions(+), 162 deletions(-) diff --git a/slsDetectorSoftware/commonFiles/sls_detector_defs.h b/slsDetectorSoftware/commonFiles/sls_detector_defs.h index a87bd07ed..95631dbb7 100755 --- a/slsDetectorSoftware/commonFiles/sls_detector_defs.h +++ b/slsDetectorSoftware/commonFiles/sls_detector_defs.h @@ -482,7 +482,7 @@ enum angleConversionParameter { protected: #endif -#include "sls_detector_funcs.h +#include "sls_detector_funcs.h" #ifdef __cplusplus diff --git a/slsDetectorSoftware/commonFiles/sls_detector_funcs.h b/slsDetectorSoftware/commonFiles/sls_detector_funcs.h index a99d83553..2970e0d58 100644 --- a/slsDetectorSoftware/commonFiles/sls_detector_funcs.h +++ b/slsDetectorSoftware/commonFiles/sls_detector_funcs.h @@ -97,8 +97,11 @@ enum { F_SET_MASTER, /**< sets master/slave flag for multi detector structures */ - F_SET_SYNCHRONIZATION_MODE /**< sets master/slave synchronization mode for multidetector structures */ + F_SET_SYNCHRONIZATION_MODE, /**< sets master/slave synchronization mode for multidetector structures */ + F_READ_COUNTER_BLOCK, + + F_RESET_COUNTER_BLOCK, /* Always append functions hereafter!!! */ diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 1301bdfb6..0e25cee3d 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -653,7 +653,7 @@ int multiSlsDetector::setMaster(int i) { \param sync syncronization mode \returns current syncronization mode */ -synchronizationMode multiSlsDetector::setSynchronization(synchronizationMode sync) { +slsDetectorDefs::synchronizationMode multiSlsDetector::setSynchronization(synchronizationMode sync) { synchronizationMode ret=GET_SYNCHRONIZATION_MODE, ret1=GET_SYNCHRONIZATION_MODE; @@ -797,7 +797,7 @@ int multiSlsDetector::setThresholdEnergy(int e_eV, int pos, detectorSettings ise } -detectorSettings multiSlsDetector::getSettings(int pos) { +slsDetectorDefs::detectorSettings multiSlsDetector::getSettings(int pos) { int i, posmin, posmax; detectorSettings ret1=GET_SETTINGS, ret; @@ -825,7 +825,7 @@ detectorSettings multiSlsDetector::getSettings(int pos) { return ret1; } -detectorSettings multiSlsDetector::setSettings(detectorSettings isettings, int pos) { +slsDetectorDefs::detectorSettings multiSlsDetector::setSettings(detectorSettings isettings, int pos) { int i, posmin, posmax; @@ -1172,7 +1172,7 @@ int multiSlsDetector::startAndReadAllNoWait(){ get run status \returns status mask */ -runStatus multiSlsDetector::getRunStatus() { +slsDetectorDefs::runStatus multiSlsDetector::getRunStatus() { runStatus s,s1; @@ -2405,7 +2405,7 @@ int multiSlsDetector::setReadOutFlags(readOutFlags flag) { } -externalCommunicationMode multiSlsDetector::setExternalCommunicationMode(externalCommunicationMode pol) { +slsDetectorDefs::externalCommunicationMode multiSlsDetector::setExternalCommunicationMode(externalCommunicationMode pol) { externalCommunicationMode ret, ret1; @@ -2429,7 +2429,7 @@ externalCommunicationMode multiSlsDetector::setExternalCommunicationMode(externa -externalSignalFlag multiSlsDetector::setExternalSignalFlags(externalSignalFlag pol, int signalindex) { +slsDetectorDefs::externalSignalFlag multiSlsDetector::setExternalSignalFlags(externalSignalFlag pol, int signalindex) { externalSignalFlag ret, ret1; @@ -2507,7 +2507,6 @@ int multiSlsDetector::configureMAC() { } - int multiSlsDetector::loadImageToDetector(imageType index,string const fname){ int ret=-100, ret1; @@ -2543,6 +2542,57 @@ int multiSlsDetector::loadImageToDetector(imageType index,string const fname){ 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()) { +#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; + } + 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 multiSlsDetector::setDynamicRange(int p) { @@ -3382,52 +3432,3 @@ int multiSlsDetector::readDataFile(string fname, int *data) { } - -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()) { -#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; - } - 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; -} diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 7db3e4b08..5232d85ba 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -4613,10 +4613,6 @@ int slsDetector:: writeAngularConversion(ofstream &ofs) { - - - - int slsDetector::loadImageToDetector(imageType index,string const fname){ int ret=FAIL; @@ -4640,13 +4636,6 @@ int slsDetector::loadImageToDetector(imageType index,string const fname){ } - - - - - - - int slsDetector::sendImageToDetector(imageType index,short int imageVals[]){ int ret=FAIL; @@ -4681,6 +4670,89 @@ int slsDetector::sendImageToDetector(imageType index,short int imageVals[]){ return ret; } +int slsDetector::getCounterBlock(short int arg[],int startACQ){ + + 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(); + } + } + } + + return ret; +} + + +int slsDetector::writeCounterBlockFile(string const fname,int startACQ){ + + 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(); + } + } + } + + return ret; +} + + @@ -5551,86 +5623,3 @@ slsDetectorDefs::synchronizationMode slsDetector::setSynchronization(synchroniza return retval; } - - -int slsDetector::getCounterBlock(short int arg[],int startACQ){ - - 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(); - } - } - } - - return ret; -} - -int slsDetector::writeCounterBlockFile(string const fname,int startACQ){ - - 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(); - } - } - } - - return ret; -} - diff --git a/slsDetectorSoftware/slsDetector/slsDetectorBase.h b/slsDetectorSoftware/slsDetector/slsDetectorBase.h index 10e76cfd1..10ba9d5f6 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorBase.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorBase.h @@ -768,13 +768,13 @@ class slsDetectorBase : public slsDetectorDefs virtual int retrieveDetectorSetup(string const fname, int level=0)=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 - */ - virtual int loadImageToDetector(imageType index,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 */ +/* *\/ */ +/* virtual int loadImageToDetector(imageType index,string const fname)=0; */ /************************************************************************ diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index 77aaa6fb8..5a66ad955 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -6,7 +6,7 @@ #include -slsDetectorCommand::slsDetectorCommand(slsDetectorBase *det) { +slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { myDet=det; @@ -134,6 +134,7 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorBase *det) { descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdCounter; i++; + /* trim/cal directories */ descrToFuncMap[i].m_pFuncName="trimdir"; //OK descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSettingsDir; @@ -1636,7 +1637,6 @@ string slsDetectorCommand::helpThreaded(int narg, char *args[], int action){ } - string slsDetectorCommand::cmdImage(int narg, char *args[], int action){ string sval; int retval; @@ -1676,7 +1676,6 @@ string slsDetectorCommand::helpImage(int narg, char *args[], int action){ } - string slsDetectorCommand::cmdCounter(int narg, char *args[], int action){ int ival; string sval; @@ -1728,6 +1727,7 @@ string slsDetectorCommand::helpCounter(int narg, char *args[], int action){ + string slsDetectorCommand::cmdPositions(int narg, char *args[], int action){ int ival; int ip; diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h index 0d48b3542..1d0f11b26 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h @@ -113,6 +113,8 @@ class slsDetectorUtils : public slsDetectorBase { using slsDetectorBase::setBadChannelCorrection; using slsDetectorBase::getAngularConversion; + /** Frees the shared memory - should not be used except for debugging*/ + virtual int freeSharedMemory()=0; /** adds the detector with ID id in postion pos @@ -375,6 +377,11 @@ class slsDetectorUtils : public slsDetectorBase { \sa angleConversionConstant mythenDetector::writeAngularConversion */ static int writeAngularConversion(ofstream& ofs, int nmod, angleConversionConstant *angOff); + + + + virtual int writeAngularConversion(const char *fname)=0; + /** set bad channels correction \param fname file with bad channel list ("" disable) @@ -650,6 +657,31 @@ s +/** + 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 + */ + 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 + */ + virtual int resetCounterBlock(int startACQ=0)=0; +