cretated the class slsDetectorDefs, more advanced funcs moved from slsDetectorBase to slsDetectorUtils, separated function index enum from other definitions (share with dectris?)

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@162 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
bergamaschi 2012-03-23 11:44:24 +00:00
parent 513e033a45
commit 13344152aa
13 changed files with 466 additions and 358 deletions

View File

@ -43,10 +43,26 @@ using namespace std;
added a function which really does not close the socket between send/receive (senddataonly, receivedataonly) added a function which really does not close the socket between send/receive (senddataonly, receivedataonly)
*/ */
#ifdef __CINT__
//class sockaddr_in;
class socklen_t;
class uint32_t;
class uint32_t_ss;
// CINT view of types:
class sockaddr_in;
// {
// unsigned short int sa_family;
// unsigned char sa_data[14];
// };
#else
#include <arpa/inet.h> #include <arpa/inet.h>
#include <netdb.h> #include <netdb.h>
#include <netinet/in.h> #include <netinet/in.h>
#endif
#include <unistd.h> #include <unistd.h>

View File

@ -29,7 +29,17 @@ and to the server programs running on the detector
/** get flag form most functions */ /** get flag form most functions */
#define GET_FLAG -1 #define GET_FLAG -1
enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS}; #ifdef __cplusplus
class slsDetectorDefs {
public:
slsDetectorDefs(){};
#endif
enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS};
@ -39,19 +49,19 @@ enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScri
\see ::channelRegisterBit \see ::channelRegisterBit
*/ */
typedef struct { typedef struct {
int chan; /**< is the channel number */ int chan; /**< is the channel number */
int chip; /**< is the chip number */ int chip; /**< is the chip number */
int module; /**< is the module number */ int module; /**< is the module number */
int64_t reg; /**< is the is the channel register (e.g. trimbits, calibration enable, comparator enable...) */ int64_t reg; /**< is the is the channel register (e.g. trimbits, calibration enable, comparator enable...) */
} sls_detector_channel; } sls_detector_channel;
/** /**
structure for a detector chip structure for a detector chip
should not be used by unexperienced users should not be used by unexperienced users
\see ::chipRegisterBit ::channelRegisterBit \see ::chipRegisterBit ::channelRegisterBit
*/ */
typedef struct { typedef struct {
int chip; /**< is the chip number */ int chip; /**< is the chip number */
int module; /**< is the module number */ int module; /**< is the module number */
int nchan; /**< is the number of channels in the chip */ int nchan; /**< is the number of channels in the chip */
@ -59,7 +69,7 @@ typedef struct {
\see ::chipRegisterBit */ \see ::chipRegisterBit */
int *chanregs; /**< is the pointer to the array of the channel registers int *chanregs; /**< is the pointer to the array of the channel registers
\see ::channelRegisterBit */ \see ::channelRegisterBit */
} sls_detector_chip; } sls_detector_chip;
/** /**
structure for a detector module structure for a detector module
@ -443,118 +453,6 @@ enum imageType {
/**
function indexes to call on the server
All set functions with argument -1 work as get, when possible
*/
enum {
// General purpose functions
F_EXEC_COMMAND=0, /**< command is executed */
F_GET_ERROR, /**< return detector error status */
// configuration functions
F_GET_DETECTOR_TYPE, /**< return detector type */
F_SET_NUMBER_OF_MODULES, /**< set/get number of installed modules */
F_GET_MAX_NUMBER_OF_MODULES, /**< get maximum number of installed modules */
F_SET_EXTERNAL_SIGNAL_FLAG, /**< set/get flag for external signal */
F_SET_EXTERNAL_COMMUNICATION_MODE, /**< set/get external communication mode (obsolete) */
// Tests and identification
F_GET_ID, /**< get detector id of version */
F_DIGITAL_TEST, /**< digital test of the detector */
F_ANALOG_TEST, /**<analog test of the detector */
F_ENABLE_ANALOG_OUT, /**<enable the analog output */
F_CALIBRATION_PULSE, /**<pulse the calibration input */
// Initialization functions
F_SET_DAC, /**< set DAC value */
F_GET_ADC, /**< get ADC value */
F_WRITE_REGISTER, /**< write to register */
F_READ_REGISTER, /**< read register */
F_WRITE_MEMORY, /**< write to memory */
F_READ_MEMORY, /**< read memory */
F_SET_CHANNEL, /**< initialize channel */
F_GET_CHANNEL, /**< get channel register */
F_SET_ALL_CHANNELS, /**< initialize all channels */
F_SET_CHIP, /**< initialize chip */
F_GET_CHIP, /**< get chip status */
F_SET_ALL_CHIPS, /**< initialize all chips */
F_SET_MODULE, /**< initialize module */
F_GET_MODULE, /**< get module status */
F_SET_ALL_MODULES, /**< initialize all modules */
F_SET_SETTINGS, /**< set detector settings */
F_GET_THRESHOLD_ENERGY, /**< get detector threshold (in eV) */
F_SET_THRESHOLD_ENERGY, /**< set detector threshold (in eV) */
// Acquisition functions
F_START_ACQUISITION, /**< start acquisition */
F_STOP_ACQUISITION, /**< stop acquisition */
F_START_READOUT, /**< start readout */
F_GET_RUN_STATUS, /**< get acquisition status */
F_START_AND_READ_ALL, /**< start acquisition and read all frames*/
F_READ_FRAME, /**< read one frame */
F_READ_ALL, /**< read alla frames */
//Acquisition setup functions
F_SET_TIMER, /**< set/get timer value */
F_GET_TIME_LEFT, /**< get current value of the timer (time left) */
F_SET_DYNAMIC_RANGE, /**< set/get detector dynamic range */
F_SET_READOUT_FLAGS, /**< set/get readout flags */
F_SET_ROI, /**< set/get region of interest */
F_SET_SPEED, /**< set/get readout speed parameters */
//Trimming
F_EXECUTE_TRIMMING, /**< execute trimming */
F_EXIT_SERVER, /**< turn off detector server */
F_LOCK_SERVER, /**< Locks/Unlocks server communication to the given client */
F_GET_LAST_CLIENT_IP, /**< returns the IP of the client last connected to the detector */
F_SET_PORT, /**< Changes communication port of the server */
F_UPDATE_CLIENT, /**< Returns all the important parameters to update the shared memory of the client */
F_CONFIGURE_MAC, /**< Configures MAC for Gotthard readout */
F_LOAD_IMAGE, /**< Loads Dark/Gain image to the Gotthard detector */
// multi detector structures
F_SET_MASTER, /**< sets master/slave flag for multi detector structures */
F_SET_SYNCHRONIZATION_MODE, /**< sets master/slave synchronization mode for multidetector structures */
// not multi detector
F_READ_COUNTER_BLOCK, /**< reads counter memory block for the Gotthard detector */
F_RESET_COUNTER_BLOCK /**< resets counter memory block for the Gotthard detector */
/* Always append functions hereafter!!! */
};
/** /**
angular conversion constant for a module angular conversion constant for a module
*/ */
@ -580,4 +478,15 @@ enum angleConversionParameter {
#ifdef __cplusplus
protected:
#endif
#include "sls_detector_funcs.h
#ifdef __cplusplus
};
#endif
#endif #endif

View File

@ -0,0 +1,108 @@
/**
@internal
function indexes to call on the server
All set functions with argument -1 work as get, when possible
*/
enum {
// General purpose functions
F_EXEC_COMMAND=0, /**< command is executed */
F_GET_ERROR, /**< return detector error status */
// configuration functions
F_GET_DETECTOR_TYPE, /**< return detector type */
F_SET_NUMBER_OF_MODULES, /**< set/get number of installed modules */
F_GET_MAX_NUMBER_OF_MODULES, /**< get maximum number of installed modules */
F_SET_EXTERNAL_SIGNAL_FLAG, /**< set/get flag for external signal */
F_SET_EXTERNAL_COMMUNICATION_MODE, /**< set/get external communication mode (obsolete) */
// Tests and identification
F_GET_ID, /**< get detector id of version */
F_DIGITAL_TEST, /**< digital test of the detector */
F_ANALOG_TEST, /**<analog test of the detector */
F_ENABLE_ANALOG_OUT, /**<enable the analog output */
F_CALIBRATION_PULSE, /**<pulse the calibration input */
// Initialization functions
F_SET_DAC, /**< set DAC value */
F_GET_ADC, /**< get ADC value */
F_WRITE_REGISTER, /**< write to register */
F_READ_REGISTER, /**< read register */
F_WRITE_MEMORY, /**< write to memory */
F_READ_MEMORY, /**< read memory */
F_SET_CHANNEL, /**< initialize channel */
F_GET_CHANNEL, /**< get channel register */
F_SET_ALL_CHANNELS, /**< initialize all channels */
F_SET_CHIP, /**< initialize chip */
F_GET_CHIP, /**< get chip status */
F_SET_ALL_CHIPS, /**< initialize all chips */
F_SET_MODULE, /**< initialize module */
F_GET_MODULE, /**< get module status */
F_SET_ALL_MODULES, /**< initialize all modules */
F_SET_SETTINGS, /**< set detector settings */
F_GET_THRESHOLD_ENERGY, /**< get detector threshold (in eV) */
F_SET_THRESHOLD_ENERGY, /**< set detector threshold (in eV) */
// Acquisition functions
F_START_ACQUISITION, /**< start acquisition */
F_STOP_ACQUISITION, /**< stop acquisition */
F_START_READOUT, /**< start readout */
F_GET_RUN_STATUS, /**< get acquisition status */
F_START_AND_READ_ALL, /**< start acquisition and read all frames*/
F_READ_FRAME, /**< read one frame */
F_READ_ALL, /**< read alla frames */
//Acquisition setup functions
F_SET_TIMER, /**< set/get timer value */
F_GET_TIME_LEFT, /**< get current value of the timer (time left) */
F_SET_DYNAMIC_RANGE, /**< set/get detector dynamic range */
F_SET_READOUT_FLAGS, /**< set/get readout flags */
F_SET_ROI, /**< set/get region of interest */
F_SET_SPEED, /**< set/get readout speed parameters */
//Trimming
F_EXECUTE_TRIMMING, /**< execute trimming */
F_EXIT_SERVER, /**< turn off detector server */
F_LOCK_SERVER, /**< Locks/Unlocks server communication to the given client */
F_GET_LAST_CLIENT_IP, /**< returns the IP of the client last connected to the detector */
F_SET_PORT, /**< Changes communication port of the server */
F_UPDATE_CLIENT, /**< Returns all the important parameters to update the shared memory of the client */
F_CONFIGURE_MAC, /**< Configures MAC for Gotthard readout */
F_LOAD_IMAGE, /**< Loads Dark/Gain image to the Gotthard detector */
// multi detector structures
F_SET_MASTER, /**< sets master/slave flag for multi detector structures */
F_SET_SYNCHRONIZATION_MODE /**< sets master/slave synchronization mode for multidetector structures */
/* Always append functions hereafter!!! */
};
/** @endinternal */

View File

@ -8,7 +8,9 @@ EXTRACT_ALL = YES
# If the EXTRACT_PRIVATE tag is set to YES all private members of a class # If the EXTRACT_PRIVATE tag is set to YES all private members of a class
# will be included in the documentation. # will be included in the documentation.
EXTRACT_PRIVATE = YES EXTRACT_PRIVATE = NO
# If the EXTRACT_STATIC tag is set to YES all static members of a file # If the EXTRACT_STATIC tag is set to YES all static members of a file
# will be included in the documentation. # will be included in the documentation.
@ -58,7 +60,29 @@ HIDE_UNDOC_CLASSES = NO
HIDE_FRIEND_COMPOUNDS = NO HIDE_FRIEND_COMPOUNDS = NO
INPUT = slsDetector/slsDetector.h mythenDetector/mythenDetector.h eigerDetector/eigerDetector.h gotthardDetector/gotthardDetector.h MySocketTCP/MySocketTCP.h usersFunctions/usersFunctions.h multiSlsDetector/multiSlsDetector.h commonFiles/sls_detector_defs.h slsDetector/slsDetector.cpp MySocketTCP/MySocketTCP.cxx usersFunctions/usersFunctions.c multiSlsDetector/multiSlsDetector.cpp gotthardDetector/gotthardDetector.cpp INTERNAL_DOCS = NO
SHOW_INCLUDE_FILES = NO
SHOW_FILES = NO
SHOW_NAMESPACES = NO
COMPACT_LATEX = YES
PAPER_TYPE = a4
PDF_HYPERLINKS = YES
USE_PDFLATEX = YES
LATEX_HIDE_INDICES = YES
PREDEFINED = __cplusplus
INPUT = slsDetector/slsDetectorBase.h commonFiles/sls_detector_defs.h
#INPUT = slsDetector/slsDetector.h MySocketTCP/MySocketTCP.h usersFunctions/usersFunctions.h multiSlsDetector/multiSlsDetector.h commonFiles/sls_detector_defs.h slsDetector/slsDetectorUtils.h slsDetector/slsDetectorBase.h slsDetector/slsDetectorCommand.h multiSlsDetector/multiSlsDetector.h
OUTPUT_DIRECTORY = docs OUTPUT_DIRECTORY = docs

View File

@ -1091,8 +1091,8 @@ int* multiSlsDetector::readAll(){
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "received "<< i<< " frames" << std::endl; std::cout<< "received "<< i<< " frames" << std::endl;
#else //#else
std::cout << std::endl; // std::cout << std::endl;
#endif #endif
return dataQueue.front(); // check what we return! return dataQueue.front(); // check what we return!
@ -1132,8 +1132,8 @@ int* multiSlsDetector::startAndReadAll(){
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "MMMM recieved "<< i<< " frames" << std::endl; std::cout<< "MMMM recieved "<< i<< " frames" << std::endl;
#else //#else
std::cout << std::endl; // std::cout << std::endl;
#endif #endif
return dataQueue.front(); // check what we return! return dataQueue.front(); // check what we return!

View File

@ -581,7 +581,7 @@ class multiSlsDetector : public slsDetectorUtils {
updates the size of the data expected from the detector updates the size of the data expected from the detector
\sa sharedSlsDetector \sa sharedSlsDetector
*/ */
int setDynamicRange(int n=-1, int pos=-1); int setDynamicRange(int n, int pos);
@ -611,7 +611,7 @@ class multiSlsDetector : public slsDetectorUtils {
\param ecorr if !=NULL the flat field correction errors will be filled with ecorr (1 otherwise) \param ecorr if !=NULL the flat field correction errors will be filled with ecorr (1 otherwise)
\returns 0 if ff correction disabled, >0 otherwise \returns 0 if ff correction disabled, >0 otherwise
*/ */
int setFlatFieldCorrection(float *corr=NULL, float *ecorr=NULL); int setFlatFieldCorrection(float *corr, float *ecorr=NULL);
/** /**
get flat field corrections get flat field corrections

View File

@ -0,0 +1 @@
../commonFiles/sls_detector_funcs.h

View File

@ -1,3 +1,4 @@
#include "slsDetector.h" #include "slsDetector.h"
#include "usersFunctions.h" #include "usersFunctions.h"
#include "slsDetectorCommand.h" #include "slsDetectorCommand.h"
@ -268,7 +269,7 @@ slsDetector::slsDetector(char *name, int id, int cport) : slsDetectorUtils(),
} }
detectorType slsDetector::getDetectorType(char *name, int cport) { slsDetectorDefs::detectorType slsDetector::getDetectorType(char *name, int cport) {
int retval=FAIL; int retval=FAIL;
detectorType t=GENERIC; detectorType t=GENERIC;
@ -377,7 +378,7 @@ int slsDetector::exists(int id) {
detectorType slsDetector::getDetectorType(int id) { slsDetectorDefs::detectorType slsDetector::getDetectorType(int id) {
detectorType t=GENERIC; detectorType t=GENERIC;
@ -740,7 +741,7 @@ int slsDetector::initializeDetectorStructure() {
return 0; return 0;
} }
sls_detector_module* slsDetector::createModule() { slsDetectorDefs::sls_detector_module* slsDetector::createModule() {
sls_detector_module *myMod=(sls_detector_module*)malloc(sizeof(sls_detector_module)); sls_detector_module *myMod=(sls_detector_module*)malloc(sizeof(sls_detector_module));
float *dacs=new float[thisDetector->nDacs]; float *dacs=new float[thisDetector->nDacs];
@ -1364,7 +1365,7 @@ enum externalSignalFlag {
}{}; }{};
*/ */
externalSignalFlag slsDetector::setExternalSignalFlags(externalSignalFlag pol, int signalindex){ slsDetectorDefs::externalSignalFlag slsDetector::setExternalSignalFlags(externalSignalFlag pol, int signalindex){
@ -1436,7 +1437,7 @@ enum externalSignalFlag {
*/ */
externalCommunicationMode slsDetector::setExternalCommunicationMode( externalCommunicationMode pol){ slsDetectorDefs::externalCommunicationMode slsDetector::setExternalCommunicationMode( externalCommunicationMode pol){
@ -2030,7 +2031,7 @@ int slsDetector::setChannel(sls_detector_channel chan){
sls_detector_channel slsDetector::getChannel(int ichan, int ichip, int imod){ slsDetectorDefs::sls_detector_channel slsDetector::getChannel(int ichan, int ichip, int imod){
int fnum=F_GET_CHANNEL; int fnum=F_GET_CHANNEL;
@ -2167,7 +2168,7 @@ int slsDetector::setChip(sls_detector_chip chip){
}; };
sls_detector_chip slsDetector::getChip(int ichip, int imod){ slsDetectorDefs::sls_detector_chip slsDetector::getChip(int ichip, int imod){
int fnum=F_GET_CHIP; int fnum=F_GET_CHIP;
sls_detector_chip myChip; sls_detector_chip myChip;
@ -2395,7 +2396,7 @@ int slsDetector::setModule(sls_detector_module module){
return retval; return retval;
}; };
sls_detector_module *slsDetector::getModule(int imod){ slsDetectorDefs::sls_detector_module *slsDetector::getModule(int imod){
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "slsDetector get module " << std::endl; std::cout << "slsDetector get module " << std::endl;
@ -2603,7 +2604,7 @@ int slsDetector::setThresholdEnergy(int e_eV, int imod, detectorSettings isetti
/* /*
select detector settings select detector settings
*/ */
detectorSettings slsDetector::getSettings(int imod){ slsDetectorDefs::detectorSettings slsDetector::getSettings(int imod){
int fnum=F_SET_SETTINGS; int fnum=F_SET_SETTINGS;
@ -2644,7 +2645,7 @@ int slsDetector::setThresholdEnergy(int e_eV, int imod, detectorSettings isetti
detectorSettings slsDetector::setSettings( detectorSettings isettings, int imod){ slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings isettings, int imod){
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "slsDetector setSettings "<< std::endl; std::cout<< "slsDetector setSettings "<< std::endl;
#endif #endif
@ -2954,7 +2955,7 @@ int slsDetector::startReadOut(){
}; };
runStatus slsDetector::getRunStatus(){ slsDetectorDefs::runStatus slsDetector::getRunStatus(){
int fnum=F_GET_RUN_STATUS; int fnum=F_GET_RUN_STATUS;
int ret=FAIL; int ret=FAIL;
char mess[100]; char mess[100];
@ -3013,6 +3014,7 @@ int* slsDetector::getDataFromDetector(int *retval){
int nel=thisDetector->dataBytes/sizeof(int); int nel=thisDetector->dataBytes/sizeof(int);
int n; int n;
int *r=retval;
// int* retval=new int[nel]; // int* retval=new int[nel];
@ -3042,7 +3044,7 @@ int* slsDetector::getDataFromDetector(int *retval){
std::cout<< "Detector successfully returned: " << mess << " " << n << std::endl; std::cout<< "Detector successfully returned: " << mess << " " << n << std::endl;
#endif #endif
} }
if (retval==NULL) { if (r==NULL) {
delete [] retval; delete [] retval;
} }
return NULL; return NULL;
@ -3056,7 +3058,7 @@ int* slsDetector::getDataFromDetector(int *retval){
std::cout<< "wrong data size received: received " << n << " but expected " << thisDetector->dataBytes << std::endl; std::cout<< "wrong data size received: received " << n << " but expected " << thisDetector->dataBytes << std::endl;
thisDetector->stoppedFlag=1; thisDetector->stoppedFlag=1;
ret=FAIL; ret=FAIL;
if (retval==NULL) { if (r==NULL) {
delete [] retval; delete [] retval;
} }
return NULL; return NULL;
@ -3101,8 +3103,8 @@ int* slsDetector::readAll(){
} }
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "received "<< i<< " frames" << std::endl; std::cout<< "received "<< i<< " frames" << std::endl;
#else //#else
std::cout << std::endl; // std::cout << std::endl;
#endif #endif
return dataQueue.front(); // check what we return! return dataQueue.front(); // check what we return!
@ -3160,8 +3162,8 @@ int* slsDetector::startAndReadAll(){
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "received "<< i<< " frames" << std::endl; std::cout<< "received "<< i<< " frames" << std::endl;
#else //#else
std::cout << std::endl; // std::cout << std::endl;
#endif #endif
return dataQueue.front(); // check what we return! return dataQueue.front(); // check what we return!
/* while ((retval=getDataFromDetectorNoWait())) /* while ((retval=getDataFromDetectorNoWait()))
@ -5147,7 +5149,7 @@ int slsDetector::retrieveDetectorSetup(string fname1, int level){
/* I/O */ /* I/O */
sls_detector_module* slsDetector::readSettingsFile(string fname, sls_detector_module *myMod){ slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(string fname, sls_detector_module *myMod){
int nflag=0; int nflag=0;
@ -5466,7 +5468,7 @@ int slsDetector::saveSettingsFile(string fname, int imod) {
\param flag can be GET_MASTER, NO_MASTER, IS_MASTER, IS_SLAVE \param flag can be GET_MASTER, NO_MASTER, IS_MASTER, IS_SLAVE
\returns master flag of the detector \returns master flag of the detector
*/ */
masterFlags slsDetector::setMaster(masterFlags flag) { slsDetectorDefs::masterFlags slsDetector::setMaster(masterFlags flag) {
int fnum=F_SET_MASTER; int fnum=F_SET_MASTER;
@ -5511,7 +5513,7 @@ masterFlags slsDetector::setMaster(masterFlags flag) {
\param sync syncronization mode can be GET_SYNCHRONIZATION_MODE, NO_SYNCHRONIZATION, MASTER_GATES, MASTER_TRIGGERS, SLAVE_STARTS_WHEN_MASTER_STOPS \param sync syncronization mode can be GET_SYNCHRONIZATION_MODE, NO_SYNCHRONIZATION, MASTER_GATES, MASTER_TRIGGERS, SLAVE_STARTS_WHEN_MASTER_STOPS
\returns current syncronization mode \returns current syncronization mode
*/ */
synchronizationMode slsDetector::setSynchronization(synchronizationMode flag) { slsDetectorDefs::synchronizationMode slsDetector::setSynchronization(synchronizationMode flag) {

View File

@ -4,8 +4,11 @@
#ifndef SLS_DETECTOR_H #ifndef SLS_DETECTOR_H
#define SLS_DETECTOR_H #define SLS_DETECTOR_H
#include "MySocketTCP.h"
class MySocketTCP;
#include "slsDetectorUtils.h" #include "slsDetectorUtils.h"
#include "MySocketTCP.h"
//#include "slsDetectorCommand.h" //#include "slsDetectorCommand.h"
@ -1096,7 +1099,7 @@ typedef struct sharedSlsDetector {
\param ecorr if !=NULL the flat field correction errors will be filled with ecorr (1 otherwise) \param ecorr if !=NULL the flat field correction errors will be filled with ecorr (1 otherwise)
\returns 0 if ff correction disabled, >0 otherwise \returns 0 if ff correction disabled, >0 otherwise
*/ */
int setFlatFieldCorrection(float *corr=NULL, float *ecorr=NULL); int setFlatFieldCorrection(float *corr, float *ecorr=NULL);
/** /**

View File

@ -16,7 +16,8 @@ This class contains the functions accessible by the users to control the slsDete
*/ */
class slsDetectorBase { class slsDetectorBase : public slsDetectorDefs
{
public: public:
@ -28,7 +29,7 @@ class slsDetectorBase {
virtual ~slsDetectorBase(){}; virtual ~slsDetectorBase(){};
/** sets the onlineFlag /** sets the onlineFlag
\param off can be: <BR> GET_ONLINE_FLAG, returns wether the detector is in online or offline state;<BR> OFFLINE_FLAG, detector in offline state (i.e. no communication to the detector - using only local structure - no data acquisition possible!);<BR> ONLINE_FLAG detector in online state (i.e. communication to the detector updating the local structure) \param online can be: <BR> GET_ONLINE_FLAG, returns wether the detector is in online or offline state;<BR> OFFLINE_FLAG, detector in offline state (i.e. no communication to the detector - using only local structure - no data acquisition possible!);<BR> ONLINE_FLAG detector in online state (i.e. communication to the detector updating the local structure)
\returns ONLINE_FLAG or OFFLINE_FLAG \returns ONLINE_FLAG or OFFLINE_FLAG
*/ */
virtual int setOnline(int const online=GET_ONLINE_FLAG)=0; virtual int setOnline(int const online=GET_ONLINE_FLAG)=0;
@ -61,12 +62,17 @@ class slsDetectorBase {
*/ */
virtual int* readFrame()=0; virtual int* readFrame()=0;
/** processes the data /* /\** processes the data */
\param delflag 0 leaves the data in the final data queue /* \param delflag 0 leaves the data in the final data queue */
\returns nothing /* \returns nothing */
/* *\/ */
/* virtual void* processData(int delflag)=0; */
*/
virtual void* processData(int delflag)=0;
/** /**
@ -86,43 +92,43 @@ class slsDetectorBase {
*/ */
virtual runStatus getRunStatus()=0; virtual runStatus getRunStatus()=0;
/** Frees the shared memory - should not be used except for debugging*/ /* /\** Frees the shared memory - should not be used except for debugging*\/ */
virtual int freeSharedMemory()=0; /* virtual int freeSharedMemory()=0; */
/** adds the detector with ID id in postion pos /* /\** adds the detector with ID id in postion pos */
\param id of the detector to be added (should already exist!) /* \param id of the detector to be added (should already exist!) */
\param pos position where it should be added (normally at the end of the list (default to -1) /* \param pos position where it should be added (normally at the end of the list (default to -1) */
\returns the actual number of detectors or -1 if it failed (always for slsDetector) /* \returns the actual number of detectors or -1 if it failed (always for slsDetector) */
*/ /* *\/ */
virtual int addSlsDetector(int id, int pos=-1){return -1;}; /* virtual int addSlsDetector(int id, int pos=-1){return -1;}; */
/** adds the detector name in position pos /* /\** adds the detector name in position pos */
\param name of the detector to be added (should already exist in shared memory or at least be online) /* \param name of the detector to be added (should already exist in shared memory or at least be online) */
\param pos position where it should be added (normally at the end of the list (default to -1) /* \param pos position where it should be added (normally at the end of the list (default to -1) */
\return the actual number of detectors or -1 if it failed (always for slsDetector) /* \return the actual number of detectors or -1 if it failed (always for slsDetector) */
*/ /* *\/ */
virtual int addSlsDetector(char* name, int pos=-1){return -1;}; /* virtual int addSlsDetector(char* name, int pos=-1){return -1;}; */
/** /* /\** */
removes the detector in position pos from the multidetector /* removes the detector in position pos from the multidetector */
\param pos position of the detector to be removed from the multidetector system (defaults to -1 i.e. last detector) /* \param pos position of the detector to be removed from the multidetector system (defaults to -1 i.e. last detector) */
\returns the actual number of detectors or -1 if it failed (always for slsDetector) /* \returns the actual number of detectors or -1 if it failed (always for slsDetector) */
*/ /* *\/ */
virtual int removeSlsDetector(int pos=-1){return -1;}; /* virtual int removeSlsDetector(int pos=-1){return -1;}; */
/**removes the detector in position pos from the multidetector /* /\**removes the detector in position pos from the multidetector */
\param name is the name of the detector /* \param name is the name of the detector */
\returns the actual number of detectors or -1 if it failed (always for slsDetector) /* \returns the actual number of detectors or -1 if it failed (always for slsDetector) */
*/ /* *\/ */
virtual int removeSlsDetector(char* name){return -1;}; /* virtual int removeSlsDetector(char* name){return -1;}; */
/** returns the detector hostname /** returns the detector hostname
\param pos position in the multi detector structure (is -1 returns concatenated hostnames divided by a +) \param pos position in the multi detector structure (is -1 returns concatenated hostnames divided by a +)
\retruns hostname \returns hostname
*/ */
virtual string getHostname(int pos=-1)=0; virtual string getHostname(int pos=-1)=0;
@ -160,10 +166,6 @@ class slsDetectorBase {
*/ */
virtual synchronizationMode setSynchronization(synchronizationMode sync=GET_SYNCHRONIZATION_MODE)=0; virtual synchronizationMode setSynchronization(synchronizationMode sync=GET_SYNCHRONIZATION_MODE)=0;
/**
Turns off the server - do not use except for debugging!
*/
virtual int exitServer()=0;
/** /**
returns the detector trimbit/settings directory returns the detector trimbit/settings directory
@ -223,7 +225,7 @@ class slsDetectorBase {
/** /**
set flat field corrections file directory set flat field corrections file directory
\param flat field correction file directory \param dir flat field correction file directory
\returns flat field correction file directory \returns flat field correction file directory
*/ */
virtual char *setFlatFieldCorrectionDir(string dir)=0; virtual char *setFlatFieldCorrectionDir(string dir)=0;
@ -255,7 +257,7 @@ class slsDetectorBase {
\param ecorr if !=NULL the flat field correction errors will be filled with ecorr (1 otherwise) \param ecorr if !=NULL the flat field correction errors will be filled with ecorr (1 otherwise)
\returns 0 if ff correction disabled, >0 otherwise \returns 0 if ff correction disabled, >0 otherwise
*/ */
virtual int setFlatFieldCorrection(float *corr=NULL, float *ecorr=NULL)=0; virtual int setFlatFieldCorrection(float *corr, float *ecorr=NULL)=0;
/** /**
set rate correction set rate correction
@ -320,7 +322,7 @@ class slsDetectorBase {
/** /**
get angular conversion get angular conversion
\param reference to diffractometer direction \param direction reference to diffractometer direction
\param angconv array that will be filled with the angular conversion constants \param angconv array that will be filled with the angular conversion constants
\returns 0 if angular conversion disabled, >0 otherwise \returns 0 if angular conversion disabled, >0 otherwise
*/ */
@ -349,32 +351,32 @@ class slsDetectorBase {
*/ */
virtual float getAngularConversionParameter(angleConversionParameter c)=0; virtual float getAngularConversionParameter(angleConversionParameter c)=0;
/** /* /\** */
writes a data file /* writes a data file */
\param name of the file to be written /* \param name of the file to be written */
\param data array of data values /* \param data array of data values */
\param err array of arrors on the data. If NULL no errors will be written /* \param err array of arrors on the data. If NULL no errors will be written */
\param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err) /* \param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err) */
\param dataformat format of the data: can be 'i' integer or 'f' float (default) /* \param dataformat format of the data: can be 'i' integer or 'f' float (default) */
\param nch number of channels to be written to file. if -1 defaults to the number of installed channels of the detector /* \param nch number of channels to be written to file. if -1 defaults to the number of installed channels of the detector */
\returns OK or FAIL if it could not write the file or data=NULL /* \returns OK or FAIL if it could not write the file or data=NULL */
*/ /* *\/ */
virtual int writeDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=-1)=0; /* virtual int writeDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=-1)=0; */
/** /* /\** */
writes an angular conversion file /* writes an angular conversion file */
\param fname file to be written /* \param fname file to be written */
\return OK/FAIL /* \return OK/FAIL */
*/ /* *\/ */
virtual int writeAngularConversion(string fname)=0; /* virtual int writeAngularConversion(string fname)=0; */
/** /* /\** */
set/get if the data processing and file writing should be done by a separate thread - do not use except for debugging! /* set/get if the data processing and file writing should be done by a separate thread - do not use except for debugging! */
\param b 0 sequencial data acquisition and file writing, 1 separate thread, -1 get /* \param i 0 sequencial data acquisition and file writing, 1 separate thread, -1 get */
\returns thread flag /* \returns thread flag */
*/ /* *\/ */
virtual int setThreadedProcessing(int i=-1)=0; /* virtual int setThreadedProcessing(int i=-1)=0; */
/** /**
set positions for the acquisition set positions for the acquisition
@ -424,7 +426,7 @@ class slsDetectorBase {
/** /**
set scan script set scan script
\param index is the scan index (0 or 1) \param index is the scan index (0 or 1)
\param fname for script ("" disable, "none" disables and overwrites current, "threshold" makes threshold scan, "trimbits" make trimbits scan, "energy" makes energy scan) \param script fname for script ("" disable, "none" disables and overwrites current, "threshold" makes threshold scan, "trimbits" make trimbits scan, "energy" makes energy scan)
\returns 0 if scan disabled, >0 otherwise \returns 0 if scan disabled, >0 otherwise
*/ */
virtual int setScanScript(int index, string script="")=0; virtual int setScanScript(int index, string script="")=0;
@ -502,8 +504,8 @@ class slsDetectorBase {
/** /**
changes/gets the port number changes/gets the port number
\param type port type can be CONTROL_PORT, DATA_PORT, STOP_PORT \param t type port type can be CONTROL_PORT, DATA_PORT, STOP_PORT
\param num new port number (<1024 gets) \param i new port number (<1024 gets)
\returns actual port number \returns actual port number
*/ */
virtual int setPort(portType t, int i=-1)=0; virtual int setPort(portType t, int i=-1)=0;
@ -531,7 +533,7 @@ class slsDetectorBase {
/** /**
set/get the size of the detector set/get the size of the detector
\param n number of modules \param i number of modules
\param d dimension \param d dimension
\returns current number of modules in direction d \returns current number of modules in direction d
*/ */
@ -548,10 +550,8 @@ class slsDetectorBase {
/** /**
set/get dynamic range set/get dynamic range
\param n dynamic range (-1 get) \param i dynamic range (-1 get)
\returns current dynamic range \returns current dynamic range
updates the size of the data expected from the detector
\sa sharedSlsDetector
*/ */
virtual int setDynamicRange(int i=-1)=0; virtual int setDynamicRange(int i=-1)=0;
@ -642,25 +642,6 @@ class slsDetectorBase {
/**
write register
\param addr address
\val value
\returns current register value
DO NOT USE!!! ONLY EXPERT USER!!!
*/
virtual int writeRegister(int addr, int val)=0;
/**
read register
\param addr address
\returns current register value
DO NOT USE!!! ONLY EXPERT USER!!!
*/
virtual int readRegister(int addr)=0;
/** /**
@ -670,7 +651,7 @@ class slsDetectorBase {
\param imod module number (if -1 alla modules) \param imod module number (if -1 alla modules)
\returns current DAC value \returns current DAC value
*/ */
virtual float setDAC(float , dacIndex, int imod=-1)=0; virtual float setDAC(float val, dacIndex index , int imod=-1)=0;
/** /**
@ -679,7 +660,7 @@ class slsDetectorBase {
\param imod module number \param imod module number
\returns current ADC value \returns current ADC value
*/ */
virtual float getADC(dacIndex, int imod=0)=0; virtual float getADC(dacIndex index, int imod=0)=0;
/** /**
@ -722,7 +703,7 @@ class slsDetectorBase {
virtual int setTrimEn(int nen, int *en=NULL)=0; virtual int setTrimEn(int nen, int *en=NULL)=0;
/** returns the number of trim energies and their value \sa sharedSlsDetector /** returns the number of trim energies and their value \sa sharedSlsDetector
\param point to the array that will contain the trim energies (in ev) \param en pointer to the array that will contain the trim energies (in ev)
\returns number of trim energies \returns number of trim energies
unused! unused!
@ -733,7 +714,7 @@ class slsDetectorBase {
/** /**
set/get the use of an external signal set/get the use of an external signal
\param pol meaning of the signal \sa externalSignalFlag \param pol meaning of the signal \sa externalSignalFlag
\param signalIndex index of the signal \param signalindex index of the signal
\returns current meaning of signal signalIndex \returns current meaning of signal signalIndex
*/ */
virtual externalSignalFlag setExternalSignalFlags(externalSignalFlag pol=GET_EXTERNAL_SIGNAL_FLAG , int signalindex=0)=0; virtual externalSignalFlag setExternalSignalFlags(externalSignalFlag pol=GET_EXTERNAL_SIGNAL_FLAG , int signalindex=0)=0;
@ -790,35 +771,12 @@ class slsDetectorBase {
/** /**
Loads dark image or gain image to the detector Loads dark image or gain image to the detector
\param index can be DARK_IMAGE or GAIN_IMAGE \param index can be DARK_IMAGE or GAIN_IMAGE
\fname file name to load data from \param fname file name to load data from
\returns OK or FAIL \returns OK or FAIL
*/ */
virtual int loadImageToDetector(imageType index,string const fname)=0; virtual int loadImageToDetector(imageType index,string const fname)=0;
/**
writes the counter memory block from the detector
\param startACQ is 1 to start acquisition after reading counter
\fname file fname to load data from
\returns OK or FAIL
*/
virtual int writeCounterBlockFile(string const fname,int startACQ=0)=0;
/**
Resets counter memory block in detector
\param startACQ is 1 to start acquisition after resetting counter
\returns OK or FAIL
*/
virtual int resetCounterBlock(int startACQ=0)=0;
/**
function to test acquisition
*/
virtual int testFunction(int itimes=0)=0;
/************************************************************************ /************************************************************************
STATIC FUNCTIONS STATIC FUNCTIONS
@ -840,7 +798,7 @@ class slsDetectorBase {
}}; }};
/** returns detector type string from detector type index /** returns detector type string from detector type index
\param type string can be Mythen, Pilatus, Eiger, Gotthard, Agipd, Unknown \param t string can be Mythen, Pilatus, Eiger, Gotthard, Agipd, Unknown
\returns MYTHEN, PILATUS, EIGER, GOTTHARD, AGIPD, GENERIC \returns MYTHEN, PILATUS, EIGER, GOTTHARD, AGIPD, GENERIC
*/ */
static string getDetectorType(detectorType t){\ static string getDetectorType(detectorType t){\
@ -854,7 +812,7 @@ class slsDetectorBase {
}}; }};
/** returns detector type index from detector type string /** returns detector type index from detector type string
\param t can be MYTHEN, PILATUS, EIGER, GOTTHARD, AGIPD, GENERIC \param type can be MYTHEN, PILATUS, EIGER, GOTTHARD, AGIPD, GENERIC
\returns Mythen, Pilatus, Eiger, Gotthard, Agipd, Unknown \returns Mythen, Pilatus, Eiger, Gotthard, Agipd, Unknown
*/ */
static detectorType getDetectorType(string const type){\ static detectorType getDetectorType(string const type){\
@ -868,7 +826,7 @@ class slsDetectorBase {
/** returns synchronization type index from string /** returns synchronization type index from string
\param t can be none, gating, trigger, complementary \param type can be none, gating, trigger, complementary
\returns ONE, MASTER_GATES, MASTER_TRIGGERS, SLAVE_STARTS_WHEN_MASTER_STOPS \returns ONE, MASTER_GATES, MASTER_TRIGGERS, SLAVE_STARTS_WHEN_MASTER_STOPS
*/ */
static synchronizationMode getSyncType(string const type){\ static synchronizationMode getSyncType(string const type){\
@ -880,8 +838,8 @@ class slsDetectorBase {
}; };
/** returns synchronization type string from index /** returns synchronization type string from index
\param t can be NONE, MASTER_GATES, MASTER_TRIGGERS, SLAVE_STARTS_WHEN_MASTER_STOPS \param s can be NONE, MASTER_GATES, MASTER_TRIGGERS, SLAVE_STARTS_WHEN_MASTER_STOPS
\returns none, gating, trigger, complementary \returns none, gating, trigger, complementary, unknown
*/ */
static string getSyncType(synchronizationMode s ){\ static string getSyncType(synchronizationMode s ){\
switch(s) { \ switch(s) { \
@ -923,8 +881,8 @@ class slsDetectorBase {
/** returns external signal type index from string /** returns external signal type index from string
\param string off, gate_in_active_high, gate_in_active_low, trigger_in_rising_edge, trigger_in_falling_edge, ro_trigger_in_rising_edge, ro_trigger_in_falling_edge, gate_out_active_high, gate_out_active_low, trigger_out_rising_edge, trigger_out_falling_edge, ro_trigger_out_rising_edge, ro_trigger_out_falling_edge, gnd, vcc, sync, unknown \param sval off, gate_in_active_high, gate_in_active_low, trigger_in_rising_edge, trigger_in_falling_edge, ro_trigger_in_rising_edge, ro_trigger_in_falling_edge, gate_out_active_high, gate_out_active_low, trigger_out_rising_edge, trigger_out_falling_edge, ro_trigger_out_rising_edge, ro_trigger_out_falling_edge, gnd, vcc, sync, unknown
\returns f can be SIGNAL_OFF, GATE_IN_ACTIVE_HIGH, GATE_IN_ACTIVE_LOW, TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE, RO_TRIGGER_IN_RISING_EDGE, RO_TRIGGER_IN_FALLING_EDGE, GATE_OUT_ACTIVE_HIGH, GATE_OUT_ACTIVE_LOW, TRIGGER_OUT_RISING_EDGE, TRIGGER_OUT_FALLING_EDGE, RO_TRIGGER_OUT_RISING_EDGE, RO_TRIGGER_OUT_FALLING_EDGE, OUTPUT_LOW, OUTPUT_HIGH, MASTER_SLAVE_SYNCHRONIZATION, GET_EXTERNAL_SIGNAL_FLAG (if unknown) \returns can be SIGNAL_OFF, GATE_IN_ACTIVE_HIGH, GATE_IN_ACTIVE_LOW, TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE, RO_TRIGGER_IN_RISING_EDGE, RO_TRIGGER_IN_FALLING_EDGE, GATE_OUT_ACTIVE_HIGH, GATE_OUT_ACTIVE_LOW, TRIGGER_OUT_RISING_EDGE, TRIGGER_OUT_FALLING_EDGE, RO_TRIGGER_OUT_RISING_EDGE, RO_TRIGGER_OUT_FALLING_EDGE, OUTPUT_LOW, OUTPUT_HIGH, MASTER_SLAVE_SYNCHRONIZATION, GET_EXTERNAL_SIGNAL_FLAG (if unknown)
*/ */
static externalSignalFlag externalSignalType(string sval){\ static externalSignalFlag externalSignalType(string sval){\
@ -946,11 +904,11 @@ class slsDetectorBase {
if (sval=="vcc") return OUTPUT_HIGH;\ if (sval=="vcc") return OUTPUT_HIGH;\
return GET_EXTERNAL_SIGNAL_FLAG ;}; return GET_EXTERNAL_SIGNAL_FLAG ;};
/** returns detector settings string from index
/** returns synchronization type string from index \param s can be standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain, undefined
\param t can be NONE, MASTER_GATES, MASTER_TRIGGERS, SLAVE_STARTS_WHEN_MASTER_STOPS \returns STANDARD, FAST, HIGHGAIN, DYNAMICGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN, GET_SETTINGS
\returns none, gating, trigger, complementary
*/ */
static detectorSettings getDetectorSettings(string s){\ static detectorSettings getDetectorSettings(string s){\
if (s=="standard") return STANDARD;\ if (s=="standard") return STANDARD;\
if (s=="fast") return FAST;\ if (s=="fast") return FAST;\
@ -963,7 +921,7 @@ class slsDetectorBase {
}; };
/** returns detector settings string from index /** returns detector settings string from index
\param t can be STANDARD, FAST, HIGHGAIN, DYNAMICGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN, GET_SETTINGS \param s can be STANDARD, FAST, HIGHGAIN, DYNAMICGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN, GET_SETTINGS
\returns standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain, undefined \returns standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain, undefined
*/ */
static string getDetectorSettings(detectorSettings s){\ static string getDetectorSettings(detectorSettings s){\
@ -1000,7 +958,7 @@ class slsDetectorBase {
/** /**
returns external communication mode index from string returns external communication mode index from string
\param s can be auto, trigger, ro_trigger, gating, triggered_gating \param sval can be auto, trigger, ro_trigger, gating, triggered_gating
\returns AUTO_TIMING, TRIGGER_EXPOSURE, TRIGGER_READOUT, GATE_FIX_NUMBER, GATE_WITH_START_TRIGGER, GET_EXTERNAL_COMMUNICATION_MODE \returns AUTO_TIMING, TRIGGER_EXPOSURE, TRIGGER_READOUT, GATE_FIX_NUMBER, GATE_WITH_START_TRIGGER, GET_EXTERNAL_COMMUNICATION_MODE
*/ */
@ -1012,6 +970,5 @@ class slsDetectorBase {
if (sval=="triggered_gating") return GATE_WITH_START_TRIGGER;\ if (sval=="triggered_gating") return GATE_WITH_START_TRIGGER;\
return GET_EXTERNAL_COMMUNICATION_MODE;}; return GET_EXTERNAL_COMMUNICATION_MODE;};
}; };
#endif #endif

View File

@ -4,7 +4,7 @@
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
#include "slsDetectorBase.h" #include "slsDetectorUtils.h"
using namespace std; using namespace std;
@ -12,12 +12,12 @@ using namespace std;
/* It is inherited by both slsDetector and multiSlsDetector */ /* It is inherited by both slsDetector and multiSlsDetector */
/* *\/ */ /* *\/ */
class slsDetectorCommand { class slsDetectorCommand : public slsDetectorDefs {
public: public:
slsDetectorCommand(slsDetectorBase *det); slsDetectorCommand(slsDetectorUtils *det);
/* /\** */ /* /\** */
@ -100,7 +100,7 @@ class slsDetectorCommand {
private: private:
slsDetectorBase *myDet; slsDetectorUtils *myDet;
string cmdUnderDevelopment(int narg, char *args[], int action); string cmdUnderDevelopment(int narg, char *args[], int action);
string cmdUnknown(int narg, char *args[], int action); string cmdUnknown(int narg, char *args[], int action);

View File

@ -19,6 +19,8 @@ slsDetectorUtils::slsDetectorUtils() : queuesize(0),
pthread_mutex_t mp1 = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t mp1 = PTHREAD_MUTEX_INITIALIZER;
mp=mp1; mp=mp1;
pthread_mutex_init(&mp, NULL); pthread_mutex_init(&mp, NULL);
mg=mp1;
pthread_mutex_init(&mg, NULL);
} }
@ -1941,7 +1943,9 @@ void* slsDetectorUtils::processData(int delflag) {
} else { } else {
thisData=new detectorData(mergingCounts,mergingErrors,mergingBins,getCurrentProgress(),(fname+string(ext)).c_str(),np); thisData=new detectorData(mergingCounts,mergingErrors,mergingBins,getCurrentProgress(),(fname+string(ext)).c_str(),np);
pthread_mutex_lock(&mg);
finalDataQueue.push(thisData); finalDataQueue.push(thisData);
pthread_mutex_unlock(&mg);
} }
pthread_mutex_lock(&mp); pthread_mutex_lock(&mp);
} }
@ -1983,7 +1987,9 @@ void* slsDetectorUtils::processData(int delflag) {
delete [] ang; delete [] ang;
} else { } else {
thisData=new detectorData(ffcdata,ffcerr,NULL,getCurrentProgress(),(fname+string(ext)).c_str(),getTotalNumberOfChannels()); thisData=new detectorData(ffcdata,ffcerr,NULL,getCurrentProgress(),(fname+string(ext)).c_str(),getTotalNumberOfChannels());
pthread_mutex_lock(&mg);
finalDataQueue.push(thisData); finalDataQueue.push(thisData);
pthread_mutex_unlock(&mg);
} }
} }
} }
@ -2054,10 +2060,12 @@ int* slsDetectorUtils::popDataQueue() {
detectorData* slsDetectorUtils::popFinalDataQueue() { detectorData* slsDetectorUtils::popFinalDataQueue() {
detectorData *retval=NULL; detectorData *retval=NULL;
pthread_mutex_unlock(&mg);
if( !finalDataQueue.empty() ) { if( !finalDataQueue.empty() ) {
retval=finalDataQueue.front(); retval=finalDataQueue.front();
finalDataQueue.pop(); finalDataQueue.pop();
} }
pthread_mutex_unlock(&mg);
return retval; return retval;
} }
@ -2073,11 +2081,13 @@ void slsDetectorUtils::resetDataQueue() {
void slsDetectorUtils::resetFinalDataQueue() { void slsDetectorUtils::resetFinalDataQueue() {
detectorData *retval=NULL; detectorData *retval=NULL;
pthread_mutex_lock(&mg);
while( !finalDataQueue.empty() ) { while( !finalDataQueue.empty() ) {
retval=finalDataQueue.front(); retval=finalDataQueue.front();
finalDataQueue.pop(); finalDataQueue.pop();
delete retval; delete retval;
} }
pthread_mutex_unlock(&mg);
} }

View File

@ -3,6 +3,29 @@
#ifndef SLS_DETECTOR_UTILS_H #ifndef SLS_DETECTOR_UTILS_H
#define SLS_DETECTOR_UTILS_H #define SLS_DETECTOR_UTILS_H
#ifdef __CINT__
class pthread_mutex_t;
class pthread_t;
#endif
extern "C" {
#include <pthread.h>
}
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <fcntl.h>
#include <unistd.h>
#ifdef __MAKECINT__
#pragma link off class _FTCOMSTAT-;
#pragma link off class _FTDCB-;
#endif
//#include "MySocketTCP.h" //#include "MySocketTCP.h"
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
@ -10,16 +33,9 @@
#include <cstring> #include <cstring>
#include <string> #include <string>
#include <sstream> #include <sstream>
#include <queue> #include <queue>
extern "C" {
#include <pthread.h>
}
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <math.h> #include <math.h>
using namespace std; using namespace std;
@ -95,12 +111,44 @@ class slsDetectorUtils : public slsDetectorBase {
using slsDetectorBase::setBadChannelCorrection;
using slsDetectorBase::getAngularConversion;
/** 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)
*/
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)
*/
virtual int addSlsDetector(char* name, int pos=-1){return -1;};
/**
removes the detector in position pos from the multidetector
\param pos position of the detector to be removed from the multidetector system (defaults to -1 i.e. last detector)
\returns the actual number of detectors or -1 if it failed (always for slsDetector)
*/
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)
*/
virtual int removeSlsDetector(char* name){return -1;};
/**
Turns off the server - do not use except for debugging!
*/
virtual int exitServer()=0;
@ -287,10 +335,9 @@ class slsDetectorUtils : public slsDetectorBase {
\param name of the file to be read \param name of the file to be read
\param data array of data values \param data array of data values
\returns OK or FAIL if it could not read the file or data=NULL \returns OK or FAIL if it could not read the file or data=NULL
\sa mythenDetector::readDataFile
*/ */
static int readDataFile(string fname, int *data, int nch); static int readDataFile(string fname, int *data, int nch);
static int readDataFile(ifstream &infile, int *data, int nch, int offset=0); static int readDataFile(ifstream &infile, int *data, int nch, int offset);
/** /**
@ -301,7 +348,7 @@ class slsDetectorUtils : public slsDetectorBase {
\sa mythenDetector::readDataFile \sa mythenDetector::readDataFile
*/ */
static int readDataFile(string fname, short int *data, int nch); static int readDataFile(string fname, short int *data, int nch);
static int readDataFile(ifstream &infile, short int *data, int nch, int offset=0); static int readDataFile(ifstream &infile, short int *data, int nch, int offset);
/** /**
@ -768,6 +815,9 @@ s
*/ */
int* popDataQueue(); int* popDataQueue();
/** /**
pops the data from thepostprocessed data queue pops the data from thepostprocessed data queue
\returns pointer to the popped data or NULL if the queue is empty. \returns pointer to the popped data or NULL if the queue is empty.
@ -776,8 +826,6 @@ s
detectorData* popFinalDataQueue(); detectorData* popFinalDataQueue();
/** /**
resets the raw data queue resets the raw data queue
\sa dataQueue \sa dataQueue
@ -790,6 +838,16 @@ s
*/ */
void resetFinalDataQueue(); void resetFinalDataQueue();
/* virtual string getScanScript(int iscan)=0; */ /* virtual string getScanScript(int iscan)=0; */
/* virtual string getScanParameter(int iscan)=0; */ /* virtual string getScanParameter(int iscan)=0; */
/* virtual string getActionScript(int iscan)=0; */ /* virtual string getActionScript(int iscan)=0; */
@ -803,6 +861,25 @@ s
/** temporary test fucntion */ /** temporary test fucntion */
int testFunction(int times=0); int testFunction(int times=0);
/**
write register
\param addr address
\param val value
\returns current register value
DO NOT USE!!! ONLY EXPERT USER!!!
*/
virtual int writeRegister(int addr, int val)=0;
/**
read register
\param addr address
\returns current register value
DO NOT USE!!! ONLY EXPERT USER!!!
*/
virtual int readRegister(int addr)=0;
protected: protected:
static const int64_t thisSoftwareVersion=0x20120124; static const int64_t thisSoftwareVersion=0x20120124;
@ -904,10 +981,11 @@ s
char *fileName; char *fileName;
int *fileIndex; int *fileIndex;
/** mutex to synchronize main and data processing threads */
/** mutex to synchronize threads */
pthread_mutex_t mp; pthread_mutex_t mp;
/** mutex to synchronizedata processing and plotting threads */
pthread_mutex_t mg;
/** sets when the acquisition is finished */ /** sets when the acquisition is finished */
int jointhread; int jointhread;