moved detParameters to sls_detector_defs

This commit is contained in:
Erik Frojdh 2019-04-17 14:28:53 +02:00
parent 91813a2c68
commit b46e107f35
4 changed files with 165 additions and 98 deletions

View File

@ -19,78 +19,7 @@ class MySocketTCP;
#define NCHIPSMAX 10
#define NCHANSMAX 65536
#define NDACSMAX 16
/**
* parameter list that has to be initialized depending on the detector type
*/
struct detParameters {
int nChanX{0};
int nChanY{0};
int nChipX{0};
int nChipY{0};
int nDacs{0};
int dynamicRange{0};
int nGappixelsX{0};
int nGappixelsY{0};
detParameters(){}
detParameters(slsDetectorDefs::detectorType type){
switch (type) {
case slsDetectorDefs::detectorType::GOTTHARD:
nChanX = 128;
nChanY = 1;
nChipX = 10;
nChipY = 1;
nDacs = 8;
dynamicRange = 16;
nGappixelsX = 0;
nGappixelsY = 0;
break;
case slsDetectorDefs::detectorType::JUNGFRAU:
nChanX = 256;
nChanY = 256;
nChipX = 4;
nChipY = 2;
nDacs = 8;
dynamicRange = 16;
nGappixelsX = 0;
nGappixelsY = 0;
break;
case slsDetectorDefs::detectorType::CHIPTESTBOARD:
nChanX = 36;
nChanY = 1;
nChipX = 1;
nChipY = 1;
nDacs = 24;
dynamicRange = 16;
nGappixelsX = 0;
nGappixelsY = 0;
break;
case slsDetectorDefs::detectorType::MOENCH:
nChanX = 32;
nChanY = 1;
nChipX = 1;
nChipY = 1;
nDacs = 8;
dynamicRange = 16;
nGappixelsX = 0;
nGappixelsY = 0;
break;
case slsDetectorDefs::detectorType::EIGER:
nChanX = 256;
nChanY = 256;
nChipX = 4;
nChipY = 1;
nDacs = 16;
dynamicRange = 16;
nGappixelsX = 6;
nGappixelsY = 1;
break;
default:
throw sls::RuntimeError("Unknown detector type! " +
slsDetectorDefs::detectorTypeToString(type));
}
}
};
/**
* @short structure allocated in shared memory to store detector settings for IPC and cache

View File

@ -15,6 +15,7 @@
#include <stdint.h>
#ifdef __cplusplus
#include "sls_detector_exceptions.h"
#include <bitset>
#include <string>
#endif
@ -62,33 +63,6 @@
#define DEFAULT_STREAMING_TIMER_IN_MS 200
/**
@short structure for a detector module
should not be used by unexperienced users
\see :: moduleRegisterBit ::chipRegisterBit :channelRegisterBit
@li reg is the module register (e.g. dynamic range? see moduleRegisterBit)
@li dacs is the pointer to the array of dac values (in V)
@li adcs is the pointer to the array of adc values (in V)
@li chipregs is the pointer to the array of chip registers
@li chanregs is the pointer to the array of channel registers
@li gain is the module gain
@li offset is the module offset
*/
typedef struct {
int serialnumber; /**< is the module serial number */
int nchan; /**< is the number of channels on the module*/
int nchip; /**< is the number of chips on the module */
int ndac; /**< is the number of dacs on the module */
int reg; /**< is the module register settings (gain level) */
int iodelay; /**< iodelay */
int tau; /**< tau */
int eV; /**< threshold energy */
int *dacs; /**< is the pointer to the array of the dac values (in V) */
int *chanregs; /**< is the pointer to the array of the channel registers */
} sls_detector_module;
typedef char mystring[MAX_STR_LENGTH];
@ -959,3 +933,133 @@ protected:
};
#endif
;
#ifdef __cplusplus
struct detParameters {
int nChanX{0};
int nChanY{0};
int nChipX{0};
int nChipY{0};
int nDacs{0};
int dynamicRange{0};
int nGappixelsX{0};
int nGappixelsY{0};
detParameters() {}
detParameters(slsDetectorDefs::detectorType type) {
switch (type) {
case slsDetectorDefs::detectorType::GOTTHARD:
nChanX = 128;
nChanY = 1;
nChipX = 10;
nChipY = 1;
nDacs = 8;
dynamicRange = 16;
nGappixelsX = 0;
nGappixelsY = 0;
break;
case slsDetectorDefs::detectorType::JUNGFRAU:
nChanX = 256;
nChanY = 256;
nChipX = 4;
nChipY = 2;
nDacs = 8;
dynamicRange = 16;
nGappixelsX = 0;
nGappixelsY = 0;
break;
case slsDetectorDefs::detectorType::CHIPTESTBOARD:
nChanX = 36;
nChanY = 1;
nChipX = 1;
nChipY = 1;
nDacs = 24;
dynamicRange = 16;
nGappixelsX = 0;
nGappixelsY = 0;
break;
case slsDetectorDefs::detectorType::MOENCH:
nChanX = 32;
nChanY = 1;
nChipX = 1;
nChipY = 1;
nDacs = 8;
dynamicRange = 16;
nGappixelsX = 0;
nGappixelsY = 0;
break;
case slsDetectorDefs::detectorType::EIGER:
nChanX = 256;
nChanY = 256;
nChipX = 4;
nChipY = 1;
nDacs = 16;
dynamicRange = 16;
nGappixelsX = 6;
nGappixelsY = 1;
break;
default:
throw sls::RuntimeError(
"Unknown detector type! " +
slsDetectorDefs::detectorTypeToString(type));
}
}
};
#endif
/**
@short structure for a detector module
should not be used by unexperienced users
\see :: moduleRegisterBit ::chipRegisterBit :channelRegisterBit
@li reg is the module register (e.g. dynamic range? see moduleRegisterBit)
@li dacs is the pointer to the array of dac values (in V)
@li adcs is the pointer to the array of adc values (in V)
@li chipregs is the pointer to the array of chip registers
@li chanregs is the pointer to the array of channel registers
@li gain is the module gain
@li offset is the module offset
*/
#ifdef __cplusplus
struct sls_detector_module {
#else
typedef struct {
#endif
int serialnumber; /**< is the module serial number */
int nchan; /**< is the number of channels on the module*/
int nchip; /**< is the number of chips on the module */
int ndac; /**< is the number of dacs on the module */
int reg; /**< is the module register settings (gain level) */
int iodelay; /**< iodelay */
int tau; /**< tau */
int eV; /**< threshold energy */
int *dacs; /**< is the pointer to the array of the dac values (in V) */
int *chanregs; /**< is the pointer to the array of the channel registers */
#ifdef __cplusplus
sls_detector_module()
: serialnumber(0), nchan(0), nchip(0), ndac(0), reg(0), iodelay(0),
tau(0), eV(0), dacs(nullptr), chanregs(nullptr) {}
sls_detector_module(slsDetectorDefs::detectorType type) {
detParameters parameters{type};
int nch = parameters.nChanX * parameters.nChanY;
int nc = parameters.nChipX * parameters.nChipY;
int nd = parameters.nDacs;
ndac = nd;
nchip = nc;
nchan = nch * nc;
dacs = new int[nd];
chanregs = new int[nch * nc];
}
~sls_detector_module(){
delete[] dacs;
delete[] chanregs;
}
};
#else
} sls_detector_module;
#endif

