mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
@ -47,8 +47,10 @@ std::ostream &operator<<(std::ostream &os,
|
||||
std::string ToString(const slsDetectorDefs::patternParameters &r);
|
||||
std::ostream &operator<<(std::ostream &os,
|
||||
const slsDetectorDefs::patternParameters &r);
|
||||
std::string ToString(const slsDetectorDefs::scanParameters &r);
|
||||
std::ostream &operator<<(std::ostream &os,
|
||||
const slsDetectorDefs::scanParameters &r);
|
||||
const std::string &ToString(const std::string &s);
|
||||
|
||||
/** Convert std::chrono::duration with specified output unit */
|
||||
template <typename T, typename Rep = double>
|
||||
typename std::enable_if<is_duration<T>::value, std::string>::type
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "sls_detector_exceptions.h"
|
||||
#include <algorithm>
|
||||
#include <bitset>
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#else
|
||||
@ -303,6 +304,7 @@ typedef struct {
|
||||
TEMPERATURE_SODR,
|
||||
TEMPERATURE_FPGA2,
|
||||
TEMPERATURE_FPGA3,
|
||||
TRIMBIT_SCAN,
|
||||
V_POWER_A = 100,
|
||||
V_POWER_B = 101,
|
||||
V_POWER_C = 102,
|
||||
@ -450,6 +452,36 @@ typedef struct {
|
||||
uint32_t patwait[3]{};
|
||||
uint64_t patwaittime[3]{};
|
||||
} __attribute__((packed));
|
||||
|
||||
/** scan structure */
|
||||
struct scanParameters {
|
||||
int enable;
|
||||
dacIndex dacInd;
|
||||
int startOffset;
|
||||
int stopOffset;
|
||||
int stepSize;
|
||||
int64_t dacSettleTime_ns;
|
||||
|
||||
/** disable scan */
|
||||
scanParameters()
|
||||
: enable(0), dacInd(DAC_0), startOffset(0), stopOffset(0),
|
||||
stepSize(0), dacSettleTime_ns{0} {}
|
||||
/** enable scan */
|
||||
scanParameters(
|
||||
dacIndex dac, int start, int stop, int step,
|
||||
std::chrono::nanoseconds t = std::chrono::milliseconds{1})
|
||||
: enable(1), dacInd(dac), startOffset(start), stopOffset(stop),
|
||||
stepSize(step) {
|
||||
dacSettleTime_ns = t.count();
|
||||
}
|
||||
bool operator==(const scanParameters &other) const {
|
||||
return ((enable == other.enable) && (dacInd == other.dacInd) &&
|
||||
(startOffset == other.startOffset) &&
|
||||
(stopOffset == other.stopOffset) &&
|
||||
(stepSize == other.stepSize) &&
|
||||
(dacSettleTime_ns == other.dacSettleTime_ns));
|
||||
}
|
||||
} __attribute__((packed));
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -101,7 +101,6 @@ enum detFuncs {
|
||||
F_RESET_FPGA,
|
||||
F_POWER_CHIP,
|
||||
F_ACTIVATE,
|
||||
F_PREPARE_ACQUISITION,
|
||||
F_THRESHOLD_TEMP,
|
||||
F_TEMP_CONTROL,
|
||||
F_TEMP_EVENT,
|
||||
@ -201,6 +200,9 @@ enum detFuncs {
|
||||
F_GET_VETO,
|
||||
F_SET_VETO,
|
||||
F_SET_PATTERN,
|
||||
F_GET_SCAN,
|
||||
F_SET_SCAN,
|
||||
F_GET_SCAN_ERROR_MESSAGE,
|
||||
|
||||
NUM_DET_FUNCTIONS,
|
||||
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this
|
||||
@ -400,7 +402,6 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
||||
case F_RESET_FPGA: return "F_RESET_FPGA";
|
||||
case F_POWER_CHIP: return "F_POWER_CHIP";
|
||||
case F_ACTIVATE: return "F_ACTIVATE";
|
||||
case F_PREPARE_ACQUISITION: return "F_PREPARE_ACQUISITION";
|
||||
case F_THRESHOLD_TEMP: return "F_THRESHOLD_TEMP";
|
||||
case F_TEMP_CONTROL: return "F_TEMP_CONTROL";
|
||||
case F_TEMP_EVENT: return "F_TEMP_EVENT";
|
||||
@ -500,6 +501,9 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
||||
case F_GET_VETO: return "F_GET_VETO";
|
||||
case F_SET_VETO: return "F_SET_VETO";
|
||||
case F_SET_PATTERN: return "F_SET_PATTERN";
|
||||
case F_GET_SCAN: return "F_GET_SCAN";
|
||||
case F_SET_SCAN: return "F_SET_SCAN";
|
||||
case F_GET_SCAN_ERROR_MESSAGE: return "F_GET_SCAN_ERROR_MESSAGE";
|
||||
|
||||
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
|
||||
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";
|
||||
|
@ -3,10 +3,10 @@
|
||||
#define APILIB 0x200409
|
||||
#define APIRECEIVER 0x200409
|
||||
#define APIGUI 0x200409
|
||||
#define APIEIGER 0x200623
|
||||
#define APICTB 0x200623
|
||||
#define APIGOTTHARD 0x200623
|
||||
#define APIGOTTHARD2 0x200623
|
||||
#define APIJUNGFRAU 0x200623
|
||||
#define APIMYTHEN3 0x200623
|
||||
#define APIMOENCH 0x200623
|
||||
#define APICTB 0x200703
|
||||
#define APIGOTTHARD 0x200703
|
||||
#define APIGOTTHARD2 0x200703
|
||||
#define APIJUNGFRAU 0x200703
|
||||
#define APIMYTHEN3 0x200703
|
||||
#define APIMOENCH 0x200702
|
||||
#define APIEIGER 0x200703
|
||||
|
@ -102,6 +102,30 @@ std::ostream &operator<<(std::ostream &os,
|
||||
return os << ToString(r);
|
||||
}
|
||||
|
||||
std::string ToString(const slsDetectorDefs::scanParameters &r) {
|
||||
std::ostringstream oss;
|
||||
oss << '[';
|
||||
if (r.enable) {
|
||||
oss << "enabled" << std::endl
|
||||
<< "dac " << ToString(r.dacInd) << std::endl
|
||||
<< "start " << r.startOffset << std::endl
|
||||
<< "stop " << r.stopOffset << std::endl
|
||||
<< "step " << r.stepSize << std::endl
|
||||
<< "settleTime "
|
||||
<< ToString(std::chrono::nanoseconds{r.dacSettleTime_ns})
|
||||
<< std::endl;
|
||||
} else {
|
||||
oss << "disabled";
|
||||
}
|
||||
oss << ']';
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &os,
|
||||
const slsDetectorDefs::scanParameters &r) {
|
||||
return os << ToString(r);
|
||||
}
|
||||
|
||||
std::string ToString(const defs::runStatus s) {
|
||||
switch (s) {
|
||||
case defs::ERROR:
|
||||
@ -465,6 +489,12 @@ std::string ToString(const defs::dacIndex s) {
|
||||
return std::string("vipre_cds");
|
||||
case defs::IBIAS_SFP:
|
||||
return std::string("ibias_sfp");
|
||||
case defs::TRIMBIT_SCAN:
|
||||
return std::string("trimbit_scan");
|
||||
case defs::HIGH_VOLTAGE:
|
||||
return std::string("vhighvoltage");
|
||||
case defs::IO_DELAY:
|
||||
return std::string("iodelay");
|
||||
default:
|
||||
return std::string("Unknown");
|
||||
}
|
||||
@ -818,6 +848,13 @@ template <> defs::dacIndex StringTo(const std::string &s) {
|
||||
return defs::VIPRE_CDS;
|
||||
if (s == "ibias_sfp")
|
||||
return defs::IBIAS_SFP;
|
||||
if (s == "trimbit_scan")
|
||||
return defs::TRIMBIT_SCAN;
|
||||
if (s == "vhighvoltage")
|
||||
return defs::HIGH_VOLTAGE;
|
||||
if (s == "iodelay")
|
||||
return defs::IO_DELAY;
|
||||
|
||||
throw sls::RuntimeError("Unknown dac Index " + s);
|
||||
}
|
||||
|
||||
|
@ -273,4 +273,29 @@ TEST_CASE("int or uin64_t to a string in hex") {
|
||||
REQUIRE(r == "[0xf4, 0xffff, 0x1900b6]");
|
||||
r = ToStringHex(temp, 8);
|
||||
REQUIRE(r == "[0x000000f4, 0x0000ffff, 0x001900b6]");
|
||||
}
|
||||
|
||||
TEST_CASE("Streaming of slsDetectorDefs::scanParameters") {
|
||||
using namespace sls;
|
||||
{
|
||||
defs::scanParameters t{};
|
||||
std::ostringstream oss;
|
||||
oss << t;
|
||||
REQUIRE(oss.str() == "[disabled]");
|
||||
}
|
||||
{
|
||||
defs::scanParameters t{defs::VTH2, 500, 1500, 500};
|
||||
std::ostringstream oss;
|
||||
oss << t;
|
||||
REQUIRE(oss.str() == "[enabled\ndac vth2\nstart 500\nstop 1500\nstep "
|
||||
"500\nsettleTime 1ms\n]");
|
||||
}
|
||||
{
|
||||
defs::scanParameters t{defs::VTH2, 500, 1500, 500,
|
||||
std::chrono::milliseconds{500}};
|
||||
std::ostringstream oss;
|
||||
oss << t;
|
||||
REQUIRE(oss.str() == "[enabled\ndac vth2\nstart 500\nstop 1500\nstep "
|
||||
"500\nsettleTime 0.5s\n]");
|
||||
}
|
||||
}
|
@ -49,4 +49,26 @@ TEST_CASE("assign module", "[support]") {
|
||||
CHECK(m3.reg == 500);
|
||||
CHECK(m3.iodelay == 750);
|
||||
CHECK(m3.nchan == 256 * 256 * 4);
|
||||
}
|
||||
|
||||
TEST_CASE("default construct scanParameters"){
|
||||
slsDetectorDefs::scanParameters p;
|
||||
CHECK(p.dacSettleTime_ns == 0);
|
||||
CHECK(p.dacInd == slsDetectorDefs::DAC_0);
|
||||
CHECK(p.enable == 0);
|
||||
CHECK(p.startOffset == 0);
|
||||
CHECK(p.stopOffset == 0);
|
||||
CHECK(p.stepSize == 0);
|
||||
|
||||
}
|
||||
|
||||
TEST_CASE("compare two scanParameters"){
|
||||
slsDetectorDefs::scanParameters p0;
|
||||
slsDetectorDefs::scanParameters p1;
|
||||
|
||||
CHECK(p0 == p1);
|
||||
|
||||
p0.enable = 1;
|
||||
CHECK_FALSE(p0 == p1);
|
||||
|
||||
}
|
Reference in New Issue
Block a user