This commit is contained in:
maliakal_d 2021-07-15 14:48:41 +02:00
parent 8354395f64
commit 4d7fb4e4e0
6 changed files with 64 additions and 45 deletions

View File

@ -1739,7 +1739,7 @@ class Detector {
private: private:
std::vector<int> getPortNumbers(int start_port); std::vector<int> getPortNumbers(int start_port);
void updateRxRateCorrections(); void updateRxRateCorrections();
defs::EthernetInterface in_{defs::NONE}; defs::EthernetInterface in_{defs::EthernetInterface::NONE};
}; };
} // namespace sls } // namespace sls

View File

@ -1825,20 +1825,21 @@ std::string CmdProxy::VetoStreaming(int action) {
if (args.empty()) { if (args.empty()) {
WrongNumberOfParameters(1); WrongNumberOfParameters(1);
} }
defs::EthernetInterface interface = defs::EthernetInterface::none; defs::EthernetInterface interface = defs::EthernetInterface::NONE;
for (const auto &arg : args) { for (const auto &arg : args) {
if (arg == "none") { if (arg == "none") {
if (args.size() > 1) { if (args.size() > 1) {
throw sls::RuntimeError( throw sls::RuntimeError(
"cannot have other arguments with 'none'. args: " + "cannot have other arguments with 'none'. args: " +
arg); ToString(args));
} }
break; break;
} }
StringTo<defs::EthernetInterface>(arg);
interface = interface | (StringTo<defs::EthernetInterface>(arg)); interface = interface | (StringTo<defs::EthernetInterface>(arg));
} }
det->setVetoStream(interface, std::vector<int>{det_id}); det->setVetoStream(interface, std::vector<int>{det_id});
os << ToString(args) << '\n'; os << ToString(interface) << '\n';
} else { } else {
throw sls::RuntimeError("Unknown action"); throw sls::RuntimeError("Unknown action");
} }

View File

