udp_numdst readonly, udp_cleardst added

This commit is contained in:
2021-09-17 16:09:57 +02:00
parent 6151096823
commit dc671e6fcf
9 changed files with 76 additions and 76 deletions

View File

@ -271,6 +271,6 @@ int get_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 get_num_dest_list(int);
int set_num_dest_list(int); int clear_all_udp_dst(int);
int get_udp_first_dest(int); int get_udp_first_dest(int);
int set_udp_first_dest(int); int set_udp_first_dest(int);

View File

@ -408,7 +408,7 @@ void function_table() {
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_GET_NUM_DEST_UDP] = &get_num_dest_list;
flist[F_SET_NUM_DEST_UDP] = &set_num_dest_list; flist[F_CLEAR_ALL_UDP_DEST] = &clear_all_udp_dst;
flist[F_GET_UDP_FIRST_DEST] = &get_udp_first_dest; flist[F_GET_UDP_FIRST_DEST] = &get_udp_first_dest;
flist[F_SET_UDP_FIRST_DEST] = &set_udp_first_dest; flist[F_SET_UDP_FIRST_DEST] = &set_udp_first_dest;
@ -9198,7 +9198,32 @@ int set_dest_udp_list(int file_des) {
} }
} }
} }
configure_mac(); // find number of destinations
int numdest = 0;
for (int i = MAX_UDP_DESTINATION; i >= 0; --i) {
if (udpDetails[i].dstip != 0) {
numdest = i + 1;
break;
}
}
// atleast 1 destination
if (numdest == 0) {
numdest = 1;
}
// set number of destinations
#if defined(JUNGFRAUD) || defined(EIGERD)
if (setNumberofDestinations(numdest) == FAIL) {
ret = FAIL;
strcpy(mess, "Could not set number of udp destinations.\n");
LOG(logERROR, (mess));
} else
#endif
{
numUdpDestinations = numdest;
LOG(logINFOBLUE, ("Number of UDP Destinations: %d\n",
numUdpDestinations));
configure_mac();
}
} }
} }
} }
@ -9210,10 +9235,13 @@ int get_num_dest_list(int file_des) {
ret = OK; ret = OK;
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
int retval = -1; int retval = -1;
#if !defined(JUNGFRAUD) && !defined(EIGERD) #if !defined(JUNGFRAUD) && !defined(EIGERD)
functionNotImplemented(); functionNotImplemented();
#else #else
retval = numUdpDestinations; retval = numUdpDestinations;
LOG(logDEBUG1, ("numUdpDestinations retval: 0x%x\n", retval));
int retval1 = 0; int retval1 = 0;
if (getNumberofDestinations(&retval1) == FAIL || retval1 != retval) { if (getNumberofDestinations(&retval1) == FAIL || retval1 != retval) {
ret = FAIL; ret = FAIL;
@ -9223,42 +9251,23 @@ int get_num_dest_list(int file_des) {
LOG(logERROR, (mess)); LOG(logERROR, (mess));
} }
#endif #endif
LOG(logDEBUG1, ("numUdpDestinations retval: 0x%x\n", retval));
return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
} }
int set_num_dest_list(int file_des) { int clear_all_udp_dst(int file_des) {
ret = OK; ret = OK;
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
int arg = -1;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) LOG(logINFO, ("Clearing all udp destinations\n"));
return printSocketReadError(); if (Server_VerifyLock() == OK) {
LOG(logDEBUG1, ("Setting number of udp destinations to %d\n", arg)); if (check_detector_idle("clear all udp destinations") == OK) {
memset(udpDetails, 0, sizeof(udpDetails));
#if !defined(JUNGFRAUD) && !defined(EIGERD) // minimum 1 destination in fpga
functionNotImplemented(); numUdpDestinations = 1;
#else configure_mac();
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) {
if (setNumberofDestinations(arg) == FAIL) {
ret = FAIL;
strcpy(mess,
"Could not set number of udp destinations.\n");
LOG(logERROR, (mess));
} else {
numUdpDestinations = arg;
configure_mac();
}
} }
} }
#endif
return Server_SendResult(file_des, INT32, NULL, 0); return Server_SendResult(file_des, INT32, NULL, 0);
} }
@ -9295,19 +9304,22 @@ int set_udp_first_dest(int file_des) {
#ifndef JUNGFRAUD #ifndef JUNGFRAUD
functionNotImplemented(); functionNotImplemented();
#else #else
if (arg < 0 || arg >= numUdpDestinations) { // only set
ret = FAIL; if (Server_VerifyLock() == OK) {
sprintf(mess, "Could not set first destination. Options: 0-%d\n", if (arg < 0 || arg >= numUdpDestinations) {
numUdpDestinations - 1); ret = FAIL;
LOG(logERROR, (mess)); sprintf(mess, "Could not set first destination. Options: 0-%d\n",
} else { numUdpDestinations - 1);
if (check_detector_idle("set first udp destination") == OK) { LOG(logERROR, (mess));
setFirstUDPDestination(arg); } else {
int retval = getFirstUDPDestination(); if (check_detector_idle("set first udp destination") == OK) {
validate(&ret, mess, arg, retval, "set udp first destination", DEC); setFirstUDPDestination(arg);
if (ret == OK) { int retval = getFirstUDPDestination();
firstUDPDestination = arg; validate(&ret, mess, arg, retval, "set udp first destination", DEC);
//configure_mac(); if (ret == OK) {
firstUDPDestination = arg;
//configure_mac();
}
} }
} }
} }

