mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 23:30:03 +02:00

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@139 951219d9-93cf-4727-9268-0efd64621fa3
1476 lines
43 KiB
C++
1476 lines
43 KiB
C++
|
|
|
|
|
|
#ifndef SLS_DETECTOR_H
|
|
#define SLS_DETECTOR_H
|
|
|
|
#include "MySocketTCP.h"
|
|
#include "slsDetectorUtils.h"
|
|
//#include "slsDetectorCommand.h"
|
|
|
|
|
|
|
|
//enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS};
|
|
|
|
|
|
|
|
|
|
|
|
//using namespace std;
|
|
/**
|
|
\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 \sa MySocketTCP slsDetector
|
|
\li the possibility of using a Qt-based graphical user interface (with eventually root analisys capabilities)
|
|
\li the possibility of runnin alla 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 \sa slsDetector::sharedSlsDetector
|
|
\section howto_sec How to use it
|
|
The best way to operate the slsDetectors is to use the software (text client or GUI) developed by the sls detectors group.
|
|
In case you need to embed the detector control in a previously existing software, compile these classes using <BR>
|
|
make package
|
|
<br>
|
|
and link the shared library created to your software bin/libSlsDetector.so.1.0.1
|
|
Then in your software you should use the class related to the detector you want to control (mythenDetector or eigerDetector).
|
|
|
|
@author Anna Bergamaschi
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
*
|
|
*
|
|
@libdoc The slsDetector class is expected to become the interface class for all SLS Detectors acquisition (and analysis) software.
|
|
*
|
|
* @short This is the base class for all SLS detector functionalities
|
|
* @author Anna Bergamaschi
|
|
* @version 0.1alpha
|
|
|
|
|
|
*/
|
|
|
|
class slsDetector : public slsDetectorUtils {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
/* /\** online flags enum \sa setOnline*\/ */
|
|
/* enum {GET_ONLINE_FLAG=-1, /\**< returns wether the detector is in online or offline state *\/ */
|
|
/* OFFLINE_FLAG=0, /\**< detector in offline state (i.e. no communication to the detector - using only local structure - no data acquisition possible!) *\/ */
|
|
/* ONLINE_FLAG =1/\**< detector in online state (i.e. communication to the detector updating the local structure) *\/ */
|
|
/* }; */
|
|
|
|
|
|
|
|
/**
|
|
@short Structure allocated in shared memory to store detector settings and be accessed in parallel by several applications (take care of possible conflicts!)
|
|
|
|
*/
|
|
typedef struct sharedSlsDetector {
|
|
/** already existing flag. If the detector does not yet exist (alreadyExisting=0) the sharedMemory will be created, otherwise it will simly be linked */
|
|
int alreadyExisting;
|
|
|
|
|
|
|
|
|
|
/** last process id accessing the shared memory */
|
|
|
|
pid_t lastPID;
|
|
|
|
|
|
|
|
|
|
/** online flag - is set if the detector is connected, unset if socket connection is not possible */
|
|
int onlineFlag;
|
|
|
|
|
|
/** stopped flag - is set if an acquisition error occurs or the detector is stopped manually. Is reset to 0 at the start of the acquisition */
|
|
int stoppedFlag;
|
|
|
|
/** is the hostname (or IP address) of the detector. needs to be set before startin the communication */
|
|
char hostname[MAX_STR_LENGTH];
|
|
|
|
/** is the port used for control functions normally it should not be changed*/
|
|
int controlPort;
|
|
/** is the port used to stop the acquisition normally it should not be changed*/
|
|
int stopPort;
|
|
/** is the port used to acquire the data normally it should not be changed*/
|
|
int dataPort;
|
|
|
|
/** detector type \ see :: detectorType*/
|
|
detectorType myDetectorType;
|
|
|
|
|
|
/** path of the trimbits/settings files */
|
|
char settingsDir[MAX_STR_LENGTH];
|
|
/** path of the calibration files */
|
|
char calDir[MAX_STR_LENGTH];
|
|
/** number of energies at which the detector has been trimmed (unused) */
|
|
int nTrimEn;
|
|
/** list of the energies at which the detector has been trimmed (unused) */
|
|
int trimEnergies[100];
|
|
|
|
|
|
/** indicator for the acquisition progress - set to 0 at the beginning of the acquisition and incremented every time that the data are written to file */
|
|
int progressIndex;
|
|
/** total number of frames to be acquired */
|
|
int totalProgress;
|
|
/** current index of the output file */
|
|
int fileIndex;
|
|
/** path of the output files */
|
|
char filePath[MAX_STR_LENGTH];
|
|
/** name root of the output files */
|
|
char fileName[MAX_STR_LENGTH];
|
|
|
|
/* size of the detector */
|
|
|
|
/** number of installed modules of the detector (x and y directions) */
|
|
int nMod[2];
|
|
/** number of modules ( nMod[X]*nMod[Y]) \see nMod */
|
|
int nMods;
|
|
/** maximum number of modules of the detector (x and y directions) */
|
|
int nModMax[2];
|
|
/** maximum number of modules (nModMax[X]*nModMax[Y]) \see nModMax */
|
|
int nModsMax;
|
|
/** number of channels per chip */
|
|
int nChans;
|
|
/** number of chips per module*/
|
|
int nChips;
|
|
/** number of dacs per module*/
|
|
int nDacs;
|
|
/** number of adcs per module */
|
|
int nAdcs;
|
|
/** dynamic range of the detector data */
|
|
int dynamicRange;
|
|
/** size of the data that are transfered from the detector */
|
|
int dataBytes;
|
|
|
|
/** corrections to be applied to the data \see ::correctionFlags */
|
|
int correctionMask;
|
|
/** threaded processing flag (i.e. if data are processed and written to file in a separate thread) */
|
|
int threadedProcessing;
|
|
/** dead time (in ns) for rate corrections */
|
|
float tDead;
|
|
/** directory where the flat field files are stored */
|
|
char flatFieldDir[MAX_STR_LENGTH];
|
|
/** file used for flat field corrections */
|
|
char flatFieldFile[MAX_STR_LENGTH];
|
|
/** number of bad channels from bad channel list */
|
|
int nBadChans;
|
|
/** file with the bad channels */
|
|
char badChanFile[MAX_STR_LENGTH];
|
|
/** list of bad channels */
|
|
int badChansList[MAX_BADCHANS];
|
|
/** number of bad channels from flat field i.e. channels which read 0 in the flat field file */
|
|
int nBadFF;
|
|
/** list of bad channels from flat field i.e. channels which read 0 in the flat field file */
|
|
int badFFList[MAX_BADCHANS];
|
|
|
|
/** file with the angular conversion factors */
|
|
char angConvFile[MAX_STR_LENGTH];
|
|
/** 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) */
|
|
float fineOffset;
|
|
/** beamline offset (might be a few degrees beacuse of encoder offset - normally it is kept fixed for a long period of time) */
|
|
float globalOffset;
|
|
/** number of positions at which the detector should acquire */
|
|
int numberOfPositions;
|
|
/** list of encoder positions at which the detector should acquire */
|
|
float detPositions[MAXPOS];
|
|
/** bin size for data merging */
|
|
float binSize;
|
|
|
|
/* infos necessary for the readout to determine the size of the data */
|
|
/** number of rois defined */
|
|
int nROI;
|
|
/** list of rois */
|
|
ROI roiLimits[MAX_ROIS];
|
|
/** readout flags */
|
|
readOutFlags roFlags;
|
|
|
|
|
|
/* detector setup - not needed */
|
|
/** name root of the output files */
|
|
char settingsFile[MAX_STR_LENGTH];
|
|
/** detector settings (standard, fast, etc.) */
|
|
detectorSettings currentSettings;
|
|
/** detector threshold (eV) */
|
|
int currentThresholdEV;
|
|
/** timer values */
|
|
int64_t timerValue[MAX_TIMERS];
|
|
/** clock divider */
|
|
//int clkDiv;
|
|
|
|
|
|
/** Scans and scripts */
|
|
////////////////////////// only in the multi detector class?!?!?!? additional shared memory class?!?!?!?
|
|
int actionMask;
|
|
|
|
mystring actionScript[MAX_ACTIONS];
|
|
|
|
mystring actionParameter[MAX_ACTIONS];
|
|
|
|
|
|
int scanMode[MAX_SCAN_LEVELS];
|
|
mystring scanScript[MAX_SCAN_LEVELS];
|
|
mystring scanParameter[MAX_SCAN_LEVELS];
|
|
int nScanSteps[MAX_SCAN_LEVELS];
|
|
mysteps scanSteps[MAX_SCAN_LEVELS];
|
|
int scanPrecision[MAX_SCAN_LEVELS];
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
/*offsets*/
|
|
/** memory offsets for the flat field coefficients */
|
|
int ffoff;
|
|
/** memory offsets for the flat filed coefficient errors */
|
|
int fferroff;
|
|
/** memory offsets for the module structures */
|
|
int modoff;
|
|
/** memory offsets for the dac arrays */
|
|
int dacoff;
|
|
/** memory offsets for the adc arrays */
|
|
int adcoff;
|
|
/** memory offsets for the chip register arrays */
|
|
int chipoff;
|
|
/** memory offsets for the channel register arrays -trimbits*/
|
|
int chanoff;
|
|
|
|
|
|
/*extra gotthard members*/
|
|
/** is the ip address of the client for gotthard; read from configuration file **/
|
|
char clientIP[MAX_STR_LENGTH];
|
|
/** is the mac address of the client for gotthard; read from configuration file **/
|
|
char clientMAC[MAX_STR_LENGTH];
|
|
/** is the mac address of the server for gotthard; read from configuration file **/
|
|
char serverMAC[MAX_STR_LENGTH];
|
|
|
|
} sharedSlsDetector;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using slsDetectorUtils::getDetectorType;
|
|
|
|
using slsDetectorUtils::flatFieldCorrect;
|
|
using slsDetectorUtils::rateCorrect;
|
|
using slsDetectorUtils::setBadChannelCorrection;
|
|
|
|
using slsDetectorUtils::readAngularConversion;
|
|
using slsDetectorUtils::writeAngularConversion;
|
|
|
|
|
|
|
|
/** (default) constructor
|
|
\param type is needed to define the size of the detector shared memory 9defaults to GENERIC i.e. the largest shared memory needed by any slsDetector is allocated
|
|
\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
|
|
|
|
|
|
*/
|
|
slsDetector(detectorType type=GENERIC, int id=0);
|
|
|
|
/** 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
|
|
|
|
|
|
*/
|
|
slsDetector(int id);
|
|
|
|
|
|
slsDetector(char *name, int id=0, int cport=DEFAULT_PORTNO);
|
|
//slsDetector(string const fname);
|
|
// ~slsDetector(){while(dataQueue.size()>0){}};
|
|
/** destructor */
|
|
~slsDetector();
|
|
|
|
int setOnline(int const online=GET_ONLINE_FLAG);
|
|
|
|
/** returns if the detector already existed
|
|
\returns 1 if the detector structure has already be initlialized, 0 otherwise */
|
|
int exists() {return thisDetector->alreadyExisting;};
|
|
|
|
/** returns 1 if the detetcor with id has already been allocated and initialized in shared memory
|
|
\param detector id
|
|
\returns 1 if the detector structure has already be initlialized, 0 otherwise */
|
|
static int exists(int id);
|
|
|
|
/**
|
|
configures mac for gotthard readout
|
|
*/
|
|
int configureMAC();
|
|
|
|
/**
|
|
Reads the configuration file fname
|
|
\param fname file name
|
|
\returns OK or FAIL
|
|
*/
|
|
int readConfigurationFile(string const fname);
|
|
|
|
|
|
int readConfigurationFile(ifstream &infile);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Writes the configuration file fname
|
|
\param fname file name
|
|
\returns OK or FAIL
|
|
|
|
*/
|
|
int writeConfigurationFile(string const fname);
|
|
int writeConfigurationFile(ofstream &outfile);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
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
|
|
|
|
*/
|
|
int dumpDetectorSetup(string const fname, int level=0);
|
|
/**
|
|
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
|
|
|
|
*/
|
|
int retrieveDetectorSetup(string const fname, int level=0);
|
|
|
|
|
|
|
|
/**
|
|
configure the socket communication and initializes the socket instances
|
|
|
|
\param name hostname - if "" the current hostname is used
|
|
\param control_port port for control commands - if -1 the current is used
|
|
\param stop_port port for stop command - if -1 the current is used
|
|
\param data_port port for receiving data - if -1 the current is used
|
|
|
|
\returns OK is connection succeded, FAIL otherwise
|
|
\sa sharedSlsDetector
|
|
*/
|
|
int setTCPSocket(string const name="", int const control_port=-1, int const stop_port=-1, int const data_port=-1);
|
|
|
|
/**
|
|
changes/gets the port number
|
|
\param type port type
|
|
\param num new port number (-1 gets)
|
|
\returns actual port number
|
|
*/
|
|
int setPort(portType type, int num=-1);
|
|
|
|
/** returns the detector control port \sa sharedSlsDetector */
|
|
int getControlPort() {return thisDetector->controlPort;};
|
|
/** returns the detector stop port \sa sharedSlsDetector */
|
|
int getStopPort() {return thisDetector->stopPort;};
|
|
/** returns the detector data port \sa sharedSlsDetector */
|
|
int getDataPort() {return thisDetector->dataPort;};
|
|
|
|
/** Locks/Unlocks the connection to the server
|
|
/param lock sets (1), usets (0), gets (-1) the lock
|
|
/returns lock status of the server
|
|
*/
|
|
int lockServer(int lock=-1);
|
|
|
|
/**
|
|
Returns the IP of the last client connecting to the detector
|
|
*/
|
|
string getLastClientIP();
|
|
|
|
/** returns the detector hostname \sa sharedSlsDetector */
|
|
string getHostname(int ipos=-1) {return string(thisDetector->hostname);};
|
|
/** returns the detector hostname \sa sharedSlsDetector */
|
|
string setHostname(char *name, int ipos=-1) {setTCPSocket(string(name)); return string(thisDetector->hostname);};
|
|
/** connect to the control port */
|
|
int connectControl();
|
|
/** disconnect from the control port */
|
|
int disconnectControl();
|
|
|
|
/** connect to the data port */
|
|
int connectData();
|
|
/** disconnect from the data port */
|
|
int disconnectData();
|
|
|
|
/** connect to the stop port */
|
|
int connectStop();
|
|
/** disconnect from the stop port */
|
|
int disconnectStop();
|
|
|
|
/**
|
|
sets the network parameters
|
|
\param i network parameter type can be CLIENT_IP, CLIENT_MAC, SERVER_MAC
|
|
\param s value to be set
|
|
\returns parameter
|
|
|
|
*/
|
|
char* setNetworkParameter(networkParameter index, string value);
|
|
|
|
/**
|
|
gets the network parameters
|
|
\param i network parameter type can be CLIENT_IP, CLIENT_MAC, SERVER_MAC
|
|
\returns parameter
|
|
|
|
*/
|
|
char* getNetworkParameter(networkParameter index);
|
|
|
|
/* I/O */
|
|
|
|
/** returns the detector trimbit/settings directory \sa sharedSlsDetector */
|
|
char* getSettingsDir() {return thisDetector->settingsDir;};
|
|
/** sets the detector trimbit/settings directory \sa sharedSlsDetector */
|
|
char* setSettingsDir(string s) {sprintf(thisDetector->settingsDir, s.c_str()); return thisDetector->settingsDir;};
|
|
|
|
|
|
|
|
/**
|
|
returns the location of the calibration files
|
|
\sa sharedSlsDetector
|
|
*/
|
|
char* getCalDir() {return thisDetector->calDir;};
|
|
/**
|
|
sets the location of the calibration files
|
|
\sa sharedSlsDetector
|
|
*/
|
|
char* setCalDir(string s) {sprintf(thisDetector->calDir, s.c_str()); return thisDetector->calDir;};
|
|
|
|
|
|
|
|
/** returns the number of trim energies and their value \sa sharedSlsDetector
|
|
\param point to the array that will contain the trim energies (in ev)
|
|
\returns number of trim energies
|
|
|
|
|
|
unused!
|
|
|
|
\sa sharedSlsDetector
|
|
*/
|
|
int getTrimEn(int *en=NULL) {if (en) {for (int ien=0; ien<thisDetector->nTrimEn; ien++) en[ien]=thisDetector->trimEnergies[ien];} return (thisDetector->nTrimEn);};
|
|
|
|
|
|
/** 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
|
|
|
|
unused!
|
|
|
|
\sa sharedSlsDetector
|
|
*/
|
|
int setTrimEn(int nen, int *en=NULL) {if (en) {for (int ien=0; ien<nen; ien++) thisDetector->trimEnergies[ien]=en[ien]; thisDetector->nTrimEn=nen;} return (thisDetector->nTrimEn);};
|
|
|
|
/**
|
|
Pure virtual function
|
|
reads a trim/settings file
|
|
\param fname name of the file to be read
|
|
\param myMod pointer to the module structure which has to be set. <BR> If it is NULL a new module structure will be created
|
|
\returns the pointer to myMod or NULL if reading the file failed
|
|
\sa mythenDetector::readSettingsFile
|
|
*/
|
|
|
|
sls_detector_module* readSettingsFile(string fname, sls_detector_module* myMod=NULL);
|
|
//virtual sls_detector_module* readSettingsFile(string fname, sls_detector_module* myMod=NULL);
|
|
|
|
/**
|
|
Pure virtual function
|
|
writes a trim/settings file
|
|
\param fname name of the file to be written
|
|
\param mod module structure which has to be written to file
|
|
\returns OK or FAIL if the file could not be written
|
|
|
|
\sa ::sls_detector_module mythenDetector::writeSettingsFile(string, sls_detector_module)
|
|
*/
|
|
int writeSettingsFile(string fname, sls_detector_module mod);
|
|
|
|
|
|
//virtual int writeSettingsFile(string fname, sls_detector_module mod);
|
|
|
|
/**
|
|
Pure virtual function
|
|
writes a trim/settings file for module number imod - the values will be read from the current detector structure
|
|
\param fname name of the file to be written
|
|
\param imod module number
|
|
\returns OK or FAIL if the file could not be written
|
|
\sa ::sls_detector_module sharedSlsDetector mythenDetector::writeSettingsFile(string, int)
|
|
*/
|
|
int writeSettingsFile(string fname, int imod);
|
|
|
|
|
|
/**
|
|
returns currently the loaded trimfile/settingsfile name
|
|
*/
|
|
const char *getSettingsFile(){\
|
|
string s(thisDetector->settingsFile); \
|
|
if (s.length()>6) {\
|
|
if (s.substr(s.length()-6,3)==string(".sn") && s.substr(s.length()-3)!=string("xxx") ) \
|
|
return s.substr(0,s.length()-6).c_str(); \
|
|
} \
|
|
return thisDetector->settingsFile;\
|
|
};
|
|
|
|
|
|
|
|
/** loads the modules settings/trimbits reading from a file
|
|
\param fname file name . If not specified, extension is automatically generated!
|
|
\param imod module number, -1 means all modules
|
|
\returns OK or FAIL
|
|
*/
|
|
int loadSettingsFile(string fname, int imod=-1);
|
|
|
|
|
|
/** saves the modules settings/trimbits writing to a file
|
|
\param fname file name . Axtension is automatically generated!
|
|
\param imod module number, -1 means all modules
|
|
\returns OK or FAIL
|
|
*/
|
|
int saveSettingsFile(string fname, int imod=-1);
|
|
|
|
|
|
/**
|
|
|
|
reads an angular conversion file
|
|
\param fname file to be read
|
|
\sa angleConversionConstant mythenDetector::readAngularConversion
|
|
*/
|
|
int readAngularConversion(string fname="");
|
|
|
|
|
|
/**
|
|
|
|
reads an angular conversion file
|
|
\param fname file to be read
|
|
\sa angleConversionConstant mythenDetector::readAngularConversion
|
|
*/
|
|
int readAngularConversion(ifstream& ifs);
|
|
|
|
|
|
|
|
/**
|
|
Pure virtual function
|
|
writes an angular conversion file
|
|
\param fname file to be written
|
|
\sa angleConversionConstant mythenDetector::writeAngularConversion
|
|
*/
|
|
int writeAngularConversion(string fname="");
|
|
|
|
|
|
|
|
/**
|
|
Pure virtual function
|
|
writes an angular conversion file
|
|
\param fname file to be written
|
|
\sa angleConversionConstant mythenDetector::writeAngularConversion
|
|
*/
|
|
int writeAngularConversion(ofstream &ofs);
|
|
|
|
|
|
|
|
|
|
|
|
/** Returns the number of channels per chip (without connecting to the detector) */
|
|
int getNChans(){return thisDetector->nChans;}; //
|
|
|
|
/** Returns the number of chips per module (without connecting to the detector) */
|
|
int getNChips(){return thisDetector->nChips;}; //
|
|
|
|
/** Returns the number of modules (without connecting to the detector) */
|
|
int getNMods(){return thisDetector->nMods;}; //
|
|
|
|
/** Returns the number of modules (without connecting to the detector) */
|
|
int getMaxMods(){return thisDetector->nModsMax;}; //
|
|
|
|
|
|
int getTotalNumberOfChannels(){return thisDetector->nChans*thisDetector->nChips*thisDetector->nMods;};
|
|
|
|
int getMaxNumberOfChannels(){return thisDetector->nChans*thisDetector->nChips*thisDetector->nModsMax;};
|
|
|
|
|
|
/* Communication to server */
|
|
|
|
|
|
/**
|
|
executes a system command on the server
|
|
e.g. mount an nfs disk, reboot and returns answer etc.
|
|
\param cmd is the command to be executed
|
|
\param answer is the answer from the detector
|
|
\returns OK or FAIL depending on the command outcome
|
|
*/
|
|
int execCommand(string cmd, string answer);
|
|
|
|
/**
|
|
sets/gets detector type
|
|
normally the detector knows what type of detector it is
|
|
\param type is the detector type (defaults to GET_DETECTOR_TYPE)
|
|
\returns returns detector type index (1 GENERIC, 2 MYTHEN, 3 PILATUS, 4 XFS, 5 GOTTHARD, 6 AGIPD, -1 command failed)
|
|
*/
|
|
int setDetectorType(detectorType type=GET_DETECTOR_TYPE);
|
|
|
|
/**
|
|
sets/gets detector type
|
|
normally the detector knows what type of detector it is
|
|
\param type is the detector type ("Mythen", "Pilatus", "XFS", "Gotthard", Agipd")
|
|
\returns returns detector type index (1 GENERIC, 2 MYTHEN, 3 PILATUS, 4 XFS, 5 GOTTHARD, 6 AGIPD, -1 command failed)
|
|
*/
|
|
int setDetectorType(string type);
|
|
|
|
/**
|
|
gets detector type
|
|
normally the detector knows what type of detector it is
|
|
\param type is the string where the detector type will be written ("Mythen", "Pilatus", "XFS", "Gotthard", Agipd")
|
|
*/
|
|
string getDetectorType();
|
|
|
|
|
|
// Detector configuration functions
|
|
/**
|
|
set/get the size of the detector
|
|
\param n number of modules
|
|
\param d dimension
|
|
\returns current number of modules in direction d
|
|
*/
|
|
|
|
// Detector configuration functions
|
|
/**
|
|
set/get the size of the detector
|
|
\param n number of modules
|
|
\param d dimension
|
|
\returns current number of modules in direction d
|
|
*/
|
|
int setNumberOfModules(int n=GET_FLAG, dimension d=X); // if n=GET_FLAG returns the number of installed modules
|
|
|
|
/*
|
|
returns the instrinsic size of the detector (maxmodx, maxmody, nchans, nchips, ndacs
|
|
enum numberOf {
|
|
MAXMODX,
|
|
MAXMODY,
|
|
CHANNELS,
|
|
CHIPS,
|
|
DACS
|
|
}
|
|
*/
|
|
|
|
|
|
/**
|
|
get the maximum size of the detector
|
|
\param d dimension
|
|
\returns maximum number of modules that can be installed in direction d
|
|
*/
|
|
int getMaxNumberOfModules(dimension d=X); //
|
|
|
|
|
|
/**
|
|
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
|
|
*/
|
|
externalSignalFlag setExternalSignalFlags(externalSignalFlag pol=GET_EXTERNAL_SIGNAL_FLAG , int signalindex=0);
|
|
|
|
|
|
/**
|
|
set/get the external communication mode
|
|
|
|
obsolete \sa setExternalSignalFlags
|
|
\param pol value to be set \sa externalCommunicationMode
|
|
\returns current external communication mode
|
|
*/
|
|
externalCommunicationMode setExternalCommunicationMode(externalCommunicationMode pol=GET_EXTERNAL_COMMUNICATION_MODE);
|
|
|
|
|
|
// Tests and identification
|
|
|
|
/**
|
|
get detector ids/versions for module
|
|
\param mode which id/version has to be read
|
|
\param imod module number for module serial number
|
|
\returns id
|
|
*/
|
|
int64_t getId(idMode mode, int imod=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
|
|
*/
|
|
int digitalTest(digitalTestMode mode, int imod=0);
|
|
/**
|
|
analog test
|
|
\param modte test mode
|
|
\return pointer to acquired data
|
|
|
|
not yet implemented
|
|
*/
|
|
|
|
int* analogTest(analogTestMode mode);
|
|
|
|
/**
|
|
enable analog output of channel ichan
|
|
|
|
not yet implemented
|
|
*/
|
|
int enableAnalogOutput(int ichan);
|
|
|
|
/**
|
|
enable analog output of channel ichan, chip ichip, module imod
|
|
|
|
not yet implemented
|
|
*/
|
|
int enableAnalogOutput(int imod, int ichip, int ichan);
|
|
|
|
/**
|
|
give a train of calibration pulses
|
|
\param vcal pulse amplitude
|
|
\param npulses number of pulses
|
|
|
|
not yet implemented
|
|
|
|
*/
|
|
int giveCalibrationPulse(float vcal, int npulses);
|
|
|
|
// Expert Initialization functions
|
|
|
|
|
|
/**
|
|
write register
|
|
\param addr address
|
|
\val value
|
|
\returns current register value
|
|
|
|
*/
|
|
int writeRegister(int addr, int val);
|
|
|
|
/**
|
|
read register
|
|
\param addr address
|
|
\returns current register value
|
|
|
|
*/
|
|
int readRegister(int addr);
|
|
|
|
/**
|
|
set dacs value
|
|
\param val value (in V)
|
|
\param index DAC index
|
|
\param imod module number (if -1 alla modules)
|
|
\returns current DAC value
|
|
*/
|
|
float setDAC(float val, dacIndex index, int imod=-1);
|
|
|
|
/**
|
|
set dacs value
|
|
\param index ADC index
|
|
\param imod module number
|
|
\returns current ADC value
|
|
*/
|
|
float 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
|
|
*/
|
|
int setChannel(int64_t reg, int ichan=-1, int ichip=-1, int imod=-1);
|
|
|
|
/**
|
|
configure channel
|
|
\param chan channel to be set - must contain correct channel, module and chip number
|
|
\returns current register value
|
|
*/
|
|
int setChannel(sls_detector_channel chan);
|
|
|
|
/**
|
|
get channel
|
|
\param ichan channel number
|
|
\param ichip chip number
|
|
\param imod module number
|
|
\returns current channel structure for channel
|
|
*/
|
|
sls_detector_channel getChannel(int ichan, int ichip, int imod);
|
|
|
|
|
|
|
|
/**
|
|
configure chip
|
|
\param reg chip register
|
|
\param ichip chip number (-1 all)
|
|
\param imod module number (-1 all)
|
|
\returns current register value
|
|
\sa ::sls_detector_chip
|
|
*/
|
|
int setChip(int reg, int ichip=-1, int imod=-1);
|
|
|
|
/**
|
|
configure chip
|
|
\param chip chip to be set - must contain correct module and chip number and also channel registers
|
|
\returns current register value
|
|
\sa ::sls_detector_chip
|
|
*/
|
|
int setChip(sls_detector_chip chip);
|
|
|
|
/**
|
|
get chip
|
|
\param ichip chip number
|
|
\param imod module number
|
|
\returns current chip structure for channel
|
|
|
|
\bug probably does not return corretly!
|
|
*/
|
|
sls_detector_chip getChip(int ichip, int imod);
|
|
|
|
|
|
/**
|
|
configure module
|
|
\param imod module number (-1 all)
|
|
\returns current register value
|
|
\sa ::sls_detector_module
|
|
*/
|
|
int setModule(int reg, int imod=-1);
|
|
//virtual int setModule(int reg, int imod=-1);
|
|
|
|
/**
|
|
configure chip
|
|
\param module module to be set - must contain correct module number and also channel and chip registers
|
|
\returns current register value
|
|
\sa ::sls_detector_module
|
|
*/
|
|
int setModule(sls_detector_module module);
|
|
//virtual int setModule(sls_detector_module module);
|
|
|
|
/**
|
|
get module
|
|
\param imod module number
|
|
\returns pointer to module structure (which has bee created and must then be deleted)
|
|
*/
|
|
sls_detector_module *getModule(int imod);
|
|
//virtual sls_detector_module *getModule(int imod);
|
|
|
|
// calibration functions
|
|
// int setCalibration(int imod, detectorSettings isettings, float gain, float offset);
|
|
//int getCalibration(int imod, detectorSettings isettings, float &gain, float &offset);
|
|
|
|
|
|
/*
|
|
calibrated setup of the threshold
|
|
*/
|
|
/**
|
|
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)
|
|
*/
|
|
int setThresholdEnergy(int e_eV, int imod=-1, detectorSettings isettings=GET_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
|
|
|
|
in this function trimbits/settings and calibration files are searched in the settingsDir and calDir directories and the detector is initialized
|
|
*/
|
|
detectorSettings setSettings(detectorSettings isettings, int imod=-1);
|
|
//virtual detectorSettings setSettings(detectorSettings isettings, int imod=-1);
|
|
|
|
/**
|
|
|
|
updates the shared memory receiving the data from the detector (without asking and closing the connection
|
|
/returns OK
|
|
|
|
*/
|
|
|
|
int updateDetectorNoWait();
|
|
|
|
/**
|
|
|
|
updates the shared memory receiving the data from the detector
|
|
/returns OK
|
|
|
|
*/
|
|
|
|
|
|
int updateDetector();
|
|
|
|
// Acquisition functions
|
|
|
|
|
|
/**
|
|
start detector acquisition
|
|
\returns OK/FAIL
|
|
*/
|
|
int startAcquisition();
|
|
|
|
/**
|
|
stop detector acquisition
|
|
\returns OK/FAIL
|
|
*/
|
|
int stopAcquisition();
|
|
|
|
/**
|
|
start readout (without exposure or interrupting exposure)
|
|
\returns OK/FAIL
|
|
*/
|
|
int startReadOut();
|
|
|
|
/**
|
|
get run status
|
|
\returns status mask
|
|
*/
|
|
//virtual runStatus getRunStatus()=0;
|
|
runStatus getRunStatus();
|
|
|
|
/**
|
|
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 leaving socket opened
|
|
\returns OK or FAIL
|
|
|
|
*/
|
|
int startAndReadAllNoWait();
|
|
|
|
/* /\** */
|
|
/* receives a data frame from the detector socket */
|
|
/* \returns pointer to the data or NULL. If NULL disconnects the socket */
|
|
/* \sa getDataFromDetector */
|
|
/* *\/ */
|
|
/* int* getDataFromDetectorNoWait(); */
|
|
|
|
/**
|
|
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
|
|
*/
|
|
int* readAll();
|
|
|
|
/**
|
|
asks and receives all data from the detector and leaves the socket opened
|
|
\returns OK or FAIL
|
|
*/
|
|
int readAllNoWait();
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
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)
|
|
*/
|
|
int64_t setTimer(timerIndex index, int64_t t=-1);
|
|
|
|
/**
|
|
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);
|
|
|
|
|
|
|
|
|
|
/** sets/gets the value of important readout speed parameters
|
|
\param sp is the parameter to be set/get
|
|
\param value is the value to be set, if -1 get value
|
|
\returns current value for the specified parameter
|
|
\sa speedVariable
|
|
*/
|
|
int setSpeed(speedVariable sp, int value=-1);
|
|
|
|
// Flags
|
|
/**
|
|
set/get dynamic range
|
|
\param n dynamic range (-1 get)
|
|
\returns current dynamic range
|
|
updates the size of the data expected from the detector
|
|
\sa sharedSlsDetector
|
|
*/
|
|
int setDynamicRange(int n=-1);
|
|
|
|
/**
|
|
set/get dynamic range
|
|
\returns number of bytes sent by the detector
|
|
\sa sharedSlsDetector
|
|
*/
|
|
int getDataBytes(){return thisDetector->dataBytes;};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
set roi
|
|
|
|
not yet implemented
|
|
*/
|
|
int setROI(int nroi=-1, int *xmin=NULL, int *xmax=NULL, int *ymin=NULL, int *ymax=NULL);
|
|
|
|
|
|
/**
|
|
set/get readout flags
|
|
\param flag readout flag to be set
|
|
\returns current flag
|
|
*/
|
|
int setReadOutFlags(readOutFlags flag=GET_READOUT_FLAGS);
|
|
|
|
/**
|
|
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
|
|
\param imod module number (-1 all)
|
|
\returns OK or FAIl (FAIL also if some channel are 0 or 63
|
|
*/
|
|
int executeTrimming(trimMode mode, int par1, int par2, int imod=-1);
|
|
|
|
|
|
//Corrections
|
|
|
|
|
|
/**
|
|
set flat field corrections
|
|
\param fname name of the flat field file (or "" if disable)
|
|
\returns 0 if disable (or file could not be read), >0 otherwise
|
|
*/
|
|
int setFlatFieldCorrection(string fname="");
|
|
|
|
/**
|
|
set flat field corrections
|
|
\param corr if !=NULL the flat field corrections will be filled with corr (NULL usets ff corrections)
|
|
\param ecorr if !=NULL the flat field correction errors will be filled with ecorr (1 otherwise)
|
|
\returns 0 if ff correction disabled, >0 otherwise
|
|
*/
|
|
int setFlatFieldCorrection(float *corr=NULL, float *ecorr=NULL);
|
|
|
|
|
|
/**
|
|
get flat field corrections
|
|
\param corr if !=NULL will be filled with the correction coefficients
|
|
\param ecorr if !=NULL will be filled with the correction coefficients errors
|
|
\returns 0 if ff correction disabled, >0 otherwise
|
|
*/
|
|
int getFlatFieldCorrection(float *corr=NULL, float *ecorr=NULL);
|
|
|
|
|
|
/**
|
|
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
|
|
\returns 0 if rate correction disabled, >0 otherwise
|
|
*/
|
|
int setRateCorrection(float t=0);
|
|
|
|
|
|
/**
|
|
get rate correction
|
|
\param t reference for dead time
|
|
\returns 0 if rate correction disabled, >0 otherwise
|
|
*/
|
|
int getRateCorrection(float &t);
|
|
|
|
|
|
/**
|
|
get rate correction tau
|
|
\returns 0 if rate correction disabled, otherwise the tau used for the correction
|
|
*/
|
|
float getRateCorrectionTau();
|
|
/**
|
|
get rate correction
|
|
\returns 0 if rate correction disabled, >0 otherwise
|
|
*/
|
|
int getRateCorrection();
|
|
|
|
/**
|
|
set bad channels correction
|
|
\param fname file with bad channel list ("" disable)
|
|
\returns 0 if bad channel disabled, >0 otherwise
|
|
*/
|
|
int setBadChannelCorrection(string fname="");
|
|
|
|
/**
|
|
set bad channels correction
|
|
\param nch number of bad channels
|
|
\param chs array of channels
|
|
\param ff 0 if normal bad channels, 1 if ff bad channels
|
|
\returns 0 if bad channel disabled, >0 otherwise
|
|
*/
|
|
int setBadChannelCorrection(int nch, int *chs, int ff=0);
|
|
|
|
/**
|
|
get bad channels correction
|
|
\param bad pointer to array that if bad!=NULL will be filled with the bad channel list
|
|
\returns 0 if bad channel disabled or no bad channels, >0 otherwise
|
|
*/
|
|
int getBadChannelCorrection(int *bad=NULL);
|
|
|
|
|
|
/**
|
|
set angular conversion
|
|
\param fname file with angular conversion constants ("" disable)
|
|
\returns 0 if angular conversion disabled, >0 otherwise
|
|
\sa mythenDetector::setAngularConversion
|
|
*/
|
|
int setAngularConversion(string fname="");
|
|
/**
|
|
pure virtual function
|
|
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
|
|
\sa mythenDetector::getAngularConversion
|
|
*/
|
|
int getAngularConversion(int &direction, angleConversionConstant *angconv=NULL) ;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
decode data from the detector converting them to an array of floats, one for each channle
|
|
\param datain data from the detector
|
|
\returns pointer to a float array with a data per channel
|
|
*/
|
|
float* decodeData(int *datain);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
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(float* datain, float *errin, float* dataout, float *errout);
|
|
|
|
|
|
|
|
|
|
/**
|
|
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(float* datain, float *errin, float* dataout, float *errout);
|
|
|
|
|
|
/**
|
|
pure virtual function
|
|
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
|
|
\sa mythenDetector::resetMerging
|
|
*/
|
|
|
|
int resetMerging(float *mp, float *mv,float *me, int *mm);
|
|
|
|
/**
|
|
pure virtual function
|
|
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
|
|
\sa mythenDetector::addToMerging
|
|
*/
|
|
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
|
|
\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 number of non empty bins (i.e. points belonging to the pattern)
|
|
\sa mythenDetector::finalizeMerging
|
|
*/
|
|
int finalizeMerging(float *mp, float *mv,float *me, int *mm);
|
|
|
|
/**
|
|
turns off server
|
|
*/
|
|
int exitServer();
|
|
|
|
|
|
/** Allocates the memory for a sls_detector_module structure and initializes it
|
|
\returns myMod the pointer to the allocate dmemory location
|
|
|
|
*/
|
|
sls_detector_module* createModule();
|
|
/** frees the memory for a sls_detector_module structure
|
|
\param myMod the pointer to the memory to be freed
|
|
|
|
*/
|
|
|
|
void deleteModule(sls_detector_module *myMod);
|
|
|
|
|
|
/** calcualtes the total number of steps of the acquisition.
|
|
called when number of frames, number of cycles, number of positions and scan steps change
|
|
*/
|
|
int setTotalProgress();
|
|
|
|
/** returns the current progress in % */
|
|
float getCurrentProgress();
|
|
|
|
|
|
float* convertAngles(float pos);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
returns the detector type from hostname and controlport
|
|
\param
|
|
\param action can be PUT_ACTION or GET_ACTION (from text client even READOUT_ACTION for acquisition)
|
|
*/
|
|
static detectorType getDetectorType(char *name, int cport=DEFAULT_PORTNO);
|
|
|
|
/**
|
|
returns the detector type from hostname and controlport
|
|
\param
|
|
\param action can be PUT_ACTION or GET_ACTION (from text client even READOUT_ACTION for acquisition)
|
|
*/
|
|
static detectorType getDetectorType(int id);
|
|
|
|
|
|
/**
|
|
Returns detector id
|
|
\returns detector id
|
|
*/
|
|
|
|
int getDetectorId(int i=-1) {return detId;};
|
|
/**
|
|
Receives a data frame from the detector socket
|
|
\returns pointer to the data (or NULL if failed)
|
|
|
|
*/
|
|
int* getDataFromDetector();
|
|
|
|
/** returns if the detector is Master, slave or nothing
|
|
\param flag can be GET_MASTER, NO_MASTER, IS_MASTER, IS_SLAVE
|
|
\returns master flag of the detector
|
|
*/
|
|
masterFlags setMaster(masterFlags flag);
|
|
|
|
/**
|
|
Loads dark image or gain image from a file and sends it to the detector
|
|
\param index is 0 for dark image and 1 for gain image
|
|
\param fname file name to load data from
|
|
|
|
*/
|
|
int loadImageToDetector(imageType index,string const fname);
|
|
|
|
/**
|
|
Called from loadImageToDetector to send the image to detector
|
|
\param index is 0 for dark image and 1 for gain image
|
|
\param arg image
|
|
|
|
*/
|
|
int sendImageToDetector(imageType index,short int arg[]);
|
|
|
|
/**
|
|
Sets/gets the synchronization mode of the various detectors
|
|
\param sync syncronization mode can be GET_SYNCHRONIZATION_MODE, NONE, MASTER_GATES, MASTER_TRIGGERS, SLAVE_STARTS_WHEN_MASTER_STOPS
|
|
\returns current syncronization mode
|
|
*/
|
|
synchronizationMode setSynchronization(synchronizationMode sync=GET_SYNCHRONIZATION_MODE);
|
|
|
|
protected:
|
|
|
|
|
|
/**
|
|
address of the detector structure in shared memory
|
|
*/
|
|
sharedSlsDetector *thisDetector;
|
|
|
|
|
|
/**
|
|
detector ID
|
|
*/
|
|
int detId;
|
|
|
|
/**
|
|
shared memeory ID
|
|
*/
|
|
int shmId;
|
|
|
|
/**
|
|
socket for control commands
|
|
*/
|
|
MySocketTCP *controlSocket;
|
|
|
|
/**
|
|
socket for emergency stop
|
|
*/
|
|
MySocketTCP *stopSocket;
|
|
|
|
/**
|
|
socket for data acquisition
|
|
*/
|
|
MySocketTCP *dataSocket;
|
|
|
|
|
|
|
|
|
|
|
|
/** pointer to flat field coefficients */
|
|
float *ffcoefficients;
|
|
/** pointer to flat field coefficient errors */
|
|
float *fferrors;
|
|
|
|
|
|
/** pointer to detector module structures */
|
|
sls_detector_module *detectorModules;
|
|
/** pointer to dac valuse */
|
|
float *dacs;
|
|
/** pointer to adc valuse */
|
|
float *adcs;
|
|
/** pointer to chip registers */
|
|
int *chipregs;
|
|
/** pointer to channal registers */
|
|
int *chanregs;
|
|
|
|
/** Initializes the shared memory
|
|
\param type is needed to define the size of the shared memory
|
|
\param id is the detector id needed to define the shared memory id
|
|
\return shm_id shared memory id
|
|
*/
|
|
int initSharedMemory(detectorType type=GENERIC, int id=0);
|
|
|
|
/** Frees the shared memory - should not be used*/
|
|
int freeSharedMemory();
|
|
/**
|
|
Initializes the thisDetector structure
|
|
\param type is needed to define the number of channels, chips, modules etc.
|
|
\sa sharedSlsDetector
|
|
*/
|
|
int initializeDetectorSize(detectorType type);
|
|
/**
|
|
Initializes the module structures in thisDetector if the detector did not exists before
|
|
*/
|
|
int initializeDetectorStructure();
|
|
/**
|
|
send a sls_detector_channel structure over socket
|
|
*/
|
|
int sendChannel(sls_detector_channel*);
|
|
/**
|
|
send a sls_detector_chip structure over socket
|
|
*/
|
|
int sendChip(sls_detector_chip*);
|
|
/**
|
|
send a sls_detector_module structure over socket
|
|
*/
|
|
int sendModule(sls_detector_module*);
|
|
/**
|
|
receive a sls_detector_channel structure over socket
|
|
*/
|
|
int receiveChannel(sls_detector_channel*);
|
|
/**
|
|
receive a sls_detector_chip structure over socket
|
|
*/
|
|
int receiveChip(sls_detector_chip*);
|
|
/**
|
|
receive a sls_detector_module structure over socket
|
|
*/
|
|
int receiveModule(sls_detector_module*);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** returns the client IP address for gotthard \sa sharedSlsDetector */
|
|
char* getClientIP() {return thisDetector->clientIP;};
|
|
/** returns the client MAC address for gotthard \sa sharedSlsDetector */
|
|
char* getClientMAC() {return thisDetector->clientMAC;};
|
|
/** returns the server MAC address for gotthard \sa sharedSlsDetector */
|
|
char* getServerMAC() {return thisDetector->serverMAC;};
|
|
/** validates and sets the client IP address for gotthard \sa sharedSlsDetector */
|
|
char* setClientIP(string clientIP);
|
|
/** validates the format of client MAC address and sets it for gotthard \sa sharedSlsDetector */
|
|
char* setClientMAC(string clientMAC);
|
|
/** validates the format of server MAC address and sets it for gotthard \sa sharedSlsDetector */
|
|
char* setServerMAC(string serverMAC);
|
|
|
|
|
|
/** temporary test fucntion */
|
|
int testFunction(int times=0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
#endif
|