indenting to emacs format and including check and start receiver before doing acquire or status start

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@291 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d 2012-10-11 16:17:07 +00:00
parent 29a540818f
commit f6a2d599a0
10 changed files with 3984 additions and 3968 deletions

File diff suppressed because it is too large Load Diff

View File

@ -28,17 +28,17 @@ class slsDetector;
/** /**
* *
* *
@libdoc The multiSlsDetector class is used to operate several slsDetectors in parallel. @libdoc The multiSlsDetector class is used to operate several slsDetectors in parallel.
* *
* @short This is the base class for multi detector system functionalities * @short This is the base class for multi detector system functionalities
* @author Anna Bergamaschi * @author Anna Bergamaschi
* @version 0.1alpha * @version 0.1alpha
*/ */
class multiSlsDetector : public slsDetectorUtils { class multiSlsDetector : public slsDetectorUtils {
//public virtual slsDetectorUtils { //public virtual slsDetectorUtils {
typedef struct sharedMultiSlsDetector { typedef struct sharedMultiSlsDetector {
@ -107,7 +107,7 @@ class multiSlsDetector : public slsDetectorUtils {
/** current index of the output file */ /** current index of the output file */
int fileIndex; int fileIndex;
/** path of the output files */ /** path of the output files */
char filePath[MAX_STR_LENGTH]; char filePath[MAX_STR_LENGTH];
@ -143,13 +143,13 @@ class multiSlsDetector : public slsDetectorUtils {
/** array of angular conversion constants for each module \see ::angleConversionConstant */ /** array of angular conversion constants for each module \see ::angleConversionConstant */
//angleConversionConstant angOff[MAXMODS]; //angleConversionConstant angOff[MAXMODS];
/** angular direction (1 if it corresponds to the encoder direction i.e. channel 0 is 0, maxchan is positive high angle, 0 otherwise */ /** angular direction (1 if it corresponds to the encoder direction i.e. channel 0 is 0, maxchan is positive high angle, 0 otherwise */
int angDirection; int angDirection;
/** beamline fine offset (of the order of mdeg, might be adjusted for each measurements) */ /** beamline fine offset (of the order of mdeg, might be adjusted for each measurements) */
double fineOffset; double fineOffset;
/** beamline offset (might be a few degrees beacuse of encoder offset - normally it is kept fixed for a long period of time) */ /** beamline offset (might be a few degrees beacuse of encoder offset - normally it is kept fixed for a long period of time) */
double globalOffset; double globalOffset;
/** bin size for data merging */ /** bin size for data merging */
double binSize; double binSize;
@ -159,9 +159,9 @@ class multiSlsDetector : public slsDetectorUtils {
//X and Y displacement //X and Y displacement
double sampleDisplacement[2]; double sampleDisplacement[2];
/** number of positions at which the detector should acquire */ /** number of positions at which the detector should acquire */
int numberOfPositions; int numberOfPositions;
/** list of encoder positions at which the detector should acquire */ /** list of encoder positions at which the detector should acquire */
double detPositions[MAXPOS]; double detPositions[MAXPOS];
@ -211,23 +211,23 @@ class multiSlsDetector : public slsDetectorUtils {
using slsDetectorUtils::flatFieldCorrect; using slsDetectorUtils::flatFieldCorrect;
using slsDetectorUtils::rateCorrect; using slsDetectorUtils::rateCorrect;
using slsDetectorUtils::setBadChannelCorrection; using slsDetectorUtils::setBadChannelCorrection;
using slsDetectorUtils::readAngularConversion; using slsDetectorUtils::readAngularConversion;
using slsDetectorUtils::writeAngularConversion; using slsDetectorUtils::writeAngularConversion;
/* /*
@short Structure allocated in shared memory to store detector settings and be accessed in parallel by several applications (take care of possible conflicts!) @short Structure allocated in shared memory to store detector settings and be accessed in parallel by several applications (take care of possible conflicts!)
*/ */
/** (default) constructor /** (default) constructor
\param id is the detector index which is needed to define the shared memory id. Different physical detectors should have different IDs in order to work independently \param id is the detector index which is needed to define the shared memory id. Different physical detectors should have different IDs in order to work independently
*/ */
multiSlsDetector(int id=0); multiSlsDetector(int id=0);
//slsDetector(string const fname); //slsDetector(string const fname);
/** destructor */ /** destructor */
@ -241,15 +241,15 @@ class multiSlsDetector : public slsDetectorUtils {
int initSharedMemory(int) ; int initSharedMemory(int) ;
/** adds the detector with ID id in postion pos /** adds the detector with ID id in postion pos
\param id of the detector to be added (should already exist!) \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) \param pos position where it should be added (normally at the end of the list (default to -1)
\return the actual number of detectors or -1 if it failed*/ \return the actual number of detectors or -1 if it failed*/
int addSlsDetector(int id, int pos=-1); int addSlsDetector(int id, int pos=-1);
/** adds the detector with ID id in postion pos /** adds the detector with ID id in postion pos
\param name of the detector to be added (should already exist in shared memory or at least be online) \param name of the detector to be added (should already exist in shared memory or at least be online)
\param pos position where it should be added (normally at the end of the list (default to -1) \param pos position where it should be added (normally at the end of the list (default to -1)
\return the actual number of detectors or -1 if it failed*/ \return the actual number of detectors or -1 if it failed*/
int addSlsDetector(const char *name, int pos=-1); int addSlsDetector(const char *name, int pos=-1);
int addSlsDetector(detectorType type, int pos=-1); int addSlsDetector(detectorType type, int pos=-1);
@ -286,17 +286,17 @@ class multiSlsDetector : public slsDetectorUtils {
/** adds a detector by id in position pos /** adds a detector by id in position pos
\param ival detector id to be added \param ival detector id to be added
\param pos position to add it (-1 fails) \param pos position to add it (-1 fails)
\returns detector ID or -1 if detector in position i is empty \returns detector ID or -1 if detector in position i is empty
*/ */
int setDetectorId(int ival, int pos=-1); int setDetectorId(int ival, int pos=-1);
/** returns the id of the detector in position i /** returns the id of the detector in position i
\param i position of the detector \param i position of the detector
\returns detector ID or -1 if detector in position i is empty*/ \returns detector ID or -1 if detector in position i is empty*/
int getDetectorId(int i); int getDetectorId(int i);
@ -307,10 +307,10 @@ class multiSlsDetector : public slsDetectorUtils {
int getMaxMods(); int getMaxMods();
int getNMods(); int getNMods();
int getChansPerMod(int imod=0); int getChansPerMod(int imod=0);
angleConversionConstant *getAngularConversionPointer(int imod=0); angleConversionConstant *getAngularConversionPointer(int imod=0);
int getTotalNumberOfChannels(){return thisMultiDetector->numberOfChannels;}; int getTotalNumberOfChannels(){return thisMultiDetector->numberOfChannels;};
@ -326,7 +326,7 @@ class multiSlsDetector : public slsDetectorUtils {
*/ */
int getDetectorOffset(int pos, int &ox, int &oy); int getDetectorOffset(int pos, int &ox, int &oy);
/** sets the detector offset (in number of channels) /** sets the detector offset (in number of channels)
\param pos position of the detector \param pos position of the detector
\param ox offset in x (-1 does not change) \param ox offset in x (-1 does not change)
\param oy offset in y (-1 does not change) \param oy offset in y (-1 does not change)
@ -347,13 +347,13 @@ class multiSlsDetector : public slsDetectorUtils {
\param sync syncronization mode \param sync syncronization mode
\returns current syncronization mode \returns current syncronization mode
*/ */
/* enum synchronizationMode { */ /* enum synchronizationMode { */
/* GET_SYNCHRONIZATION_MODE=-1, /\**< the multidetector will return its synchronization mode *\/ */ /* GET_SYNCHRONIZATION_MODE=-1, /\**< the multidetector will return its synchronization mode *\/ */
/* NONE, /\**< all detectors are independent (no cabling) *\/ */ /* NONE, /\**< all detectors are independent (no cabling) *\/ */
/* MASTER_GATES, /\**< the master gates the other detectors *\/ */ /* MASTER_GATES, /\**< the master gates the other detectors *\/ */
/* MASTER_TRIGGERS, /\**< the master triggers 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 *\/ */ /* SLAVE_STARTS_WHEN_MASTER_STOPS /\**< the slave acquires when the master finishes, to avoid deadtime *\/ */
/* }; */ /* }; */
synchronizationMode setSynchronization(synchronizationMode sync=GET_SYNCHRONIZATION_MODE); synchronizationMode setSynchronization(synchronizationMode sync=GET_SYNCHRONIZATION_MODE);
@ -371,22 +371,22 @@ class multiSlsDetector : public slsDetectorUtils {
/** /**
\returns 1 if the detector structure has already be initlialized with the given id and belongs to this multiDetector instance, 0 otherwise */ \returns 1 if the detector structure has already be initlialized with the given id and belongs to this multiDetector instance, 0 otherwise */
int exists(); int exists();
/** /**
Purely virtual function Purely virtual function
Should be implemented in the specific detector class Should be implemented in the specific detector class
/sa mythenDetector::readConfigurationFile /sa mythenDetector::readConfigurationFile
*/ */
int readConfigurationFile(string const fname); int readConfigurationFile(string const fname);
/** /**
Purely virtual function Purely virtual function
Should be implemented in the specific detector class Should be implemented in the specific detector class
/sa mythenDetector::writeConfigurationFile /sa mythenDetector::writeConfigurationFile
*/ */
int writeConfigurationFile(string const fname); int writeConfigurationFile(string const fname);
@ -401,45 +401,45 @@ class multiSlsDetector : public slsDetectorUtils {
// Expert Initialization functions // Expert Initialization functions
/** /**
get threshold energy get threshold energy
\param imod module number (-1 all) \param imod module number (-1 all)
\returns current threshold value for imod in ev (-1 failed) \returns current threshold value for imod in ev (-1 failed)
*/ */
int getThresholdEnergy(int imod=-1); int getThresholdEnergy(int imod=-1);
/** /**
set threshold energy set threshold energy
\param e_eV threshold in eV \param e_eV threshold in eV
\param imod module number (-1 all) \param imod module number (-1 all)
\param isettings ev. change settings \param isettings ev. change settings
\returns current threshold value for imod in ev (-1 failed) \returns current threshold value for imod in ev (-1 failed)
*/ */
int setThresholdEnergy(int e_eV, int imod=-1, detectorSettings isettings=GET_SETTINGS); int setThresholdEnergy(int e_eV, int imod=-1, detectorSettings isettings=GET_SETTINGS);
/** /**
get detector settings get detector settings
\param imod module number (-1 all) \param imod module number (-1 all)
\returns current settings \returns current settings
*/ */
detectorSettings getSettings(int imod=-1); detectorSettings getSettings(int imod=-1);
/** /**
set detector settings set detector settings
\param isettings settings \param isettings settings
\param imod module number (-1 all) \param imod module number (-1 all)
\returns current settings \returns current settings
in this function trimbits and calibration files are searched in the trimDir and calDir directories and the detector is initialized in this function trimbits and calibration files are searched in the trimDir and calDir directories and the detector is initialized
*/ */
detectorSettings setSettings(detectorSettings isettings, int imod=-1); detectorSettings setSettings(detectorSettings isettings, int imod=-1);
/** /**
Returns the trimbits from the detector's shared memmory Returns the trimbits from the detector's shared memmory
\param retval is the array with the trimbits \param retval is the array with the trimbits
\param fromDetector is true if the trimbits shared memory have to be uploaded from detector \param fromDetector is true if the trimbits shared memory have to be uploaded from detector
\returns the total number of channels for the detector \returns the total number of channels for the detector
*/ */
int getChanRegs(double* retval,bool fromDetector); int getChanRegs(double* retval,bool fromDetector);
@ -485,81 +485,81 @@ class multiSlsDetector : public slsDetectorUtils {
// Acquisition functions // Acquisition functions
/** /**
start detector acquisition (master is started as last) start detector acquisition (master is started as last)
\returns OK if all detectors are properly started, FAIL otherwise \returns OK if all detectors are properly started, FAIL otherwise
*/ */
int startAcquisition(); int startAcquisition();
/** /**
stop detector acquisition (master firtst) stop detector acquisition (master firtst)
\returns OK/FAIL \returns OK/FAIL
*/ */
int stopAcquisition(); int stopAcquisition();
/** /**
start readout (without exposure or interrupting exposure) (master first) start readout (without exposure or interrupting exposure) (master first)
\returns OK/FAIL \returns OK/FAIL
*/ */
int startReadOut(); int startReadOut();
/** /**
start detector acquisition and read all data putting them a data queue start detector acquisition and read all data putting them a data queue
\returns pointer to the front of the data queue \returns pointer to the front of the data queue
\sa startAndReadAllNoWait getDataFromDetector dataQueue \sa startAndReadAllNoWait getDataFromDetector dataQueue
*/ */
int* startAndReadAll(); int* startAndReadAll();
/** /**
start detector acquisition and read out, but does not read data from socket start detector acquisition and read out, but does not read data from socket
*/ */
int startAndReadAllNoWait(); int startAndReadAllNoWait();
/** /**
receives a data frame from the detector socket receives a data frame from the detector socket
\returns pointer to the data or NULL. If NULL disconnects the socket \returns pointer to the data or NULL. If NULL disconnects the socket
\sa getDataFromDetector \sa getDataFromDetector
*/ */
//int* getDataFromDetectorNoWait(); //int* getDataFromDetectorNoWait();
/** /**
receives a data frame from the detector socket receives a data frame from the detector socket
\returns pointer to the data or NULL. If NULL disconnects the socket \returns pointer to the data or NULL. If NULL disconnects the socket
\sa getDataFromDetector \sa getDataFromDetector
*/ */
int* getDataFromDetector(); int* getDataFromDetector();
/** /**
asks and receives a data frame from the detector and puts it in the data queue asks and receives a data frame from the detector and puts it in the data queue
\returns pointer to the data or NULL. \returns pointer to the data or NULL.
\sa getDataFromDetector \sa getDataFromDetector
*/ */
int* readFrame(); int* readFrame();
/** /**
asks and receives all data from the detector and puts them in a data queue asks and receives all data from the detector and puts them in a data queue
\returns pointer to the front of the queue or NULL. \returns pointer to the front of the queue or NULL.
\sa getDataFromDetector dataQueue \sa getDataFromDetector dataQueue
*/ */
int* readAll(); int* readAll();
/** /**
pops the data from the data queue pops the data from the data queue
\returns pointer to the popped data or NULL if the queue is empty. \returns pointer to the popped data or NULL if the queue is empty.
\sa dataQueue \sa dataQueue
*/ */
int* popDataQueue(); int* popDataQueue();
/** /**
pops the data from thepostprocessed data queue pops the data from thepostprocessed data queue
\returns pointer to the popped data or NULL if the queue is empty. \returns pointer to the popped data or NULL if the queue is empty.
\sa finalDataQueue \sa finalDataQueue
*/ */
detectorData* popFinalDataQueue(); detectorData* popFinalDataQueue();
@ -567,14 +567,14 @@ class multiSlsDetector : public slsDetectorUtils {
/** /**
resets the raw data queue resets the raw data queue
\sa dataQueue \sa dataQueue
*/ */
void resetDataQueue(); void resetDataQueue();
/** /**
resets the postprocessed data queue resets the postprocessed data queue
\sa finalDataQueue \sa finalDataQueue
*/ */
void resetFinalDataQueue(); void resetFinalDataQueue();
@ -602,12 +602,12 @@ class multiSlsDetector : public slsDetectorUtils {
*/ */
int64_t getTimeLeft(timerIndex index); int64_t getTimeLeft(timerIndex index);
/* /\** */ /* /\** */
/* get current timer value */ /* get current timer value */
/* \param index timer index */ /* \param index timer index */
/* \returns elapsed time value in ns or number of...(e.g. frames, gates, probes) */ /* \returns elapsed time value in ns or number of...(e.g. frames, gates, probes) */
/* *\/ */ /* *\/ */
/* int64_t getTimeLeft(timerIndex index); */ /* int64_t getTimeLeft(timerIndex index); */
@ -737,9 +737,9 @@ class multiSlsDetector : public slsDetectorUtils {
/** /**
decode data from the detector converting them to an array of doubles, one for each channle decode data from the detector converting them to an array of doubles, one for each channle
\param datain data from the detector \param datain data from the detector
\returns pointer to a double array with a data per channel \returns pointer to a double array with a data per channel
*/ */
double* decodeData(int *datain, double *fdata=NULL); double* decodeData(int *datain, double *fdata=NULL);
@ -747,48 +747,48 @@ class multiSlsDetector : public slsDetectorUtils {
/** /**
flat field correct data flat field correct data
\param datain data \param datain data
\param errin error on data (if<=0 will default to sqrt(datain) \param errin error on data (if<=0 will default to sqrt(datain)
\param dataout corrected data \param dataout corrected data
\param errout error on corrected data \param errout error on corrected data
\param ffcoefficient flat field correction coefficient \param ffcoefficient flat field correction coefficient
\param fferr erro on ffcoefficient \param fferr erro on ffcoefficient
\returns 0 \returns 0
*/ */
// int flatFieldCorrect(double datain, double errin, double &dataout, double &errout, double ffcoefficient, double fferr); // int flatFieldCorrect(double datain, double errin, double &dataout, double &errout, double ffcoefficient, double fferr);
/** /**
flat field correct data flat field correct data
\param datain data array \param datain data array
\param errin error array on data (if NULL will default to sqrt(datain) \param errin error array on data (if NULL will default to sqrt(datain)
\param dataout array of corrected data \param dataout array of corrected data
\param errout error on corrected data (if not NULL) \param errout error on corrected data (if not NULL)
\returns 0 \returns 0
*/ */
int flatFieldCorrect(double* datain, double *errin, double* dataout, double *errout); int flatFieldCorrect(double* datain, double *errin, double* dataout, double *errout);
/** /**
rate correct data rate correct data
\param datain data \param datain data
\param errin error on data (if<=0 will default to sqrt(datain) \param errin error on data (if<=0 will default to sqrt(datain)
\param dataout corrected data \param dataout corrected data
\param errout error on corrected data \param errout error on corrected data
\param tau dead time 9in ns) \param tau dead time 9in ns)
\param t acquisition time (in ns) \param t acquisition time (in ns)
\returns 0 \returns 0
*/ */
// int rateCorrect(double datain, double errin, double &dataout, double &errout, double tau, double t); // int rateCorrect(double datain, double errin, double &dataout, double &errout, double tau, double t);
/** /**
rate correct data rate correct data
\param datain data array \param datain data array
\param errin error array on data (if NULL will default to sqrt(datain) \param errin error array on data (if NULL will default to sqrt(datain)
\param dataout array of corrected data \param dataout array of corrected data
\param errout error on corrected data (if not NULL) \param errout error on corrected data (if not NULL)
\returns 0 \returns 0
*/ */
int rateCorrect(double* datain, double *errin, double* dataout, double *errout); int rateCorrect(double* datain, double *errin, double* dataout, double *errout);
@ -798,9 +798,9 @@ class multiSlsDetector : public slsDetectorUtils {
int exitServer(); int exitServer();
/** pure /////////////////////////////////////////////////// virtual function /** pure /////////////////////////////////////////////////// virtual function
function for processing data function for processing data
/param delflag if 1 the data are processed, written to file and then deleted. If 0 they are added to the finalDataQueue /param delflag if 1 the data are processed, written to file and then deleted. If 0 they are added to the finalDataQueue
\sa mythenDetector::processData \sa mythenDetector::processData
*/ */
/////////////////////////////////////////////////// virtual void* processData(int delflag=1); // thread function /////////////////////////////////////////////////// virtual void* processData(int delflag=1); // thread function
@ -817,29 +817,29 @@ class multiSlsDetector : public slsDetectorUtils {
/** /**
set dacs value set dacs value
\param val value (in V) \param val value (in V)
\param index DAC index \param index DAC index
\param imod module number (if -1 alla modules) \param imod module number (if -1 alla modules)
\returns current DAC value \returns current DAC value
*/ */
dacs_t setDAC(dacs_t val, dacIndex index, int imod=-1); dacs_t setDAC(dacs_t val, dacIndex index, int imod=-1);
/** /**
set dacs value set dacs value
\param val value (in V) \param val value (in V)
\param index DAC index \param index DAC index
\param imod module number (if -1 alla modules) \param imod module number (if -1 alla modules)
\returns current DAC value \returns current DAC value
*/ */
dacs_t getADC(dacIndex index, int imod=0); dacs_t getADC(dacIndex index, int imod=0);
/** /**
configure channel configure channel
\param reg channel register \param reg channel register
\param ichan channel number (-1 all) \param ichan channel number (-1 all)
\param ichip chip number (-1 all) \param ichip chip number (-1 all)
\param imod module number (-1 all) \param imod module number (-1 all)
\returns current register value \returns current register value
\sa ::sls_detector_channel \sa ::sls_detector_channel
*/ */
int setChannel(int64_t reg, int ichan=-1, int ichip=-1, int imod=-1); int setChannel(int64_t reg, int ichan=-1, int ichip=-1, int imod=-1);
/** /**
@ -856,7 +856,7 @@ class multiSlsDetector : public slsDetectorUtils {
/** /**
get run status get run status
\returns status mask \returns status mask
*/ */
//virtual runStatus getRunStatus()=0; //virtual runStatus getRunStatus()=0;
runStatus getRunStatus(); runStatus getRunStatus();
@ -869,14 +869,14 @@ class multiSlsDetector : public slsDetectorUtils {
char* getSettingsDir(); char* getSettingsDir();
/** sets the detector trimbit/settings directory \sa sharedSlsDetector */ /** sets the detector trimbit/settings directory \sa sharedSlsDetector */
char* setSettingsDir(string s); char* setSettingsDir(string s);
/** /**
returns the location of the calibration files returns the location of the calibration files
\sa sharedSlsDetector \sa sharedSlsDetector
*/ */
char* getCalDir(); char* getCalDir();
/** /**
sets the location of the calibration files sets the location of the calibration files
\sa sharedSlsDetector \sa sharedSlsDetector
*/ */
char* setCalDir(string s); char* setCalDir(string s);
@ -906,25 +906,25 @@ class multiSlsDetector : public slsDetectorUtils {
int setTrimEn(int nen, int *en=NULL); int setTrimEn(int nen, int *en=NULL);
int getTrimEn(int *en=NULL); int getTrimEn(int *en=NULL);
externalSignalFlag setExternalSignalFlags(externalSignalFlag pol=GET_EXTERNAL_SIGNAL_FLAG , int signalindex=0); externalSignalFlag setExternalSignalFlags(externalSignalFlag pol=GET_EXTERNAL_SIGNAL_FLAG , int signalindex=0);
int setReadOutFlags(readOutFlags flag=GET_READOUT_FLAGS); int setReadOutFlags(readOutFlags flag=GET_READOUT_FLAGS);
externalCommunicationMode setExternalCommunicationMode(externalCommunicationMode pol=GET_EXTERNAL_COMMUNICATION_MODE); externalCommunicationMode setExternalCommunicationMode(externalCommunicationMode pol=GET_EXTERNAL_COMMUNICATION_MODE);
/** /**
Loads dark image or gain image to the detector Loads dark image or gain image to the detector
\param index can be DARK_IMAGE or GAIN_IMAGE \param index can be DARK_IMAGE or GAIN_IMAGE
\fname file name to load data from \fname file name to load data from
\returns OK or FAIL \returns OK or FAIL
*/ */
int loadImageToDetector(imageType index,string const fname); int loadImageToDetector(imageType index,string const fname);
/** /**
sets the value of s angular conversion parameter sets the value of s angular conversion parameter
\param c can be ANGULAR_DIRECTION, GLOBAL_OFFSET, FINE_OFFSET, BIN_SIZE \param c can be ANGULAR_DIRECTION, GLOBAL_OFFSET, FINE_OFFSET, BIN_SIZE
\param v the value to be set \param v the value to be set
@ -933,153 +933,153 @@ class multiSlsDetector : public slsDetectorUtils {
double setAngularConversionParameter(angleConversionParameter c, double v); double setAngularConversionParameter(angleConversionParameter c, double v);
/** /**
writes a data file writes a data file
\param name of the file to be written \param name of the file to be written
\param data array of data values \param data array of data values
\param err array of arrors on the data. If NULL no errors will be written \param err array of arrors on the data. If NULL no errors will be written
\param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err) \param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err)
\param dataformat format of the data: can be 'i' integer or 'f' double (default) \param dataformat format of the data: can be 'i' integer or 'f' double (default)
\param nch number of channels to be written to file. if -1 defaults to the number of installed channels of the detector \param nch number of channels to be written to file. if -1 defaults to the number of installed channels of the detector
\returns OK or FAIL if it could not write the file or data=NULL \returns OK or FAIL if it could not write the file or data=NULL
\sa mythenDetector::writeDataFile \sa mythenDetector::writeDataFile
*/ */
int writeDataFile(string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int nch=-1); int writeDataFile(string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int nch=-1);
/** /**
writes a data file writes a data file
\param name of the file to be written \param name of the file to be written
\param data array of data values \param data array of data values
\returns OK or FAIL if it could not write the file or data=NULL \returns OK or FAIL if it could not write the file or data=NULL
\sa mythenDetector::writeDataFile \sa mythenDetector::writeDataFile
*/ */
int writeDataFile(string fname, int *data); int writeDataFile(string fname, int *data);
/** /**
reads a data file reads a data file
\param name of the file to be read \param name of the file to be read
\param data array of data values to be filled \param data array of data values to be filled
\param err array of arrors on the data. If NULL no errors are expected on the file \param err array of arrors on the data. If NULL no errors are expected on the file
\param ang array of angular values. If NULL data are expected in the form chan-val(-err) otherwise ang-val(-err) \param ang array of angular values. If NULL data are expected in the form chan-val(-err) otherwise ang-val(-err)
\param dataformat format of the data: can be 'i' integer or 'f' double (default) \param dataformat format of the data: can be 'i' integer or 'f' double (default)
\param nch number of channels to be written to file. if <=0 defaults to the number of installed channels of the detector \param nch number of channels to be written to file. if <=0 defaults to the number of installed channels of the detector
\returns OK or FAIL if it could not read the file or data=NULL \returns OK or FAIL if it could not read the file or data=NULL
\sa mythenDetector::readDataFile \sa mythenDetector::readDataFile
*/ */
int readDataFile(string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f'); int readDataFile(string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f');
/** /**
reads a data file reads a data file
\param name of the file to be read \param name of the file to be read
\param data array of data values \param data array of data values
\returns OK or FAIL if it could not read the file or data=NULL \returns OK or FAIL if it could not read the file or data=NULL
\sa mythenDetector::readDataFile \sa mythenDetector::readDataFile
*/ */
int readDataFile(string fname, int *data); int readDataFile(string fname, int *data);
/** /**
writes the counter memory block from the detector writes the counter memory block from the detector
\param startACQ is 1 to start acquisition after reading counter \param startACQ is 1 to start acquisition after reading counter
\param fname file name to load data from \param fname file name to load data from
\returns OK or FAIL \returns OK or FAIL
*/ */
int writeCounterBlockFile(string const fname,int startACQ=0); int writeCounterBlockFile(string const fname,int startACQ=0);
/** /**
Resets counter in detector Resets counter in detector
\param startACQ is 1 to start acquisition after resetting counter \param startACQ is 1 to start acquisition after resetting counter
\returns OK or FAIL \returns OK or FAIL
*/ */
int resetCounterBlock(int startACQ=0); int resetCounterBlock(int startACQ=0);
int getMoveFlag(int imod); int getMoveFlag(int imod);
slsDetector *getSlsDetector(int pos) {if (pos>=0 && pos< MAXDET) return detectors[pos]; return NULL;}; slsDetector *getSlsDetector(int pos) {if (pos>=0 && pos< MAXDET) return detectors[pos]; return NULL;};
//receiver //receiver
/** /**
calls setReceiverTCPSocket if online and sets the flag calls setReceiverTCPSocket if online and sets the flag
*/ */
int setReceiverOnline(int const online=GET_ONLINE_FLAG); int setReceiverOnline(int const online=GET_ONLINE_FLAG);
/** /**
Checks if the receiver is really online Checks if the receiver is really online
*/ */
string checkReceiverOnline(); string checkReceiverOnline();
/** /**
Sets up the receiver file name Sets up the receiver file name
@param fileName file name @param fileName file name
\returns file name \returns file name
*/ */
string setReceiverFileName(string fileName=""); string setReceiverFileName(string fileName="");
/** /**
Sets up the receiver file directory Sets up the receiver file directory
@param fileName fileDir file directory @param fileName fileDir file directory
\returns file dir \returns file dir
*/ */
string setReceiverFileDir(string fileDir=""); string setReceiverFileDir(string fileDir="");
/** /**
Sets up the receiver file index Sets up the receiver file index
@param fileIndex file index @param fileIndex file index
\returns file index \returns file index
*/ */
int setReceiverFileIndex(int fileIndex=-1); int setReceiverFileIndex(int fileIndex=-1);
/** Starts the listening mode of receiver /** Starts the listening mode of receiver
\returns OK or FAIL \returns OK or FAIL
*/ */
int startReceiver(); int startReceiver();
/** Stops the listening mode of receiver /** Stops the listening mode of receiver
\returns OK or FAIL \returns OK or FAIL
*/ */
int stopReceiver(); int stopReceiver();
/** gets the status of the listening mode of receiver /** gets the status of the listening mode of receiver
\returns status \returns status
*/ */
runStatus getReceiverStatus(); runStatus getReceiverStatus();
/** gets the number of frames caught by receiver /** gets the number of frames caught by receiver
\returns number of frames caught by receiver \returns number of frames caught by receiver
*/ */
int getFramesCaughtByReciver(); int getFramesCaughtByReciver();
/** Locks/Unlocks the connection to the receiver /** Locks/Unlocks the connection to the receiver
/param lock sets (1), usets (0), gets (-1) the lock /param lock sets (1), usets (0), gets (-1) the lock
/returns lock status of the receiver /returns lock status of the receiver
*/ */
int lockReceiver(int lock=-1); int lockReceiver(int lock=-1);
/** /**
Returns the IP of the last client connecting to the receiver Returns the IP of the last client connecting to the receiver
*/ */
string getReceiverLastClientIP(); string getReceiverLastClientIP();
int fillModuleMask(int *mM); int fillModuleMask(int *mM);
protected: protected:

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -2,37 +2,37 @@
#ifndef SLS_DETECTOR_BASE_H #ifndef SLS_DETECTOR_BASE_H
#define SLS_DETECTOR_BASE_H #define SLS_DETECTOR_BASE_H
/** /**
\mainpage Common C++ library for SLS detectors data acquisition \mainpage Common C++ library for SLS detectors data acquisition
* *
* \section intro_sec Introduction * \section intro_sec Introduction
* \subsection mot_sec Motivation * \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 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 \subsection arch_sec System Architecture
The architecture of the acquisitions system is intended as follows: 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 A socket server running on the detector (or more than one in some special cases)
\li C++ classes common to all detectors for client-server communication. These can be supplied to users as libraries and embedded also in acquisition systems which are not developed by the SLS \li C++ classes common to all detectors for client-server communication. These can be supplied to users as libraries and embedded also in acquisition systems which are not developed by the SLS
\li the possibility of using a Qt-based graphical user interface (with eventually root analisys capabilities) \li the possibility of using a Qt-based graphical user interface (with eventually root analisys capabilities)
\li the possibility of running all commands from command line. In order to ensure a fast operation of this so called "text client" the detector parameters should not be re-initialized everytime. For this reason a shared memory block is allocated where the main detector flags and parameters are stored \li the possibility of running all commands from command line. In order to ensure a fast operation of this so called "text client" the detector parameters should not be re-initialized everytime. For this reason a shared memory block is allocated where the main detector flags and parameters are stored
\li a Root library for data postprocessing and detector calibration (energy, angle). \li a Root library for data postprocessing and detector calibration (energy, angle).
\section howto_sec How to use it \section howto_sec How to use it
The detectors can be simply operated by using the provided GUi or command line executable. <br> The detectors can be simply operated by using the provided GUi or command line executable. <br>
In case you need to embed the detector control e.g in the beamline control software, compile these classes using In case you need to embed the detector control e.g in the beamline control software, compile these classes using
<BR> <BR>
make package make package
<br> <br>
and link the shared library created to your software slsDetectorSoftware/bin/libSlsDetector.so and link the shared library created to your software slsDetectorSoftware/bin/libSlsDetector.so
<br> <br>
The software can also be installed (with super-user rights)<br> The software can also be installed (with super-user rights)<br>
make install make install
<br> <br>
<br> <br>
Most methods of interest for the user are implemented in the ::slsDetectorBase interface class, but the classes to be implemented in the main program are either ::slsDetector (for single controller detectors) or ::multiSlsDetector (for multiple controllers, but can work also for single controllers). Most methods of interest for the user are implemented in the ::slsDetectorBase interface class, but the classes to be implemented in the main program are either ::slsDetector (for single controller detectors) or ::multiSlsDetector (for multiple controllers, but can work also for single controllers).
@author Anna Bergamaschi @author Anna Bergamaschi
@version 0.1alpha @version 0.1alpha
*/ */
@ -58,7 +58,7 @@ using namespace std;
@libdoc The slsDetectorBase contains also a set of purely virtual functions useful for the implementation of the derived classes @libdoc The slsDetectorBase contains also a set of purely virtual functions useful for the implementation of the derived classes
* @short This is the base class for all detector functionalities * @short This is the base class for all detector functionalities
*/ */
@ -68,119 +68,119 @@ class slsDetectorBase : public virtual slsDetectorDefs {
public: public:
/** default constructor */ /** default constructor */
slsDetectorBase(){}; slsDetectorBase(){};
/** virtual destructor */ /** virtual destructor */
virtual ~slsDetectorBase(){}; virtual ~slsDetectorBase(){};
string getDetectorDeveloper(){return string("PSI");}; string getDetectorDeveloper(){return string("PSI");};
// protected: // protected:
/** /**
set angular conversion set angular conversion
\param fname file with angular conversion constants ("" disable) \param fname file with angular conversion constants ("" disable)
\returns 0 if angular conversion disabled, >0 otherwise \returns 0 if angular conversion disabled, >0 otherwise
*/ */
virtual int setAngularConversionFile(string fname="")=0; virtual int setAngularConversionFile(string fname="")=0;
/** /**
pure virtual function pure virtual function
returns the angular conversion file returns the angular conversion file
*/ */
virtual string getAngularConversionFile()=0; virtual string getAngularConversionFile()=0;
/** /**
set action set action
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS} \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS}
\param fname for script ("" disable) \param fname for script ("" disable)
\returns 0 if action disabled, >0 otherwise \returns 0 if action disabled, >0 otherwise
*/ */
virtual int setActionScript(int iaction, string fname="")=0; virtual int setActionScript(int iaction, string fname="")=0;
/** /**
set action set action
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS} \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS}
\param par for script ("" disable) \param par for script ("" disable)
\returns 0 if action disabled, >0 otherwise \returns 0 if action disabled, >0 otherwise
*/ */
virtual int setActionParameter(int iaction, string par="")=0; virtual int setActionParameter(int iaction, string par="")=0;
/** /**
returns action script returns action script
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript} \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript}
\returns action script \returns action script
*/ */
virtual string getActionScript(int iaction)=0; virtual string getActionScript(int iaction)=0;
/** /**
returns action parameter returns action parameter
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript} \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript}
\returns action parameter \returns action parameter
*/ */
virtual string getActionParameter(int iaction)=0; virtual string getActionParameter(int iaction)=0;
/** /**
set scan script set scan script
\param index is the scan index (0 or 1) \param index is the scan index (0 or 1)
\param script fname for script ("" disable, "none" disables and overwrites current, "threshold" makes threshold scan, "trimbits" make trimbits scan, "energy" makes energy scan) \param script fname for script ("" disable, "none" disables and overwrites current, "threshold" makes threshold scan, "trimbits" make trimbits scan, "energy" makes energy scan)
\returns 0 if scan disabled, >0 otherwise \returns 0 if scan disabled, >0 otherwise
*/ */
virtual int setScanScript(int index, string script="")=0; virtual int setScanScript(int index, string script="")=0;
/** /**
set scan script parameter set scan script parameter
\param index is the scan index (0 or 1) \param index is the scan index (0 or 1)
\param spar parameter to be passed to the scan script with syntax par=spar \param spar parameter to be passed to the scan script with syntax par=spar
\returns 0 if scan disabled, >0 otherwise \returns 0 if scan disabled, >0 otherwise
*/ */
virtual int setScanParameter(int index, string spar="")=0; virtual int setScanParameter(int index, string spar="")=0;
/** set scan precision /** set scan precision
\param index is the scan index (0 or 1) \param index is the scan index (0 or 1)
\param precision number of decimals to use for the scan variable in the file name \param precision number of decimals to use for the scan variable in the file name
\returns 0 if scan disabled, >0 otherwise */ \returns 0 if scan disabled, >0 otherwise */
virtual int setScanPrecision(int index, int precision=-1)=0; virtual int setScanPrecision(int index, int precision=-1)=0;
/** /**
set scan steps (passed to the scan script as var=step) set scan steps (passed to the scan script as var=step)
\param index is the scan index (0 or 1) \param index is the scan index (0 or 1)
\param nvalues is the number of steps \param nvalues is the number of steps
\param values array of steps \param values array of steps
\returns 0 if scan disabled, >0 otherwise*/ \returns 0 if scan disabled, >0 otherwise*/
virtual int setScanSteps(int index, int nvalues=-1, double *values=NULL)=0; virtual int setScanSteps(int index, int nvalues=-1, double *values=NULL)=0;
/** /**
get scan script get scan script
\param index is the scan index (0 or 1) \param index is the scan index (0 or 1)
\returns "none" if disables, "threshold" threshold scan, "trimbits" trimbits scan, "energy" energy scan or scan script name \returns "none" if disables, "threshold" threshold scan, "trimbits" trimbits scan, "energy" energy scan or scan script name
*/ */
virtual string getScanScript(int index)=0; virtual string getScanScript(int index)=0;
/** /**
get scan script get scan script
\param index is the scan index (0 or 1) \param index is the scan index (0 or 1)
\returns scan script parameter \returns scan script parameter
*/ */
virtual string getScanParameter(int index)=0; virtual string getScanParameter(int index)=0;
/** /**
get scan precision get scan precision
\param index is the scan index (0 or 1) \param index is the scan index (0 or 1)
\returns precision i.e. number of decimals to use for the scan variable in the file name \returns precision i.e. number of decimals to use for the scan variable in the file name
*/ */
virtual int getScanPrecision(int index)=0; virtual int getScanPrecision(int index)=0;
/** /**
get scan steps get scan steps
\param index is the scan index (0 or 1) \param index is the scan index (0 or 1)
\param values pointer to array of values (must be allocated in advance) \param values pointer to array of values (must be allocated in advance)
\returns number of steps \returns number of steps
*/ */
virtual int getScanSteps(int index, double *values=NULL)=0; virtual int getScanSteps(int index, double *values=NULL)=0;
@ -193,64 +193,64 @@ class slsDetectorBase : public virtual slsDetectorDefs {
virtual int writeConfigurationFile(string const fname)=0; virtual int writeConfigurationFile(string const fname)=0;
/** /**
Loads dark image or gain image to the detector Loads dark image or gain image to the detector
\param index can be DARK_IMAGE or GAIN_IMAGE \param index can be DARK_IMAGE or GAIN_IMAGE
\param fname file name to load data from \param fname file name to load data from
\returns OK or FAIL \returns OK or FAIL
*/ */
virtual int loadImageToDetector(imageType index,string const fname)=0; virtual int loadImageToDetector(imageType index,string const fname)=0;
/** /**
\returns number of positions \returns number of positions
*/ */
virtual int getNumberOfPositions()=0;// {return 0;}; virtual int getNumberOfPositions()=0;// {return 0;};
/** /**
\returns action mask \returns action mask
*/ */
virtual int getActionMask()=0;// {return 0;}; virtual int getActionMask()=0;// {return 0;};
/** /**
\param index scan level index \param index scan level index
\returns current scan variable \returns current scan variable
*/ */
virtual double getCurrentScanVariable(int index)=0;// {return 0;}; virtual double getCurrentScanVariable(int index)=0;// {return 0;};
/** /**
\returns current position index \returns current position index
*/ */
virtual int getCurrentPositionIndex()=0;// {return 0;}; virtual int getCurrentPositionIndex()=0;// {return 0;};
/** /**
\returns total number of channels \returns total number of channels
*/ */
virtual int getTotalNumberOfChannels()=0; virtual int getTotalNumberOfChannels()=0;
/** generates file name without extension */ /** generates file name without extension */
virtual string createFileName()=0; virtual string createFileName()=0;
virtual void incrementProgress()=0; virtual void incrementProgress()=0;
virtual double getCurrentProgress()=0; virtual double getCurrentProgress()=0;
virtual void incrementFileIndex()=0; virtual void incrementFileIndex()=0;
virtual int setTotalProgress()=0; virtual int setTotalProgress()=0;
virtual double* decodeData(int *datain, double *fdata=NULL)=0; virtual double* decodeData(int *datain, double *fdata=NULL)=0;
virtual string getCurrentFileName()=0; virtual string getCurrentFileName()=0;
virtual int getFileIndexFromFileName(string fname)=0; virtual int getFileIndexFromFileName(string fname)=0;
virtual double *convertAngles()=0; virtual double *convertAngles()=0;
/** /**
set rate correction set rate correction
\param t dead time in ns - if 0 disable correction, if >0 set dead time to t, if <0 set deadtime to default dead time for current settings \param t dead time in ns - if 0 disable correction, if >0 set dead time to t, if <0 set deadtime to default dead time for current settings
@ -275,7 +275,7 @@ class slsDetectorBase : public virtual slsDetectorDefs {
int setFlatFieldCorrectionFile(string fname=""){return setFlatFieldCorrection(fname);}; int setFlatFieldCorrectionFile(string fname=""){return setFlatFieldCorrection(fname);};
/** /**
set/get dynamic range set/get dynamic range
\param i dynamic range (-1 get) \param i dynamic range (-1 get)
\returns current dynamic range \returns current dynamic range
@ -308,11 +308,11 @@ class slsDetectorBase : public virtual slsDetectorDefs {
/** performs a complete acquisition including scansand data processing /** performs a complete acquisition including scansand data processing
moves the detector to next position <br> moves the detector to next position <br>
starts and reads the detector <br> starts and reads the detector <br>
reads the IC (if required) <br> reads the IC (if required) <br>
reads the encoder (iof required for angualr conversion) <br> reads the encoder (iof required for angualr conversion) <br>
processes the data (flat field, rate, angular conversion and merging ::processData()) processes the data (flat field, rate, angular conversion and merging ::processData())
\param delflag 0 leaves the data in the final data queue (default is 1) \param delflag 0 leaves the data in the final data queue (default is 1)
\returns nothing \returns nothing
*/ */
@ -321,74 +321,74 @@ class slsDetectorBase : public virtual slsDetectorDefs {
int startMeasurement(){acquire(0); return OK;}; int startMeasurement(){acquire(0); return OK;};
/** /**
asks and receives a data frame from the detector, writes it to disk and processes the data asks and receives a data frame from the detector, writes it to disk and processes the data
\returns pointer to the data or NULL (unused!!!). \returns pointer to the data or NULL (unused!!!).
*/ */
virtual int* readFrame()=0; virtual int* readFrame()=0;
/** /**
start detector acquisition start detector acquisition
\returns OK/FAIL \returns OK/FAIL
*/ */
virtual int startAcquisition()=0; virtual int startAcquisition()=0;
/** /**
stop detector acquisition stop detector acquisition
\returns OK/FAIL \returns OK/FAIL
*/ */
virtual int stopAcquisition()=0; virtual int stopAcquisition()=0;
int stopMeasurement(){return stopAcquisition();}; int stopMeasurement(){return stopAcquisition();};
virtual int getChansPerMod(int imod=0)=0; virtual int getChansPerMod(int imod=0)=0;
/** /**
set/get timer value set/get timer value
\param index timer index \param index timer index
\param t time in ns or number of...(e.g. frames, gates, probes) \param t time in ns or number of...(e.g. frames, gates, probes)
\returns timer set value in ns or number of...(e.g. frames, gates, probes) \returns timer set value in ns or number of...(e.g. frames, gates, probes)
*/ */
virtual int64_t setTimer(timerIndex index, int64_t t=-1)=0; virtual int64_t setTimer(timerIndex index, int64_t t=-1)=0;
int64_t setExposureTime(int64_t t=-1){return setTimer(ACQUISITION_TIME,t);}; int64_t setExposureTime(int64_t t=-1){return setTimer(ACQUISITION_TIME,t);};
int64_t setExposurePeriod(int64_t t=-1){return setTimer(FRAME_PERIOD,t);}; int64_t setExposurePeriod(int64_t t=-1){return setTimer(FRAME_PERIOD,t);};
int64_t setDelayAfterTrigger(int64_t t=-1){return setTimer(DELAY_AFTER_TRIGGER,t);}; int64_t setDelayAfterTrigger(int64_t t=-1){return setTimer(DELAY_AFTER_TRIGGER,t);};
int64_t setNumberOfGates(int64_t t=-1){return setTimer(GATES_NUMBER,t);}; int64_t setNumberOfGates(int64_t t=-1){return setTimer(GATES_NUMBER,t);};
int64_t setNumberOfFrames(int64_t t=-1){return setTimer(FRAME_NUMBER,t);}; int64_t setNumberOfFrames(int64_t t=-1){return setTimer(FRAME_NUMBER,t);};
int64_t setNumberOfCycles(int64_t t=-1){return setTimer(CYCLES_NUMBER,t);}; int64_t setNumberOfCycles(int64_t t=-1){return setTimer(CYCLES_NUMBER,t);};
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
/** /**
@short get run status @short get run status
\returns status mask \returns status mask
*/ */
virtual runStatus getRunStatus()=0; virtual runStatus getRunStatus()=0;
int getDetectorStatus() {return (int)getRunStatus();}; int getDetectorStatus() {return (int)getRunStatus();};
/** @short sets the onlineFlag /** @short sets the onlineFlag
\param online can be: -1 returns wether the detector is in online (1) or offline (0) state; 0 detector in offline state; 1 detector in online state \param online can be: -1 returns wether the detector is in online (1) or offline (0) state; 0 detector in offline state; 1 detector in online state
\returns 0 (offline) or 1 (online) \returns 0 (offline) or 1 (online)
*/ */
virtual int setOnline(int const online=-1)=0; virtual int setOnline(int const online=-1)=0;
/** /**
@short set detector settings @short set detector settings
\param isettings settings index (-1 gets) \param isettings settings index (-1 gets)
\returns current settings \returns current settings
*/ */
virtual detectorSettings setSettings(detectorSettings isettings, int imod=-1)=0; virtual detectorSettings setSettings(detectorSettings isettings, int imod=-1)=0;
int setSettings(int isettings){return (int)setSettings((detectorSettings)isettings,-1);}; int setSettings(int isettings){return (int)setSettings((detectorSettings)isettings,-1);};
virtual detectorSettings getSettings(int imod=-1)=0; virtual detectorSettings getSettings(int imod=-1)=0;
/** /**
get threshold energy get threshold energy
\param imod module number (-1 all) \param imod module number (-1 all)
\returns current threshold value for imod in ev (-1 failed) \returns current threshold value for imod in ev (-1 failed)
*/ */
virtual int getThresholdEnergy(int imod)=0; virtual int getThresholdEnergy(int imod)=0;
int getThresholdEnergy(){return getThresholdEnergy(-1);}; int getThresholdEnergy(){return getThresholdEnergy(-1);};
/** /**
set/get the external communication mode set/get the external communication mode
obsolete \sa setExternalSignalFlags obsolete \sa setExternalSignalFlags
\param pol value to be set \sa externalCommunicationMode \param pol value to be set \sa externalCommunicationMode
\returns current external communication mode \returns current external communication mode
*/ */
@ -417,12 +417,12 @@ int64_t setNumberOfCycles(int64_t t=-1){return setTimer(CYCLES_NUMBER,t);};
int retrieveDetectorSetup(string const fname){return retrieveDetectorSetup(fname,0);}; int retrieveDetectorSetup(string const fname){return retrieveDetectorSetup(fname,0);};
/** /**
@short @short
\returns the default output file index \returns the default output file index
*/ */
virtual int getFileIndex()=0; virtual int getFileIndex()=0;
/** /**
@short sets the default output file index @short sets the default output file index
\param i file index \param i file index
\returns the default output file index \returns the default output file index
*/ */
@ -431,50 +431,50 @@ int64_t setNumberOfCycles(int64_t t=-1){return setTimer(CYCLES_NUMBER,t);};
//receiver //receiver
/** /**
calls setReceiverTCPSocket if online and sets the flag calls setReceiverTCPSocket if online and sets the flag
*/ */
virtual int setReceiverOnline(int const online=GET_ONLINE_FLAG)=0; virtual int setReceiverOnline(int const online=GET_ONLINE_FLAG)=0;
/** /**
Sets up the receiver file name Sets up the receiver file name
@param fileName file name @param fileName file name
\returns file name \returns file name
*/ */
virtual string setReceiverFileName(string fileName="")=0; virtual string setReceiverFileName(string fileName="")=0;
/** /**
Sets up the receiver file directory Sets up the receiver file directory
@param fileName fileDir file directory @param fileName fileDir file directory
\returns file dir \returns file dir
*/ */
virtual string setReceiverFileDir(string fileDir="")=0; virtual string setReceiverFileDir(string fileDir="")=0;
/** /**
Sets up the receiver file index Sets up the receiver file index
@param fileIndex file index @param fileIndex file index
\returns file index \returns file index
*/ */
virtual int setReceiverFileIndex(int fileIndex=-1)=0; virtual int setReceiverFileIndex(int fileIndex=-1)=0;
/** Starts the listening mode of receiver /** Starts the listening mode of receiver
\returns OK or FAIL \returns OK or FAIL
*/ */
virtual int startReceiver()=0; virtual int startReceiver()=0;
/** Stops the listening mode of receiver /** Stops the listening mode of receiver
\returns OK or FAIL \returns OK or FAIL
*/ */
virtual int stopReceiver()=0; virtual int stopReceiver()=0;
/** gets the status of the listening mode of receiver /** gets the status of the listening mode of receiver
\returns status \returns status
*/ */
virtual runStatus getReceiverStatus()=0; virtual runStatus getReceiverStatus()=0;
/** gets the number of frames caught by receiver /** gets the number of frames caught by receiver
\returns number of frames caught by receiver \returns number of frames caught by receiver
*/ */
virtual int getFramesCaughtByReciver()=0; virtual int getFramesCaughtByReciver()=0;
/** Locks/Unlocks the connection to the receiver /** Locks/Unlocks the connection to the receiver
@ -496,7 +496,7 @@ int64_t setNumberOfCycles(int64_t t=-1){return setTimer(CYCLES_NUMBER,t);};
case GOTTHARD: return string("Gotthard"); \ case GOTTHARD: return string("Gotthard"); \
case AGIPD: return string("Agipd"); \ case AGIPD: return string("Agipd"); \
default: return string("Unknown"); \ default: return string("Unknown"); \
}}; }};
/** returns detector type index from detector type string /** returns detector type index from detector type string
\param type can be MYTHEN, PILATUS, EIGER, GOTTHARD, AGIPD, GENERIC \param type can be MYTHEN, PILATUS, EIGER, GOTTHARD, AGIPD, GENERIC
@ -573,23 +573,23 @@ int64_t setNumberOfCycles(int64_t t=-1){return setTimer(CYCLES_NUMBER,t);};
*/ */
static externalSignalFlag externalSignalType(string sval){\ static externalSignalFlag externalSignalType(string sval){\
if (sval=="off") return SIGNAL_OFF;\ if (sval=="off") return SIGNAL_OFF;\
if (sval=="gate_in_active_high") return GATE_IN_ACTIVE_HIGH; \ if (sval=="gate_in_active_high") return GATE_IN_ACTIVE_HIGH; \
if (sval=="gate_in_active_low") return GATE_IN_ACTIVE_LOW;\ if (sval=="gate_in_active_low") return GATE_IN_ACTIVE_LOW;\
if (sval=="trigger_in_rising_edge") return TRIGGER_IN_RISING_EDGE;\ if (sval=="trigger_in_rising_edge") return TRIGGER_IN_RISING_EDGE;\
if (sval=="trigger_in_falling_edge") return TRIGGER_IN_FALLING_EDGE;\ if (sval=="trigger_in_falling_edge") return TRIGGER_IN_FALLING_EDGE;\
if (sval=="ro_trigger_in_rising_edge") return RO_TRIGGER_IN_RISING_EDGE;\ if (sval=="ro_trigger_in_rising_edge") return RO_TRIGGER_IN_RISING_EDGE;\
if (sval=="ro_trigger_in_falling_edge") return RO_TRIGGER_IN_FALLING_EDGE;\ if (sval=="ro_trigger_in_falling_edge") return RO_TRIGGER_IN_FALLING_EDGE;\
if (sval=="gate_out_active_high") return GATE_OUT_ACTIVE_HIGH;\ if (sval=="gate_out_active_high") return GATE_OUT_ACTIVE_HIGH;\
if (sval=="gate_out_active_low") return GATE_OUT_ACTIVE_LOW;\ if (sval=="gate_out_active_low") return GATE_OUT_ACTIVE_LOW;\
if (sval=="trigger_out_rising_edge") return TRIGGER_OUT_RISING_EDGE;\ if (sval=="trigger_out_rising_edge") return TRIGGER_OUT_RISING_EDGE;\
if (sval=="trigger_out_falling_edge") return TRIGGER_OUT_FALLING_EDGE;\ if (sval=="trigger_out_falling_edge") return TRIGGER_OUT_FALLING_EDGE;\
if (sval=="ro_trigger_out_rising_edge") return RO_TRIGGER_OUT_RISING_EDGE;\ if (sval=="ro_trigger_out_rising_edge") return RO_TRIGGER_OUT_RISING_EDGE;\
if (sval=="ro_trigger_out_falling_edge") return RO_TRIGGER_OUT_FALLING_EDGE;\ if (sval=="ro_trigger_out_falling_edge") return RO_TRIGGER_OUT_FALLING_EDGE;\
if (sval=="sync") return MASTER_SLAVE_SYNCHRONIZATION;\ if (sval=="sync") return MASTER_SLAVE_SYNCHRONIZATION;\
if (sval=="gnd") return OUTPUT_LOW;\ if (sval=="gnd") return OUTPUT_LOW;\
if (sval=="vcc") return OUTPUT_HIGH;\ if (sval=="vcc") return OUTPUT_HIGH;\
return GET_EXTERNAL_SIGNAL_FLAG ;}; return GET_EXTERNAL_SIGNAL_FLAG ;};
/** returns detector settings string from index /** returns detector settings string from index
\param s can be STANDARD, FAST, HIGHGAIN, DYNAMICGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN, GET_SETTINGS \param s can be STANDARD, FAST, HIGHGAIN, DYNAMICGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN, GET_SETTINGS
@ -651,14 +651,14 @@ int64_t setNumberOfCycles(int64_t t=-1){return setTimer(CYCLES_NUMBER,t);};
*/ */
static externalCommunicationMode externalCommunicationType(string sval){\ static externalCommunicationMode externalCommunicationType(string sval){\
if (sval=="auto") return AUTO_TIMING;\ if (sval=="auto") return AUTO_TIMING;\
if (sval=="trigger") return TRIGGER_EXPOSURE; \ if (sval=="trigger") return TRIGGER_EXPOSURE; \
if (sval=="trigger_frame") return TRIGGER_FRAME; \ if (sval=="trigger_frame") return TRIGGER_FRAME; \
if (sval=="ro_trigger") return TRIGGER_READOUT;\ if (sval=="ro_trigger") return TRIGGER_READOUT;\
if (sval=="gating") return GATE_FIX_NUMBER;\ if (sval=="gating") return GATE_FIX_NUMBER;\
if (sval=="triggered_gating") return GATE_WITH_START_TRIGGER;\ if (sval=="triggered_gating") return GATE_WITH_START_TRIGGER;\
if (sval=="trigger_window") return TRIGGER_WINDOW; \ if (sval=="trigger_window") return TRIGGER_WINDOW; \
return GET_EXTERNAL_COMMUNICATION_MODE; \ return GET_EXTERNAL_COMMUNICATION_MODE; \
}; };
/** returns string from run status index /** returns string from run status index

File diff suppressed because it is too large Load Diff

View File

@ -16,73 +16,73 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
public: public:
slsDetectorCommand(slsDetectorUtils *det); slsDetectorCommand(slsDetectorUtils *det);
/* /\** */ /* /\** */
/* executes a set of string arguments according to a given format. It is used to read/write configuration file, dump and retrieve detector settings and for the command line interface command parsing */ /* executes a set of string arguments according to a given format. It is used to read/write configuration file, dump and retrieve detector settings and for the command line interface command parsing */
/* \param narg number of arguments */ /* \param narg number of arguments */
/* \param args array of string arguments */ /* \param args array of string arguments */
/* \param action can be PUT_ACTION or GET_ACTION (from text client even READOUT_ACTION for acquisition) */ /* \param action can be PUT_ACTION or GET_ACTION (from text client even READOUT_ACTION for acquisition) */
/* \returns answer string */ /* \returns answer string */
/* *\/ */ /* *\/ */
virtual string executeLine(int narg, char *args[], int action); virtual string executeLine(int narg, char *args[], int action);
/* /\** */ /* /\** */
/* returns the help for the executeLine command */ /* returns the help for the executeLine command */
/* \param os output stream to return the help to */ /* \param os output stream to return the help to */
/* \param action can be PUT_ACTION or GET_ACTION (from text client even READOUT_ACTION for acquisition) */ /* \param action can be PUT_ACTION or GET_ACTION (from text client even READOUT_ACTION for acquisition) */
/* *\/ */ /* *\/ */
string helpLine(int narg, char *args[], int action=HELP_ACTION); string helpLine(int narg, char *args[], int action=HELP_ACTION);
static string helpAcquire(int narg, char *args[], int action); static string helpAcquire(int narg, char *args[], int action);
static string helpData(int narg, char *args[], int action); static string helpData(int narg, char *args[], int action);
static string helpFrame(int narg, char *args[], int action); static string helpFrame(int narg, char *args[], int action);
static string helpStatus(int narg, char *args[], int action); static string helpStatus(int narg, char *args[], int action);
static string helpFree(int narg, char *args[], int action); static string helpFree(int narg, char *args[], int action);
static string helpAdd(int narg, char *args[], int action); static string helpAdd(int narg, char *args[], int action);
static string helpRemove(int narg, char *args[], int action); static string helpRemove(int narg, char *args[], int action);
static string helpHostname(int narg, char *args[], int action); static string helpHostname(int narg, char *args[], int action);
static string helpId(int narg, char *args[], int action); static string helpId(int narg, char *args[], int action);
static string helpMaster(int narg, char *args[], int action); static string helpMaster(int narg, char *args[], int action);
static string helpSync(int narg, char *args[], int action); static string helpSync(int narg, char *args[], int action);
static string helpExitServer(int narg, char *args[], int action); static string helpExitServer(int narg, char *args[], int action);
static string helpSettingsDir(int narg, char *args[], int action); static string helpSettingsDir(int narg, char *args[], int action);
static string helpCalDir(int narg, char *args[], int action); static string helpCalDir(int narg, char *args[], int action);
static string helpTrimEn(int narg, char *args[], int action); static string helpTrimEn(int narg, char *args[], int action);
static string helpOutDir(int narg, char *args[], int action); static string helpOutDir(int narg, char *args[], int action);
static string helpFileName(int narg, char *args[], int action); static string helpFileName(int narg, char *args[], int action);
static string helpFileIndex(int narg, char *args[], int action); static string helpFileIndex(int narg, char *args[], int action);
static string helpFlatField(int narg, char *args[], int action); static string helpFlatField(int narg, char *args[], int action);
static string helpRateCorr(int narg, char *args[], int action); static string helpRateCorr(int narg, char *args[], int action);
static string helpBadChannels(int narg, char *args[], int action); static string helpBadChannels(int narg, char *args[], int action);
static string helpAngConv(int narg, char *args[], int action); static string helpAngConv(int narg, char *args[], int action);
static string helpThreaded(int narg, char *args[], int action); static string helpThreaded(int narg, char *args[], int action);
static string helpPositions(int narg, char *args[], int action); static string helpPositions(int narg, char *args[], int action);
static string helpScripts(int narg, char *args[], int action); static string helpScripts(int narg, char *args[], int action);
static string helpScans(int narg, char *args[], int action); static string helpScans(int narg, char *args[], int action);
static string helpNetworkParameter(int narg, char *args[], int action); static string helpNetworkParameter(int narg, char *args[], int action);
static string helpPort(int narg, char *args[], int action); static string helpPort(int narg, char *args[], int action);
static string helpLock(int narg, char *args[], int action); static string helpLock(int narg, char *args[], int action);
static string helpLastClient(int narg, char *args[], int action); static string helpLastClient(int narg, char *args[], int action);
static string helpOnline(int narg, char *args[], int action); static string helpOnline(int narg, char *args[], int action);
static string helpConfigureMac(int narg, char *args[], int action); static string helpConfigureMac(int narg, char *args[], int action);
static string helpDetectorSize(int narg, char *args[], int action); static string helpDetectorSize(int narg, char *args[], int action);
static string helpSettings(int narg, char *args[], int action); static string helpSettings(int narg, char *args[], int action);
static string helpSN(int narg, char *args[], int action); static string helpSN(int narg, char *args[], int action);
static string helpDigiTest(int narg, char *args[], int action); static string helpDigiTest(int narg, char *args[], int action);
static string helpRegister(int narg, char *args[], int action); static string helpRegister(int narg, char *args[], int action);
static string helpDAC(int narg, char *args[], int action); static string helpDAC(int narg, char *args[], int action);
static string helpTimer(int narg, char *args[], int action); static string helpTimer(int narg, char *args[], int action);
static string helpTiming(int narg, char *args[], int action); static string helpTiming(int narg, char *args[], int action);
static string helpTimeLeft(int narg, char *args[], int action); static string helpTimeLeft(int narg, char *args[], int action);
static string helpSpeed(int narg, char *args[], int action); static string helpSpeed(int narg, char *args[], int action);
static string helpAdvanced(int narg, char *args[], int action); static string helpAdvanced(int narg, char *args[], int action);
static string helpConfiguration(int narg, char *args[], int action); static string helpConfiguration(int narg, char *args[], int action);
static string helpImage(int narg, char *args[], int action); static string helpImage(int narg, char *args[], int action);
static string helpCounter(int narg, char *args[], int action); static string helpCounter(int narg, char *args[], int action);
static string helpADC(int narg, char *args[], int action); static string helpADC(int narg, char *args[], int action);
static string helpEnablefwrite(int narg, char *args[], int action); static string helpEnablefwrite(int narg, char *args[], int action);
static string helpReceiver(int narg, char *args[], int action); static string helpReceiver(int narg, char *args[], int action);
@ -101,76 +101,76 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
slsDetectorUtils *myDet; slsDetectorUtils *myDet;
string cmdUnderDevelopment(int narg, char *args[], int action); string cmdUnderDevelopment(int narg, char *args[], int action);
string cmdUnknown(int narg, char *args[], int action); string cmdUnknown(int narg, char *args[], int action);
string cmdAcquire(int narg, char *args[], int action); string cmdAcquire(int narg, char *args[], int action);
string cmdData(int narg, char *args[], int action); string cmdData(int narg, char *args[], int action);
string cmdFrame(int narg, char *args[], int action); string cmdFrame(int narg, char *args[], int action);
string cmdStatus(int narg, char *args[], int action); string cmdStatus(int narg, char *args[], int action);
string cmdFree(int narg, char *args[], int action); string cmdFree(int narg, char *args[], int action);
string cmdAdd(int narg, char *args[], int action); string cmdAdd(int narg, char *args[], int action);
string cmdRemove(int narg, char *args[], int action); string cmdRemove(int narg, char *args[], int action);
string cmdHostname(int narg, char *args[], int action); string cmdHostname(int narg, char *args[], int action);
string cmdId(int narg, char *args[], int action); string cmdId(int narg, char *args[], int action);
string cmdMaster(int narg, char *args[], int action); string cmdMaster(int narg, char *args[], int action);
string cmdSync(int narg, char *args[], int action); string cmdSync(int narg, char *args[], int action);
string cmdHelp(int narg, char *args[], int action); string cmdHelp(int narg, char *args[], int action);
string cmdExitServer(int narg, char *args[], int action); string cmdExitServer(int narg, char *args[], int action);
string cmdSettingsDir(int narg, char *args[], int action); string cmdSettingsDir(int narg, char *args[], int action);
string cmdCalDir(int narg, char *args[], int action); string cmdCalDir(int narg, char *args[], int action);
string cmdTrimEn(int narg, char *args[], int action); string cmdTrimEn(int narg, char *args[], int action);
string cmdOutDir(int narg, char *args[], int action); string cmdOutDir(int narg, char *args[], int action);
string cmdFileName(int narg, char *args[], int action); string cmdFileName(int narg, char *args[], int action);
string cmdFileIndex(int narg, char *args[], int action); string cmdFileIndex(int narg, char *args[], int action);
string cmdFlatField(int narg, char *args[], int action); string cmdFlatField(int narg, char *args[], int action);
string cmdRateCorr(int narg, char *args[], int action); string cmdRateCorr(int narg, char *args[], int action);
string cmdBadChannels(int narg, char *args[], int action); string cmdBadChannels(int narg, char *args[], int action);
string cmdAngConv(int narg, char *args[], int action); string cmdAngConv(int narg, char *args[], int action);
string cmdThreaded(int narg, char *args[], int action); string cmdThreaded(int narg, char *args[], int action);
string cmdPositions(int narg, char *args[], int action); string cmdPositions(int narg, char *args[], int action);
string cmdScripts(int narg, char *args[], int action); string cmdScripts(int narg, char *args[], int action);
string cmdScans(int narg, char *args[], int action); string cmdScans(int narg, char *args[], int action);
string cmdNetworkParameter(int narg, char *args[], int action); string cmdNetworkParameter(int narg, char *args[], int action);
string cmdPort(int narg, char *args[], int action); string cmdPort(int narg, char *args[], int action);
string cmdLock(int narg, char *args[], int action); string cmdLock(int narg, char *args[], int action);
string cmdLastClient(int narg, char *args[], int action); string cmdLastClient(int narg, char *args[], int action);
string cmdOnline(int narg, char *args[], int action); string cmdOnline(int narg, char *args[], int action);
string cmdConfigureMac(int narg, char *args[], int action); string cmdConfigureMac(int narg, char *args[], int action);
string cmdDetectorSize(int narg, char *args[], int action); string cmdDetectorSize(int narg, char *args[], int action);
string cmdSettings(int narg, char *args[], int action); string cmdSettings(int narg, char *args[], int action);
string cmdSN(int narg, char *args[], int action); string cmdSN(int narg, char *args[], int action);
string cmdDigiTest(int narg, char *args[], int action); string cmdDigiTest(int narg, char *args[], int action);
string cmdRegister(int narg, char *args[], int action); string cmdRegister(int narg, char *args[], int action);
string cmdDAC(int narg, char *args[], int action); string cmdDAC(int narg, char *args[], int action);
string cmdTiming(int narg, char *args[], int action); string cmdTiming(int narg, char *args[], int action);
string cmdTimer(int narg, char *args[], int action); string cmdTimer(int narg, char *args[], int action);
string cmdTimeLeft(int narg, char *args[], int action); string cmdTimeLeft(int narg, char *args[], int action);
string cmdSpeed(int narg, char *args[], int action); string cmdSpeed(int narg, char *args[], int action);
string cmdAdvanced(int narg, char *args[], int action); string cmdAdvanced(int narg, char *args[], int action);
string cmdConfiguration(int narg, char *args[], int action); string cmdConfiguration(int narg, char *args[], int action);
string cmdImage(int narg, char *args[], int action); string cmdImage(int narg, char *args[], int action);
string cmdCounter(int narg, char *args[], int action); string cmdCounter(int narg, char *args[], int action);
string cmdADC(int narg, char *args[], int action); string cmdADC(int narg, char *args[], int action);
string cmdEnablefwrite(int narg, char *args[], int action); string cmdEnablefwrite(int narg, char *args[], int action);
string cmdReceiver(int narg, char *args[], int action); string cmdReceiver(int narg, char *args[], int action);
int numberOfCommands; int numberOfCommands;
string cmd; string cmd;
typedef string (slsDetectorCommand::*MemFuncGetter)(int narg, char *args[], int action); typedef string (slsDetectorCommand::*MemFuncGetter)(int narg, char *args[], int action);
struct FuncTable struct FuncTable
{ {
string m_pFuncName; string m_pFuncName;
//const char* m_pFuncName; //const char* m_pFuncName;
MemFuncGetter m_pFuncPtr; MemFuncGetter m_pFuncPtr;
}; };
FuncTable descrToFuncMap[1000]; FuncTable descrToFuncMap[1000];

View File

@ -48,7 +48,7 @@ void slsDetectorUtils::acquire(int delflag){
angCalLogClass *aclog=NULL; angCalLogClass *aclog=NULL;
enCalLogClass *eclog=NULL; enCalLogClass *eclog=NULL;
// int lastindex=startindex, nowindex=startindex; // int lastindex=startindex, nowindex=startindex;
int connectChannels=0; int connectChannels=0;
#ifdef VERBOSE #ifdef VERBOSE
@ -124,217 +124,217 @@ void slsDetectorUtils::acquire(int delflag){
cout << " starting measurement "<< im << " of " << nm << endl; cout << " starting measurement "<< im << " of " << nm << endl;
#endif #endif
//cout << "data thread started " << endl; //cout << "data thread started " << endl;
//loop measurements //loop measurements
pthread_mutex_lock(&mp); pthread_mutex_lock(&mp);
setStartIndex(*fileIndex); setStartIndex(*fileIndex);
pthread_mutex_unlock(&mp); pthread_mutex_unlock(&mp);
//cout << "action at start" << endl; //cout << "action at start" << endl;
if (*stoppedFlag==0) { if (*stoppedFlag==0) {
executeAction(startScript); executeAction(startScript);
} }
for (int is0=0; is0<ns0; is0++) { for (int is0=0; is0<ns0; is0++) {
// cout << "scan0 loop" << endl; // cout << "scan0 loop" << endl;
if (*stoppedFlag==0) { if (*stoppedFlag==0) {
executeScan(0,is0); executeScan(0,is0);
} else } else
break; break;
for (int is1=0; is1<ns1; is1++) { for (int is1=0; is1<ns1; is1++) {
// cout << "scan1 loop" << endl; // cout << "scan1 loop" << endl;
if (*stoppedFlag==0) { if (*stoppedFlag==0) {
executeScan(1,is1); executeScan(1,is1);
} else } else
break; break;
if (*stoppedFlag==0) { if (*stoppedFlag==0) {
executeAction(scriptBefore); executeAction(scriptBefore);
} else } else
break; break;
ResetPositionIndex(); ResetPositionIndex();
for (int ip=0; ip<np; ip++) { for (int ip=0; ip<np; ip++) {
// cout << "positions " << endl; // cout << "positions " << endl;
if (*stoppedFlag==0) { if (*stoppedFlag==0) {
if (getNumberOfPositions()>0) { if (getNumberOfPositions()>0) {
moveDetector(detPositions[ip]); moveDetector(detPositions[ip]);
IncrementPositionIndex(); IncrementPositionIndex();
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "moving to position" << std::endl; std::cout<< "moving to position" << std::endl;
#endif #endif
} }
} else } else
break; break;
pthread_mutex_lock(&mp); pthread_mutex_lock(&mp);
createFileName(); createFileName();
pthread_mutex_unlock(&mp); pthread_mutex_unlock(&mp);
if (*stoppedFlag==0) { if (*stoppedFlag==0) {
executeAction(scriptBefore); executeAction(scriptBefore);
} else } else
break; break;
if (*stoppedFlag==0) { if (*stoppedFlag==0) {
executeAction(headerBefore); executeAction(headerBefore);
if (*correctionMask&(1<< ANGULAR_CONVERSION) || aclog || eclog) { if (*correctionMask&(1<< ANGULAR_CONVERSION) || aclog || eclog) {
positionFinished(0); positionFinished(0);
setCurrentPosition(getDetectorPosition()); setCurrentPosition(getDetectorPosition());
} }
if (aclog) if (aclog)
aclog->addStep(getCurrentPosition(), getCurrentFileName()); aclog->addStep(getCurrentPosition(), getCurrentFileName());
if (eclog) if (eclog)
eclog->addStep(setDAC(-1,THRESHOLD), getCurrentFileName()); eclog->addStep(setDAC(-1,THRESHOLD), getCurrentFileName());
if (*correctionMask&(1<< I0_NORMALIZATION)) { if (*correctionMask&(1<< I0_NORMALIZATION)) {
if (get_i0) if (get_i0)
get_i0(0, IOarg); get_i0(0, IOarg);
} }
startAndReadAll(); startAndReadAll();
#ifdef VERBOSE #ifdef VERBOSE
cout << "returned! " << endl; cout << "returned! " << endl;
#endif #endif
if (*correctionMask&(1<< I0_NORMALIZATION)) { if (*correctionMask&(1<< I0_NORMALIZATION)) {
if (get_i0) if (get_i0)
currentI0=get_i0(1,IOarg); // this is the correct i0!!!!! currentI0=get_i0(1,IOarg); // this is the correct i0!!!!!
} }
#ifdef VERBOSE #ifdef VERBOSE
cout << "pos finished? " << endl; cout << "pos finished? " << endl;
#endif #endif
positionFinished(1); positionFinished(1);
#ifdef VERBOSE #ifdef VERBOSE
cout << "done! " << endl; cout << "done! " << endl;
#endif #endif
if (*threadedProcessing==0){ if (*threadedProcessing==0){
#ifdef VERBOSE #ifdef VERBOSE
cout << "start unthreaded process data " << endl; cout << "start unthreaded process data " << endl;
#endif #endif
processData(delflag); processData(delflag);
} }
} else } else
break; break;
// wait until data processing thread has finished the data // wait until data processing thread has finished the data
#ifdef VERBOSE #ifdef VERBOSE
cout << "check data queue size " << endl; cout << "check data queue size " << endl;
#endif #endif
while (dataQueueSize()){ while (dataQueueSize()){
#ifdef VERBOSE #ifdef VERBOSE
cout << "AAAAAAAAA check data queue size " << endl; cout << "AAAAAAAAA check data queue size " << endl;
#endif #endif
usleep(100000); usleep(100000);
} }
pthread_mutex_lock(&mp); pthread_mutex_lock(&mp);
if (*stoppedFlag==0) { if (*stoppedFlag==0) {
executeAction(headerAfter); executeAction(headerAfter);
setLastIndex(*fileIndex); setLastIndex(*fileIndex);
} else { } else {
setLastIndex(*fileIndex); setLastIndex(*fileIndex);
break; break;
} }
pthread_mutex_unlock(&mp); pthread_mutex_unlock(&mp);
if (*stoppedFlag) { if (*stoppedFlag) {
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "exiting since the detector has been stopped" << std::endl; std::cout<< "exiting since the detector has been stopped" << std::endl;
#endif #endif
break; break;
} else if (ip<(np-1)) { } else if (ip<(np-1)) {
pthread_mutex_lock(&mp); pthread_mutex_lock(&mp);
*fileIndex=setStartIndex(); *fileIndex=setStartIndex();
pthread_mutex_unlock(&mp); pthread_mutex_unlock(&mp);
} }
} // loop on position finished } // loop on position finished
//script after //script after
if (*stoppedFlag==0) { if (*stoppedFlag==0) {
executeAction(scriptAfter); executeAction(scriptAfter);
} else } else
break; break;
if (*stoppedFlag) { if (*stoppedFlag) {
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "exiting since the detector has been stopped" << std::endl; std::cout<< "exiting since the detector has been stopped" << std::endl;
#endif #endif
break; break;
} else if (is1<(ns1-1)) { } else if (is1<(ns1-1)) {
pthread_mutex_lock(&mp); pthread_mutex_lock(&mp);
*fileIndex=setStartIndex(); *fileIndex=setStartIndex();
pthread_mutex_unlock(&mp); pthread_mutex_unlock(&mp);
} }
} }
//end scan1 loop is1 //end scan1 loop is1
if (*stoppedFlag) { if (*stoppedFlag) {
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "exiting since the detector has been stopped" << std::endl; std::cout<< "exiting since the detector has been stopped" << std::endl;
#endif #endif
break; break;
} else if (is0<(ns0-1)) { } else if (is0<(ns0-1)) {
pthread_mutex_lock(&mp);
*fileIndex=setStartIndex();
pthread_mutex_unlock(&mp);
}
} //end scan0 loop is0
pthread_mutex_lock(&mp); pthread_mutex_lock(&mp);
*fileIndex=setStartIndex(); *fileIndex=setLastIndex();
pthread_mutex_unlock(&mp); pthread_mutex_unlock(&mp);
} if (*stoppedFlag==0) {
executeAction(stopScript);
} else
break;
} //end scan0 loop is0 // loop measurements
pthread_mutex_lock(&mp);
*fileIndex=setLastIndex();
pthread_mutex_unlock(&mp);
if (*stoppedFlag==0) {
executeAction(stopScript);
} else
break;
// loop measurements
if (measurement_finished) if (measurement_finished)
measurement_finished(im,*fileIndex,measFinished_p); measurement_finished(im,*fileIndex,measFinished_p);
if (*stoppedFlag) { if (*stoppedFlag) {
break; break;
} }
} }
@ -346,21 +346,21 @@ void slsDetectorUtils::acquire(int delflag){
} }
if (connectChannels) { if (connectChannels) {
if (disconnect_channels) if (disconnect_channels)
disconnect_channels(DCarg); disconnect_channels(DCarg);
} }
if (aclog) if (aclog)
delete aclog; delete aclog;
if (eclog) if (eclog)
delete eclog; delete eclog;
if (acquisition_finished) if (acquisition_finished)
acquisition_finished(getCurrentProgress(),getDetectorStatus(),acqFinished_p); acquisition_finished(getCurrentProgress(),getDetectorStatus(),acqFinished_p);
} }
@ -378,33 +378,33 @@ int slsDetectorUtils::setTotalProgress() {
nf=timerValue[FRAME_NUMBER]; nf=timerValue[FRAME_NUMBER];
if (timerValue[CYCLES_NUMBER]>0) if (timerValue[CYCLES_NUMBER]>0)
nc=timerValue[CYCLES_NUMBER]; nc=timerValue[CYCLES_NUMBER];
if (timerValue[MEASUREMENTS_NUMBER]>0) if (timerValue[MEASUREMENTS_NUMBER]>0)
nm=timerValue[MEASUREMENTS_NUMBER]; nm=timerValue[MEASUREMENTS_NUMBER];
if (*numberOfPositions>0) if (*numberOfPositions>0)
npos=*numberOfPositions; npos=*numberOfPositions;
if ((nScanSteps[0]>0) && (*actionMask & (1 << MAX_ACTIONS))) if ((nScanSteps[0]>0) && (*actionMask & (1 << MAX_ACTIONS)))
nscan[0]=nScanSteps[0]; nscan[0]=nScanSteps[0];
if ((nScanSteps[1]>0) && (*actionMask & (1 << (MAX_ACTIONS+1)))) if ((nScanSteps[1]>0) && (*actionMask & (1 << (MAX_ACTIONS+1))))
nscan[1]=nScanSteps[1]; nscan[1]=nScanSteps[1];
totalProgress=nm*nf*nc*npos*nscan[0]*nscan[1]; totalProgress=nm*nf*nc*npos*nscan[0]*nscan[1];
#ifdef VERBOSE #ifdef VERBOSE
cout << "nc " << nc << endl; cout << "nc " << nc << endl;
cout << "nm " << nm << endl; cout << "nm " << nm << endl;
cout << "nf " << nf << endl; cout << "nf " << nf << endl;
cout << "npos " << npos << endl; cout << "npos " << npos << endl;
cout << "nscan[0] " << nscan[0] << endl; cout << "nscan[0] " << nscan[0] << endl;
cout << "nscan[1] " << nscan[1] << endl; cout << "nscan[1] " << nscan[1] << endl;
cout << "Set total progress " << totalProgress << endl; cout << "Set total progress " << totalProgress << endl;
#endif #endif
return totalProgress; return totalProgress;
} }
@ -460,26 +460,26 @@ int slsDetectorUtils::setBadChannelCorrection(string fname, int &nbadtot, int *b
infile.open(fn.c_str(), ios_base::in); infile.open(fn.c_str(), ios_base::in);
if (infile.is_open()==0) { if (infile.is_open()==0) {
std::cout << "could not open file " << fname <<std::endl; std::cout << "could not open file " << fname <<std::endl;
return -1; return -1;
}
nbad=setBadChannelCorrection(infile, nbad, badlist, offset);
infile.close();
for (int ich=0; ich<nbad; ich++) {
if (nbadtot<MAX_BADCHANS) {
badchanlist[nbadtot]=badlist[ich];
nbadtot++;
} }
nbad=setBadChannelCorrection(infile, nbad, badlist, offset);
infile.close();
for (int ich=0; ich<nbad; ich++) {
if (nbadtot<MAX_BADCHANS) {
badchanlist[nbadtot]=badlist[ich];
nbadtot++;
}
}
offset+=getChansPerMod(im);
} }
offset+=getChansPerMod(im);
}
} }
if (nbadtot>0 && nbadtot<MAX_BADCHANS) { if (nbadtot>0 && nbadtot<MAX_BADCHANS) {
@ -511,7 +511,7 @@ void slsDetectorUtils::incrementProgress() {
cout << fixed << setprecision(2) << setw (6) << 100.*((double)progressIndex)/((double)totalProgress) << " \%"; cout << fixed << setprecision(2) << setw (6) << 100.*((double)progressIndex)/((double)totalProgress) << " \%";
pthread_mutex_unlock(&mp); pthread_mutex_unlock(&mp);
#ifdef VERBOSE #ifdef VERBOSE
cout << endl; cout << endl;
#else #else
cout << "\r" << flush; cout << "\r" << flush;
#endif #endif
@ -521,88 +521,88 @@ void slsDetectorUtils::incrementProgress() {
int slsDetectorUtils::testFunction(int times) { int slsDetectorUtils::testFunction(int times) {
int i,count=0; int i,count=0;
runStatus s; runStatus s;
char controlval[1000]; char controlval[1000];
char statusval[1000]; char statusval[1000];
int nchans = getTotalNumberOfChannels(); int nchans = getTotalNumberOfChannels();
short int dataVals[nchans]; short int dataVals[nchans];
for(i=0;i<times;i++){ for(i=0;i<times;i++){
sprintf(statusval,"%x",readRegister(0x25));
std::cout<<std::endl<<dec<<i+1<<": stat:\t"<<statusval<<"\t";
sprintf(controlval,"%x",readRegister(0x24));
std::cout<<"cont:"<<controlval<<"\t"<<std::endl;
startAcquisition();
sprintf(controlval,"%x",readRegister(0x24));
std::cout<<"cont:"<<controlval<<"\t"<<std::endl;
//sprintf(statusval,"%x",readRegister(0x25));
//std::cout<<statusval<<std::endl;
s = getRunStatus();
if(s==IDLE){
std::cout<<"IDLE\t"<<std::endl;
s = getRunStatus();
if(s==IDLE){
std::cout<<"IDLE"<<std::endl;
exit(-1);
}
;
}
else {
if (s==RUNNING){
count=0;
while(s==RUNNING){
count++;//std::cout<<"count:"<<count<<std::endl;
if(count==4){
sprintf(statusval,"%x",readRegister(0x25)); sprintf(statusval,"%x",readRegister(0x25));
std::cout<<std::endl<<dec<<i+1<<": stat:\t"<<statusval<<"\t";
sprintf(controlval,"%x",readRegister(0x24));
std::cout<<"cont:"<<controlval<<"\t"<<std::endl;
startAcquisition();
sprintf(controlval,"%x",readRegister(0x24));
std::cout<<"cont:"<<controlval<<"\t"<<std::endl;
//sprintf(statusval,"%x",readRegister(0x25));
//std::cout<<statusval<<std::endl;
s = getRunStatus();
if(s==IDLE){
std::cout<<"IDLE\t"<<std::endl;
s = getRunStatus();
if(s==IDLE){
std::cout<<"IDLE"<<std::endl;
exit(-1);
}
;
}
else {
if (s==RUNNING){
count=0;
while(s==RUNNING){
count++;//std::cout<<"count:"<<count<<std::endl;
if(count==4){
sprintf(statusval,"%x",readRegister(0x25));
std::cout<<"STUCK: stat"<<statusval<<std::endl; std::cout<<"STUCK: stat"<<statusval<<std::endl;
exit(-1); exit(-1);
} }
usleep(50000); usleep(50000);
//val=readRegister(0x25); //val=readRegister(0x25);
s = getRunStatus(); s = getRunStatus();
}
}
}
/* else{
std::cout<<"\nWeird Status. "<<runStatusType(s)<<" Exit\n";
exit(-1);
}*/
system("rm ~/wORKSPACE/scratch/run* ");
//system("more ~/wORKSPACE/scratch/run* ");
usleep(1000000);
setFileIndex(0);
int b;
b=setThreadedProcessing(-1);
setThreadedProcessing(0);
readAll();
processData(1);
setThreadedProcessing(b);
if(!readDataFile("/home/l_maliakal_d/wORKSPACE/scratch/run_1.raw",dataVals)){
std::cout<< "Could not open file "<< std::endl;
exit(-1);
}
std::cout<<std::endl;
for(int j=1277;j< (nchans);j++)
std::cout<<"\t"<<j<<":"<<dataVals[j];
if(dataVals[1278]!=2558){
std::cout<< "DATA ERROR!! "<< std::endl;
exit(-1);
}
} }
std::cout<<std::endl; }
return 0; }
/* else{
std::cout<<"\nWeird Status. "<<runStatusType(s)<<" Exit\n";
exit(-1);
}*/
system("rm ~/wORKSPACE/scratch/run* ");
//system("more ~/wORKSPACE/scratch/run* ");
usleep(1000000);
setFileIndex(0);
int b;
b=setThreadedProcessing(-1);
setThreadedProcessing(0);
readAll();
processData(1);
setThreadedProcessing(b);
if(!readDataFile("/home/l_maliakal_d/wORKSPACE/scratch/run_1.raw",dataVals)){
std::cout<< "Could not open file "<< std::endl;
exit(-1);
}
std::cout<<std::endl;
for(int j=1277;j< (nchans);j++)
std::cout<<"\t"<<j<<":"<<dataVals[j];
if(dataVals[1278]!=2558){
std::cout<< "DATA ERROR!! "<< std::endl;
exit(-1);
}
}
std::cout<<std::endl;
return 0;
} }
@ -615,13 +615,13 @@ int slsDetectorUtils::retrieveDetectorSetup(string const fname1, int level){
slsDetectorCommand *cmd; slsDetectorCommand *cmd;
char ext[100]; char ext[100];
int skip=0; int skip=0;
string fname; string fname;
string str; string str;
ifstream infile; ifstream infile;
int iargval; int iargval;
int interrupt=0; int interrupt=0;
char *args[10]; char *args[10];
char myargs[10][1000]; char myargs[10][1000];
@ -633,8 +633,8 @@ int slsDetectorUtils::retrieveDetectorSetup(string const fname1, int level){
int iline=0; int iline=0;
if (level==2) { if (level==2) {
// fname=fname1+string(".config"); // fname=fname1+string(".config");
// readConfigurationFile(fname); // readConfigurationFile(fname);
#ifdef VERBOSE #ifdef VERBOSE
cout << "config file read" << endl; cout << "config file read" << endl;
#endif #endif
@ -665,14 +665,14 @@ int slsDetectorUtils::retrieveDetectorSetup(string const fname1, int level){
while (ssstr.good()) { while (ssstr.good()) {
ssstr >> sargname; ssstr >> sargname;
// if (ssstr.good()) { // if (ssstr.good()) {
strcpy(myargs[iargval],sargname.c_str()); strcpy(myargs[iargval],sargname.c_str());
args[iargval]=myargs[iargval]; args[iargval]=myargs[iargval];
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< args[iargval] << std::endl; std::cout<< args[iargval] << std::endl;
#endif #endif
iargval++; iargval++;
// } // }
skip=0; skip=0;
} }
if (level!=2) { if (level!=2) {
@ -749,7 +749,7 @@ int slsDetectorUtils::dumpDetectorSetup(string const fname, int level){
char ext[100]; char ext[100];
int iv=0; int iv=0;
string fname1; string fname1;
@ -809,26 +809,26 @@ int slsDetectorUtils::dumpDetectorSetup(string const fname, int level){
if (level==2) { if (level==2) {
strcpy(args[0],names[iv].c_str()); strcpy(args[0],names[iv].c_str());
size_t c=fname.rfind('/'); size_t c=fname.rfind('/');
if (c<string::npos) { if (c<string::npos) {
fname1=fname.substr(0,c+1)+string("trim_")+fname.substr(c+1); fname1=fname.substr(0,c+1)+string("trim_")+fname.substr(c+1);
} else { } else {
fname1=string("trim_")+fname; fname1=string("trim_")+fname;
} }
strcpy(args[1],fname1.c_str()); strcpy(args[1],fname1.c_str());
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "writing to file " << fname1 << std::endl; std::cout<< "writing to file " << fname1 << std::endl;
#endif #endif
outfile << names[iv] << " " << cmd->executeLine(nargs,args,GET_ACTION) << std::endl; outfile << names[iv] << " " << cmd->executeLine(nargs,args,GET_ACTION) << std::endl;
iv++; iv++;
} }
delete cmd; delete cmd;
outfile.close(); outfile.close();
} }

View File

@ -56,7 +56,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
public: public:
slsDetectorUtils(); slsDetectorUtils();
virtual ~slsDetectorUtils(){}; virtual ~slsDetectorUtils(){};
@ -84,14 +84,14 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
// int getFileIndex(){return fileIO::getFileIndex();}; // int getFileIndex(){return fileIO::getFileIndex();};
// int setFileIndex(int s){return fileIO::setFileIndex(s);}; // int setFileIndex(int s){return fileIO::setFileIndex(s);};
/* /*
int getScanPrecision(int i){return slsDetectorActions::getScanPrecision(i);}; int getScanPrecision(int i){return slsDetectorActions::getScanPrecision(i);};
int getActionMask() {return slsDetectorActions::getActionMask();}; int getActionMask() {return slsDetectorActions::getActionMask();};
float getCurrentScanVariable(int i) {return slsDetectorActions::getCurrentScanVariable(i);}; float getCurrentScanVariable(int i) {return slsDetectorActions::getCurrentScanVariable(i);};
int getCurrentPositionIndex(){return angularConversion::getCurrentPositionIndex();}; int getCurrentPositionIndex(){return angularConversion::getCurrentPositionIndex();};
int getNumberOfPositions(){return angularConversion::getNumberOfPositions();}; int getNumberOfPositions(){return angularConversion::getNumberOfPositions();};
*/ */
// int getActionMask() {return slsDetectorActions::getActionMask();}; // int getActionMask() {return slsDetectorActions::getActionMask();};
// double getCurrentScanVariable(int i) {return slsDetectorActions::getCurrentScanVariable(i);}; // double getCurrentScanVariable(int i) {return slsDetectorActions::getCurrentScanVariable(i);};
@ -175,7 +175,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
*/ */
virtual char *setNetworkParameter(networkParameter i, string s)=0; virtual char *setNetworkParameter(networkParameter i, string s)=0;
/** /**
changes/gets the port number changes/gets the port number
\param t type port type can be CONTROL_PORT, DATA_PORT, STOP_PORT \param t type port type can be CONTROL_PORT, DATA_PORT, STOP_PORT
\param i new port number (<1024 gets) \param i new port number (<1024 gets)
@ -183,7 +183,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
*/ */
virtual int setPort(portType t, int i=-1)=0; virtual int setPort(portType t, int i=-1)=0;
/** /**
get detector ids/versions for module=0 get detector ids/versions for module=0
\param mode which id/version has to be read \param mode which id/version has to be read
\param imod module number for module serial number \param imod module number for module serial number
@ -192,21 +192,21 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
virtual int64_t getId(idMode mode, int imod=0)=0; virtual int64_t getId(idMode mode, int imod=0)=0;
/** /**
checks if the detector(s) are online/offline checks if the detector(s) are online/offline
\returns hostname if offline \returns hostname if offline
*/ */
virtual string checkOnline()=0; virtual string checkOnline()=0;
/** /**
Digital test of the modules Digital test of the modules
\param mode test mode \param mode test mode
\param imod module number for chip test or module firmware test \param imod module number for chip test or module firmware test
\returns OK or error mask \returns OK or error mask
*/ */
virtual int digitalTest(digitalTestMode mode, int imod=0)=0; virtual int digitalTest(digitalTestMode mode, int imod=0)=0;
/** /**
execute trimming execute trimming
\param mode trim mode \param mode trim mode
\param par1 if noise, beam or fixed setting trimming it is count limit, if improve maximum number of iterations \param par1 if noise, beam or fixed setting trimming it is count limit, if improve maximum number of iterations
\param par2 if noise or beam nsigma, if improve par2!=means vthreshold will be optimized, if fixed settings par2<0 trimwith median, par2>=0 trim with level \param par2 if noise or beam nsigma, if improve par2!=means vthreshold will be optimized, if fixed settings par2<0 trimwith median, par2>=0 trim with level
@ -222,7 +222,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
virtual const char *getSettingsFile()=0; virtual const char *getSettingsFile()=0;
/** /**
get current timer value get current timer value
\param index timer index \param index timer index
\returns elapsed time value in ns or number of...(e.g. frames, gates, probes) \returns elapsed time value in ns or number of...(e.g. frames, gates, probes)
@ -232,11 +232,11 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
/** sets the number of trim energies and their value \sa sharedSlsDetector /** sets the number of trim energies and their value \sa sharedSlsDetector
\param nen number of energies \param nen number of energies
\param en array of energies \param en array of energies
\returns number of trim energies \returns number of trim energies
unused! unused!
*/ */
virtual int setTrimEn(int nen, int *en=NULL)=0; virtual int setTrimEn(int nen, int *en=NULL)=0;
@ -252,7 +252,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
/** /**
set/get the use of an external signal set/get the use of an external signal
\param pol meaning of the signal \sa externalSignalFlag \param pol meaning of the signal \sa externalSignalFlag
\param signalindex index of the signal \param signalindex index of the signal
\returns current meaning of signal signalIndex \returns current meaning of signal signalIndex
@ -267,7 +267,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
\param value is the value to be set, if -1 get value \param value is the value to be set, if -1 get value
\returns current value for the specified parameter \returns current value for the specified parameter
\sa speedVariable \sa speedVariable
*/ */
virtual int setSpeed(speedVariable sp, int value=-1)=0; virtual int setSpeed(speedVariable sp, int value=-1)=0;
@ -292,7 +292,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
/** sets/gets position of the master in a multi detector structure /** sets/gets position of the master in a multi detector structure
\param i position of the detector in the multidetector structure \param i position of the detector in the multidetector structure
\returns position of the master in a multi detector structure (-1 no master or always in slsDetector) \returns position of the master in a multi detector structure (-1 no master or always in slsDetector)
*/ */
@ -320,7 +320,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
virtual char* getCalDir()=0; virtual char* getCalDir()=0;
/** /**
sets the location of the calibration files sets the location of the calibration files
*/ */
virtual char* setCalDir(string s)=0; virtual char* setCalDir(string s)=0;
@ -329,17 +329,17 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
/** adds the detector with ID id in postion pos /** adds the detector with ID id in postion pos
\param id of the detector to be added (should already exist!) \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) \param pos position where it should be added (normally at the end of the list (default to -1)
\returns the actual number of detectors or -1 if it failed (always for slsDetector) \returns the actual number of detectors or -1 if it failed (always for slsDetector)
*/ */
virtual int addSlsDetector(int id, int pos=-1){return -1;}; virtual int addSlsDetector(int id, int pos=-1){return -1;};
/** adds the detector name in position pos /** adds the detector name in position pos
\param name of the detector to be added (should already exist in shared memory or at least be online) \param name of the detector to be added (should already exist in shared memory or at least be online)
\param pos position where it should be added (normally at the end of the list (default to -1) \param pos position where it should be added (normally at the end of the list (default to -1)
\return the actual number of detectors or -1 if it failed (always for slsDetector) \return the actual number of detectors or -1 if it failed (always for slsDetector)
*/ */
virtual int addSlsDetector(char* name, int pos=-1){return -1;}; virtual int addSlsDetector(char* name, int pos=-1){return -1;};
@ -351,13 +351,13 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
*/ */
virtual int removeSlsDetector(int pos=-1){return -1;}; virtual int removeSlsDetector(int pos=-1){return -1;};
/**removes the detector in position pos from the multidetector /**removes the detector in position pos from the multidetector
\param name is the name of the detector \param name is the name of the detector
\returns the actual number of detectors or -1 if it failed (always for slsDetector) \returns the actual number of detectors or -1 if it failed (always for slsDetector)
*/ */
virtual int removeSlsDetector(char* name){return -1;}; virtual int removeSlsDetector(char* name){return -1;};
/** /**
Turns off the server - do not use except for debugging! Turns off the server - do not use except for debugging!
*/ */
virtual int exitServer()=0; virtual int exitServer()=0;
@ -365,28 +365,28 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
/** /**
Loads dark image or gain image to the detector Loads dark image or gain image to the detector
\param index can be DARK_IMAGE or GAIN_IMAGE \param index can be DARK_IMAGE or GAIN_IMAGE
\fname file name to load data from \fname file name to load data from
\returns OK or FAIL \returns OK or FAIL
*/ */
virtual int loadImageToDetector(imageType index,string const fname)=0; virtual int loadImageToDetector(imageType index,string const fname)=0;
/** /**
writes the counter memory block from the detector writes the counter memory block from the detector
\param startACQ is 1 to start acquisition after reading counter \param startACQ is 1 to start acquisition after reading counter
\fname file fname to load data from \fname file fname to load data from
\returns OK or FAIL \returns OK or FAIL
*/ */
virtual int writeCounterBlockFile(string const fname,int startACQ=0)=0; virtual int writeCounterBlockFile(string const fname,int startACQ=0)=0;
/** /**
Resets counter memory block in detector Resets counter memory block in detector
\param startACQ is 1 to start acquisition after resetting counter \param startACQ is 1 to start acquisition after resetting counter
\returns OK or FAIL \returns OK or FAIL
*/ */
virtual int resetCounterBlock(int startACQ=0)=0; virtual int resetCounterBlock(int startACQ=0)=0;
@ -395,8 +395,8 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
/** /**
asks and receives all data from the detector and puts them in a data queue asks and receives all data from the detector and puts them in a data queue
\returns pointer to the front of the queue or NULL. \returns pointer to the front of the queue or NULL.
*/ */
virtual int* readAll()=0; virtual int* readAll()=0;
@ -404,11 +404,11 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
/** performs a complete acquisition including scansand data processing /** performs a complete acquisition including scansand data processing
moves the detector to next position <br> moves the detector to next position <br>
starts and reads the detector <br> starts and reads the detector <br>
reads the IC (if required) <br> reads the IC (if required) <br>
reads the encoder (iof required for angualr conversion) <br> reads the encoder (iof required for angualr conversion) <br>
processes the data (flat field, rate, angular conversion and merging ::processData()) processes the data (flat field, rate, angular conversion and merging ::processData())
\param delflag 0 leaves the data in the final data queue \param delflag 0 leaves the data in the final data queue
\returns nothing \returns nothing
*/ */
@ -420,7 +420,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
// virtual double* convertAngles(double pos)=0; // virtual double* convertAngles(double pos)=0;
virtual int setThresholdEnergy(int, int im=-1, detectorSettings isettings=GET_SETTINGS)=0; virtual int setThresholdEnergy(int, int im=-1, detectorSettings isettings=GET_SETTINGS)=0;
virtual int setChannel(int64_t, int ich=-1, int ichip=-1, int imod=-1)=0; virtual int setChannel(int64_t, int ich=-1, int ichip=-1, int imod=-1)=0;
virtual double getRateCorrectionTau()=0; virtual double getRateCorrectionTau()=0;
virtual int* startAndReadAll()=0; virtual int* startAndReadAll()=0;
@ -465,7 +465,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
*/ */
virtual int readRegister(int addr)=0; virtual int readRegister(int addr)=0;
/** /**
Returns the IP of the last client connecting to the detector Returns the IP of the last client connecting to the detector
*/ */
virtual string getLastClientIP()=0; virtual string getLastClientIP()=0;
@ -483,7 +483,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
\param fname file name . If not specified, extension is automatically generated! \param fname file name . If not specified, extension is automatically generated!
\param imod module number, -1 means all modules \param imod module number, -1 means all modules
\returns OK or FAIL \returns OK or FAIL
*/ */
virtual int loadSettingsFile(string fname, int imod=-1)=0; virtual int loadSettingsFile(string fname, int imod=-1)=0;
@ -492,17 +492,17 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
\param fname file name . Axtension is automatically generated! \param fname file name . Axtension is automatically generated!
\param imod module number, -1 means all modules \param imod module number, -1 means all modules
\returns OK or FAIL \returns OK or FAIL
*/ */
virtual int saveSettingsFile(string fname, int imod=-1)=0; virtual int saveSettingsFile(string fname, int imod=-1)=0;
/** /**
set dacs value set dacs value
\param val value (in V) \param val value (in V)
\param index DAC index \param index DAC index
\param imod module number (if -1 alla modules) \param imod module number (if -1 alla modules)
\returns current DAC value \returns current DAC value
*/ */
virtual dacs_t setDAC(dacs_t val, dacIndex index , int imod=-1)=0; virtual dacs_t setDAC(dacs_t val, dacIndex index , int imod=-1)=0;
@ -516,9 +516,9 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
virtual dacs_t getADC(dacIndex index, int imod=0)=0; virtual dacs_t getADC(dacIndex index, int imod=0)=0;
/** /**
get the maximum size of the detector get the maximum size of the detector
\param d dimension \param d dimension
\returns maximum number of modules that can be installed in direction d \returns maximum number of modules that can be installed in direction d
*/ */
virtual int getMaxNumberOfModules(dimension d=X)=0; virtual int getMaxNumberOfModules(dimension d=X)=0;
@ -547,7 +547,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
/** /**
Saves the detector setup to file Saves the detector setup to file
\param fname file to write to \param fname file to write to
\param level if 2 reads also trimbits, flat field, angular correction etc. and writes them to files with automatically added extension \param level if 2 reads also trimbits, flat field, angular correction etc. and writes them to files with automatically added extension
\returns OK or FAIL \returns OK or FAIL
@ -557,7 +557,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
/** /**
Loads the detector setup from file Loads the detector setup from file
\param fname file to read from \param fname file to read from
\param level if 2 reads also reads trimbits, angular conversion coefficients etc. from files with default extensions as generated by dumpDetectorSetup \param level if 2 reads also reads trimbits, angular conversion coefficients etc. from files with default extensions as generated by dumpDetectorSetup
\returns OK or FAIL \returns OK or FAIL
@ -571,26 +571,26 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
//receiver //receiver
/** /**
Checks if the receiver is really online Checks if the receiver is really online
*/ */
virtual string checkReceiverOnline()=0; virtual string checkReceiverOnline()=0;
/** /**
Returns the IP of the last client connecting to the receiver Returns the IP of the last client connecting to the receiver
*/ */
virtual string getReceiverLastClientIP()=0; virtual string getReceiverLastClientIP()=0;
protected: protected:
static const int64_t thisSoftwareVersion=0x20120124; static const int64_t thisSoftwareVersion=0x20120124;
//protected: //protected:
int *stoppedFlag; int *stoppedFlag;
int64_t *timerValue; int64_t *timerValue;

View File

@ -70,20 +70,20 @@ int energyConversion::writeCalibrationFile(string fname, double gain, double off
#ifndef MYROOT #ifndef MYROOT
/* I/O */ /* I/O */
slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string fname, detectorType myDetectorType, sls_detector_module *myMod){ slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string fname, detectorType myDetectorType, sls_detector_module *myMod){
int nflag=0; int nflag=0;
if (myMod==NULL) { if (myMod==NULL) {
myMod=createModule(myDetectorType); myMod=createModule(myDetectorType);
nflag=1; nflag=1;
} }
string myfname; string myfname;
string str; string str;
ifstream infile; ifstream infile;
ostringstream oss; ostringstream oss;
@ -97,101 +97,101 @@ slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "reading settings file for module number "<< myMod->module << std::endl; std::cout<< "reading settings file for module number "<< myMod->module << std::endl;
#endif #endif
myfname=fname; myfname=fname;
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "file name is "<< myfname << std::endl; std::cout<< "file name is "<< myfname << std::endl;
#endif #endif
infile.open(myfname.c_str(), ios_base::in); infile.open(myfname.c_str(), ios_base::in);
if (infile.is_open()) { if (infile.is_open()) {
switch (myDetectorType) { switch (myDetectorType) {
case MYTHEN: case MYTHEN:
for (int iarg=0; iarg<myMod->ndac; iarg++) { for (int iarg=0; iarg<myMod->ndac; iarg++) {
getline(infile,str); getline(infile,str);
iline++; iline++;
istringstream ssstr(str); istringstream ssstr(str);
ssstr >> sargname >> ival; ssstr >> sargname >> ival;
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< sargname << " dac nr. " << idac << " is " << ival << std::endl; std::cout<< sargname << " dac nr. " << idac << " is " << ival << std::endl;
#endif #endif
myMod->dacs[idac]=ival; myMod->dacs[idac]=ival;
idac++; idac++;
} }
for (ichip=0; ichip<myMod->nchip; ichip++) { for (ichip=0; ichip<myMod->nchip; ichip++) {
getline(infile,str); getline(infile,str);
iline++; iline++;
#ifdef VERBOSE #ifdef VERBOSE
// std::cout<< str << std::endl; // std::cout<< str << std::endl;
#endif #endif
istringstream ssstr(str); istringstream ssstr(str);
ssstr >> sargname >> ival; ssstr >> sargname >> ival;
#ifdef VERBOSE #ifdef VERBOSE
// std::cout<< "chip " << ichip << " " << sargname << " is " << ival << std::endl; // std::cout<< "chip " << ichip << " " << sargname << " is " << ival << std::endl;
#endif #endif
myMod->chipregs[ichip]=ival; myMod->chipregs[ichip]=ival;
for (ichan=0; ichan<nch; ichan++) { for (ichan=0; ichan<nch; ichan++) {
getline(infile,str); getline(infile,str);
#ifdef VERBOSE #ifdef VERBOSE
// std::cout<< str << std::endl; // std::cout<< str << std::endl;
#endif #endif
istringstream ssstr(str); istringstream ssstr(str);
#ifdef VERBOSE #ifdef VERBOSE
// std::cout<< "channel " << ichan+ichip*thisDetector->nChans <<" iline " << iline<< std::endl; // std::cout<< "channel " << ichan+ichip*thisDetector->nChans <<" iline " << iline<< std::endl;
#endif #endif
iline++; iline++;
myMod->chanregs[ichip*nch+ichan]=0; myMod->chanregs[ichip*nch+ichan]=0;
for (int iarg=0; iarg<6 ; iarg++) { for (int iarg=0; iarg<6 ; iarg++) {
ssstr >> ival; ssstr >> ival;
//if (ssstr.good()) { //if (ssstr.good()) {
switch (iarg) { switch (iarg) {
case 0: case 0:
#ifdef VERBOSE #ifdef VERBOSE
// std::cout<< "trimbits " << ival ; // std::cout<< "trimbits " << ival ;
#endif #endif
myMod->chanregs[ichip*nch+ichan]|=ival&TRIMBITMASK; myMod->chanregs[ichip*nch+ichan]|=ival&TRIMBITMASK;
break; break;
case 1: case 1:
#ifdef VERBOSE #ifdef VERBOSE
//std::cout<< " compen " << ival ; //std::cout<< " compen " << ival ;
#endif #endif
myMod->chanregs[ichip*nch+ichan]|=ival<<9; myMod->chanregs[ichip*nch+ichan]|=ival<<9;
break; break;
case 2: case 2:
#ifdef VERBOSE #ifdef VERBOSE
//std::cout<< " anen " << ival ; //std::cout<< " anen " << ival ;
#endif #endif
myMod->chanregs[ichip*nch+ichan]|=ival<<8; myMod->chanregs[ichip*nch+ichan]|=ival<<8;
break; break;
case 3: case 3:
#ifdef VERBOSE #ifdef VERBOSE
//std::cout<< " calen " << ival ; //std::cout<< " calen " << ival ;
#endif #endif
myMod->chanregs[ichip*nch+ichan]|=ival<<7; myMod->chanregs[ichip*nch+ichan]|=ival<<7;
break; break;
case 4: case 4:
#ifdef VERBOSE #ifdef VERBOSE
//std::cout<< " outcomp " << ival ; //std::cout<< " outcomp " << ival ;
#endif #endif
myMod->chanregs[ichip*nch+ichan]|=ival<<10; myMod->chanregs[ichip*nch+ichan]|=ival<<10;
break; break;
case 5: case 5:
#ifdef VERBOSE #ifdef VERBOSE
//std::cout<< " counts " << ival << std::endl; //std::cout<< " counts " << ival << std::endl;
#endif #endif
myMod->chanregs[ichip*nch+ichan]|=ival<<11; myMod->chanregs[ichip*nch+ichan]|=ival<<11;
break; break;
default: default:
std::cout<< " too many columns" << std::endl; std::cout<< " too many columns" << std::endl;
break; break;
}
} }
} }
// } }
// }
} }
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "read " << ichan*ichip << " channels" <<std::endl; std::cout<< "read " << ichan*ichip << " channels" <<std::endl;
@ -201,45 +201,45 @@ slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string
break; break;
case GOTTHARD: case GOTTHARD:
//---------------dacs--------------- //---------------dacs---------------
for (int iarg=0; iarg<myMod->ndac; iarg++) { for (int iarg=0; iarg<myMod->ndac; iarg++) {
getline(infile,str); getline(infile,str);
iline++; iline++;
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< str << std::endl; std::cout<< str << std::endl;
#endif #endif
istringstream ssstr(str); istringstream ssstr(str);
ssstr >> sargname >> ival; ssstr >> sargname >> ival;
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< sargname << " dac nr. " << idac << " is " << ival << std::endl; std::cout<< sargname << " dac nr. " << idac << " is " << ival << std::endl;
#endif #endif
myMod->dacs[idac]=ival; myMod->dacs[idac]=ival;
idac++; idac++;
} }
break; break;
default: default:
std::cout<< "Unknown detector type - don't know how to read file" << myfname << std::endl; std::cout<< "Unknown detector type - don't know how to read file" << myfname << std::endl;
infile.close();
deleteModule(myMod);
return NULL;
}
infile.close(); infile.close();
strcpy(settingsFile,fname.c_str()); deleteModule(myMod);
return myMod;
} else {
std::cout<< "could not open settings file " << myfname << std::endl;
if (nflag)
deleteModule(myMod);
return NULL; return NULL;
} }
infile.close();
strcpy(settingsFile,fname.c_str());
return myMod;
} else {
std::cout<< "could not open settings file " << myfname << std::endl;
if (nflag)
deleteModule(myMod);
return NULL;
}
}; };