View File

@ -671,8 +671,7 @@ class Detector {
/** [Jungfrau][Eiger] */ /** [Jungfrau][Eiger] */
Result<int> getNumberofUDPDestinations(Positions pos = {}) const; Result<int> getNumberofUDPDestinations(Positions pos = {}) const;
/**[Jungfrau][Eiger] Options 1-32 */ void clearUDPDestination(Positions pos = {});
void setNumberofUDPDestinations(const int value, Positions pos = {});
/** [Jungfrau] */ /** [Jungfrau] */
Result<int> getFirstUDPDestination(Positions pos = {}) const; Result<int> getFirstUDPDestination(Positions pos = {}) const;

View File

@ -861,6 +861,7 @@ class CmdProxy {
{"selinterface", &CmdProxy::selinterface}, {"selinterface", &CmdProxy::selinterface},
{"udp_dstlist", &CmdProxy::UDPDestinationList}, {"udp_dstlist", &CmdProxy::UDPDestinationList},
{"udp_numdst", &CmdProxy::udp_numdst}, {"udp_numdst", &CmdProxy::udp_numdst},
{"udp_cleardst", &CmdProxy::udp_cleardst},
{"udp_firstdst", &CmdProxy::udp_firstdst}, {"udp_firstdst", &CmdProxy::udp_firstdst},
{"udp_srcip", &CmdProxy::udp_srcip}, {"udp_srcip", &CmdProxy::udp_srcip},
{"udp_srcip2", &CmdProxy::udp_srcip2}, {"udp_srcip2", &CmdProxy::udp_srcip2},
@ -1542,6 +1543,9 @@ class CmdProxy {
"destinations that the detector will stream images " "destinations that the detector will stream images "
"out in a round robin fashion. This is get only command. Default: 1"); "out in a round robin fashion. This is get only command. Default: 1");
EXECUTE_SET_COMMAND(udp_cleardst, clearUDPDestination,
"\n\tClears udp destination details on the detector.");
INTEGER_COMMAND_VEC_ID( INTEGER_COMMAND_VEC_ID(
udp_firstdst, getFirstUDPDestination, setFirstUDPDestination, udp_firstdst, getFirstUDPDestination, setFirstUDPDestination,
StringTo<int>, StringTo<int>,

View File

@ -921,8 +921,8 @@ Result<int> Detector::getNumberofUDPDestinations(Positions pos) const {
return pimpl->Parallel(&Module::getNumberofUDPDestinations, pos); return pimpl->Parallel(&Module::getNumberofUDPDestinations, pos);
} }
void Detector::setNumberofUDPDestinations(const int value, Positions pos) { void Detector::clearUDPDestination(Positions pos) {
pimpl->Parallel(&Module::setNumberofUDPDestinations, pos, value); pimpl->Parallel(&Module::clearUDPDestination, pos);
} }
Result<int> Detector::getFirstUDPDestination(Positions pos) const { Result<int> Detector::getFirstUDPDestination(Positions pos) const {

View File

@ -970,9 +970,7 @@ int Module::getNumberofUDPDestinations() const {
return sendToDetector<int>(F_GET_NUM_DEST_UDP); return sendToDetector<int>(F_GET_NUM_DEST_UDP);
} }
void Module::setNumberofUDPDestinations(const int value) { void Module::clearUDPDestination() { sendToDetector(F_CLEAR_ALL_UDP_DEST); }
sendToDetector(F_SET_NUM_DEST_UDP, value, nullptr);
}
int Module::getFirstUDPDestination() const { int Module::getFirstUDPDestination() const {
return sendToDetector<int>(F_GET_UDP_FIRST_DEST); return sendToDetector<int>(F_GET_UDP_FIRST_DEST);

View File

@ -224,7 +224,7 @@ class Module : public virtual slsDetectorDefs {
sls::UdpDestination getDestinationUDPList(const uint32_t entry) const; sls::UdpDestination getDestinationUDPList(const uint32_t entry) const;
void setDestinationUDPList(const sls::UdpDestination dest); void setDestinationUDPList(const sls::UdpDestination dest);
int getNumberofUDPDestinations() const; int getNumberofUDPDestinations() const;
void setNumberofUDPDestinations(const int value); void clearUDPDestination();
int getFirstUDPDestination() const; int getFirstUDPDestination() const;
void setFirstUDPDestination(const int value); void setFirstUDPDestination(const int value);
sls::IpAddr getDestinationUDPIP() const; sls::IpAddr getDestinationUDPIP() const;

View File

@ -2229,33 +2229,20 @@ TEST_CASE("udp_numdst", "[.cmd]") {
CmdProxy proxy(&det); CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash(); auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU || det_type == defs::EIGER) { if (det_type == defs::JUNGFRAU || det_type == defs::EIGER) {
auto prev_val = det.getNumberofUDPDestinations(); REQUIRE_NOTHROW(proxy.Call("udp_numdst", {}, -1, GET));
{
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 { } else {
REQUIRE_THROWS(proxy.Call("udp_numdst", {}, -1, GET)); REQUIRE_THROWS(proxy.Call("udp_numdst", {}, -1, GET));
} }
} }
TEST_CASE("udp_cleardst", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
REQUIRE_THROWS(proxy.Call("udp_cleardst", {}, -1, GET));
REQUIRE_NOTHROW(proxy.Call("udp_cleardst", {}, -1, PUT));
}
TEST_CASE("udp_firstdst", "[.cmd]") { TEST_CASE("udp_firstdst", "[.cmd]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);

View File

@ -247,7 +247,7 @@ enum detFuncs {
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_GET_NUM_DEST_UDP,
F_SET_NUM_DEST_UDP, F_CLEAR_ALL_UDP_DEST,
F_GET_UDP_FIRST_DEST, F_GET_UDP_FIRST_DEST,
F_SET_UDP_FIRST_DEST, F_SET_UDP_FIRST_DEST,
@ -604,7 +604,7 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
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_GET_NUM_DEST_UDP: return "F_GET_NUM_DEST_UDP";
case F_SET_NUM_DEST_UDP: return "F_SET_NUM_DEST_UDP"; case F_CLEAR_ALL_UDP_DEST: return "F_CLEAR_ALL_UDP_DEST";
case F_GET_UDP_FIRST_DEST: return "F_GET_UDP_FIRST_DEST"; case F_GET_UDP_FIRST_DEST: return "F_GET_UDP_FIRST_DEST";
case F_SET_UDP_FIRST_DEST: return "F_SET_UDP_FIRST_DEST"; case F_SET_UDP_FIRST_DEST: return "F_SET_UDP_FIRST_DEST";