added udp_numdst

This commit is contained in:
2021-08-19 15:50:02 +02:00
parent de4f06287d
commit ab59f7db7b
9 changed files with 128 additions and 1 deletions

View File

@ -671,6 +671,12 @@ class Detector {
void setDestinationUDPList(const defs::udpDestination, const int module_id);
/** [Jungfrau][Eiger] */
Result<int> getNumberofUDPDestinations(Positions pos = {}) const;
/**[Jungfrau][Eiger] Options 1-32 */
void setNumberofUDPDestinations(const int value, Positions pos = {});
Result<IpAddr> getDestinationUDPIP(Positions pos = {}) const;
/** IP of the interface in receiver that the detector sends data to */

View File

@ -858,6 +858,7 @@ class CmdProxy {
{"numinterfaces", &CmdProxy::numinterfaces},
{"selinterface", &CmdProxy::selinterface},
{"udp_dstlist", &CmdProxy::UDPDestinationList},
{"udp_numdst", &CmdProxy::udp_numdst},
{"udp_srcip", &CmdProxy::udp_srcip},
{"udp_srcip2", &CmdProxy::udp_srcip2},
{"udp_dstip", &CmdProxy::UDPDestinationIP},
@ -1532,6 +1533,12 @@ class CmdProxy {
"[0, 1]\n\t[Jungfrau] The udp interface to stream data from detector. "
"Effective only when number of interfaces is 1. Default: 0 (outer)");
INTEGER_COMMAND_VEC_ID(udp_numdst, getNumberofUDPDestinations,
setNumberofUDPDestinations, StringTo<int>,
"[1 - 32]\n\t[Jungfrau][Eiger] One can set upto 32 "
"destinations that the detector will stream images "
"out in a round robin fashion. Default: 1");
INTEGER_COMMAND_VEC_ID(
udp_srcip, getSourceUDPIP, setSourceUDPIP, IpAddr,
"[x.x.x.x]\n\tIp address of the detector (source) udp "

View File

@ -921,6 +921,14 @@ void Detector::setDestinationUDPList(const defs::udpDestination dest,
pimpl->Parallel(&Module::setDestinationUDPList, {module_id}, dest);
}
Result<int> Detector::getNumberofUDPDestinations(Positions pos) const {
return pimpl->Parallel(&Module::getNumberofUDPDestinations, pos);
}
void Detector::setNumberofUDPDestinations(const int value, Positions pos) {
pimpl->Parallel(&Module::setNumberofUDPDestinations, pos, value);
}
Result<IpAddr> Detector::getDestinationUDPIP(Positions pos) const {
return pimpl->Parallel(&Module::getDestinationUDPIP, pos);
}

View File

@ -962,6 +962,14 @@ void Module::setDestinationUDPList(const slsDetectorDefs::udpDestination dest) {
}
}
int Module::getNumberofUDPDestinations() const {
return sendToDetector<int>(F_GET_NUM_DEST_UDP);
}
void Module::setNumberofUDPDestinations(const int value) {
sendToDetector(F_SET_NUM_DEST_UDP, value, nullptr);
}
sls::IpAddr Module::getDestinationUDPIP() const {
return sendToDetector<sls::IpAddr>(F_GET_DEST_UDP_IP);
}

View File

@ -224,6 +224,8 @@ class Module : public virtual slsDetectorDefs {
void setSourceUDPMAC2(const sls::MacAddr mac);
udpDestination getDestinationUDPList(const uint32_t entry) const;
void setDestinationUDPList(const defs::udpDestination dest);
int getNumberofUDPDestinations() const;
void setNumberofUDPDestinations(const int value);
sls::IpAddr getDestinationUDPIP() const;
void setDestinationUDPIP(const sls::IpAddr ip);
sls::IpAddr getDestinationUDPIP2() const;

View File

@ -2215,6 +2215,53 @@ TEST_CASE("udp_srcip", "[.cmd]") {
}
}
TEST_CASE("udp_dstlist", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU || det_type == defs::EIGER) {
REQUIRE_NOTHROW(proxy.Call("udp_dstlist", {"0"}, -1, GET));
REQUIRE_THROWS(proxy.Call(
"udp_dstlist",
{"entry=0", "ip=0.0.0.0", "mac=00:00:00:00:00:00", "port=1233"}, -1,
PUT));
} else {
REQUIRE_THROWS(proxy.Call("udp_dstlist", {"0"}, -1, GET));
}
}
TEST_CASE("udp_numdst", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU || det_type == defs::EIGER) {
auto prev_val = det.getNumberofUDPDestinations();
{
std::ostringstream oss;
proxy.Call("udp_numdst", {"10"}, -1, PUT, oss);
REQUIRE(oss.str() == "udp_numdst 10\n");
}
{
std::ostringstream oss;
proxy.Call("udp_numdst", {}, -1, GET, oss);
REQUIRE(oss.str() == "udp_numdst 10\n");
}
{
std::ostringstream oss;
proxy.Call("udp_numdst", {"32"}, -1, PUT, oss);
REQUIRE(oss.str() == "udp_numdst 32\n");
}
REQUIRE_THROWS(proxy.Call("udp_numdst", {"0"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("udp_numdst", {"33"}, -1, PUT));
for (int i = 0; i != det.size(); ++i) {
det.setNumberofUDPDestinations(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("udp_numdst", {}, -1, GET));
}
}
TEST_CASE("udp_dstip", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);