added const overloads for sendToDetector and sendToReceiver (#46)

This commit is contained in:
Erik Fröjdh 2019-08-06 16:58:22 +02:00 committed by Dhanya Thattil
parent d72b6c3659
commit e20b5e6952
3 changed files with 1064 additions and 943 deletions

View File

@ -1,14 +1,14 @@
#pragma once #pragma once
#include "ClientSocket.h" #include "ClientSocket.h"
#include "FixedCapacityContainer.h"
#include "SharedMemory.h" #include "SharedMemory.h"
#include "logger.h" #include "logger.h"
#include "sls_detector_defs.h"
#include "network_utils.h" #include "network_utils.h"
#include "FixedCapacityContainer.h" #include "sls_detector_defs.h"
#include <array>
#include <cmath> #include <cmath>
#include <vector> #include <vector>
#include <array>
class ServerInterface; class ServerInterface;
@ -16,7 +16,8 @@ class ServerInterface;
#define SLS_SHMVERSION 0x190726 #define SLS_SHMVERSION 0x190726
/** /**
* @short structure allocated in shared memory to store detector settings for IPC and cache * @short structure allocated in shared memory to store detector settings for
* IPC and cache
*/ */
struct sharedSlsDetector { struct sharedSlsDetector {
@ -34,8 +35,8 @@ struct sharedSlsDetector {
/** END OF FIXED PATTERN -----------------------------------------------*/ /** END OF FIXED PATTERN -----------------------------------------------*/
/** Detector offset in the X & Y direction in the multi detector structure
/** Detector offset in the X & Y direction in the multi detector structure */ */
int offset[2]; int offset[2];
/** Number of detectors in multi list in x dir and y dir */ /** Number of detectors in multi list in x dir and y dir */
@ -114,13 +115,15 @@ struct sharedSlsDetector {
/** ip address of the receiver for the detector to send packets to**/ /** ip address of the receiver for the detector to send packets to**/
sls::IpAddr rxUDPIP; sls::IpAddr rxUDPIP;
/** ip address of the receiver for the 2nd interface of the detector to send packets to**/ /** ip address of the receiver for the 2nd interface of the detector to send
* packets to**/
sls::IpAddr rxUDPIP2; sls::IpAddr rxUDPIP2;
/** mac address of receiver for the detector to send packets to **/ /** mac address of receiver for the detector to send packets to **/
sls::MacAddr rxUDPMAC; sls::MacAddr rxUDPMAC;
/** mac address of receiver for the 2nd interface of the detector to send packets to **/ /** mac address of receiver for the 2nd interface of the detector to send
* packets to **/
sls::MacAddr rxUDPMAC2; sls::MacAddr rxUDPMAC2;
/** mac address of the detector **/ /** mac address of the detector **/
@ -224,32 +227,29 @@ struct sharedSlsDetector {
/** reciever dbit offset */ /** reciever dbit offset */
int rxDbitOffset; int rxDbitOffset;
}; };
class slsDetector : public virtual slsDetectorDefs{ class slsDetector : public virtual slsDetectorDefs {
public: public:
/** /**
* Constructor called when creating new shared memory * Constructor called when creating new shared memory
* @param type detector type * @param type detector type
* @param multi_id multi detector shared memory id * @param multi_id multi detector shared memory id
* @param id sls detector id (position in detectors list) * @param id sls detector id (position in detectors list)
* @param verify true to verify if shared memory version matches existing one * @param verify true to verify if shared memory version matches existing
* one
*/ */
explicit slsDetector(detectorType type, explicit slsDetector(detectorType type, int multi_id = 0, int det_id = 0,
int multi_id = 0,
int det_id = 0,
bool verify = true); bool verify = true);
/** /**
* Constructor called when opening existing shared memory * Constructor called when opening existing shared memory
* @param multi_id multi detector shared memory id * @param multi_id multi detector shared memory id
* @param id sls detector id (position in detectors list) * @param id sls detector id (position in detectors list)
* @param verify true to verify if shared memory version matches existing one * @param verify true to verify if shared memory version matches existing
* one
*/ */
explicit slsDetector(int multi_id = 0, explicit slsDetector(int multi_id = 0, int det_id = 0, bool verify = true);
int det_id = 0,
bool verify = true);
/** /**
* Destructor * Destructor
@ -257,7 +257,8 @@ class slsDetector : public virtual slsDetectorDefs{
virtual ~slsDetector(); virtual ~slsDetector();
/** /**
* Returns false if it cannot get fixed pattern from an old version of shm (hostname, type), else true * Returns false if it cannot get fixed pattern from an old version of shm
* (hostname, type), else true
*/ */
bool isFixedPatternSharedMemoryCompatible(); bool isFixedPatternSharedMemoryCompatible();
@ -281,71 +282,14 @@ class slsDetector : public virtual slsDetectorDefs{
/** /**
* Get Receiver Software version * Get Receiver Software version
*/ */
int64_t getReceiverSoftwareVersion(); int64_t getReceiverSoftwareVersion() const;
/**
* Send function parameters to detector (control server)
* @param fnum function enum
* @param args argument pointer
* @param args_size size of argument
* @param retval return pointers
* @param retval_size size of return value
*/
void sendToDetector(int fnum, const void *args, size_t args_size,
void *retval, size_t retval_size);
template <typename Arg, typename Ret>
void sendToDetector(int fnum, const Arg &args, Ret &retval);
template<typename Arg>
void sendToDetector(int fnum, const Arg &args, std::nullptr_t);
template<typename Ret>
void sendToDetector(int fnum, std::nullptr_t, Ret & retval);
void sendToDetector(int fnum);
/**
* Send function parameters to detector (stop server)
* @param fnum function enum
* @param args argument pointer
* @param args_size size of argument
* @param retval return pointers
* @param retval_size size of return value
*/
void sendToDetectorStop(int fnum, const void *args, size_t args_size,
void *retval, size_t retval_size);
template <typename Arg, typename Ret>
void sendToDetectorStop(int fnum, const Arg &args, Ret &retval);
template<typename Arg>
void sendToDetectorStop(int fnum, const Arg &args, std::nullptr_t);
template<typename Ret>
void sendToDetectorStop(int fnum, std::nullptr_t, Ret & retval);
void sendToDetectorStop(int fnum);
/**
* Send function parameters to receiver
* @param fnum function enum
* @param args argument pointer
* @param args_size size of argument
* @param retval return pointers
* @param retval_size size of return value
*/
void sendToReceiver(int fnum, const void *args, size_t args_size,
void *retval, size_t retval_size);
template<typename Arg, typename Ret>
void sendToReceiver(int fnum, const Arg& args, Ret& retval);
template<typename Arg>
void sendToReceiver(int fnum, const Arg& args, std::nullptr_t);
template<typename Ret>
void sendToReceiver(int fnum, std::nullptr_t, Ret& retval);
void sendToReceiver(int fnum);
/** /**
* Free shared memory and delete shared memory structure * Free shared memory and delete shared memory structure
* occupied by the sharedSlsDetector structure * occupied by the sharedSlsDetector structure
* Is only safe to call if one deletes the slsDetector object afterward * Is only safe to call if one deletes the slsDetector object afterward
* and frees multi shared memory/updates thisMultiDetector->numberOfDetectors * and frees multi shared memory/updates
* thisMultiDetector->numberOfDetectors
*/ */
void freeSharedMemory(); void freeSharedMemory();
@ -365,7 +309,8 @@ class slsDetector : public virtual slsDetectorDefs{
* Get detector type by connecting to the detector * Get detector type by connecting to the detector
* @returns detector tpe or GENERIC if failed * @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 * Get Detector type from shared memory variable
@ -406,8 +351,8 @@ class slsDetector : public virtual slsDetectorDefs{
int getTotalNumberOfChannels(dimension d) const; int getTotalNumberOfChannels(dimension d) const;
/** /**
* Returns the total number of channels of in dimension d including gap pixels * Returns the total number of channels of in dimension d including gap
* from shared memory * pixels from shared memory
* @param d dimension d * @param d dimension d
* @returns the total number of channels including gap pixels in dimension d * @returns the total number of channels including gap pixels in dimension d
* including gap pixels * including gap pixels
@ -421,7 +366,8 @@ class slsDetector : public virtual slsDetectorDefs{
int getNChans() const; int getNChans() const;
/** /**
* returns the number of channels per chip in dimension d from shared memory (Mythen) * returns the number of channels per chip in dimension d from shared memory
* (Mythen)
* @param d dimension d * @param d dimension d
* @returns number of channels per chip in dimension d * @returns number of channels per chip in dimension d
*/ */
@ -434,7 +380,8 @@ class slsDetector : public virtual slsDetectorDefs{
int getNChips() const; int getNChips() const;
/** /**
* returns the number of chips per module in dimension d from shared memory (Mythen) * returns the number of chips per module in dimension d from shared memory
* (Mythen)
* @param d dimension d * @param d dimension d
* @returns number of chips per module in dimension d * @returns number of chips per module in dimension d
*/ */
@ -547,18 +494,18 @@ class slsDetector : public virtual slsDetectorDefs{
detectorSettings getSettings(); detectorSettings getSettings();
/** /**
* Load detector settings from the settings file picked from the trimdir/settingsdir * Load detector settings from the settings file picked from the
* Eiger only stores in shared memory ( a get will overwrite this) * trimdir/settingsdir Eiger only stores in shared memory ( a get will
* For Eiger, one must use threshold * overwrite this) For Eiger, one must use threshold Gotthard, Propix,
* Gotthard, Propix, Jungfrau and Moench only sends the settings enum to the detector * Jungfrau and Moench only sends the settings enum to the detector
* @param isettings settings * @param isettings settings
* @returns current settings * @returns current settings
*/ */
detectorSettings setSettings(detectorSettings isettings); detectorSettings setSettings(detectorSettings isettings);
/** /**
* Send detector settings only (set only for Jungfrau, Gotthard, Moench, get for all) * Send detector settings only (set only for Jungfrau, Gotthard, Moench, get
* Only the settings enum is sent to the detector, where it will * for all) Only the settings enum is sent to the detector, where it will
* initialize al the dacs already hard coded in the detector server * initialize al the dacs already hard coded in the detector server
* @param isettings settings * @param isettings settings
* @returns current settings * @returns current settings
@ -579,7 +526,8 @@ class slsDetector : public virtual slsDetectorDefs{
* @param tb 1 to include trimbits, 0 to exclude * @param tb 1 to include trimbits, 0 to exclude
* @returns current threshold value in ev (-1 failed) * @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) * Set threshold energy and settings (Eiger only)
@ -587,7 +535,8 @@ class slsDetector : public virtual slsDetectorDefs{
* @param isettings ev. change settings * @param isettings ev. change settings
* @param tb 1 to include trimbits, 0 to exclude * @param tb 1 to include trimbits, 0 to exclude
*/ */
void setThresholdEnergyAndSettings(int e_eV, detectorSettings isettings, int tb = 1); void setThresholdEnergyAndSettings(int e_eV, detectorSettings isettings,
int tb = 1);
/** /**
* Returns the detector trimbit/settings directory \sa sharedSlsDetector * Returns the detector trimbit/settings directory \sa sharedSlsDetector
@ -620,7 +569,7 @@ class slsDetector : public virtual slsDetectorDefs{
* Get run status of the detector * Get run status of the detector
* @returns the status of the detector * @returns the status of the detector
*/ */
runStatus getRunStatus(); runStatus getRunStatus() const;
/** /**
* Prepares detector for acquisition (Eiger) * Prepares detector for acquisition (Eiger)
@ -643,12 +592,14 @@ class slsDetector : public virtual slsDetectorDefs{
void sendSoftwareTrigger(); void sendSoftwareTrigger();
/** /**
* Start detector acquisition and read all data (Blocking until end of acquisition) * Start detector acquisition and read all data (Blocking until end of
* acquisition)
*/ */
void startAndReadAll(); void startAndReadAll();
/** /**
* Start readout (without exposure or interrupting exposure) (Eiger store in ram) * Start readout (without exposure or interrupting exposure) (Eiger store in
* ram)
*/ */
void startReadOut(); void startReadOut();
@ -678,31 +629,37 @@ class slsDetector : public virtual slsDetectorDefs{
* Set/get timer value (not all implemented for all detectors) * Set/get timer value (not all implemented for all detectors)
* @param index timer index * @param index timer index
* @param t time in ns or number of...(e.g. frames, gates, probes) * @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) * @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) * Set/get timer value left in acquisition (not all implemented for all
* detectors)
* @param index timer index * @param index timer index
* @param t time in ns or number of...(e.g. frames, gates, probes) * @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) * @returns timer set value in ns or number of...(e.g. frames, gates,
* probes)
*/ */
int64_t getTimeLeft(timerIndex index); int64_t getTimeLeft(timerIndex index) const;
/** /**
* Set speed * Set speed
* @param sp speed type (clkdivider option for Jungfrau and Eiger, * @param sp speed type (clkdivider option for Jungfrau and Eiger,
* adcphase for Gotthard, others for CTB & Moench) * adcphase for Gotthard, others for CTB & Moench)
* @param value (clkdivider 0,1,2 for full, half and quarter speed). Other values check manual * @param value (clkdivider 0,1,2 for full, half and quarter speed). Other
* @param mode 0 for shift, 1 for degrees. relevant only for speed type adcphase and dbit phase * values check manual
* @param mode 0 for shift, 1 for degrees. relevant only for speed type
* adcphase and dbit phase
* @returns value of speed set * @returns value of speed set
*/ */
int setSpeed(speedVariable sp, int value = -1, int mode = 0); int setSpeed(speedVariable sp, int value = -1, int mode = 0);
/** /**
* Set/get dynamic range and updates the number of dataBytes * Set/get dynamic range and updates the number of dataBytes
* (Eiger: If i is 32, also sets clkdivider to 2, if 16, sets clkdivider to 1) * (Eiger: If i is 32, also sets clkdivider to 2, if 16, sets clkdivider to
* 1)
* @param i dynamic range (-1 get) * @param i dynamic range (-1 get)
* @returns current dynamic range * @returns current dynamic range
* \sa sharedSlsDetector * \sa sharedSlsDetector
@ -733,7 +690,8 @@ class slsDetector : public virtual slsDetectorDefs{
/** /**
* Get adc value * Get adc value
* @param index adc(DAC) index * @param index adc(DAC) index
* @returns current adc value (temperature for eiger and jungfrau in millidegrees) * @returns current adc value (temperature for eiger and jungfrau in
* millidegrees)
*/ */
int getADC(dacIndex index); int getADC(dacIndex index);
@ -742,18 +700,22 @@ class slsDetector : public virtual slsDetectorDefs{
* @param pol timing mode (-1 gets) * @param pol timing mode (-1 gets)
* @returns current timing mode * @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) * Set/get external signal flags (to specify triggerinrising edge etc)
* (Gotthard, Mythen)
* @param pol external signal flag (-1 gets) * @param pol external signal flag (-1 gets)
* @returns current timing mode * @returns current timing mode
*/ */
externalSignalFlag setExternalSignalFlags(externalSignalFlag pol = GET_EXTERNAL_SIGNAL_FLAG); externalSignalFlag
setExternalSignalFlags(externalSignalFlag pol = GET_EXTERNAL_SIGNAL_FLAG);
/** /**
* Set/get readout flags (Eiger, Mythen) * Set/get readout flags (Eiger, Mythen)
* @param flag readout flag (Eiger options: parallel, nonparallel, safe etc.) (-1 gets) * @param flag readout flag (Eiger options: parallel, nonparallel, safe
* etc.) (-1 gets)
* @returns readout flag * @returns readout flag
*/ */
int setReadOutFlags(readOutFlags flag = GET_READOUT_FLAGS); int setReadOutFlags(readOutFlags flag = GET_READOUT_FLAGS);
@ -802,7 +764,8 @@ class slsDetector : public virtual slsDetectorDefs{
uint32_t clearBit(uint32_t addr, int n); uint32_t clearBit(uint32_t addr, int n);
/** /**
* Validates the format of the detector MAC address and sets it \sa sharedSlsDetector * Validates the format of the detector MAC address and sets it \sa
* sharedSlsDetector
* @param detectorMAC detector MAC address * @param detectorMAC detector MAC address
* @returns the detector MAC address * @returns the detector MAC address
*/ */
@ -815,7 +778,8 @@ class slsDetector : public virtual slsDetectorDefs{
sls::MacAddr getDetectorMAC(); sls::MacAddr getDetectorMAC();
/** /**
* Validates the format of the detector MAC address (bottom half) and sets it (Jungfrau only) * Validates the format of the detector MAC address (bottom half) and sets
* it (Jungfrau only)
* @param detectorMAC detector MAC address (bottom half) * @param detectorMAC detector MAC address (bottom half)
* @returns the detector MAC address (bottom half) * @returns the detector MAC address (bottom half)
*/ */
@ -828,7 +792,8 @@ class slsDetector : public virtual slsDetectorDefs{
sls::MacAddr getDetectorMAC2(); sls::MacAddr getDetectorMAC2();
/** /**
* Validates the format of the detector IP address and sets it \sa sharedSlsDetector * Validates the format of the detector IP address and sets it \sa
* sharedSlsDetector
* @param detectorIP detector IP address * @param detectorIP detector IP address
* @returns the detector IP address * @returns the detector IP address
*/ */
@ -841,7 +806,8 @@ class slsDetector : public virtual slsDetectorDefs{
sls::IpAddr getDetectorIP() const; sls::IpAddr getDetectorIP() const;
/** /**
* Validates the format of the detector IP address (bottom half) and sets it (Jungfrau only) * Validates the format of the detector IP address (bottom half) and sets it
* (Jungfrau only)
* @param detectorIP detector IP address (bottom half) * @param detectorIP detector IP address (bottom half)
* @returns the detector IP address (bottom half) * @returns the detector IP address (bottom half)
*/ */
@ -855,8 +821,9 @@ class slsDetector : public virtual slsDetectorDefs{
/** /**
* Validates and sets the receiver. * Validates and sets the receiver.
* Also updates the receiver with all the shared memory parameters significant for the receiver * Also updates the receiver with all the shared memory parameters
* Also configures the detector to the receiver as UDP destination * significant for the receiver Also configures the detector to the receiver
* as UDP destination
* @param receiver receiver hostname or IP address * @param receiver receiver hostname or IP address
* @returns the receiver IP address from shared memory * @returns the receiver IP address from shared memory
*/ */
@ -869,7 +836,8 @@ class slsDetector : public virtual slsDetectorDefs{
std::string getReceiverHostname() const; std::string getReceiverHostname() const;
/** /**
* Validates the format of the receiver UDP IP address and sets it \sa sharedSlsDetector * Validates the format of the receiver UDP IP address and sets it \sa
* sharedSlsDetector
* @param udpip receiver UDP IP address * @param udpip receiver UDP IP address
* @returns the receiver UDP IP address * @returns the receiver UDP IP address
*/ */
@ -882,7 +850,8 @@ class slsDetector : public virtual slsDetectorDefs{
sls::IpAddr getReceiverUDPIP() const; sls::IpAddr getReceiverUDPIP() const;
/** /**
* Validates the format of the receiver UDP IP address (bottom half) and sets it(Jungfrau only) * Validates the format of the receiver UDP IP address (bottom half) and
* sets it(Jungfrau only)
* @param udpip receiver UDP IP address (bottom half) * @param udpip receiver UDP IP address (bottom half)
* @returns the receiver UDP IP address (bottom half) * @returns the receiver UDP IP address (bottom half)
*/ */
@ -895,7 +864,8 @@ class slsDetector : public virtual slsDetectorDefs{
sls::IpAddr getReceiverUDPIP2() const; sls::IpAddr getReceiverUDPIP2() const;
/** /**
* Validates the format of the receiver UDP MAC address and sets it \sa sharedSlsDetector * Validates the format of the receiver UDP MAC address and sets it \sa
* sharedSlsDetector
* @param udpmac receiver UDP MAC address * @param udpmac receiver UDP MAC address
* @returns the receiver UDP MAC address * @returns the receiver UDP MAC address
*/ */
@ -908,7 +878,8 @@ class slsDetector : public virtual slsDetectorDefs{
sls::MacAddr getReceiverUDPMAC() const; sls::MacAddr getReceiverUDPMAC() const;
/** /**
* Validates the format of the receiver UDP MAC address (bottom half) and sets it (Jungfrau only) * Validates the format of the receiver UDP MAC address (bottom half) and
* sets it (Jungfrau only)
* @param udpmac receiver UDP MAC address (bottom half) * @param udpmac receiver UDP MAC address (bottom half)
* @returns the receiver UDP MAC address (bottom half) * @returns the receiver UDP MAC address (bottom half)
*/ */
@ -934,40 +905,46 @@ class slsDetector : public virtual slsDetectorDefs{
int getReceiverUDPPort() const; int getReceiverUDPPort() const;
/** /**
* Sets the receiver UDP port 2\sa sharedSlsDetector (Eiger and Jungfrau only) * Sets the receiver UDP port 2\sa sharedSlsDetector (Eiger and Jungfrau
* only)
* @param udpport receiver UDP port 2 * @param udpport receiver UDP port 2
* @returns the receiver UDP port 2 * @returns the receiver UDP port 2
*/ */
int setReceiverUDPPort2(int udpport); int setReceiverUDPPort2(int udpport);
/** /**
* Returns the receiver UDP port 2 of same interface\sa sharedSlsDetector (Eiger and Jungfrau only) * Returns the receiver UDP port 2 of same interface\sa sharedSlsDetector
* (Eiger and Jungfrau only)
* @returns the receiver UDP port 2 of same interface * @returns the receiver UDP port 2 of same interface
*/ */
int getReceiverUDPPort2() const; int getReceiverUDPPort2() const;
/** /**
* Sets the number of UDP interfaces to stream data from detector (Jungfrau only) * Sets the number of UDP interfaces to stream data from detector (Jungfrau
* only)
* @param n number of interfaces. Options 1 or 2. * @param n number of interfaces. Options 1 or 2.
* @returns the number of interfaces * @returns the number of interfaces
*/ */
int setNumberofUDPInterfaces(int n); int setNumberofUDPInterfaces(int n);
/** /**
* Returns the number of UDP interfaces to stream data from detector (Jungfrau only) * Returns the number of UDP interfaces to stream data from detector
* (Jungfrau only)
* @returns the number of interfaces * @returns the number of interfaces
*/ */
int getNumberofUDPInterfaces() const; int getNumberofUDPInterfaces() const;
/** /**
* Selects the UDP interfaces to stream data from detector. Effective only when number of interfaces is 1. (Jungfrau only) * Selects the UDP interfaces to stream data from detector. Effective only
* when number of interfaces is 1. (Jungfrau only)
* @param n selected interface. Options 1 or 2. * @param n selected interface. Options 1 or 2.
* @returns the interface selected * @returns the interface selected
*/ */
int selectUDPInterface(int n); int selectUDPInterface(int n);
/** /**
* Returns the UDP interfaces to stream data from detector. Effective only when number of interfaces is 1. (Jungfrau only) * Returns the UDP interfaces to stream data from detector. Effective only
* when number of interfaces is 1. (Jungfrau only)
* @returns the interface selected * @returns the interface selected
*/ */
int getSelectedUDPInterface() const; int getSelectedUDPInterface() const;
@ -1004,7 +981,8 @@ class slsDetector : public virtual slsDetectorDefs{
/** /**
* Returns the client zmq ip \sa sharedSlsDetector * Returns the client zmq ip \sa sharedSlsDetector
* @returns the client zmq ip, returns "none" if default setting and no custom ip set * @returns the client zmq ip, returns "none" if default setting and no
* custom ip set
*/ */
std::string getClientStreamingIP(); std::string getClientStreamingIP();
@ -1016,7 +994,8 @@ class slsDetector : public virtual slsDetectorDefs{
/** /**
* Returns the receiver zmq ip \sa sharedSlsDetector * Returns the receiver zmq ip \sa sharedSlsDetector
* @returns the receiver zmq ip, returns "none" if default setting and no custom ip set * @returns the receiver zmq ip, returns "none" if default setting and no
* custom ip set
*/ */
std::string getReceiverStreamingIP(); std::string getReceiverStreamingIP();
@ -1032,24 +1011,28 @@ class slsDetector : public virtual slsDetectorDefs{
/** /**
* Sets the additional json header\sa sharedSlsDetector * Sets the additional json header\sa sharedSlsDetector
* @param jsonheader additional json header * @param jsonheader additional json header
* @returns additional json header, returns "none" if default setting and no custom ip set * @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 * Returns the additional json header \sa sharedSlsDetector
* @returns the additional json header, returns "none" if default setting and no custom ip set * @returns the additional json header, returns "none" if default setting
* and no custom ip set
*/ */
std::string getAdditionalJsonHeader(); std::string getAdditionalJsonHeader();
/** /**
* Sets the value for the additional json header parameter if found, else append it * Sets the value for the additional json header parameter if found, else
* append it
* @param key additional json header parameter * @param key additional json header parameter
* @param value additional json header parameter value (cannot be empty) * @param value additional json header parameter value (cannot be empty)
* @returns the additional json header parameter value, * @returns the additional json header parameter value,
* empty if no parameter found in additional json header * 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 * Returns the additional json header parameter value
@ -1076,7 +1059,7 @@ class slsDetector : public virtual slsDetectorDefs{
* Returns the receiver real UDP socket buffer size\sa sharedSlsDetector * Returns the receiver real UDP socket buffer size\sa sharedSlsDetector
* @returns the receiver real UDP socket buffer size * @returns the receiver real UDP socket buffer size
*/ */
int64_t getReceiverRealUDPSocketBufferSize(); int64_t getReceiverRealUDPSocketBufferSize() const;
/** /**
* Execute a digital test (Gotthard, Mythen) * Execute a digital test (Gotthard, Mythen)
@ -1122,7 +1105,8 @@ class slsDetector : public virtual slsDetectorDefs{
/** /**
* Set/get counter bit in detector (Gotthard) * Set/get counter bit in detector (Gotthard)
* @param i is -1 to get, 0 to reset and any other value to set the counter bit * @param i is -1 to get, 0 to reset and any other value to set the counter
* bit
* @returns the counter bit in detector * @returns the counter bit in detector
*/ */
int setCounterBit(int cb = -1); int setCounterBit(int cb = -1);
@ -1136,11 +1120,12 @@ class slsDetector : public virtual slsDetectorDefs{
void setROI(int n = -1, ROI roiLimits[] = nullptr); void setROI(int n = -1, ROI roiLimits[] = nullptr);
/** /**
* Get ROI from each detector and convert it to the multi detector scale (Gotthard) * Get ROI from each detector and convert it to the multi detector scale
* (Gotthard)
* @param n number of rois * @param n number of rois
* @returns OK or FAIL * @returns OK or FAIL
*/ */
const slsDetectorDefs::ROI * getROI(int &n); const slsDetectorDefs::ROI *getROI(int &n);
/** /**
* Returns number of rois * Returns number of rois
@ -1224,7 +1209,7 @@ class slsDetector : public virtual slsDetectorDefs{
* @param detPos -1 for all detectors in list or specific detector position * @param detPos -1 for all detectors in list or specific detector position
* @returns external sampling enable * @returns external sampling enable
*/ */
std::vector<int> getReceiverDbitList(); std::vector<int> getReceiverDbitList() const;
/** /**
* Set digital data offset in bytes (CTB only) * Set digital data offset in bytes (CTB only)
@ -1240,7 +1225,8 @@ class slsDetector : public virtual slsDetectorDefs{
int getReceiverDbitOffset(); int getReceiverDbitOffset();
/** /**
* Write to ADC register (Gotthard, Jungfrau, ChipTestBoard). For expert users * Write to ADC register (Gotthard, Jungfrau, ChipTestBoard). For expert
* users
* @param addr address of adc register * @param addr address of adc register
* @param val value * @param val value
*/ */
@ -1255,8 +1241,10 @@ class slsDetector : public virtual slsDetectorDefs{
/** /**
* Set deactivated Receiver padding mode (Eiger only) * Set deactivated Receiver padding mode (Eiger only)
* @param padding padding option for deactivated receiver. Can be 1 (padding), 0 (no padding), -1 (gets) * @param padding padding option for deactivated receiver. Can be 1
* @returns 1 (padding), 0 (no padding), -1 (inconsistent values) for padding option * (padding), 0 (no padding), -1 (gets)
* @returns 1 (padding), 0 (no padding), -1 (inconsistent values) for
* padding option
*/ */
bool setDeactivatedRxrPaddingMode(int padding = -1); bool setDeactivatedRxrPaddingMode(int padding = -1);
@ -1298,7 +1286,7 @@ class slsDetector : public virtual slsDetectorDefs{
* @param vector os trimmed energies * @param vector os trimmed energies
* @returns number of trim energies * @returns number of trim energies
*/ */
int setTrimEn(std::vector<int> energies={}); int setTrimEn(std::vector<int> energies = {});
/** /**
* Returns a vector with the trimmed energies (Eiger) * Returns a vector with the trimmed energies (Eiger)
@ -1373,7 +1361,8 @@ class slsDetector : public virtual slsDetectorDefs{
* @param fname name of detector server binary * @param fname name of detector server binary
* @param hostname name of pc to tftp from * @param hostname name of pc to tftp from
*/ */
void copyDetectorServer(const std::string &fname, const std::string &hostname); void copyDetectorServer(const std::string &fname,
const std::string &hostname);
/** /**
* Reboot detector controller (blackfin/ powerpc) * Reboot detector controller (blackfin/ powerpc)
@ -1394,7 +1383,6 @@ class slsDetector : public virtual slsDetectorDefs{
*/ */
int setAutoComparatorDisableMode(int ival = -1); int setAutoComparatorDisableMode(int ival = -1);
/** /**
* Get trimbit filename with path for settings and energy * Get trimbit filename with path for settings and energy
* *
@ -1409,11 +1397,12 @@ class slsDetector : public virtual slsDetectorDefs{
* @param tb 1 to include trimbits, 0 to exclude (used for eiger) * @param tb 1 to include trimbits, 0 to exclude (used for eiger)
* \sa ::sls_detector_module * \sa ::sls_detector_module
*/ */
void setModule(sls_detector_module& module, int tb = 1); void setModule(sls_detector_module &module, int tb = 1);
/** /**
* Get module structure from detector (all detectors) * Get module structure from detector (all detectors)
* @returns pointer to module structure (which has been created and must then be deleted) * @returns pointer to module structure (which has been created and must
* then be deleted)
*/ */
sls_detector_module getModule(); sls_detector_module getModule();
@ -1466,7 +1455,7 @@ class slsDetector : public virtual slsDetectorDefs{
* Returns the IP of the last client connecting to the receiver * Returns the IP of the last client connecting to the receiver
* @returns the IP of the last client connecting to the receiver * @returns the IP of the last client connecting to the receiver
*/ */
std::string getReceiverLastClientIP(); std::string getReceiverLastClientIP() const;
/** /**
* Exits the receiver TCP server * Exits the receiver TCP server
@ -1544,7 +1533,8 @@ class slsDetector : public virtual slsDetectorDefs{
* @param f frames discard policy * @param f frames discard policy
* @returns frames discard policy set in receiver * @returns frames discard policy set in receiver
*/ */
frameDiscardPolicy setReceiverFramesDiscardPolicy(frameDiscardPolicy f = GET_FRAME_DISCARD_POLICY); frameDiscardPolicy setReceiverFramesDiscardPolicy(
frameDiscardPolicy f = GET_FRAME_DISCARD_POLICY);
/** /**
* Sets the partial frames padding enable in receiver * Sets the partial frames padding enable in receiver
@ -1600,19 +1590,19 @@ class slsDetector : public virtual slsDetectorDefs{
* Gets the status of the listening mode of receiver * Gets the status of the listening mode of receiver
* @returns status * @returns status
*/ */
runStatus getReceiverStatus(); runStatus getReceiverStatus() const;
/** /**
* Gets the number of frames caught by receiver * Gets the number of frames caught by receiver
* @returns number of frames caught by receiver * @returns number of frames caught by receiver
*/ */
int getFramesCaughtByReceiver(); int getFramesCaughtByReceiver() const;
/** /**
* Gets the current frame index of receiver * Gets the current frame index of receiver
* @returns current frame index of receiver * @returns current frame index of receiver
*/ */
uint64_t getReceiverCurrentFrameIndex(); uint64_t getReceiverCurrentFrameIndex() const;
/** /**
* Resets framescaught in receiver * Resets framescaught in receiver
@ -1662,7 +1652,8 @@ class slsDetector : public virtual slsDetectorDefs{
/** /**
* (previously setReadReceiverFrequency) * (previously setReadReceiverFrequency)
* Sets the receiver streaming frequency * Sets the receiver streaming frequency
* @param freq nth frame streamed out, if 0, streamed out at a timer of 200 ms * @param freq nth frame streamed out, if 0, streamed out at a timer of 200
* ms
* @param detPos -1 for all detectors in list or specific detector position * @param detPos -1 for all detectors in list or specific detector position
* @returns receiver streaming frequency * @returns receiver streaming frequency
*/ */
@ -1738,7 +1729,8 @@ class slsDetector : public virtual slsDetectorDefs{
/** /**
* Writes a pattern word (CTB/ Moench) * Writes a pattern word (CTB/ Moench)
* @param addr address of the word * @param addr address of the word
* @param word 64bit word to be written, -1 reads the addr (same as executing the pattern) * @param word 64bit word to be written, -1 reads the addr (same as
* executing the pattern)
* @returns actual value * @returns actual value
*/ */
uint64_t setPatternWord(int addr, uint64_t word); uint64_t setPatternWord(int addr, uint64_t word);
@ -1751,7 +1743,8 @@ class slsDetector : public virtual slsDetectorDefs{
* @param n number of loops for level 0-2, -1 gets * @param n number of loops for level 0-2, -1 gets
* @returns array of start addr, stop addr and number of loops * @returns array of start addr, stop addr and number of loops
*/ */
std::array<int, 3> setPatternLoops(int level = -1, int start = -1, int stop = -1, int n = -1); std::array<int, 3> setPatternLoops(int level = -1, int start = -1,
int stop = -1, int n = -1);
/** /**
* Sets the wait address (CTB/ Moench) * Sets the wait address (CTB/ Moench)
@ -1782,13 +1775,15 @@ class slsDetector : public virtual slsDetectorDefs{
uint64_t getPatternMask(); uint64_t getPatternMask();
/** /**
* Selects the bits that the mask will be applied to for every pattern (CTB/ Moench) * Selects the bits that the mask will be applied to for every pattern (CTB/
* Moench)
* @param mask mask to select bits * @param mask mask to select bits
*/ */
void setPatternBitMask(uint64_t mask); void setPatternBitMask(uint64_t mask);
/** /**
* Gets the bits that the mask will be applied to for every pattern (CTB/ Moench) * Gets the bits that the mask will be applied to for every pattern (CTB/
* Moench)
* @returns mask of bits selected * @returns mask of bits selected
*/ */
uint64_t getPatternBitMask(); uint64_t getPatternBitMask();
@ -1808,6 +1803,98 @@ class slsDetector : public virtual slsDetectorDefs{
void setDigitalIODelay(uint64_t pinMask, int delay); void setDigitalIODelay(uint64_t pinMask, int delay);
private: private:
/**
* Send function parameters to detector (control server)
* @param fnum function enum
* @param args argument pointer
* @param args_size size of argument
* @param retval return pointers
* @param retval_size size of return value
*/
void sendToDetector(int fnum, const void *args, size_t args_size,
void *retval, size_t retval_size);
template <typename Arg, typename Ret>
void sendToDetector(int fnum, const Arg &args, Ret &retval);
template <typename Arg>
void sendToDetector(int fnum, const Arg &args, std::nullptr_t);
template <typename Ret>
void sendToDetector(int fnum, std::nullptr_t, Ret &retval);
void sendToDetector(int fnum);
/**
* Send function parameters to detector (stop server)
* @param fnum function enum
* @param args argument pointer
* @param args_size size of argument
* @param retval return pointers
* @param retval_size size of return value
*/
void sendToDetectorStop(int fnum, const void *args, size_t args_size,
void *retval, size_t retval_size);
void sendToDetectorStop(int fnum, const void *args, size_t args_size,
void *retval, size_t retval_size) const;
template <typename Arg, typename Ret>
void sendToDetectorStop(int fnum, const Arg &args, Ret &retval);
template <typename Arg, typename Ret>
void sendToDetectorStop(int fnum, const Arg &args, Ret &retval) const;
template <typename Arg>
void sendToDetectorStop(int fnum, const Arg &args, std::nullptr_t);
template <typename Arg>
void sendToDetectorStop(int fnum, const Arg &args, std::nullptr_t) const;
template <typename Ret>
void sendToDetectorStop(int fnum, std::nullptr_t, Ret &retval);
template <typename Ret>
void sendToDetectorStop(int fnum, std::nullptr_t, Ret &retval) const;
void sendToDetectorStop(int fnum);
void sendToDetectorStop(int fnum) const;
/**
* Send function parameters to receiver
* @param fnum function enum
* @param args argument pointer
* @param args_size size of argument
* @param retval return pointers
* @param retval_size size of return value
*/
void sendToReceiver(int fnum, const void *args, size_t args_size,
void *retval, size_t retval_size);
void sendToReceiver(int fnum, const void *args, size_t args_size,
void *retval, size_t retval_size) const;
template <typename Arg, typename Ret>
void sendToReceiver(int fnum, const Arg &args, Ret &retval);
template <typename Arg, typename Ret>
void sendToReceiver(int fnum, const Arg &args, Ret &retval) const;
template <typename Arg>
void sendToReceiver(int fnum, const Arg &args, std::nullptr_t);
template <typename Arg>
void sendToReceiver(int fnum, const Arg &args, std::nullptr_t) const;
template <typename Ret>
void sendToReceiver(int fnum, std::nullptr_t, Ret &retval);
template <typename Ret>
void sendToReceiver(int fnum, std::nullptr_t, Ret &retval) const;
void sendToReceiver(int fnum);
void sendToReceiver(int fnum) const;
/** /**
* Get Detector Type from Shared Memory (opening shm without verifying size) * Get Detector Type from Shared Memory (opening shm without verifying size)
* @param multi_id multi detector Id * @param multi_id multi detector Id
@ -1838,14 +1925,14 @@ class slsDetector : public virtual slsDetectorDefs{
* @param myMod module structure to send * @param myMod module structure to send
* @returns number of bytes sent to the detector * @returns number of bytes sent to the detector
*/ */
int sendModule(sls_detector_module *myMod, sls::ClientSocket& client); int sendModule(sls_detector_module *myMod, sls::ClientSocket &client);
/** /**
* Receive a sls_detector_module structure over socket * Receive a sls_detector_module structure over socket
* @param myMod module structure to receive * @param myMod module structure to receive
* @returns number of bytes received from the detector * @returns number of bytes received from the detector
*/ */
int receiveModule(sls_detector_module *myMod, sls::ClientSocket& client); int receiveModule(sls_detector_module *myMod, sls::ClientSocket &client);
/** /**
* Get MAC from the receiver using udpip and * Get MAC from the receiver using udpip and
@ -1854,10 +1941,12 @@ class slsDetector : public virtual slsDetectorDefs{
void setUDPConnection(); void setUDPConnection();
/* /*
* Template function to do linear interpolation between two points (Eiger only) * Template function to do linear interpolation between two points (Eiger
* only)
*/ */
template <typename E, typename V> template <typename E, typename V>
V linearInterpolation(const E x, const E x1, const E x2, const V y1, const V y2) { 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 k = static_cast<double>(y2 - y1) / (x2 - x1);
double m = y1 - k * x1; double m = y1 - k * x1;
int y = round(k * x + m); int y = round(k * x + m);
@ -1872,11 +1961,13 @@ class slsDetector : public virtual slsDetectorDefs{
* @param e1 reference trim value * @param e1 reference trim value
* @param e2 reference trim value * @param e2 reference trim value
* @param tb 1 to include trimbits, 0 to exclude (used for eiger) * @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 * @returns the pointer to the module structure with interpolated values or
* NULL if error
*/ */
sls_detector_module interpolateTrim( sls_detector_module interpolateTrim(sls_detector_module *a,
sls_detector_module *a, sls_detector_module *b, const int energy, sls_detector_module *b,
const int e1, const int e2, int tb = 1); const int energy, const int e1,
const int e2, int tb = 1);
/** /**
* reads a trim/settings file * reads a trim/settings file
@ -1894,7 +1985,7 @@ class slsDetector : public virtual slsDetectorDefs{
* @param fname name of the file to be written * @param fname name of the file to be written
* @param mod module structure which has to be written to file * @param mod module structure which has to be written to file
*/ */
void writeSettingsFile(const std::string &fname, sls_detector_module& mod); void writeSettingsFile(const std::string &fname, sls_detector_module &mod);
/** /**
* Get Names of dacs in settings file * Get Names of dacs in settings file
@ -1906,7 +1997,5 @@ class slsDetector : public virtual slsDetectorDefs{
const int detId; const int detId;
/** Shared Memory object */ /** Shared Memory object */
mutable sls::SharedMemory<sharedSlsDetector> shm{0,0}; mutable sls::SharedMemory<sharedSlsDetector> shm{0, 0};
}; };

View File

@ -116,7 +116,7 @@ int64_t slsDetector::getId(idMode mode) {
return retval; return retval;
} }
int64_t slsDetector::getReceiverSoftwareVersion() { int64_t slsDetector::getReceiverSoftwareVersion() const {
FILE_LOG(logDEBUG1) << "Getting receiver software version"; FILE_LOG(logDEBUG1) << "Getting receiver software version";
int64_t retval = -1; int64_t retval = -1;
if (shm()->useReceiverFlag) { if (shm()->useReceiverFlag) {
@ -158,6 +158,13 @@ void slsDetector::sendToDetector(int fnum) {
void slsDetector::sendToDetectorStop(int fnum, const void *args, void slsDetector::sendToDetectorStop(int fnum, const void *args,
size_t args_size, void *retval, size_t args_size, void *retval,
size_t retval_size) { size_t retval_size) {
static_cast<const slsDetector &>(*this).sendToDetectorStop(
fnum, args, args_size, retval, retval_size);
}
void slsDetector::sendToDetectorStop(int fnum, const void *args,
size_t args_size, void *retval,
size_t retval_size) const {
auto stop = DetectorSocket(shm()->hostname, shm()->stopPort); auto stop = DetectorSocket(shm()->hostname, shm()->stopPort);
stop.sendCommandThenRead(fnum, args, args_size, retval, retval_size); stop.sendCommandThenRead(fnum, args, args_size, retval, retval_size);
stop.close(); stop.close();
@ -168,31 +175,54 @@ void slsDetector::sendToDetectorStop(int fnum, const Arg &args, Ret &retval) {
sendToDetectorStop(fnum, &args, sizeof(args), &retval, sizeof(retval)); sendToDetectorStop(fnum, &args, sizeof(args), &retval, sizeof(retval));
} }
template <typename Arg, typename Ret>
void slsDetector::sendToDetectorStop(int fnum, const Arg &args,
Ret &retval) const {
sendToDetectorStop(fnum, &args, sizeof(args), &retval, sizeof(retval));
}
template <typename Arg> template <typename Arg>
void slsDetector::sendToDetectorStop(int fnum, const Arg &args, void slsDetector::sendToDetectorStop(int fnum, const Arg &args,
std::nullptr_t) { std::nullptr_t) {
sendToDetectorStop(fnum, &args, sizeof(args), nullptr, 0); sendToDetectorStop(fnum, &args, sizeof(args), nullptr, 0);
} }
template <typename Arg>
void slsDetector::sendToDetectorStop(int fnum, const Arg &args,
std::nullptr_t) const {
sendToDetectorStop(fnum, &args, sizeof(args), nullptr, 0);
}
template <typename Ret> template <typename Ret>
void slsDetector::sendToDetectorStop(int fnum, std::nullptr_t, Ret &retval) { void slsDetector::sendToDetectorStop(int fnum, std::nullptr_t, Ret &retval) {
sendToDetectorStop(fnum, nullptr, 0, &retval, sizeof(retval)); sendToDetectorStop(fnum, nullptr, 0, &retval, sizeof(retval));
} }
template <typename Ret>
void slsDetector::sendToDetectorStop(int fnum, std::nullptr_t,
Ret &retval) const {
sendToDetectorStop(fnum, nullptr, 0, &retval, sizeof(retval));
}
void slsDetector::sendToDetectorStop(int fnum) { void slsDetector::sendToDetectorStop(int fnum) {
sendToDetectorStop(fnum, nullptr, 0, nullptr, 0); sendToDetectorStop(fnum, nullptr, 0, nullptr, 0);
} }
void slsDetector::sendToDetectorStop(int fnum) const {
sendToDetectorStop(fnum, nullptr, 0, nullptr, 0);
}
void slsDetector::sendToReceiver(int fnum, const void *args, size_t args_size, void slsDetector::sendToReceiver(int fnum, const void *args, size_t args_size,
void *retval, size_t retval_size) { void *retval, size_t retval_size) {
auto receiver = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort); static_cast<const slsDetector &>(*this).sendToReceiver(
fnum, args, args_size, retval, retval_size);
}
auto ret = receiver.sendCommandThenRead(fnum, args, args_size, retval, void slsDetector::sendToReceiver(int fnum, const void *args, size_t args_size,
retval_size); void *retval, size_t retval_size) const {
auto receiver = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort);
receiver.sendCommandThenRead(fnum, args, args_size, retval, retval_size);
receiver.close(); receiver.close();
if (ret == FORCE_UPDATE) {
updateCachedReceiverVariables();
}
} }
template <typename Arg, typename Ret> template <typename Arg, typename Ret>
@ -200,20 +230,40 @@ void slsDetector::sendToReceiver(int fnum, const Arg &args, Ret &retval) {
sendToReceiver(fnum, &args, sizeof(args), &retval, sizeof(retval)); sendToReceiver(fnum, &args, sizeof(args), &retval, sizeof(retval));
} }
template <typename Arg, typename Ret>
void slsDetector::sendToReceiver(int fnum, const Arg &args, Ret &retval) const {
sendToReceiver(fnum, &args, sizeof(args), &retval, sizeof(retval));
}
template <typename Arg> template <typename Arg>
void slsDetector::sendToReceiver(int fnum, const Arg &args, std::nullptr_t) { void slsDetector::sendToReceiver(int fnum, const Arg &args, std::nullptr_t) {
sendToReceiver(fnum, &args, sizeof(args), nullptr, 0); sendToReceiver(fnum, &args, sizeof(args), nullptr, 0);
} }
template <typename Arg>
void slsDetector::sendToReceiver(int fnum, const Arg &args,
std::nullptr_t) const {
sendToReceiver(fnum, &args, sizeof(args), nullptr, 0);
}
template <typename Ret> template <typename Ret>
void slsDetector::sendToReceiver(int fnum, std::nullptr_t, Ret &retval) { void slsDetector::sendToReceiver(int fnum, std::nullptr_t, Ret &retval) {
sendToReceiver(fnum, nullptr, 0, &retval, sizeof(retval)); sendToReceiver(fnum, nullptr, 0, &retval, sizeof(retval));
} }
template <typename Ret>
void slsDetector::sendToReceiver(int fnum, std::nullptr_t, Ret &retval) const {
sendToReceiver(fnum, nullptr, 0, &retval, sizeof(retval));
}
void slsDetector::sendToReceiver(int fnum) { void slsDetector::sendToReceiver(int fnum) {
sendToReceiver(fnum, nullptr, 0, nullptr, 0); sendToReceiver(fnum, nullptr, 0, nullptr, 0);
} }
void slsDetector::sendToReceiver(int fnum) const {
sendToReceiver(fnum, nullptr, 0, nullptr, 0);
}
void slsDetector::freeSharedMemory() { void slsDetector::freeSharedMemory() {
if (shm.IsExisting()) { if (shm.IsExisting()) {
shm.RemoveSharedMemory(); shm.RemoveSharedMemory();
@ -1147,7 +1197,7 @@ void slsDetector::saveSettingsFile(const std::string &fname) {
writeSettingsFile(fn, myMod); writeSettingsFile(fn, myMod);
} }
slsDetectorDefs::runStatus slsDetector::getRunStatus() { slsDetectorDefs::runStatus slsDetector::getRunStatus() const {
runStatus retval = ERROR; runStatus retval = ERROR;
FILE_LOG(logDEBUG1) << "Getting status"; FILE_LOG(logDEBUG1) << "Getting status";
sendToDetectorStop(F_GET_RUN_STATUS, nullptr, retval); sendToDetectorStop(F_GET_RUN_STATUS, nullptr, retval);
@ -1404,7 +1454,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) {
return shm()->timerValue[index]; return shm()->timerValue[index];
} }
int64_t slsDetector::getTimeLeft(timerIndex index) { int64_t slsDetector::getTimeLeft(timerIndex index) const {
int64_t retval = -1; int64_t retval = -1;
FILE_LOG(logDEBUG1) << "Getting " << getTimerType(index) << " left"; FILE_LOG(logDEBUG1) << "Getting " << getTimerType(index) << " left";
sendToDetectorStop(F_GET_TIME_LEFT, index, retval); sendToDetectorStop(F_GET_TIME_LEFT, index, retval);
@ -1540,7 +1590,6 @@ bool slsDetector::getInterruptSubframe() {
return static_cast<bool>(retval); return static_cast<bool>(retval);
} }
uint32_t slsDetector::writeRegister(uint32_t addr, uint32_t val) { uint32_t slsDetector::writeRegister(uint32_t addr, uint32_t val) {
uint32_t args[]{addr, val}; uint32_t args[]{addr, val};
uint32_t retval = -1; uint32_t retval = -1;
@ -2115,7 +2164,7 @@ int64_t slsDetector::getReceiverUDPSocketBufferSize() {
return setReceiverUDPSocketBufferSize(); return setReceiverUDPSocketBufferSize();
} }
int64_t slsDetector::getReceiverRealUDPSocketBufferSize() { int64_t slsDetector::getReceiverRealUDPSocketBufferSize() const {
int64_t retval = -1; int64_t retval = -1;
FILE_LOG(logDEBUG1) << "Getting real UDP Socket Buffer size from receiver"; FILE_LOG(logDEBUG1) << "Getting real UDP Socket Buffer size from receiver";
if (shm()->useReceiverFlag) { if (shm()->useReceiverFlag) {
@ -2455,7 +2504,7 @@ void slsDetector::setReceiverDbitList(std::vector<int> list) {
} }
} }
std::vector<int> slsDetector::getReceiverDbitList() { std::vector<int> slsDetector::getReceiverDbitList() const {
sls::FixedCapacityContainer<int, MAX_RX_DBIT> retval; sls::FixedCapacityContainer<int, MAX_RX_DBIT> retval;
FILE_LOG(logDEBUG1) << "Getting Receiver Dbit List"; FILE_LOG(logDEBUG1) << "Getting Receiver Dbit List";
if (shm()->useReceiverFlag) { if (shm()->useReceiverFlag) {
@ -2896,7 +2945,7 @@ int slsDetector::lockReceiver(int lock) {
return retval; return retval;
} }
std::string slsDetector::getReceiverLastClientIP() { std::string slsDetector::getReceiverLastClientIP() const {
char retval[INET_ADDRSTRLEN]{}; char retval[INET_ADDRSTRLEN]{};
FILE_LOG(logDEBUG1) << "Getting last client ip to receiver server"; FILE_LOG(logDEBUG1) << "Getting last client ip to receiver server";
if (shm()->useReceiverFlag) { if (shm()->useReceiverFlag) {
@ -3200,7 +3249,7 @@ void slsDetector::stopReceiver() {
} }
} }
slsDetectorDefs::runStatus slsDetector::getReceiverStatus() { slsDetectorDefs::runStatus slsDetector::getReceiverStatus() const {
runStatus retval = ERROR; runStatus retval = ERROR;
FILE_LOG(logDEBUG1) << "Getting Receiver Status"; FILE_LOG(logDEBUG1) << "Getting Receiver Status";
if (shm()->useReceiverFlag) { if (shm()->useReceiverFlag) {
@ -3210,7 +3259,7 @@ slsDetectorDefs::runStatus slsDetector::getReceiverStatus() {
return retval; return retval;
} }
int slsDetector::getFramesCaughtByReceiver() { int slsDetector::getFramesCaughtByReceiver() const {
int retval = -1; int retval = -1;
FILE_LOG(logDEBUG1) << "Getting Frames Caught by Receiver"; FILE_LOG(logDEBUG1) << "Getting Frames Caught by Receiver";
if (shm()->useReceiverFlag) { if (shm()->useReceiverFlag) {
@ -3220,7 +3269,7 @@ int slsDetector::getFramesCaughtByReceiver() {
return retval; return retval;
} }
uint64_t slsDetector::getReceiverCurrentFrameIndex() { uint64_t slsDetector::getReceiverCurrentFrameIndex() const {
uint64_t retval = -1; uint64_t retval = -1;
FILE_LOG(logDEBUG1) << "Getting Current Frame Index of Receiver"; FILE_LOG(logDEBUG1) << "Getting Current Frame Index of Receiver";
if (shm()->useReceiverFlag) { if (shm()->useReceiverFlag) {

View File

@ -382,23 +382,6 @@ TEST_CASE("rx_lastclient", "[.cmd]") {
REQUIRE(oss.str() == "rx_lastclient " + test::my_ip + "\n"); REQUIRE(oss.str() == "rx_lastclient " + test::my_ip + "\n");
} }
TEST_CASE("rx_online", "[.cmd]") {
{
std::ostringstream oss;
multiSlsDetectorClient("rx_online 0", PUT, nullptr, oss);
REQUIRE(oss.str() == "rx_online 0\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("rx_online", GET, nullptr, oss);
REQUIRE(oss.str() == "rx_online 0\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("rx_online 1", PUT, nullptr, oss);
REQUIRE(oss.str() == "rx_online 1\n");
}
}
TEST_CASE("rx_checkonline", "[.cmd]") { TEST_CASE("rx_checkonline", "[.cmd]") {