@ -1549,7 +1549,9 @@ void Detector::setVeto(bool enable, Positions pos) {
Result<defs::EthernetInterface> Detector::getVetoStream(Positions pos) const { Result<defs::EthernetInterface> Detector::getVetoStream(Positions pos) const {
// return pimpl->Parallel(&Module::getVetoStream, pos); // return pimpl->Parallel(&Module::getVetoStream, pos);
return Result<defs::EthernetInterface> res{in_}; Result<defs::EthernetInterface> res(1);
res[0] = in_;
return res;
} }
void Detector::setVetoStream(defs::EthernetInterface interface, Positions pos) { void Detector::setVetoStream(defs::EthernetInterface interface, Positions pos) {

View File

@ -557,27 +557,44 @@ TEST_CASE("vetostream", "[.cmd]") {
CmdProxy proxy(&det); CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash(); auto det_type = det.getDetectorType().squash();
if (det_type == defs::GOTTHARD2) { if (det_type == defs::GOTTHARD2) {
// auto prev_val = det.getNumberofUDPInterfaces().tsquash( auto prev_val = det.getVetoStream();
// "inconsistent numinterfaces to test");
/* {
std::ostringstream oss;
proxy.Call("vetostream", {"sdf"}, -1, PUT, oss);
REQUIRE(oss.str() == "vetostream 2\n");
}
{ {
std::ostringstream oss; std::ostringstream oss;
proxy.Call("vetostream", {"1"}, -1, PUT, oss); proxy.Call("vetostream", {"none"}, -1, PUT, oss);
REQUIRE(oss.str() == "vetostream 1\n"); REQUIRE(oss.str() == "vetostream none\n");
} }
{ {
std::ostringstream oss; std::ostringstream oss;
proxy.Call("vetostream", {}, -1, GET, oss); proxy.Call("vetostream", {}, -1, GET, oss);
REQUIRE(oss.str() == "vetostream 1\n"); REQUIRE(oss.str() == "vetostream none\n");
}*/ }
// det.setNumberofUDPInterfaces(prev_val); {
std::ostringstream oss;
proxy.Call("vetostream", {"3gbe"}, -1, PUT, oss);
REQUIRE(oss.str() == "vetostream 3gbe\n");
}
{
std::ostringstream oss;
proxy.Call("vetostream", {}, -1, GET, oss);
REQUIRE(oss.str() == "vetostream 3gbe\n");
}
{
std::ostringstream oss;
proxy.Call("vetostream", {"3gbe", "10gbe"}, -1, PUT, oss);
REQUIRE(oss.str() == "vetostream 3gbe, 10gbe\n");
}
{
std::ostringstream oss;
proxy.Call("vetostream", {}, -1, GET, oss);
REQUIRE(oss.str() == "vetostream 3gbe, 10gbe\n");
}
REQUIRE_THROWS(proxy.Call("vetostream", {"3gbe", "none"}, -1, PUT));
for (int i = 0; i != det.size(); ++i) {
det.setVetoStream(prev_val[i], {i});
}
} else { } else {
REQUIRE_THROWS(proxy.Call("vetostream", {}, -1, GET)); REQUIRE_THROWS(proxy.Call("vetostream", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("vetostream", {"1"}, -1, PUT)); REQUIRE_THROWS(proxy.Call("vetostream", {"none"}, -1, PUT));
} }
REQUIRE_THROWS(proxy.Call("vetostream", {"dfgd"}, -1, GET)); REQUIRE_THROWS(proxy.Call("vetostream", {"dfgd"}, -1, GET));
} }

View File

@ -405,18 +405,6 @@ typedef struct {
ALL = I3GBE | I10GBE 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 #ifdef __cplusplus
/** scan structure */ /** scan structure */
@ -508,8 +496,18 @@ typedef struct {
#ifdef __cplusplus #ifdef __cplusplus
}; };
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 bool operator&(const slsDetectorDefs::EthernetInterface &a,
const slsDetectorDefs::EthernetInterface &b) {
return (static_cast<int32_t>(a) & static_cast<int32_t>(b));
};
#endif #endif
;
#ifdef __cplusplus #ifdef __cplusplus
struct detParameters { struct detParameters {

View File

@ -523,15 +523,15 @@ std::string ToString(const defs::EthernetInterface s) {
std::ostringstream os; std::ostringstream os;
std::string rs; std::string rs;
switch (s) { switch (s) {
case defs::NONE: case defs::EthernetInterface::NONE:
return std::string("none"); return std::string("none");
default: default:
if (s & defs::I3GBE) if (s & defs::EthernetInterface::I3GBE)
os << "3gbe, "; os << "3gbe, ";
if (s & defs::I10GBE) if (s & defs::EthernetInterface::I10GBE)
os << "10gbe, "; os << "10gbe, ";
auto rs = os.str(); auto rs = os.str();
rs.erase(rs.end() - 2); rs.erase(rs.end() - 2, rs.end());
return rs; return rs;
} }
} }
@ -878,13 +878,14 @@ template <> defs::timingSourceType StringTo(const std::string &s) {
template <> defs::EthernetInterface StringTo(const std::string &s) { template <> defs::EthernetInterface StringTo(const std::string &s) {
std::string rs = s; std::string rs = s;
if (s.find(',') != std::string::npos)
rs.erase(rs.find(',')); rs.erase(rs.find(','));
if (rs == "none") if (rs == "none")
return defs::NONE; return defs::EthernetInterface::NONE;
if (rs == "3gbe") if (rs == "3gbe")
return defs::I3GBE; return defs::EthernetInterface::I3GBE;
if (rs == "10gbe") if (rs == "10gbe")
return defs::I10GBE; return defs::EthernetInterface::I10GBE;
throw sls::RuntimeError("Unknown EthernetInterface type " + s); throw sls::RuntimeError("Unknown EthernetInterface type " + s);
} }