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

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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