mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
vetoalg: wip
This commit is contained in:
@ -36,7 +36,8 @@ 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 defs::ethernetInterface s);
|
||||
std::string ToString(const defs::vetoAlgorithm s);
|
||||
|
||||
std::string ToString(const slsDetectorDefs::xy &coord);
|
||||
std::ostream &operator<<(std::ostream &os, const slsDetectorDefs::xy &coord);
|
||||
@ -298,7 +299,8 @@ 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 <> defs::ethernetInterface StringTo(const std::string &s);
|
||||
template <> defs::vetoAlgorithm StringTo(const std::string &s);
|
||||
|
||||
template <> uint32_t StringTo(const std::string &s);
|
||||
template <> uint64_t StringTo(const std::string &s);
|
||||
|
@ -395,9 +395,9 @@ typedef struct {
|
||||
enum timingSourceType { TIMING_INTERNAL, TIMING_EXTERNAL };
|
||||
|
||||
#ifdef __cplusplus
|
||||
enum class EthernetInterface {
|
||||
enum class ethernetInterface {
|
||||
#else
|
||||
enum EthernetInterface {
|
||||
enum ethernetInterface {
|
||||
#endif
|
||||
NONE = 0,
|
||||
I3GBE = 1 << 1,
|
||||
@ -405,6 +405,8 @@ typedef struct {
|
||||
ALL = I3GBE | I10GBE
|
||||
};
|
||||
|
||||
enum vetoAlgorithm { DEFAULT_ALGORITHM };
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
/** scan structure */
|
||||
@ -496,16 +498,18 @@ typedef struct {
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
inline slsDetectorDefs::EthernetInterface
|
||||
operator|( const slsDetectorDefs::EthernetInterface &a,
|
||||
const slsDetectorDefs::EthernetInterface &b) {
|
||||
return slsDetectorDefs::EthernetInterface(static_cast<int32_t>(a) |
|
||||
inline slsDetectorDefs::ethernetInterface
|
||||
operator|(const slsDetectorDefs::ethernetInterface &a,
|
||||
const slsDetectorDefs::ethernetInterface &b) {
|
||||
return slsDetectorDefs::ethernetInterface(static_cast<int32_t>(a) |
|
||||
static_cast<int32_t>(b));
|
||||
};
|
||||
|
||||
inline slsDetectorDefs::EthernetInterface operator&( const slsDetectorDefs::EthernetInterface &a,
|
||||
const slsDetectorDefs::EthernetInterface &b) {
|
||||
return slsDetectorDefs::EthernetInterface(static_cast<int32_t>(a) & static_cast<int32_t>(b));
|
||||
inline slsDetectorDefs::ethernetInterface
|
||||
operator&(const slsDetectorDefs::ethernetInterface &a,
|
||||
const slsDetectorDefs::ethernetInterface &b) {
|
||||
return slsDetectorDefs::ethernetInterface(static_cast<int32_t>(a) &
|
||||
static_cast<int32_t>(b));
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -583,7 +587,7 @@ struct detParameters {
|
||||
#ifdef __cplusplus
|
||||
struct sls_detector_module {
|
||||
#else
|
||||
typedef struct {
|
||||
typedef struct {
|
||||
#endif
|
||||
int serialnumber; /**< is the module serial number */
|
||||
int nchan; /**< is the number of channels on the module*/
|
||||
|
@ -519,16 +519,18 @@ std::string ToString(const defs::timingSourceType s) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string ToString(const defs::EthernetInterface s) {
|
||||
std::string ToString(const defs::ethernetInterface s) {
|
||||
std::ostringstream os;
|
||||
std::string rs;
|
||||
switch (s) {
|
||||
case defs::EthernetInterface::NONE:
|
||||
case defs::ethernetInterface::NONE:
|
||||
return std::string("none");
|
||||
default:
|
||||
if ((s & defs::EthernetInterface::I3GBE)!=defs::EthernetInterface::NONE)
|
||||
if ((s & defs::ethernetInterface::I3GBE) !=
|
||||
defs::ethernetInterface::NONE)
|
||||
os << "3gbe, ";
|
||||
if ((s & defs::EthernetInterface::I10GBE)!=defs::EthernetInterface::NONE)
|
||||
if ((s & defs::ethernetInterface::I10GBE) !=
|
||||
defs::ethernetInterface::NONE)
|
||||
os << "10gbe, ";
|
||||
auto rs = os.str();
|
||||
rs.erase(rs.end() - 2, rs.end());
|
||||
@ -536,6 +538,15 @@ std::string ToString(const defs::EthernetInterface s) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string ToString(const defs::vetoAlgorithm s) {
|
||||
switch (s) {
|
||||
case defs::DEFAULT_ALGORITHM:
|
||||
return std::string("default");
|
||||
default:
|
||||
return std::string("Unknown");
|
||||
}
|
||||
}
|
||||
|
||||
const std::string &ToString(const std::string &s) { return s; }
|
||||
|
||||
template <> defs::detectorType StringTo(const std::string &s) {
|
||||
@ -876,17 +887,23 @@ template <> defs::timingSourceType StringTo(const std::string &s) {
|
||||
throw sls::RuntimeError("Unknown timing source type " + s);
|
||||
}
|
||||
|
||||
template <> defs::EthernetInterface StringTo(const std::string &s) {
|
||||
template <> defs::ethernetInterface StringTo(const std::string &s) {
|
||||
std::string rs = s;
|
||||
if (s.find(',') != std::string::npos)
|
||||
rs.erase(rs.find(','));
|
||||
if (rs == "none")
|
||||
return defs::EthernetInterface::NONE;
|
||||
return defs::ethernetInterface::NONE;
|
||||
if (rs == "3gbe")
|
||||
return defs::EthernetInterface::I3GBE;
|
||||
return defs::ethernetInterface::I3GBE;
|
||||
if (rs == "10gbe")
|
||||
return defs::EthernetInterface::I10GBE;
|
||||
throw sls::RuntimeError("Unknown EthernetInterface type " + s);
|
||||
return defs::ethernetInterface::I10GBE;
|
||||
throw sls::RuntimeError("Unknown ethernetInterface type " + s);
|
||||
}
|
||||
|
||||
template <> defs::vetoAlgorithm StringTo(const std::string &s) {
|
||||
if (s == "default")
|
||||
return defs::DEFAULT_ALGORITHM;
|
||||
throw sls::RuntimeError("Unknown veto algorithm " + s);
|
||||
}
|
||||
|
||||
template <> uint32_t StringTo(const std::string &s) {
|
||||
|
@ -324,10 +324,10 @@ TEST_CASE("Print a member of patternParameters") {
|
||||
REQUIRE(ToString(pat->limits) == "[4, 100]");
|
||||
}
|
||||
|
||||
TEST_CASE("EthernetInterface") {
|
||||
REQUIRE(ToString(sls::defs::EthernetInterface::NONE) == "none");
|
||||
REQUIRE(ToString(sls::defs::EthernetInterface::I10GBE) == "10gbe");
|
||||
REQUIRE(ToString(sls::defs::EthernetInterface::I3GBE) == "3gbe");
|
||||
REQUIRE(ToString(sls::defs::EthernetInterface::I3GBE |
|
||||
sls::defs::EthernetInterface::I10GBE) == "3gbe, 10gbe");
|
||||
TEST_CASE("ethernetInterface") {
|
||||
REQUIRE(ToString(sls::defs::ethernetInterface::NONE) == "none");
|
||||
REQUIRE(ToString(sls::defs::ethernetInterface::I10GBE) == "10gbe");
|
||||
REQUIRE(ToString(sls::defs::ethernetInterface::I3GBE) == "3gbe");
|
||||
REQUIRE(ToString(sls::defs::ethernetInterface::I3GBE |
|
||||
sls::defs::ethernetInterface::I10GBE) == "3gbe, 10gbe");
|
||||
}
|
Reference in New Issue
Block a user