rx_hostname, port, port2, dstlist works

This commit is contained in:
maliakal_d 2021-10-25 11:10:12 +02:00
parent 41dc8329ab
commit b9b5c623ec
5 changed files with 68 additions and 28 deletions

View File

@ -0,0 +1,12 @@
hostname bchip258+
0:rx_hostname pc13784:1954+pc13784:1955+
udp_srcip 10.0.2.184
udp_dstip 10.0.2.1
0:0 udp_dstport 50000
0:1 udp_dstport 50001
#0:0 udp_dstlist port=50001
#0:1 udp_dstlist port=50002

View File

@ -1444,7 +1444,7 @@ std::string CmdProxy::UDPDestinationList(int action) {
}
if (rx_id < 0 || rx_id >= MAX_UDP_DESTINATION) {
throw sls::RuntimeError(
"Invalid receiver index to set round robin entry.");
std::string("Invalid receiver index ") + std::to_string(rx_id) + std::string(" to set round robin entry."));
}
auto t = getUdpEntry();
det->setDestinationUDPList(t, det_id);
@ -1579,8 +1579,8 @@ std::string CmdProxy::ReceiverHostname(int action) {
"Cannot add multiple receivers at RR level");
}
auto t = sls::split(args[0], '+');
det->setRxHostname(t);
os << ToString(t) << '\n';
det->setRxHostname(args[0]);
os << ToString(args[0]) << '\n';
}
// single receiver
else {

View File

@ -186,7 +186,7 @@
}
/** int or enum */
#define INTEGER_COMMAND_VEC_ID_GET(CMDNAME, GETFCN, SETFCN, CONV, HLPSTR) \
#define INTEGER_COMMAND_VEC_ID_PUT_SINGLE_ID(CMDNAME, GETFCN, SETFCN, CONV, HLPSTR) \
std::string CMDNAME(const int action) { \
std::ostringstream os; \
os << cmd << ' '; \
@ -211,6 +211,31 @@
return os.str(); \
}
#define INTEGER_COMMAND_VEC_ID_P_RX_SINGLE_ID(CMDNAME, GETFCN, SETFCN, CONV, HLPSTR) \
std::string CMDNAME(const int action) { \
std::ostringstream os; \
os << cmd << ' '; \
if (action == slsDetectorDefs::HELP_ACTION) \
os << HLPSTR << '\n'; \
else if (action == slsDetectorDefs::GET_ACTION) { \
if (!args.empty()) { \
WrongNumberOfParameters(0); \
} \
auto t = det->GETFCN(std::vector<int>{det_id}, rx_id); \
os << OutString(t) << '\n'; \
} else if (action == slsDetectorDefs::PUT_ACTION) { \
if (args.size() != 1) { \
WrongNumberOfParameters(1); \
} \
auto val = CONV(args[0]); \
det->SETFCN(val, det_id, rx_id); \
os << args.front() << '\n'; \
} else { \
throw sls::RuntimeError("Unknown action"); \
} \
return os.str(); \
}
/** int or enum */
#define INTEGER_COMMAND_SINGLE_ID(CMDNAME, GETFCN, SETFCN, CONV, HLPSTR) \
std::string CMDNAME(const int action) { \
@ -1612,14 +1637,14 @@ class CmdProxy {
"[Gotthard2] veto "
"debugging.");
INTEGER_COMMAND_VEC_ID_GET(
INTEGER_COMMAND_VEC_ID_P_RX_SINGLE_ID(
udp_dstport, getDestinationUDPPort, setDestinationUDPPort,
StringTo<int>,
"[n]\n\tPort number of the receiver (destination) udp "
"interface. Default is 50001. \n\tIf multi command, ports for each "
"module is calculated (incremented by 1 if no 2nd interface)");
INTEGER_COMMAND_VEC_ID_GET(
INTEGER_COMMAND_VEC_ID_P_RX_SINGLE_ID(
udp_dstport2, getDestinationUDPPort2, setDestinationUDPPort2,
StringTo<int>,
"[n]\n\t[Jungfrau][Eiger][Gotthard2] Port number of the "
@ -1678,7 +1703,7 @@ class CmdProxy {
/* Receiver Config */
INTEGER_COMMAND_VEC_ID_GET(
INTEGER_COMMAND_VEC_ID_P_RX_SINGLE_ID(
rx_tcpport, getRxPort, setRxPort, StringTo<int>,
"[port]\n\tTCP port for client-receiver communication. Default is "
"1954. Must be different if multiple receivers on same pc. Must be "
@ -1800,7 +1825,7 @@ class CmdProxy {
"default, which streams the first frame in an acquisition, "
"and then depending on the rx zmq frequency/ timer");
INTEGER_COMMAND_VEC_ID_GET(
INTEGER_COMMAND_VEC_ID_PUT_SINGLE_ID(
rx_zmqport, getRxZmqPort, setRxZmqPort, StringTo<int>,
"[port]\n\tZmq port for data to be streamed out of the receiver. Also "
"restarts receiver zmq streaming if enabled. Default is 30001. "
@ -1808,7 +1833,7 @@ class CmdProxy {
"client(gui). Must be different for every detector (and udp port). "
"Multi command will automatically increment for individual modules.");
INTEGER_COMMAND_VEC_ID_GET(
INTEGER_COMMAND_VEC_ID_PUT_SINGLE_ID(
zmqport, getClientZmqPort, setClientZmqPort, StringTo<int>,
"[port]\n\tZmq port in client(gui) or intermediate process for data to "
"be streamed to from receiver. Default connects to receiver zmq "

View File

@ -87,7 +87,7 @@ void Detector::loadParameters(const std::vector<std::string> &parameters) {
for (const auto &current_line : parameters) {
parser.Parse(current_line);
proxy.Call(parser.command(), parser.arguments(), parser.detector_id(),
defs::PUT_ACTION);
defs::PUT_ACTION, std::cout, parser.receiver_id());
}
}
@ -1087,11 +1087,11 @@ void Detector::setRxHostname(const std::vector<std::string> &name) {
if (name.size() == 1) {
pimpl->Parallel(&Module::setReceiverHostname, {}, name[0]);
} else {
if ((int)name.size() != size()) {
/*if ((int)name.size() != size()) {
throw RuntimeError(
"Receiver hostnames size " + std::to_string(name.size()) +
" does not match detector size " + std::to_string(size()));
}
}*/
// set each rx_hostname
for (int idet = 0; idet < size(); ++idet) {
pimpl->Parallel(&Module::setReceiverHostname, {idet}, name[idet]);

View File

@ -1281,8 +1281,7 @@ void Module::setReceiverHostname(const std::string &receiverIP) {
std::vector<std::string> list;
// many rx hostames concatenated with + (RR)
if (receiverIP.find('+') != std::string::npos) {
auto t = sls::split(receiverIP, '+');
list.push_back(t);
list = sls::split(receiverIP, '+');
} else {
list.push_back(receiverIP);
}
@ -1294,8 +1293,9 @@ void Module::setReceiverHostname(const std::string &receiverIP) {
}
// start updating
for (int i = 0; i != list.size(); ++i) {
std::string host = receiverIP;
for (size_t i = 0; i != list.size(); ++i) {
LOG(logINFOBLUE) << i << ": " << list[i];
std::string host = list[i];
auto res = sls::split(host, ':');
if (res.size() > 1) {
host = res[0];
@ -1319,18 +1319,21 @@ void Module::setReceiverHostname(const std::string &receiverIP) {
sls::MacAddr retvals[2];
sendToReceiver(i, F_SETUP_RECEIVER, retval, retvals);
// update Modules with dest mac
if (retval.udp_dstmac == 0 && retvals[0] != 0) {
LOG(logINFO) << "Setting destination udp mac of "
"Module "
<< moduleIndex << " to " << retvals[0];
sendToDetector(F_SET_DEST_UDP_MAC, retvals[0], nullptr);
}
if (retval.udp_dstmac2 == 0 && retvals[1] != 0) {
LOG(logINFO) << "Setting destination udp mac2 of "
"Module "
<< moduleIndex << " to " << retvals[1];
sendToDetector(F_SET_DEST_UDP_MAC2, retvals[1], nullptr);
if (i == 0) {
// update Modules with dest mac
if (retval.udp_dstmac == 0 && retvals[0] != 0) {
LOG(logINFO) << "Setting destination udp mac of "
"Module "
<< moduleIndex << " to " << retvals[0];
sendToDetector(F_SET_DEST_UDP_MAC, retvals[0], nullptr);
}
if (retval.udp_dstmac2 == 0 && retvals[1] != 0) {
LOG(logINFO) << "Setting destination udp mac2 of "
"Module "
<< moduleIndex << " to " << retvals[1];
sendToDetector(F_SET_DEST_UDP_MAC2, retvals[1], nullptr);
}
}
shm()->numUDPInterfaces = retval.udpInterfaces;