2. Dev/add jf pedestal feature (#807)

This commit is contained in:
2023-09-29 11:25:58 +02:00
committed by GitHub
parent 72bec5d62e
commit d003a6d8e0
27 changed files with 751 additions and 109 deletions

View File

@ -155,6 +155,23 @@ std::ostream &operator<<(std::ostream &os,
return os << ToString(r);
}
std::string ToString(const slsDetectorDefs::pedestalParameters &r) {
std::ostringstream oss;
oss << '[';
if (r.enable)
oss << "enabled, " << std::to_string(r.frames) << ", " << r.loops;
else
oss << "disabled";
oss << ']';
return oss.str();
}
std::ostream &operator<<(std::ostream &os,
const slsDetectorDefs::pedestalParameters &r) {
return os << ToString(r);
}
std::string ToString(const defs::runStatus s) {
switch (s) {
case defs::ERROR:
@ -1083,6 +1100,17 @@ template <> defs::polarity StringTo(const std::string &s) {
throw RuntimeError("Unknown polarity mode " + s);
}
template <> uint8_t StringTo(const std::string &s) {
int base = s.find("0x") != std::string::npos ? 16 : 10;
int value = std::stoi(s, nullptr, base);
if (value < std::numeric_limits<uint8_t>::min() ||
value > std::numeric_limits<uint8_t>::max()) {
throw RuntimeError("Cannot scan uint8_t from string '" + s +
"'. Value must be in range 0 - 255.");
}
return static_cast<uint8_t>(value);
}
template <> uint16_t StringTo(const std::string &s) {
int base = s.find("0x") != std::string::npos ? 16 : 10;
int value = std::stoi(s, nullptr, base);