This commit is contained in:
Erik Frojdh 2020-01-16 12:26:22 +01:00
parent 4b69ac5cfc
commit bcb4942793
2 changed files with 19 additions and 24 deletions

View File

@ -14,14 +14,20 @@
#define __cplusplus #define __cplusplus
#endif #endif
#include <stdint.h> #include "ansi.h"
#ifdef __cplusplus #ifdef __cplusplus
//C++ includes
#include "sls_detector_exceptions.h" #include "sls_detector_exceptions.h"
#include <algorithm> #include <algorithm>
#include <cstdint>
#include <bitset> #include <bitset>
#include <string> #include <string>
#else
//C includes
#include <stdint.h>
#endif #endif
#include "ansi.h"
#define BIT32_MASK 0xFFFFFFFF #define BIT32_MASK 0xFFFFFFFF
#define MAX_RX_DBIT 64 #define MAX_RX_DBIT 64
@ -72,7 +78,6 @@
#ifdef __cplusplus #ifdef __cplusplus
class slsDetectorDefs { class slsDetectorDefs {
public: public:
slsDetectorDefs(){};
#endif #endif
/** Type of the detector */ /** Type of the detector */
@ -146,20 +151,13 @@ class slsDetectorDefs {
#ifdef __cplusplus #ifdef __cplusplus
#define MAX_NUM_PACKETS 512 #define MAX_NUM_PACKETS 512
using sls_bitset = std::bitset<MAX_NUM_PACKETS>;
typedef std::bitset<MAX_NUM_PACKETS> sls_bitset; using bitset_storage = uint8_t[MAX_NUM_PACKETS / 8];
struct sls_receiver_header{
typedef struct {
sls_detector_header detHeader; /**< is the detector header */ sls_detector_header detHeader; /**< is the detector header */
sls_bitset packetsMask; /**< is the packets caught bit mask */ sls_bitset packetsMask; /**< is the packets caught bit mask */
} sls_receiver_header; };
typedef uint8_t bitset_storage[MAX_NUM_PACKETS / 8];
#endif #endif
/**
* frameDiscardPolicy
*/
enum frameDiscardPolicy { enum frameDiscardPolicy {
GET_FRAME_DISCARD_POLICY = -1, /**< to get the missing packet mode */ GET_FRAME_DISCARD_POLICY = -1, /**< to get the missing packet mode */
NO_DISCARD, /**< pad incomplete packets with -1, default mode */ NO_DISCARD, /**< pad incomplete packets with -1, default mode */
@ -171,9 +169,6 @@ class slsDetectorDefs {
NUM_DISCARD_POLICIES NUM_DISCARD_POLICIES
}; };
/**
format
*/
enum fileFormat { enum fileFormat {
GET_FILE_FORMAT = -1, /**< the receiver will return its file format */ GET_FILE_FORMAT = -1, /**< the receiver will return its file format */
BINARY, /**< binary format */ BINARY, /**< binary format */
@ -214,8 +209,8 @@ format
#ifdef __cplusplus #ifdef __cplusplus
struct xy { struct xy {
int x=0; int x{0};
int y=0; int y{0};
}; };
#endif #endif
@ -466,8 +461,8 @@ struct detParameters {
int nGappixelsX{0}; int nGappixelsX{0};
int nGappixelsY{0}; int nGappixelsY{0};
detParameters() {} detParameters() = default;
detParameters(slsDetectorDefs::detectorType type) { explicit detParameters(slsDetectorDefs::detectorType type) {
switch (type) { switch (type) {
case slsDetectorDefs::detectorType::GOTTHARD: case slsDetectorDefs::detectorType::GOTTHARD:
nChanX = 128; nChanX = 128;
@ -582,7 +577,7 @@ typedef struct {
: serialnumber(0), nchan(0), nchip(0), ndac(0), reg(0), iodelay(0), : serialnumber(0), nchan(0), nchip(0), ndac(0), reg(0), iodelay(0),
tau(0), eV(0), dacs(nullptr), chanregs(nullptr) {} tau(0), eV(0), dacs(nullptr), chanregs(nullptr) {}
sls_detector_module(slsDetectorDefs::detectorType type) explicit sls_detector_module(slsDetectorDefs::detectorType type)
: sls_detector_module() { : sls_detector_module() {
detParameters parameters{type}; detParameters parameters{type};
int nch = parameters.nChanX * parameters.nChanY; int nch = parameters.nChanX * parameters.nChanY;
@ -633,5 +628,5 @@ typedef struct {
namespace sls{ namespace sls{
using Positions = const std::vector<int> &; using Positions = const std::vector<int> &;
using defs = slsDetectorDefs; using defs = slsDetectorDefs;
} } // namespace sls
#endif #endif

View File

@ -54,7 +54,7 @@ public:
GuiError(const std::string& msg):RuntimeError(msg) {} GuiError(const std::string& msg):RuntimeError(msg) {}
}; };
} } // namespce sls