added udp_numdst

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

View File

@ -271,3 +271,5 @@ int get_module_id(int);
int set_module_id(int); int set_module_id(int);
int get_dest_udp_list(int); int get_dest_udp_list(int);
int set_dest_udp_list(int); int set_dest_udp_list(int);
int get_num_dest_list(int);
int set_num_dest_list(int);

View File

@ -404,6 +404,8 @@ void function_table() {
flist[F_SET_MODULE_ID] = &set_module_id; flist[F_SET_MODULE_ID] = &set_module_id;
flist[F_GET_DEST_UDP_LIST] = &get_dest_udp_list; flist[F_GET_DEST_UDP_LIST] = &get_dest_udp_list;
flist[F_SET_DEST_UDP_LIST] = &set_dest_udp_list; flist[F_SET_DEST_UDP_LIST] = &set_dest_udp_list;
flist[F_GET_NUM_DEST_UDP] = &get_num_dest_list;
flist[F_SET_NUM_DEST_UDP] = &set_num_dest_list;
// check // check
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) { if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
@ -9112,3 +9114,44 @@ int set_dest_udp_list(int file_des) {
#endif #endif
return Server_SendResult(file_des, INT32, NULL, 0); return Server_SendResult(file_des, INT32, NULL, 0);
} }
int get_num_dest_list(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int retval = -1;
#if !defined(JUNGFRAUD) && !defined(EIGERD)
functionNotImplemented();
#else
retval = numUdpDestinations;
#endif
LOG(logDEBUG1, ("numUdpDestinations retval: 0x%x\n", retval));
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
int set_num_dest_list(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int arg = -1;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
LOG(logDEBUG1, ("Setting number of udp destinations to %d\n", arg));
#if !defined(JUNGFRAUD) && !defined(EIGERD)
functionNotImplemented();
#else
if (arg < 1 || arg > MAX_UDP_DESTINATION) {
ret = FAIL;
sprintf(mess,
"Could not set number of udp destinations. Options: 1-%d\n",
MAX_UDP_DESTINATION);
LOG(logERROR, (mess));
} else {
if (check_detector_idle("set number of udp destinations") == OK) {
numUdpDestinations = arg;
configure_mac();
}
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}

View File

@ -671,6 +671,12 @@ class Detector {
void setDestinationUDPList(const defs::udpDestination, const int module_id); 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; Result<IpAddr> getDestinationUDPIP(Positions pos = {}) const;
/** IP of the interface in receiver that the detector sends data to */ /** IP of the interface in receiver that the detector sends data to */

View File

@ -858,6 +858,7 @@ class CmdProxy {
{"numinterfaces", &CmdProxy::numinterfaces}, {"numinterfaces", &CmdProxy::numinterfaces},
{"selinterface", &CmdProxy::selinterface}, {"selinterface", &CmdProxy::selinterface},
{"udp_dstlist", &CmdProxy::UDPDestinationList}, {"udp_dstlist", &CmdProxy::UDPDestinationList},
{"udp_numdst", &CmdProxy::udp_numdst},
{"udp_srcip", &CmdProxy::udp_srcip}, {"udp_srcip", &CmdProxy::udp_srcip},
{"udp_srcip2", &CmdProxy::udp_srcip2}, {"udp_srcip2", &CmdProxy::udp_srcip2},
{"udp_dstip", &CmdProxy::UDPDestinationIP}, {"udp_dstip", &CmdProxy::UDPDestinationIP},
@ -1532,6 +1533,12 @@ class CmdProxy {
"[0, 1]\n\t[Jungfrau] The udp interface to stream data from detector. " "[0, 1]\n\t[Jungfrau] The udp interface to stream data from detector. "
"Effective only when number of interfaces is 1. Default: 0 (outer)"); "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( INTEGER_COMMAND_VEC_ID(
udp_srcip, getSourceUDPIP, setSourceUDPIP, IpAddr, udp_srcip, getSourceUDPIP, setSourceUDPIP, IpAddr,
"[x.x.x.x]\n\tIp address of the detector (source) udp " "[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); 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 { Result<IpAddr> Detector::getDestinationUDPIP(Positions pos) const {
return pimpl->Parallel(&Module::getDestinationUDPIP, pos); 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 { sls::IpAddr Module::getDestinationUDPIP() const {
return sendToDetector<sls::IpAddr>(F_GET_DEST_UDP_IP); 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); void setSourceUDPMAC2(const sls::MacAddr mac);
udpDestination getDestinationUDPList(const uint32_t entry) const; udpDestination getDestinationUDPList(const uint32_t entry) const;
void setDestinationUDPList(const defs::udpDestination dest); void setDestinationUDPList(const defs::udpDestination dest);
int getNumberofUDPDestinations() const;
void setNumberofUDPDestinations(const int value);
sls::IpAddr getDestinationUDPIP() const; sls::IpAddr getDestinationUDPIP() const;
void setDestinationUDPIP(const sls::IpAddr ip); void setDestinationUDPIP(const sls::IpAddr ip);
sls::IpAddr getDestinationUDPIP2() const; 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]") { TEST_CASE("udp_dstip", "[.cmd]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);

View File

@ -247,6 +247,8 @@ enum detFuncs {
F_SET_MODULE_ID, F_SET_MODULE_ID,
F_GET_DEST_UDP_LIST, F_GET_DEST_UDP_LIST,
F_SET_DEST_UDP_LIST, F_SET_DEST_UDP_LIST,
F_GET_NUM_DEST_UDP,
F_SET_NUM_DEST_UDP,
NUM_DET_FUNCTIONS, NUM_DET_FUNCTIONS,
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this RECEIVER_ENUM_START = 256, /**< detector function should not exceed this
@ -601,6 +603,8 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_SET_MODULE_ID: return "F_SET_MODULE_ID"; case F_SET_MODULE_ID: return "F_SET_MODULE_ID";
case F_GET_DEST_UDP_LIST: return "F_GET_DEST_UDP_LIST"; case F_GET_DEST_UDP_LIST: return "F_GET_DEST_UDP_LIST";
case F_SET_DEST_UDP_LIST: return "F_SET_DEST_UDP_LIST"; case F_SET_DEST_UDP_LIST: return "F_SET_DEST_UDP_LIST";
case F_GET_NUM_DEST_UDP: return "F_GET_NUM_DEST_UDP";
case F_SET_NUM_DEST_UDP: return "F_SET_NUM_DEST_UDP";
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS"; case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START"; case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";