mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-01-16 16:08:38 +01:00
wip
This commit is contained in:
@@ -36,6 +36,7 @@ std::string ToString(const defs::dacIndex s);
|
||||
std::string ToString(const std::vector<defs::dacIndex> &vec);
|
||||
std::string ToString(const defs::burstMode s);
|
||||
std::string ToString(const defs::timingSourceType s);
|
||||
std::string ToString(const defs::EthernetInterface s);
|
||||
|
||||
std::string ToString(const slsDetectorDefs::xy &coord);
|
||||
std::ostream &operator<<(std::ostream &os, const slsDetectorDefs::xy &coord);
|
||||
@@ -297,6 +298,7 @@ template <> defs::readoutMode StringTo(const std::string &s);
|
||||
template <> defs::dacIndex StringTo(const std::string &s);
|
||||
template <> defs::burstMode StringTo(const std::string &s);
|
||||
template <> defs::timingSourceType StringTo(const std::string &s);
|
||||
template <> defs::EthernetInterface StringTo(const std::string &s);
|
||||
|
||||
template <> uint32_t StringTo(const std::string &s);
|
||||
template <> uint64_t StringTo(const std::string &s);
|
||||
|
||||
@@ -394,6 +394,29 @@ typedef struct {
|
||||
*/
|
||||
enum timingSourceType { TIMING_INTERNAL, TIMING_EXTERNAL };
|
||||
|
||||
#ifdef __cplusplus
|
||||
enum class EthernetInterface : int32_t {
|
||||
#else
|
||||
enum EthernetInterface {
|
||||
#endif
|
||||
NONE = 0,
|
||||
I3GBE = 1 << 1,
|
||||
I10GBE = 1 << 2,
|
||||
ALL = I3GBE | I10GBE
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
inline EthernetInterface operator|(EthernetInterface a,
|
||||
EthernetInterface b) {
|
||||
return EthernetInterface(static_cast<int32_t>(a) |
|
||||
static_cast<int32_t>(b));
|
||||
}
|
||||
|
||||
inline bool operator&(EthernetInterface a, EthernetInterface b) {
|
||||
return (static_cast<int32_t>(a) & static_cast<int32_t>(b));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
/** scan structure */
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user