mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-08-01 19:13:38 +02:00
Merge branch 'developer' into dev/ctb_clocks
This commit is contained in:
@@ -37,6 +37,8 @@ std::string ToString(const defs::externalSignalFlag s);
|
||||
std::string ToString(const defs::readoutMode s);
|
||||
std::string ToString(const defs::dacIndex s);
|
||||
std::string ToString(const std::vector<defs::dacIndex> &vec);
|
||||
std::string ToString(const defs::powerIndex s);
|
||||
std::string ToString(const std::vector<defs::powerIndex> &vec);
|
||||
std::string ToString(const defs::burstMode s);
|
||||
std::string ToString(const defs::timingSourceType s);
|
||||
std::string ToString(const defs::M3_GainCaps s);
|
||||
@@ -49,6 +51,7 @@ std::string ToString(const defs::timingInfoDecoder s);
|
||||
std::string ToString(const defs::collectionMode s);
|
||||
|
||||
std::string ToString(bool value);
|
||||
std::string ToString(bool value, defs::boolFormat format);
|
||||
|
||||
std::string ToString(const slsDetectorDefs::xy &coord);
|
||||
std::ostream &operator<<(std::ostream &os, const slsDetectorDefs::xy &coord);
|
||||
@@ -316,6 +319,7 @@ template <> defs::fileFormat StringTo(const std::string &s);
|
||||
template <> defs::externalSignalFlag StringTo(const std::string &s);
|
||||
template <> defs::readoutMode StringTo(const std::string &s);
|
||||
template <> defs::dacIndex StringTo(const std::string &s);
|
||||
template <> defs::powerIndex StringTo(const std::string &s);
|
||||
template <> defs::burstMode StringTo(const std::string &s);
|
||||
template <> defs::timingSourceType StringTo(const std::string &s);
|
||||
template <> defs::M3_GainCaps StringTo(const std::string &s);
|
||||
@@ -335,6 +339,7 @@ template <> uint32_t StringTo(const std::string &s);
|
||||
template <> uint64_t StringTo(const std::string &s);
|
||||
template <> int StringTo(const std::string &s);
|
||||
template <> bool StringTo(const std::string &s);
|
||||
bool StringTo(const std::string &s, defs::boolFormat format);
|
||||
template <> int64_t StringTo(const std::string &s);
|
||||
|
||||
/** For types with a .str() method use this for conversion */
|
||||
|
||||
@@ -104,6 +104,8 @@ class slsDetectorDefs {
|
||||
/** return values */
|
||||
enum { OK, FAIL };
|
||||
|
||||
enum boolFormat { TrueFalse, OnOff, OneZero };
|
||||
|
||||
/** staus mask */
|
||||
enum runStatus {
|
||||
IDLE,
|
||||
@@ -394,18 +396,6 @@ typedef struct {
|
||||
TEMPERATURE_FPGA2,
|
||||
TEMPERATURE_FPGA3,
|
||||
TRIMBIT_SCAN,
|
||||
V_POWER_A = 100,
|
||||
V_POWER_B = 101,
|
||||
V_POWER_C = 102,
|
||||
V_POWER_D = 103,
|
||||
V_POWER_IO = 104,
|
||||
V_POWER_CHIP = 105,
|
||||
I_POWER_A = 106,
|
||||
I_POWER_B = 107,
|
||||
I_POWER_C = 108,
|
||||
I_POWER_D = 109,
|
||||
I_POWER_IO = 110,
|
||||
V_LIMIT = 111,
|
||||
SLOW_ADC0 = 1000,
|
||||
SLOW_ADC1,
|
||||
SLOW_ADC2,
|
||||
@@ -417,6 +407,20 @@ typedef struct {
|
||||
SLOW_ADC_TEMP
|
||||
};
|
||||
|
||||
enum powerIndex {
|
||||
V_POWER_A,
|
||||
V_POWER_B,
|
||||
V_POWER_C,
|
||||
V_POWER_D,
|
||||
V_POWER_IO,
|
||||
V_POWER_CHIP,
|
||||
I_POWER_A,
|
||||
I_POWER_B,
|
||||
I_POWER_C,
|
||||
I_POWER_D,
|
||||
I_POWER_IO
|
||||
};
|
||||
|
||||
/**
|
||||
detector settings indexes
|
||||
*/
|
||||
|
||||
@@ -301,6 +301,13 @@ enum detFuncs {
|
||||
F_SET_PATTERN_WAIT_INTERVAL,
|
||||
F_SPI_READ,
|
||||
F_SPI_WRITE,
|
||||
F_GET_POWER,
|
||||
F_SET_POWER,
|
||||
F_GET_POWER_DAC,
|
||||
F_SET_POWER_DAC,
|
||||
F_GET_POWER_ADC,
|
||||
F_GET_VOLTAGE_LIMIT,
|
||||
F_SET_VOLTAGE_LIMIT,
|
||||
|
||||
NUM_DET_FUNCTIONS,
|
||||
RECEIVER_ENUM_START = 512, /**< detector function should not exceed this
|
||||
@@ -713,6 +720,13 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
||||
case F_SET_PATTERN_WAIT_INTERVAL: return "F_SET_PATTERN_WAIT_INTERVAL";
|
||||
case F_SPI_READ: return "F_SPI_READ";
|
||||
case F_SPI_WRITE: return "F_SPI_WRITE";
|
||||
case F_GET_POWER: return "F_GET_POWER";
|
||||
case F_SET_POWER: return "F_SET_POWER";
|
||||
case F_GET_POWER_DAC: return "F_GET_POWER_DAC";
|
||||
case F_SET_POWER_DAC: return "F_SET_POWER_DAC";
|
||||
case F_GET_POWER_ADC: return "F_GET_POWER_ADC";
|
||||
case F_GET_VOLTAGE_LIMIT: return "F_GET_VOLTAGE_LIMIT";
|
||||
case F_SET_VOLTAGE_LIMIT: return "F_SET_VOLTAGE_LIMIT";
|
||||
|
||||
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
|
||||
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
/** API versions */
|
||||
#define APILIB "0.0.0 0x250909"
|
||||
#define APIRECEIVER "0.0.0 0x250822"
|
||||
#define APICTB "0.0.0 0x260317"
|
||||
#define APIGOTTHARD2 "0.0.0 0x260227"
|
||||
#define APIMOENCH "0.0.0 0x260227"
|
||||
#define APIEIGER "0.0.0 0x260227"
|
||||
#define APIXILINXCTB "0.0.0 0x260317"
|
||||
#define APIJUNGFRAU "0.0.0 0x260227"
|
||||
#define APIMYTHEN3 "0.0.0 0x260227"
|
||||
#define APICTB "0.0.0 0x260421"
|
||||
#define APIGOTTHARD2 "0.0.0 0x260420"
|
||||
#define APIMOENCH "0.0.0 0x260420"
|
||||
#define APIEIGER "0.0.0 0x260420"
|
||||
#define APIXILINXCTB "0.0.0 0x260420"
|
||||
#define APIJUNGFRAU "0.0.0 0x260420"
|
||||
#define APIMYTHEN3 "0.0.0 0x260420"
|
||||
|
||||
@@ -7,6 +7,17 @@ namespace sls {
|
||||
|
||||
std::string ToString(bool value) { return value ? "1" : "0"; }
|
||||
|
||||
std::string ToString(bool value, defs::boolFormat format) {
|
||||
switch (format) {
|
||||
case defs::boolFormat::TrueFalse:
|
||||
return value ? "true" : "false";
|
||||
case defs::boolFormat::OnOff:
|
||||
return value ? "on" : "off";
|
||||
default:
|
||||
return value ? "1" : "0";
|
||||
}
|
||||
}
|
||||
|
||||
std::string ToString(const slsDetectorDefs::xy &coord) {
|
||||
std::ostringstream oss;
|
||||
oss << '[' << coord.x << ", " << coord.y << ']';
|
||||
@@ -552,6 +563,38 @@ std::string ToString(const std::vector<defs::dacIndex> &vec) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string ToString(const defs::powerIndex s) {
|
||||
switch (s) {
|
||||
case defs::V_POWER_A:
|
||||
return std::string("v_a");
|
||||
case defs::V_POWER_B:
|
||||
return std::string("v_b");
|
||||
case defs::V_POWER_C:
|
||||
return std::string("v_c");
|
||||
case defs::V_POWER_D:
|
||||
return std::string("v_d");
|
||||
case defs::V_POWER_IO:
|
||||
return std::string("v_io");
|
||||
case defs::V_POWER_CHIP:
|
||||
return std::string("v_chip");
|
||||
default:
|
||||
return std::string("Unknown");
|
||||
}
|
||||
}
|
||||
|
||||
std::string ToString(const std::vector<defs::powerIndex> &vec) {
|
||||
std::ostringstream os;
|
||||
os << '[';
|
||||
if (!vec.empty()) {
|
||||
auto it = vec.begin();
|
||||
os << ToString(*it++);
|
||||
while (it != vec.end())
|
||||
os << ", " << ToString(*it++);
|
||||
}
|
||||
os << ']';
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string ToString(const defs::burstMode s) {
|
||||
switch (s) {
|
||||
case defs::BURST_INTERNAL:
|
||||
@@ -1018,6 +1061,22 @@ template <> defs::dacIndex StringTo(const std::string &s) {
|
||||
throw RuntimeError("Unknown dac Index " + s);
|
||||
}
|
||||
|
||||
template <> defs::powerIndex StringTo(const std::string &s) {
|
||||
if (s == "v_a")
|
||||
return defs::V_POWER_A;
|
||||
if (s == "v_b")
|
||||
return defs::V_POWER_B;
|
||||
if (s == "v_c")
|
||||
return defs::V_POWER_C;
|
||||
if (s == "v_d")
|
||||
return defs::V_POWER_D;
|
||||
if (s == "v_io")
|
||||
return defs::V_POWER_IO;
|
||||
if (s == "v_chip")
|
||||
return defs::V_POWER_CHIP;
|
||||
throw RuntimeError("Unknown power Index " + s);
|
||||
}
|
||||
|
||||
template <> defs::burstMode StringTo(const std::string &s) {
|
||||
if (s == "burst_internal")
|
||||
return defs::BURST_INTERNAL;
|
||||
@@ -1165,14 +1224,38 @@ template <> int StringTo(const std::string &s) {
|
||||
}
|
||||
|
||||
template <> bool StringTo(const std::string &s) {
|
||||
int i = std::stoi(s, nullptr, 10);
|
||||
switch (i) {
|
||||
case 0:
|
||||
return false;
|
||||
case 1:
|
||||
return true;
|
||||
return StringTo(s, defs::boolFormat::OneZero);
|
||||
}
|
||||
|
||||
bool StringTo(const std::string &s, defs::boolFormat format) {
|
||||
switch (format) {
|
||||
case defs::boolFormat::TrueFalse: {
|
||||
if (s == "true")
|
||||
return true;
|
||||
if (s == "false")
|
||||
return false;
|
||||
throw RuntimeError("Unknown boolean. Expecting 'true' or 'false'.");
|
||||
}
|
||||
case defs::boolFormat::OnOff: {
|
||||
if (s == "on")
|
||||
return true;
|
||||
if (s == "off")
|
||||
return false;
|
||||
throw RuntimeError("Unknown boolean. Expecting 'on' or 'off'.");
|
||||
}
|
||||
case defs::boolFormat::OneZero: {
|
||||
int i = std::stoi(s, nullptr, 10);
|
||||
switch (i) {
|
||||
case 0:
|
||||
return false;
|
||||
case 1:
|
||||
return true;
|
||||
default:
|
||||
throw RuntimeError("Unknown boolean. Expecting 0 or 1.");
|
||||
}
|
||||
}
|
||||
default:
|
||||
throw RuntimeError("Unknown boolean. Expecting be 0 or 1.");
|
||||
throw RuntimeError("Unknown boolean format.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,24 @@ TEST_CASE("Convert string to bool", "[support]") {
|
||||
REQUIRE(StringTo<bool>("0") == false);
|
||||
}
|
||||
|
||||
TEST_CASE("Convert bool format to string", "[support]") {
|
||||
REQUIRE(ToString(true, defs::boolFormat::TrueFalse) == "true");
|
||||
REQUIRE(ToString(false, defs::boolFormat::TrueFalse) == "false");
|
||||
REQUIRE(ToString(true, defs::boolFormat::OnOff) == "on");
|
||||
REQUIRE(ToString(false, defs::boolFormat::OnOff) == "off");
|
||||
REQUIRE(ToString(true, defs::boolFormat::OneZero) == "1");
|
||||
REQUIRE(ToString(false, defs::boolFormat::OneZero) == "0");
|
||||
}
|
||||
|
||||
TEST_CASE("Convert string to bool format", "[support]") {
|
||||
REQUIRE(StringTo("1", defs::boolFormat::OneZero) == true);
|
||||
REQUIRE(StringTo("0", defs::boolFormat::OneZero) == false);
|
||||
REQUIRE(StringTo("true", defs::boolFormat::TrueFalse) == true);
|
||||
REQUIRE(StringTo("false", defs::boolFormat::TrueFalse) == false);
|
||||
REQUIRE(StringTo("on", defs::boolFormat::OnOff) == true);
|
||||
REQUIRE(StringTo("off", defs::boolFormat::OnOff) == false);
|
||||
}
|
||||
|
||||
TEST_CASE("Integer conversions", "[support]") {
|
||||
REQUIRE(ToString(0) == "0");
|
||||
REQUIRE(ToString(1) == "1");
|
||||
|
||||
Reference in New Issue
Block a user