View File

@ -5,4 +5,5 @@ target_sources(tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/test-network_utils.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test-string_utils.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test-Timer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test-sls_detector_defs.cpp
)

View File

@ -0,0 +1,33 @@
#include "catch.hpp"
#include "sls_detector_defs.h"
#include "slsDetector.h"
using dt = slsDetectorDefs::detectorType;
TEST_CASE("sls_detector_module default construction", "[support][new]") {
sls_detector_module m;
CHECK(m.serialnumber == 0);
CHECK(m.nchan == 0);
CHECK(m.nchip == 0);
CHECK(m.ndac == 0);
CHECK(m.reg == 0);
CHECK(m.iodelay == 0);
CHECK(m.tau == 0);
CHECK(m.eV == 0);
CHECK(m.dacs == nullptr);
CHECK(m.chanregs == nullptr);
}
TEST_CASE("sls_detector_module from type", "[support][new]") {
sls_detector_module m(dt::EIGER);
CHECK(m.serialnumber == 0);
CHECK(m.nchan == 256*256*4);
CHECK(m.nchip == 4);
CHECK(m.ndac == 16);
CHECK(m.reg == 0);
CHECK(m.iodelay == 0);
CHECK(m.tau == 0);
CHECK(m.eV == 0);
CHECK(m.dacs != nullptr);
CHECK(m.chanregs != nullptr);
}