#pragma once /************************************************ * @file sls_detector_defs.h * @short contains all the constants, enum definitions and enum-string *conversions ***********************************************/ /** *@short contains all the constants, enum definitions and enum-string *conversions */ #ifdef __CINT__ #define MYROOT #define __cplusplus #endif #ifdef __cplusplus // C++ includes #include "sls_detector_exceptions.h" #include #include #include #include #else // C includes #include #endif #define BIT32_MASK 0xFFFFFFFF #define MAX_RX_DBIT 64 /** default ports */ #define DEFAULT_PORTNO 1952 #define DEFAULT_UDP_PORTNO 50001 #define DEFAULT_ZMQ_CL_PORTNO 30001 #define DEFAULT_ZMQ_RX_PORTNO 30001 #define SLS_DETECTOR_HEADER_VERSION 0x2 #define SLS_DETECTOR_JSON_HEADER_VERSION 0x4 // ctb/ moench 1g udp (read from fifo) #define UDP_PACKET_DATA_BYTES (1344) /** maximum rois */ #define MAX_ROIS 100 /** maximum trim en */ #define MAX_TRIMEN 100 /** maximum unit size of program sent to detector */ #define MAX_FPGAPROGRAMSIZE (2 * 1024 * 1024) /** get flag form most functions */ #define GET_FLAG -1 #define DEFAULT_DET_MAC "00:aa:bb:cc:dd:ee" #define DEFAULT_DET_IP "129.129.202.45" #define DEFAULT_DET_MAC2 "00:aa:bb:cc:dd:ff" #define DEFAULT_DET_IP2 "129.129.202.46" /** default maximum string length */ #define MAX_STR_LENGTH 1000 #define SHORT_STR_LENGTH 20 #define DEFAULT_STREAMING_TIMER_IN_MS 200 #ifdef __cplusplus class slsDetectorDefs { public: #endif /** Type of the detector */ enum detectorType { GET_DETECTOR_TYPE = -1, GENERIC, EIGER, GOTTHARD, JUNGFRAU, CHIPTESTBOARD, MOENCH, MYTHEN3, GOTTHARD2, }; /** return values */ enum { OK, /**< function succeeded */ FAIL /**< function failed */ }; /** staus mask */ enum runStatus { IDLE, /**< detector ready to start acquisition - no data in memory */ ERROR, /**< error i.e. normally fifo full */ WAITING, /**< waiting for trigger or gate signal */ RUN_FINISHED, /**< acquisition not running but data in memory */ TRANSMITTING, /**< acquisition running and data in memory */ RUNNING, /**< acquisition running, no data in memory */ STOPPED /**< acquisition stopped externally */ }; /** @short structure for a Detector Packet or Image Header @li frameNumber is the frame number @li expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) @li packetNumber is the packet number @li bunchId is the bunch id from beamline @li timestamp is the time stamp with 10 MHz clock @li modId is the unique module id (unique even for left, right, top, bottom) @li row is the row index in the complete detector system @li column is the column index in the complete detector system @li reserved is reserved @li debug is for debugging purposes @li roundRNumber is the round robin set number @li detType is the detector type see :: detectorType @li version is the version number of this structure format */ typedef struct { uint64_t frameNumber; /**< is the frame number */ uint32_t expLength; /**< is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) */ uint32_t packetNumber; /**< is the packet number */ uint64_t bunchId; /**< is the bunch id from beamline */ uint64_t timestamp; /**< is the time stamp with 10 MHz clock */ uint16_t modId; /**< is the unique module id (unique even for left, right, top, bottom) */ uint16_t row; /**< is the row index in the complete detector system */ uint16_t column; /**< is the column index in the complete detector system */ uint16_t reserved; /**< is reserved */ uint32_t debug; /**< is for debugging purposes */ uint16_t roundRNumber; /**< is the round robin set number */ uint8_t detType; /**< is the detector type see :: detectorType */ uint8_t version; /**< is the version number of this structure format */ } sls_detector_header; #ifdef __cplusplus #define MAX_NUM_PACKETS 512 using sls_bitset = std::bitset; using bitset_storage = uint8_t[MAX_NUM_PACKETS / 8]; struct sls_receiver_header { sls_detector_header detHeader; /**< is the detector header */ sls_bitset packetsMask; /**< is the packets caught bit mask */ }; #endif enum frameDiscardPolicy { GET_FRAME_DISCARD_POLICY = -1, /**< to get the missing packet mode */ NO_DISCARD, /**< pad incomplete packets with -1, default mode */ DISCARD_EMPTY_FRAMES, /**< discard incomplete frames, fastest mode, save space, not suitable for multiple modules */ DISCARD_PARTIAL_FRAMES, /**< ignore missing packets, must check with packetsMask for data integrity, fast mode and suitable for multiple modules */ NUM_DISCARD_POLICIES }; enum fileFormat { GET_FILE_FORMAT = -1, /**< the receiver will return its file format */ BINARY, /**< binary format */ HDF5, /**< hdf5 format */ NUM_FILE_FORMATS }; /** @short structure for a region of interest xmin,xmax,ymin,ymax define the limits of the region */ #ifdef __cplusplus struct ROI { int xmin{-1}; /**< is the roi xmin (in channel number) */ int xmax{-1}; /**< is the roi xmax (in channel number)*/ } __attribute__((packed)); #else typedef struct { int xmin; /**< is the roi xmin (in channel number) */ int xmax; /**< is the roi xmax (in channel number)*/ } ROI; #endif /** type of action performed (for text client) */ enum { GET_ACTION, PUT_ACTION, READOUT_ACTION, HELP_ACTION }; /** dimension indexes */ enum dimension { X = 0, /**< X dimension */ Y = 1 /**< Y dimension */ }; #ifdef __cplusplus struct xy { int x{0}; int y{0}; xy() = default; xy(int x, int y) : x(x), y(y){}; } __attribute__((packed)); #endif /** use of the external signals */ enum externalSignalFlag { GET_EXTERNAL_SIGNAL_FLAG = -1, /** //hmm... but currently no way around namespace sls { using Positions = const std::vector &; using defs = slsDetectorDefs; } // namespace sls #endif