most methods moved to slsDetector (instead of mythen and gotthard) and connect/disconnect method added to users functions (to possibly comply with epics) - mutex added to the acquisition and data processing threads to avoid wrong indexes.

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@38 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
bergamaschi 2011-11-03 13:51:26 +00:00
parent 5ec765e41e
commit 848305f9ac
6 changed files with 2757 additions and 2731 deletions

File diff suppressed because it is too large Load Diff

View File

@ -37,27 +37,6 @@ class mythenDetector : public slsDetector{
virtual ~mythenDetector(){};
/**
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
*/
string executeLine(int narg, char *args[], int action=GET_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)
*/
static string helpLine(int action=GET_ACTION);
/**
type of action performed
*/
enum {GET_ACTION, PUT_ACTION, READOUT_ACTION};
/**
@ -175,164 +154,8 @@ enum {GET_ACTION, PUT_ACTION, READOUT_ACTION};
int writeCalibrationFile(string fname, float gain, float offset);
/**
reads an angular conversion file
\param fname file to be read
\sa angleConversionConstant
*/
int readAngularConversion(string fname="");
/**
writes an angular conversion file
\param fname file to be written
\sa angleConversionConstant
*/
int writeAngularConversion(string fname="");
//Corrections
/**
set angular conversion
\param fname file with angular conversion constants ("" disable)
\returns 0 if angular conversion disabled, >0 otherwise
*/
int setAngularConversion(string fname="");
/**
get angular conversion
\param reference to diffractometer direction
\param angconv array that will be filled with the angular conversion constants
\returns 0 if angular conversion disabled, >0 otherwise
*/
int getAngularConversion(int &direction, angleConversionConstant *angconv=NULL);
/** returns the angular conversion file */
string getAngularConversion() {if (thisDetector->correctionMask&(1<< ANGULAR_CONVERSION)) return string(thisDetector->angConvFile); else return string("none");};
/**
set detector global offset
*/
float setGlobalOffset(float f){thisDetector->globalOffset=f; return thisDetector->globalOffset;};
/**
set detector fine offset
*/
float setFineOffset(float f){thisDetector->fineOffset=f; return thisDetector->fineOffset;};
/**
get detector fine offset
*/
float getFineOffset(){return thisDetector->fineOffset;};
/**
get detector global offset
*/
float getGlobalOffset(){return thisDetector->globalOffset;};
/**
set positions for the acquisition
\param nPos number of positions
\param pos array with the encoder positions
\returns number of positions
*/
int setPositions(int nPos, float *pos);
/**
get positions for the acquisition
\param pos array which will contain the encoder positions
\returns number of positions
*/
int getPositions(float *pos=NULL);
/** set detector bin size used for merging (approx angular resolution)*/
float setBinSize(float bs) {thisDetector->binSize=bs; return thisDetector->binSize;}
/** return detector bin size used for merging (approx angular resolution)*/
float getBinSize() {return thisDetector->binSize;}
/** sets the arrays of the merged data to 0. NB The array should be created with size >= 360./getBinSize();
\param mp already merged postions
\param mv already merged data
\param me already merged errors (squared sum)
\param mm multiplicity of merged arrays
\returns OK or FAIL
*/
int resetMerging(float *mp, float *mv,float *me, int *mm);
/** merge dataset
\param p1 angular positions of dataset
\param v1 data
\param e1 errors
\param mp already merged postions
\param mv already merged data
\param me already merged errors (squared sum)
\param mm multiplicity of merged arrays
*/
int addToMerging(float *p1, float *v1, float *e1, float *mp, float *mv,float *me, int *mm);
/**
calculates the "final" positions, data value and errors for the emrged data
\param mp already merged postions
\param mv already merged data
\param me already merged errors (squared sum)
\param mm multiplicity of merged arrays
\returns FAIL or the
*/
int finalizeMerging(float *mp, float *mv,float *me, int *mm);
/**
function for processing data
\param delflag if 1 the data are deleted, else left there for further processing (or plotting?)
*/
void* processData(int delflag=1); // thread function
/** performs the complete acquisition and 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())
\param delflag if 1 the data are deleted, else left there for further processing (or plotting?)
*/
void acquire(int delflag=1);
/**
get current timer value on the stop socket
\param index timer index
\returns elapsed time value in ns or number of...(e.g. frames, gates, probes)
*/
int64_t getTimeLeft(timerIndex index);
/**
get run status on the stop socket
\returns status mask
*/
runStatus getRunStatus();
private:
/**
start data processing thread
*/
void startThread(int delflag=1); //
/** the data processing thread */
pthread_t dataProcessingThread;
/** sets when the acquisition is finished */
int jointhread;
/** data queue size */
int queuesize;
};
static void* startProcessData(void *n);
static void* startProcessDataNoDelete(void *n);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -312,7 +312,7 @@ typedef struct sharedSlsDetector {
//slsDetector(string const fname);
// ~slsDetector(){while(dataQueue.size()>0){}};
/** destructor */
virtual ~slsDetector(){};
virtual ~slsDetector();//{ disconnect_channels();};
/** sets the onlineFlag
@ -348,13 +348,13 @@ typedef struct sharedSlsDetector {
Should be implemented in the specific detector class
/sa mythenDetector::dumpDetectorSetup
*/
virtual int dumpDetectorSetup(string const fname, int level)=0;
virtual int dumpDetectorSetup(string const fname, int level=0)=0;
/**
Purely virtual function
Should be implemented in the specific detector class
/sa mythenDetector::retrieveDetectorSetup
*/
virtual int retrieveDetectorSetup(string const fname, int level)=0;
virtual int retrieveDetectorSetup(string const fname, int level=0)=0;
/**
configure the socket communication and initializes the socket instances
@ -587,14 +587,14 @@ typedef struct sharedSlsDetector {
\param fname file to be read
\sa angleConversionConstant mythenDetector::readAngularConversion
*/
virtual int readAngularConversion(string fname="")=0;
int readAngularConversion(string fname="");
/**
Pure virtual function
writes an angular conversion file
\param fname file to be written
\sa angleConversionConstant mythenDetector::writeAngularConversion
*/
virtual int writeAngularConversion(string fname="")=0;
int writeAngularConversion(string fname="");
/** Returns the number of channels per chip */
int getNChans(){return thisDetector->nChans;}; //
@ -930,7 +930,8 @@ typedef struct sharedSlsDetector {
get run status
\returns status mask
*/
virtual runStatus getRunStatus()=0;
//virtual runStatus getRunStatus()=0;
runStatus getRunStatus();
/**
start detector acquisition and read all data putting them a data queue
@ -1161,7 +1162,7 @@ s
\returns 0 if angular conversion disabled, >0 otherwise
\sa mythenDetector::setAngularConversion
*/
virtual int setAngularConversion(string fname="")=0;
int setAngularConversion(string fname="");
/**
pure virtual function
@ -1171,41 +1172,41 @@ s
\returns 0 if angular conversion disabled, >0 otherwise
\sa mythenDetector::getAngularConversion
*/
virtual int getAngularConversion(int &direction, angleConversionConstant *angconv=NULL)=0;
int getAngularConversion(int &direction, angleConversionConstant *angconv=NULL) ;
/**
pure virtual function
returns the angular conversion file
\sa mythenDetector::getAngularConversion */
virtual string getAngularConversion()=0;
string getAngularConversion(){if (thisDetector->correctionMask&(1<< ANGULAR_CONVERSION)) return string(thisDetector->angConvFile); else return string("none");};
/**
pure virtual function
set detector global offset
\sa mythenDetector::setGlobalOffset
*/
virtual float setGlobalOffset(float f)=0;
float setGlobalOffset(float f){thisDetector->globalOffset=f; return thisDetector->globalOffset;};
/**
pure virtual function
set detector fine offset
\sa mythenDetector::setFineOffset
*/
virtual float setFineOffset(float f)=0;
float setFineOffset(float f){thisDetector->fineOffset=f; return thisDetector->fineOffset;};
/**
pure virtual function
get detector fine offset
\sa mythenDetector::getFineOffset
*/
virtual float getFineOffset()=0;
float getFineOffset(){return thisDetector->fineOffset;};
/**
pure virtual function
get detector global offset
\sa mythenDetector::getGlobalOffset
*/
virtual float getGlobalOffset()=0;
float getGlobalOffset(){return thisDetector->globalOffset;};
/**
pure virtual function
@ -1215,7 +1216,7 @@ s
\returns number of positions
\sa mythenDetector::setPositions
*/
virtual int setPositions(int nPos, float *pos)=0;
int setPositions(int nPos, float *pos);
/**
pure virtual function
get positions for the acquisition
@ -1223,7 +1224,7 @@ s
\returns number of positions
\sa mythenDetector::getPositions
*/
virtual int getPositions(float *pos=NULL)=0;
int getPositions(float *pos=NULL);
/** pure virtual function
@ -1232,13 +1233,13 @@ s
\returns current bin size
\sa mythenDetector::setBinSize
*/
virtual float setBinSize(float bs)=0;
float setBinSize(float bs){thisDetector->binSize=bs; return thisDetector->binSize;};
/** pure virtual function
return detector bin size used for merging (approx angular resolution)
\sa mythenDetector::getBinSize
*/
virtual float getBinSize()=0;
float getBinSize() {return thisDetector->binSize;};
@ -1412,7 +1413,7 @@ s
\returns OK or FAIL
\sa mythenDetector::resetMerging
*/
virtual int resetMerging(float *mp, float *mv,float *me, int *mm)=0;
int resetMerging(float *mp, float *mv,float *me, int *mm);
/**
pure virtual function
merge dataset
@ -1425,7 +1426,7 @@ s
\param mm multiplicity of merged arrays
\sa mythenDetector::addToMerging
*/
virtual int addToMerging(float *p1, float *v1, float *e1, float *mp, float *mv,float *me, int *mm)=0;
int addToMerging(float *p1, float *v1, float *e1, float *mp, float *mv,float *me, int *mm);
/** pure virtual function
calculates the "final" positions, data value and errors for the emrged data
@ -1448,7 +1449,7 @@ s
/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)=0; // thread function
void* processData(int delflag=1); // thread function
/** Allocates the memory for a sls_detector_module structure and initializes it
\returns myMod the pointer to the allocate dmemory location
@ -1473,7 +1474,7 @@ s
\sa mythenDetector::acquire()
*/
virtual void acquire(int delflag=1)=0;
void acquire(int delflag=1);
/** calcualtes the total number of steps of the acquisition.
called when number of frames, number of cycles, number of positions and scan steps change
@ -1483,6 +1484,90 @@ s
/** returns the current progress in % */
float getCurrentProgress();
/**
type of action performed (for text client)
*/
enum {GET_ACTION, PUT_ACTION, READOUT_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
*/
string executeLine(int narg, char *args[], int action=GET_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)
*/
static string helpLine(int action=GET_ACTION);
protected:
@ -1660,8 +1745,41 @@ s
fill bad channel mask (0 if channel is good, 1 if bad)
*/
int fillBadChannelMask();
/**
start data processing thread
*/
void startThread(int delflag=1); //
/** the data processing thread */
pthread_t dataProcessingThread;
/** sets when the acquisition is finished */
int jointhread;
/** data queue size */
int queuesize;
/** mutex to synchronize threads */
pthread_mutex_t mp;
};
static void* startProcessData(void *n);
static void* startProcessDataNoDelete(void *n);
//static void* startProcessData(void *n);
#endif

View File

@ -198,3 +198,5 @@ float get_i0() {
return i0++;
}
int disconnect_channels() { }
int connect_channels() {}

View File

@ -35,6 +35,9 @@ extern "C" {
int go_to_position(float p);
int go_to_position_no_wait(float p);
int connect_channels();
int disconnect_channels();
float get_i0();