This commit is contained in:
2021-07-15 13:44:42 +02:00
parent a127f8c97a
commit 8354395f64
14 changed files with 216 additions and 42 deletions

View File

@ -519,6 +519,23 @@ std::string ToString(const defs::timingSourceType s) {
}
}
std::string ToString(const defs::EthernetInterface s) {
std::ostringstream os;
std::string rs;
switch (s) {
case defs::NONE:
return std::string("none");
default:
if (s & defs::I3GBE)
os << "3gbe, ";
if (s & defs::I10GBE)
os << "10gbe, ";
auto rs = os.str();
rs.erase(rs.end() - 2);
return rs;
}
}
const std::string &ToString(const std::string &s) { return s; }
template <> defs::detectorType StringTo(const std::string &s) {
@ -859,6 +876,18 @@ template <> defs::timingSourceType StringTo(const std::string &s) {
throw sls::RuntimeError("Unknown timing source type " + s);
}
template <> defs::EthernetInterface StringTo(const std::string &s) {
std::string rs = s;
rs.erase(rs.find(','));
if (rs == "none")
return defs::NONE;
if (rs == "3gbe")
return defs::I3GBE;
if (rs == "10gbe")
return defs::I10GBE;
throw sls::RuntimeError("Unknown EthernetInterface type " + s);
}
template <> uint32_t StringTo(const std::string &s) {
int base = s.find("0x") != std::string::npos ? 16 : 10;
return std::stoul(s, nullptr, base);