removed typedef for shared struct

This commit is contained in:
Erik Frojdh
2019-03-12 14:42:27 +01:00
parent d4e4fb8ffe
commit 7e793539ca
2 changed files with 682 additions and 701 deletions

View File

@ -7,10 +7,10 @@
* @short This is the base class for multi detector system functionalities
* @author Anna Bergamaschi
*/
#include "SharedMemory.h"
#include "error_defs.h"
#include "logger.h"
#include "sls_detector_defs.h"
#include "SharedMemory.h"
class slsDetector;
// class SharedMemory;
class ZmqSocket;
@ -27,12 +27,11 @@ class detectorData;
#define SHORT_STRING_LENGTH 50
#define DATE_LENGTH 30
/**
/**
* @short structure allocated in shared memory to store detector settings
* for IPC and cache
*/
typedef struct sharedMultiSlsDetector {
struct sharedMultiSlsDetector {
/* FIXED PATTERN FOR STATIC FUNCTIONS. DO NOT CHANGE, ONLY APPEND
* ------*/
@ -107,15 +106,13 @@ class detectorData;
/** data streaming (up stream) enable in receiver */
bool receiver_upstream;
} sharedMultiSlsDetector;
};
class multiSlsDetector : public virtual slsDetectorDefs,
public virtual errorDefs {
// private:
public:
/**
* Constructor
@ -444,8 +441,6 @@ class multiSlsDetector : public virtual slsDetectorDefs,
*/
int setReceiverPort(int port_number = -1, int detPos = -1);
/**
* Lock server for this client IP
* @param p 0 to unlock, 1 to lock
@ -474,7 +469,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
* @param detPos -1 for all detectors in list or specific detector position
* @returns OK or FAIL
*/
int execCommand(const std::string& cmd, int detPos);
int execCommand(const std::string &cmd, int detPos);
/**
* Load configuration from a configuration File
@ -545,7 +540,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
* @param detPos -1 for all detectors in list or specific detector position
* @returns the trimbit/settings directory
*/
std::string setSettingsDir(const std::string& directory, int detPos = -1);
std::string setSettingsDir(const std::string &directory, int detPos = -1);
/**
* Loads the modules settings/trimbits reading from a specific file
@ -554,7 +549,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
* @param detPos -1 for all detectors in list or specific detector position
* returns OK or FAIL
*/
int loadSettingsFile(const std::string& fname, int detPos = -1);
int loadSettingsFile(const std::string &fname, int detPos = -1);
/**
* Saves the modules settings/trimbits to a specific file
@ -563,7 +558,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
* @param detPos -1 for all detectors in list or specific detector position
* returns OK or FAIL
*/
int saveSettingsFile(const std::string& fname, int detPos = -1);
int saveSettingsFile(const std::string &fname, int detPos = -1);
/**
* Get Detector run status
@ -872,7 +867,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
* @param detPos -1 for all detectors in list or specific detector position
* @returns the detector MAC address
*/
std::string setDetectorMAC(const std::string& detectorMAC, int detPos = -1);
std::string setDetectorMAC(const std::string &detectorMAC, int detPos = -1);
/**
* Returns the detector MAC address
@ -887,7 +882,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
* @param detPos -1 for all detectors in list or specific detector position
* @returns the detector IP address
*/
std::string setDetectorIP(const std::string& detectorIP, int detPos = -1);
std::string setDetectorIP(const std::string &detectorIP, int detPos = -1);
/**
* Returns the detector IP address
@ -904,7 +899,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
* @param detPos -1 for all detectors in list or specific detector position
* @returns the receiver IP address from shared memory
*/
std::string setReceiver(const std::string& receiver, int detPos = -1);
std::string setReceiver(const std::string &receiver, int detPos = -1);
/**
* Returns the receiver IP address
@ -919,7 +914,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
* @param detPos -1 for all detectors in list or specific detector position
* @returns the receiver UDP IP address
*/
std::string setReceiverUDPIP(const std::string& udpip, int detPos = -1);
std::string setReceiverUDPIP(const std::string &udpip, int detPos = -1);
/**
* Returns the receiver UDP IP address
@ -934,7 +929,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
* @param detPos -1 for all detectors in list or specific detector position
* @returns the receiver UDP MAC address
*/
std::string setReceiverUDPMAC(const std::string& udpmac, int detPos = -1);
std::string setReceiverUDPMAC(const std::string &udpmac, int detPos = -1);
/**
* Returns the receiver UDP MAC address
@ -951,7 +946,6 @@ class multiSlsDetector : public virtual slsDetectorDefs,
*/
int setReceiverUDPPort(int udpport, int detPos = -1);
/**
* Returns the receiver UDP port
* @param detPos -1 for all detectors in list or specific detector position
@ -1017,7 +1011,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
* By default, it is the IP of receiver hostname
* @param detPos -1 for all detectors in list or specific detector position
*/
void setClientDataStreamingInIP(const std::string& ip = "",
void setClientDataStreamingInIP(const std::string &ip = "",
int detPos = -1);
/**
@ -1035,7 +1029,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
* By default, it is the IP of receiver hostname
* @param detPos -1 for all detectors in list or specific detector position
*/
void setReceiverDataStreamingOutIP(const std::string& ip = "",
void setReceiverDataStreamingOutIP(const std::string &ip = "",
int detPos = -1);
/**
@ -1062,7 +1056,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
* @param detPos -1 for all detectors in list or specific detector position
* @returns additional json header, default is empty
*/
std::string setAdditionalJsonHeader(const std::string& jsonheader, int detPos = -1);
std::string setAdditionalJsonHeader(const std::string &jsonheader, int detPos = -1);
/**
* Returns the additional json header
@ -1079,7 +1073,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
* @returns the additional json header parameter value,
* empty if no parameter found in additional json header
*/
std::string setAdditionalJsonParameter(const std::string& key, const std::string& value, int detPos = -1);
std::string setAdditionalJsonParameter(const std::string &key, const std::string &value, int detPos = -1);
/**
* Returns the additional json header parameter value
@ -1088,7 +1082,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
* @returns the additional json header parameter value,
* empty if no parameter found in additional json header
*/
std::string getAdditionalJsonParameter(const std::string& key, int detPos = -1);
std::string getAdditionalJsonParameter(const std::string &key, int detPos = -1);
/**
* Sets the detector minimum/maximum energy threshold in processor (for Moench only)
@ -1120,14 +1114,14 @@ class multiSlsDetector : public virtual slsDetectorDefs,
* @param detPos -1 for all detectors in list or specific detector position
* @returns receiver udp socket buffer size
*/
uint64_t setReceiverUDPSocketBufferSize(uint64_t udpsockbufsize=-1, int detPos = -1);
uint64_t setReceiverUDPSocketBufferSize(uint64_t udpsockbufsize = -1, int detPos = -1);
/**
* Returns the receiver UDP socket buffer size
* @param detPos -1 for all detectors in list or specific detector position
* @returns the receiver UDP socket buffer size
*/
uint64_t getReceiverUDPSocketBufferSize(int detPos = -1) ;
uint64_t getReceiverUDPSocketBufferSize(int detPos = -1);
/**
* Returns the receiver real UDP socket buffer size
@ -1363,7 +1357,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
* @param detPos -1 for all detectors in list or specific detector position
* @returns OK or FAIL
*/
int programFPGA(const std::string& fname, int detPos = -1);
int programFPGA(const std::string &fname, int detPos = -1);
/**
* Resets FPGA (Jungfrau)
@ -1464,7 +1458,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
* @param detPos -1 for all detectors in list or specific detector position
* @returns OK or FAIL
*/
int execReceiverCommand(const std::string& cmd, int detPos = -1);
int execReceiverCommand(const std::string &cmd, int detPos = -1);
/**
* Returns output file directory
@ -1479,7 +1473,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
* @param s file directory
* @returns file dir
*/
std::string setFilePath(const std::string& path, int detPos = -1);
std::string setFilePath(const std::string &path, int detPos = -1);
/**
* Returns file name prefix
@ -1494,7 +1488,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
* @param s file name prefix
* @returns file name prefix
*/
std::string setFileName(const std::string& fname, int detPos = -1);
std::string setFileName(const std::string &fname, int detPos = -1);
/**
* Sets the max frames per file in receiver
@ -1696,7 +1690,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
* @param detPos -1 for all detectors in list or specific detector position
* @returns OK/FAIL
*/
int setPattern(const std::string& fname, int detPos = -1);
int setPattern(const std::string &fname, int detPos = -1);
/**
* Writes a pattern word to the CTB
@ -1900,7 +1894,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
* Add sls detector
* @param s hostname of the single detector
*/
void addSlsDetector(const std::string& hostname);
void addSlsDetector(const std::string &hostname);
/**
* add gap pixels to the image (only for Eiger in 4 bit mode)
@ -1966,14 +1960,13 @@ class multiSlsDetector : public virtual slsDetectorDefs,
int detId;
/** Shared Memory object */
SharedMemory<sharedMultiSlsDetector> sharedMemory{0,-1};
SharedMemory<sharedMultiSlsDetector> sharedMemory{0, -1};
/** pointers to the slsDetector structures */
std::vector<std::unique_ptr<slsDetector>> detectors;
/** data streaming (down stream) enabled in client (zmq sckets created) */
bool client_downstream {false};
bool client_downstream{false};
/** ZMQ Socket - Receiver to Client */
std::vector<std::unique_ptr<ZmqSocket>> zmqSocket;
@ -1987,10 +1980,10 @@ class multiSlsDetector : public virtual slsDetectorDefs,
sem_t sem_endRTAcquisition;
/** Total number of frames/images for next acquisition */
int totalProgress {0};
int totalProgress{0};
/** Current progress or frames/images processed in current acquisition */
int progressIndex {0};
int progressIndex{0};
/** mutex to synchronize main and data processing threads */
mutable std::mutex mp;
@ -1999,26 +1992,26 @@ class multiSlsDetector : public virtual slsDetectorDefs,
mutable std::mutex mg;
/** sets when the acquisition is finished */
bool jointhread {false};
bool jointhread{false};
/** the data processing thread */
// pthread_t dataProcessingThread;
std::thread dataProcessingThread;
/** detector data packed for the gui */
detectorData *thisData {nullptr};
detectorData *thisData{nullptr};
int (*acquisition_finished)(double, int, void *) {nullptr};
void *acqFinished_p {nullptr};
int (*acquisition_finished)(double, int, void *){nullptr};
void *acqFinished_p{nullptr};
int (*measurement_finished)(int, int, void *) {nullptr};
void *measFinished_p {nullptr};
int (*measurement_finished)(int, int, void *){nullptr};
void *measFinished_p{nullptr};
int (*progress_call)(double, void *);
void *pProgressCallArg {nullptr};
void *pProgressCallArg{nullptr};
int (*dataReady)(detectorData *, int, int, void *){nullptr};
void *pCallbackArg {nullptr};
void *pCallbackArg{nullptr};
};
#endif

View File

@ -9,11 +9,11 @@
* @author Anna Bergamaschi
*/
#include "sls_detector_defs.h"
#include "error_defs.h"
#include "logger.h"
#include "ClientSocket.h"
#include "SharedMemory.h"
#include "error_defs.h"
#include "logger.h"
#include "sls_detector_defs.h"
class ClientInterface;
#include <cmath>
@ -41,11 +41,10 @@ typedef struct detParameterList {
int nGappixelsY;
} detParameterList;
/**
/**
* @short structure allocated in shared memory to store detector settings for IPC and cache
*/
typedef struct sharedSlsDetector {
struct sharedSlsDetector {
/* FIXED PATTERN FOR STATIC FUNCTIONS. DO NOT CHANGE, ONLY APPEND ------*/
@ -69,9 +68,6 @@ typedef struct detParameterList {
/** END OF FIXED PATTERN -----------------------------------------------*/
/** Detector offset in the X & Y direction in the multi detector structure */
int offset[2];
@ -257,12 +253,10 @@ typedef struct detParameterList {
/** overwriteenable */
bool receiver_overWriteEnable;
} sharedSlsDetector;
};
class slsDetector : public virtual slsDetectorDefs, public virtual errorDefs {
public:
public:
/**
* Constructor called when creating new shared memory
* @param type detector type
@ -333,7 +327,7 @@ public:
* Sets the hostname, if online flag is set connects to update the detector
* @param name hostname
*/
void setHostname(const std::string& hostname);
void setHostname(const std::string &hostname);
/**
* Gets the hostname of detector
@ -350,7 +344,7 @@ public:
* Get detector type by connecting to the detector
* @returns detector tpe or GENERIC if failed
*/
static detectorType getTypeFromDetector(const std::string& hostname, int cport=DEFAULT_PORTNO);
static detectorType getTypeFromDetector(const std::string &hostname, int cport = DEFAULT_PORTNO);
/**
* Get Detector type from shared memory variable
@ -369,7 +363,7 @@ public:
* @param type the detector type
* @returns detector type in receiver
*/
int setDetectorType(detectorType type=GET_DETECTOR_TYPE);
int setDetectorType(detectorType type = GET_DETECTOR_TYPE);
/**
* Returns the total number of channels from shared memory
@ -454,8 +448,7 @@ public:
* if ONLINE_FLAG, detector in online state (i.e. communication to the detector updating the local structure)
* @returns online/offline status
*/
int setOnline(int value=GET_ONLINE_FLAG);
int setOnline(int value = GET_ONLINE_FLAG);
/**
* Returns the online flag
@ -491,14 +484,14 @@ public:
* Returns the receiver TCP port \sa sharedSlsDetector
* @returns the receiver TCP port
*/
int getReceiverPort() const ;
int getReceiverPort() const;
/**
* Lock server for this client IP
* @param p 0 to unlock, 1 to lock (-1 gets)
* @returns 1 for locked or 0 for unlocked
*/
int lockServer(int lock=-1);
int lockServer(int lock = -1);
/**
* Get last client IP saved on detector server
@ -518,13 +511,13 @@ public:
* @param cmd command to be executed
* @returns OK or FAIL
*/
int execCommand(const std::string& cmd);
int execCommand(const std::string &cmd);
/**
* Updates some of the shared memory receiving the data from the detector
* @returns OK
*/
int updateDetectorNoWait( sls::ClientSocket &client);
int updateDetectorNoWait(sls::ClientSocket &client);
/**
* Updates some of the shared memory receiving the data from the detector
@ -540,7 +533,7 @@ public:
* @param m multiSlsDetector reference to parse commands
* @returns OK or FAIL
*/
int writeConfigurationFile(const std::string& fname, multiSlsDetector* m);
int writeConfigurationFile(const std::string &fname, multiSlsDetector *m);
/**
* Write current configuration to a stream
@ -548,7 +541,7 @@ public:
* @param m multiSlsDetector reference to parse commands
* @returns OK or FAIL
*/
int writeConfigurationFile(std::ofstream &outfile, multiSlsDetector* m);
int writeConfigurationFile(std::ofstream &outfile, multiSlsDetector *m);
/**
* Returns the trimfile or settings file name (Useless??)
@ -563,7 +556,7 @@ public:
* @returns OK or FAIL if the file could not be written
* \sa ::sls_detector_module sharedSlsDetector mythenDetector::writeSettingsFile(string, int)
*/
int writeSettingsFile(const std::string& fname);
int writeSettingsFile(const std::string &fname);
/**
* Get detector settings
@ -596,7 +589,6 @@ public:
*/
int getThresholdEnergy();
/**
* Set threshold energy (Mythen and Eiger)
* For Eiger, calls setThresholdEneryAndSettings
@ -605,7 +597,7 @@ public:
* @param tb 1 to include trimbits, 0 to exclude
* @returns current threshold value in ev (-1 failed)
*/
int setThresholdEnergy(int e_eV, detectorSettings isettings=GET_SETTINGS, int tb=1);
int setThresholdEnergy(int e_eV, detectorSettings isettings = GET_SETTINGS, int tb = 1);
/**
* Set threshold energy and settings (Eiger only)
@ -614,7 +606,7 @@ public:
* @param tb 1 to include trimbits, 0 to exclude
* @returns OK if successful, else FAIL
*/
int setThresholdEnergyAndSettings(int e_eV, detectorSettings isettings, int tb=1);
int setThresholdEnergyAndSettings(int e_eV, detectorSettings isettings, int tb = 1);
/**
* Returns the detector trimbit/settings directory \sa sharedSlsDetector
@ -627,7 +619,7 @@ public:
* @param s trimbits/settings directory
* @returns the trimbit/settings directory
*/
std::string setSettingsDir(const std::string& dir);
std::string setSettingsDir(const std::string &dir);
/**
* Loads the modules settings/trimbits reading from a specific file
@ -635,7 +627,7 @@ public:
* @param fname specific settings/trimbits file
* returns OK or FAIL
*/
int loadSettingsFile(const std::string& fname);
int loadSettingsFile(const std::string &fname);
/**
* Saves the modules settings/trimbits to a specific file
@ -643,7 +635,7 @@ public:
* @param fname specific settings/trimbits file
* returns OK or FAIL
*/
int saveSettingsFile(const std::string& fname);
int saveSettingsFile(const std::string &fname);
/**
* Get run status of the detector
@ -705,7 +697,7 @@ public:
* @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);
int64_t setTimer(timerIndex index, int64_t t = -1);
/**
* Set/get timer value left in acquisition (not all implemented for all detectors)
@ -721,7 +713,7 @@ public:
* @param value (clkdivider 0,1,2 for full, half and quarter speed). Other values check manual
* @returns value of speed set
*/
int setSpeed(speedVariable sp, int value=-1);
int setSpeed(speedVariable sp, int value = -1);
/**
* Set/get dynamic range and updates the number of dataBytes
@ -730,7 +722,7 @@ public:
* @returns current dynamic range
* \sa sharedSlsDetector
*/
int setDynamicRange(int n=-1);
int setDynamicRange(int n = -1);
/**
* Recalculated number of data bytes
@ -765,7 +757,7 @@ public:
* @param pol timing mode (-1 gets)
* @returns current timing mode
*/
externalCommunicationMode setExternalCommunicationMode(externalCommunicationMode pol=GET_EXTERNAL_COMMUNICATION_MODE);
externalCommunicationMode setExternalCommunicationMode(externalCommunicationMode pol = GET_EXTERNAL_COMMUNICATION_MODE);
/**
* Set/get external signal flags (to specify triggerinrising edge etc) (Gotthard, Mythen)
@ -773,14 +765,14 @@ public:
* @param signalindex singal index (0 - 3)
* @returns current timing mode
*/
externalSignalFlag setExternalSignalFlags(externalSignalFlag pol=GET_EXTERNAL_SIGNAL_FLAG , int signalindex=0);
externalSignalFlag setExternalSignalFlags(externalSignalFlag pol = GET_EXTERNAL_SIGNAL_FLAG, int signalindex = 0);
/**
* Set/get readout flags (Eiger, Mythen)
* @param flag readout flag (Eiger options: parallel, nonparallel, safe etc.) (-1 gets)
* @returns readout flag
*/
int setReadOutFlags(readOutFlags flag=GET_READOUT_FLAGS);
int setReadOutFlags(readOutFlags flag = GET_READOUT_FLAGS);
/**
* Write in a register. For Advanced users
@ -818,7 +810,7 @@ public:
* @param detectorMAC detector MAC address
* @returns the detector MAC address
*/
std::string setDetectorMAC(const std::string& detectorMAC);
std::string setDetectorMAC(const std::string &detectorMAC);
/**
* Returns the detector MAC address\sa sharedSlsDetector
@ -831,7 +823,7 @@ public:
* @param detectorIP detector IP address
* @returns the detector IP address
*/
std::string setDetectorIP(const std::string& detectorIP);
std::string setDetectorIP(const std::string &detectorIP);
/**
* Returns the detector IP address\sa sharedSlsDetector
@ -846,7 +838,7 @@ public:
* @param receiver receiver hostname or IP address
* @returns the receiver IP address from shared memory
*/
std::string setReceiver(const std::string& receiver);
std::string setReceiver(const std::string &receiver);
/**
* Returns the receiver IP address\sa sharedSlsDetector
@ -859,7 +851,7 @@ public:
* @param udpip receiver UDP IP address
* @returns the receiver UDP IP address
*/
std::string setReceiverUDPIP(const std::string& udpip);
std::string setReceiverUDPIP(const std::string &udpip);
/**
* Returns the receiver UDP IP address\sa sharedSlsDetector
@ -872,7 +864,7 @@ public:
* @param udpmac receiver UDP MAC address
* @returns the receiver UDP MAC address
*/
std::string setReceiverUDPMAC(const std::string& udpmac);
std::string setReceiverUDPMAC(const std::string &udpmac);
/**
* Returns the receiver UDP MAC address\sa sharedSlsDetector
@ -934,7 +926,7 @@ public:
* Sets the client zmq ip\sa sharedSlsDetector
* @param sourceIP client zmq ip
*/
void setClientStreamingIP(const std::string& sourceIP);
void setClientStreamingIP(const std::string &sourceIP);
/**
* Returns the client zmq ip \sa sharedSlsDetector
@ -968,7 +960,7 @@ public:
* @param jsonheader additional json header
* @returns additional json header, returns "none" if default setting and no custom ip set
*/
std::string setAdditionalJsonHeader(const std::string& jsonheader);
std::string setAdditionalJsonHeader(const std::string &jsonheader);
/**
* Returns the additional json header \sa sharedSlsDetector
@ -983,7 +975,7 @@ public:
* @returns the additional json header parameter value,
* empty if no parameter found in additional json header
*/
std::string setAdditionalJsonParameter(const std::string& key, const std::string& value);
std::string setAdditionalJsonParameter(const std::string &key, const std::string &value);
/**
* Returns the additional json header parameter value
@ -991,20 +983,20 @@ public:
* @returns the additional json header parameter value,
* empty if no parameter found in additional json header
*/
std::string getAdditionalJsonParameter(const std::string& key);
std::string getAdditionalJsonParameter(const std::string &key);
/**
* Sets the receiver UDP socket buffer size
* @param udpsockbufsize additional json header
* @returns receiver udp socket buffer size
*/
uint64_t setReceiverUDPSocketBufferSize(uint64_t udpsockbufsize=-1);
uint64_t setReceiverUDPSocketBufferSize(uint64_t udpsockbufsize = -1);
/**
* Returns the receiver UDP socket buffer size\sa sharedSlsDetector
* @returns the receiver UDP socket buffer size
*/
uint64_t getReceiverUDPSocketBufferSize() ;
uint64_t getReceiverUDPSocketBufferSize();
/**
* Returns the receiver real UDP socket buffer size\sa sharedSlsDetector
@ -1018,7 +1010,7 @@ public:
* @param value 1 to set or 0 to clear the digital test bit
* @returns result of test
*/
int digitalTest(digitalTestMode mode, int ival=-1);
int digitalTest(digitalTestMode mode, int ival = -1);
/**
* Load dark or gain image to detector (Gotthard)
@ -1026,7 +1018,7 @@ public:
* @param fname file name from which to load image
* @returns OK or FAIL
*/
int loadImageToDetector(imageType index, const std::string& fname);
int loadImageToDetector(imageType index, const std::string &fname);
/**
* Called from loadImageToDetector to send the image to detector
@ -1042,7 +1034,7 @@ public:
* @param startACQ is 1 to start acquisition after reading counter
* @returns OK or FAIL
*/
int writeCounterBlockFile(const std::string& fname,int startACQ=0);
int writeCounterBlockFile(const std::string &fname, int startACQ = 0);
/**
* Gets counter memory block in detector (Gotthard)
@ -1050,14 +1042,14 @@ public:
* @param startACQ 1 to start acquisition afterwards, else 0
* @returns OK or FAIL
*/
int getCounterBlock(int16_t image[],int startACQ=0);
int getCounterBlock(int16_t image[], int startACQ = 0);
/**
* Resets counter in detector
* @param startACQ is 1 to start acquisition after resetting counter
* @returns OK or FAIL
*/
int resetCounterBlock(int startACQ=0);
int resetCounterBlock(int startACQ = 0);
/**
* Set/get counter bit in detector (Gotthard)
@ -1079,14 +1071,14 @@ public:
* @param roiLimits array of roi
* @returns OK or FAIL
*/
int setROI(int n=-1,ROI roiLimits[]=nullptr);
int setROI(int n = -1, ROI roiLimits[] = nullptr);
/**
* Get ROI from each detector and convert it to the multi detector scale (Gotthard)
* @param n number of rois
* @returns OK or FAIL
*/
slsDetectorDefs::ROI* getROI(int &n);
slsDetectorDefs::ROI *getROI(int &n);
/**
* Returns number of rois
@ -1101,7 +1093,7 @@ public:
* @param roiLimits ROI
* @returns OK or FAIL
*/
int sendROI(int n=-1,ROI roiLimits[]=nullptr);
int sendROI(int n = -1, ROI roiLimits[] = nullptr);
/**
* Write to ADC register (Gotthard, Jungfrau, ChipTestBoard). For expert users
@ -1116,21 +1108,21 @@ public:
* @param enable active (1) or inactive (0), -1 gets
* @returns 0 (inactive) or 1 (active)for activate mode
*/
int activate(int const enable=-1);
int activate(int const enable = -1);
/**
* Set deactivated Receiver padding mode (Eiger only)
* @param padding padding option for deactivated receiver. Can be 1 (padding), 0 (no padding), -1 (gets)
* @returns 1 (padding), 0 (no padding), -1 (inconsistent values) for padding option
*/
int setDeactivatedRxrPaddingMode(int padding=-1);
int setDeactivatedRxrPaddingMode(int padding = -1);
/**
* Returns the enable if data will be flipped across x or y axis (Eiger)
* @param d axis across which data is flipped
* @returns 1 for flipped, else 0
*/
int getFlippedData(dimension d=X);
int getFlippedData(dimension d = X);
/**
* Sets the enable which determines if
@ -1139,7 +1131,7 @@ public:
* @param value 0 or 1 to reset/set or -1 to get value
* @returns enable flipped data across x or y axis
*/
int setFlippedData(dimension d=X, int value=-1);
int setFlippedData(dimension d = X, int value = -1);
/**
* Sets all the trimbits to a particular value (Eiger)
@ -1154,7 +1146,7 @@ public:
* @param val 1 sets, 0 unsets, -1 gets
* @returns gap pixel enable or -1 for error
*/
int enableGapPixels(int val=-1);
int enableGapPixels(int val = -1);
/**
* Sets the number of trim energies and their value (Eiger)
@ -1163,7 +1155,7 @@ public:
* @param en array of energies
* @returns number of trim energies
*/
int setTrimEn(int nen, int *en=nullptr);
int setTrimEn(int nen, int *en = nullptr);
/**
* Returns the number of trim energies and their value (Eiger)
@ -1171,7 +1163,7 @@ public:
* @param en array of energies
* @returns number of trim energies
*/
int getTrimEn(int *en=nullptr);
int getTrimEn(int *en = nullptr);
/**
* Pulse Pixel (Eiger)
@ -1180,7 +1172,7 @@ public:
* @param y is y coordinate
* @returns OK or FAIL
*/
int pulsePixel(int n=0,int x=0,int y=0);
int pulsePixel(int n = 0, int x = 0, int y = 0);
/**
* Pulse Pixel and move by a relative value (Eiger)
@ -1189,49 +1181,49 @@ public:
* @param y is relative y value
* @returns OK or FAIL
*/
int pulsePixelNMove(int n=0,int x=0,int y=0);
int pulsePixelNMove(int n = 0, int x = 0, int y = 0);
/**
* Pulse Chip (Eiger)
* @param n is number of times to pulse
* @returns OK or FAIL
*/
int pulseChip(int n=0);
int pulseChip(int n = 0);
/**
* Set/gets threshold temperature (Jungfrau)
* @param val value in millidegrees, -1 gets
* @returns threshold temperature in millidegrees
*/
int setThresholdTemperature(int val=-1);
int setThresholdTemperature(int val = -1);
/**
* Enables/disables temperature control (Jungfrau)
* @param val value, -1 gets
* @returns temperature control enable
*/
int setTemperatureControl(int val=-1);
int setTemperatureControl(int val = -1);
/**
* Resets/ gets over-temperature event (Jungfrau)
* @param val value, -1 gets
* @returns over-temperature event
*/
int setTemperatureEvent(int val=-1);
int setTemperatureEvent(int val = -1);
/**
* Set storage cell that stores first acquisition of the series (Jungfrau)
* @param value storage cell index. Value can be 0 to 15. (-1 gets)
* @returns the storage cell that stores the first acquisition of the series
*/
int setStoragecellStart(int pos=-1);
int setStoragecellStart(int pos = -1);
/**
* Programs FPGA with pof file (Jungfrau)
* @param fname file name
* @returns OK or FAIL
*/
int programFPGA(const std::string& fname);
int programFPGA(const std::string &fname);
/**
* Resets FPGA (Jungfrau)
@ -1244,22 +1236,21 @@ public:
* @param ival on is 1, off is 0, -1 to get
* @returns OK or FAIL
*/
int powerChip(int ival= -1);
int powerChip(int ival = -1);
/**
* Automatic comparator disable (Jungfrau)
* @param ival on is 1, off is 0, -1 to get
* @returns OK or FAIL
*/
int setAutoComparatorDisableMode(int ival= -1);
int setAutoComparatorDisableMode(int ival = -1);
/**
* Returns the trimbits from the detector's shared memmory (Eiger)
* @param retval is the array with the trimbits
* @returns total number of channels for the detector
*/
int getChanRegs(double* retval);
int getChanRegs(double *retval);
/**
* Configure Module (Eiger)
@ -1272,7 +1263,6 @@ public:
*/
int setModule(sls_detector_module module, int tb = 1);
/**
* Get module structure from detector (all detectors)
* @returns pointer to module structure (which has been created and must then be deleted)
@ -1306,7 +1296,7 @@ public:
* @param online 1 to set online, 0 to set offline, -1 gets
* @returns online, offline (from shared memory)
*/
int setReceiverOnline(int value=GET_ONLINE_FLAG);
int setReceiverOnline(int value = GET_ONLINE_FLAG);
int getReceiverOnline() const;
@ -1321,7 +1311,7 @@ public:
* @param lock sets (1), usets (0), gets (-1) the lock
* @returns lock status of the receiver
*/
int lockReceiver(int lock=-1);
int lockReceiver(int lock = -1);
/**
* Returns the IP of the last client connecting to the receiver
@ -1341,13 +1331,13 @@ public:
* @param cmd command to be executed
* @returns OK or FAIL
*/
int execReceiverCommand(const std::string& cmd);
int execReceiverCommand(const std::string &cmd);
/**
updates the shared memory receiving the data from the detector (without asking and closing the connection
/returns OK
*/
int updateReceiverNoWait(sls::ClientSocket& receiver);
int updateReceiverNoWait(sls::ClientSocket &receiver);
/**
* Updates the shared memory receiving the data from the detector
@ -1385,7 +1375,7 @@ public:
* @param s file directory
* @returns file dir
*/
std::string setFilePath(const std::string& path);
std::string setFilePath(const std::string &path);
/**
* Returns file name prefix
@ -1398,14 +1388,14 @@ public:
* @param s file name prefix
* @returns file name prefix
*/
std::string setFileName(const std::string& fname);
std::string setFileName(const std::string &fname);
/**
* Sets the max frames per file in receiver
* @param f max frames per file
* @returns max frames per file in receiver
*/
int setReceiverFramesPerFile(int f=-1);
int setReceiverFramesPerFile(int f = -1);
/**
* Sets the frames discard policy in receiver
@ -1495,14 +1485,14 @@ public:
* @param enable 1 or 0 to set/reset file write enable
* @returns file write enable
*/
int enableWriteToFile(int enable=-1);
int enableWriteToFile(int enable = -1);
/**
* Sets/Gets file overwrite enable
* @param enable 1 or 0 to set/reset file overwrite enable
* @returns file overwrite enable
*/
int overwriteFile(int enable=-1);
int overwriteFile(int enable = -1);
/**
* (previously setReadReceiverFrequency)
@ -1511,7 +1501,7 @@ public:
* @param detPos -1 for all detectors in list or specific detector position
* @returns receiver streaming frequency
*/
int setReceiverStreamingFrequency(int freq=-1);
int setReceiverStreamingFrequency(int freq = -1);
/**
* (previously setReceiverReadTimer)
@ -1521,14 +1511,14 @@ public:
* @param time_in_ms timer between frames
* @returns receiver streaming timer in ms
*/
int setReceiverStreamingTimer(int time_in_ms=500);
int setReceiverStreamingTimer(int time_in_ms = 500);
/**
* Enable or disable streaming data from receiver to client
* @param enable 0 to disable 1 to enable -1 to only get the value
* @returns data streaming from receiver enable
*/
int enableDataStreamingFromReceiver(int enable=-1);
int enableDataStreamingFromReceiver(int enable = -1);
/**
* Enable/disable or 10Gbe
@ -1565,7 +1555,7 @@ public:
* @param fname pattern file to open
* @returns OK/FAIL
*/
int setPattern(const std::string& fname);
int setPattern(const std::string &fname);
/**
* Writes a pattern word to the CTB
@ -1573,7 +1563,7 @@ public:
* @param word 64bit word to be written, -1 gets
* @returns actual value
*/
uint64_t setPatternWord(int addr,uint64_t word=-1);
uint64_t setPatternWord(int addr, uint64_t word = -1);
/**
* Sets the pattern or loop limits in the CTB
@ -1583,7 +1573,7 @@ public:
* @param n number of loops (if level >=0)
* @returns OK/FAIL
*/
int setPatternLoops(int level,int &start, int &stop, int &n);
int setPatternLoops(int level, int &start, int &stop, int &n);
/**
* Sets the wait address in the CTB
@ -1591,7 +1581,7 @@ public:
* @param addr wait address, -1 gets
* @returns actual value
*/
int setPatternWaitAddr(uint64_t level, uint64_t addr=-1);
int setPatternWaitAddr(uint64_t level, uint64_t addr = -1);
/**
* Sets the wait time in the CTB
@ -1599,7 +1589,7 @@ public:
* @param t wait time, -1 gets
* @returns actual value
*/
uint64_t setPatternWaitTime(uint64_t level, uint64_t t=-1);
uint64_t setPatternWaitTime(uint64_t level, uint64_t t = -1);
/**
* Sets the mask applied to every pattern
@ -1642,8 +1632,7 @@ public:
*/
int setDigitalIODelay(uint64_t pinMask, int delay);
private:
private:
/**
* Get Detector Type from Shared Memory (opening shm without verifying size)
* @param multiId multi detector Id
@ -1667,7 +1656,7 @@ private:
* @param type detector type
* @param list structure of parameters to initialize depending on detector type
*/
void setDetectorSpecificParameters(detectorType type, detParameterList& list);
void setDetectorSpecificParameters(detectorType type, detParameterList &list);
/**
* Calculate shared memory size based on detector type
@ -1702,7 +1691,7 @@ private:
* Uses current detector type
* @returns myMod the pointer to the allocate dmemory location
*/
sls_detector_module* createModule();
sls_detector_module *createModule();
/**
* Allocates the memory for a sls_detector_module structure and initializes it
@ -1710,7 +1699,7 @@ private:
* @param type detector type
* @returns myMod the pointer to the allocate dmemory location
*/
sls_detector_module* createModule(detectorType type);
sls_detector_module *createModule(detectorType type);
/**
* Frees the memory for a sls_detector_module structure
@ -1723,14 +1712,14 @@ private:
* @param myMod module structure to send
* @returns number of bytes sent to the detector
*/
int sendModule(sls_detector_module* myMod);
int sendModule(sls_detector_module *myMod);
/**
* Receive a sls_detector_module structure over socket
* @param myMod module structure to receive
* @returns number of bytes received from the detector
*/
int receiveModule(sls_detector_module* myMod);
int receiveModule(sls_detector_module *myMod);
/**
* Get MAC from the receiver using udpip and
@ -1743,10 +1732,10 @@ private:
* Template function to do linear interpolation between two points (Eiger only)
*/
template <typename E, typename V>
V linearInterpolation(const E x, const E x1, const E x2, const V y1, const V y2){
double k = static_cast<double>(y2-y1)/(x2-x1);
double m = y1-k*x1;
int y = round( k*x+m );
V linearInterpolation(const E x, const E x1, const E x2, const V y1, const V y2) {
double k = static_cast<double>(y2 - y1) / (x2 - x1);
double m = y1 - k * x1;
int y = round(k * x + m);
return static_cast<V>(y);
}
@ -1760,9 +1749,9 @@ private:
* @param tb 1 to include trimbits, 0 to exclude (used for eiger)
* @returns the pointer to the module structure with interpolated values or NULL if error
*/
sls_detector_module* interpolateTrim(
sls_detector_module* a, sls_detector_module* b, const int energy,
const int e1, const int e2, int tb=1);
sls_detector_module *interpolateTrim(
sls_detector_module *a, sls_detector_module *b, const int energy,
const int e1, const int e2, int tb = 1);
/**
* reads a trim/settings file
@ -1773,7 +1762,7 @@ private:
* @returns the pointer to myMod or NULL if reading the file failed
*/
sls_detector_module* readSettingsFile(const std::string& fname, sls_detector_module* myMod=nullptr, int tb=1);
sls_detector_module *readSettingsFile(const std::string &fname, sls_detector_module *myMod = nullptr, int tb = 1);
/**
* writes a trim/settings file
@ -1781,26 +1770,25 @@ private:
* @param mod module structure which has to be written to file
* @returns OK or FAIL if the file could not be written
*/
int writeSettingsFile(const std::string& fname, sls_detector_module mod);
int writeSettingsFile(const std::string &fname, sls_detector_module mod);
/** slsDetector Id or position in the detectors list */
int detId;
/** Shared Memory object */
SharedMemory<sharedSlsDetector>* sharedMemory {nullptr};
SharedMemory<sharedSlsDetector> *sharedMemory{nullptr};
/** Shared memory structure */
sharedSlsDetector *thisDetector {nullptr};
sharedSlsDetector *thisDetector{nullptr};
/** pointer to detector module structures in shared memory */
sls_detector_module *detectorModules {nullptr};
sls_detector_module *detectorModules{nullptr};
/** pointer to dac valuse in shared memory */
int *dacs {nullptr};
int *dacs{nullptr};
/** pointer to channel registers in shared memory */
int *chanregs {nullptr};
int *chanregs{nullptr};
};
#endif