mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-08 19:10:42 +02:00
rx_hostname, port, port2, dstlist works
This commit is contained in:
parent
41dc8329ab
commit
b9b5c623ec
12
examples/jungfrau_rr.config
Normal file
12
examples/jungfrau_rr.config
Normal 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
|
@ -1444,7 +1444,7 @@ std::string CmdProxy::UDPDestinationList(int action) {
|
|||||||
}
|
}
|
||||||
if (rx_id < 0 || rx_id >= MAX_UDP_DESTINATION) {
|
if (rx_id < 0 || rx_id >= MAX_UDP_DESTINATION) {
|
||||||
throw sls::RuntimeError(
|
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();
|
auto t = getUdpEntry();
|
||||||
det->setDestinationUDPList(t, det_id);
|
det->setDestinationUDPList(t, det_id);
|
||||||
@ -1579,8 +1579,8 @@ std::string CmdProxy::ReceiverHostname(int action) {
|
|||||||
"Cannot add multiple receivers at RR level");
|
"Cannot add multiple receivers at RR level");
|
||||||
}
|
}
|
||||||
auto t = sls::split(args[0], '+');
|
auto t = sls::split(args[0], '+');
|
||||||
det->setRxHostname(t);
|
det->setRxHostname(args[0]);
|
||||||
os << ToString(t) << '\n';
|
os << ToString(args[0]) << '\n';
|
||||||
}
|
}
|
||||||
// single receiver
|
// single receiver
|
||||||
else {
|
else {
|
||||||
|
@ -186,7 +186,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** int or enum */
|
/** 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::string CMDNAME(const int action) { \
|
||||||
std::ostringstream os; \
|
std::ostringstream os; \
|
||||||
os << cmd << ' '; \
|
os << cmd << ' '; \
|
||||||
@ -211,6 +211,31 @@
|
|||||||
return os.str(); \
|
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 */
|
/** int or enum */
|
||||||
#define INTEGER_COMMAND_SINGLE_ID(CMDNAME, GETFCN, SETFCN, CONV, HLPSTR) \
|
#define INTEGER_COMMAND_SINGLE_ID(CMDNAME, GETFCN, SETFCN, CONV, HLPSTR) \
|
||||||
std::string CMDNAME(const int action) { \
|
std::string CMDNAME(const int action) { \
|
||||||
@ -1612,14 +1637,14 @@ class CmdProxy {
|
|||||||
"[Gotthard2] veto "
|
"[Gotthard2] veto "
|
||||||
"debugging.");
|
"debugging.");
|
||||||
|
|
||||||
INTEGER_COMMAND_VEC_ID_GET(
|
INTEGER_COMMAND_VEC_ID_P_RX_SINGLE_ID(
|
||||||
udp_dstport, getDestinationUDPPort, setDestinationUDPPort,
|
udp_dstport, getDestinationUDPPort, setDestinationUDPPort,
|
||||||
StringTo<int>,
|
StringTo<int>,
|
||||||
"[n]\n\tPort number of the receiver (destination) udp "
|
"[n]\n\tPort number of the receiver (destination) udp "
|
||||||
"interface. Default is 50001. \n\tIf multi command, ports for each "
|
"interface. Default is 50001. \n\tIf multi command, ports for each "
|
||||||
"module is calculated (incremented by 1 if no 2nd interface)");
|
"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,
|
udp_dstport2, getDestinationUDPPort2, setDestinationUDPPort2,
|
||||||
StringTo<int>,
|
StringTo<int>,
|
||||||
"[n]\n\t[Jungfrau][Eiger][Gotthard2] Port number of the "
|
"[n]\n\t[Jungfrau][Eiger][Gotthard2] Port number of the "
|
||||||
@ -1678,7 +1703,7 @@ class CmdProxy {
|
|||||||
|
|
||||||
/* Receiver Config */
|
/* Receiver Config */
|
||||||
|
|
||||||
INTEGER_COMMAND_VEC_ID_GET(
|
INTEGER_COMMAND_VEC_ID_P_RX_SINGLE_ID(
|
||||||
rx_tcpport, getRxPort, setRxPort, StringTo<int>,
|
rx_tcpport, getRxPort, setRxPort, StringTo<int>,
|
||||||
"[port]\n\tTCP port for client-receiver communication. Default is "
|
"[port]\n\tTCP port for client-receiver communication. Default is "
|
||||||
"1954. Must be different if multiple receivers on same pc. Must be "
|
"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, "
|
"default, which streams the first frame in an acquisition, "
|
||||||
"and then depending on the rx zmq frequency/ timer");
|
"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>,
|
rx_zmqport, getRxZmqPort, setRxZmqPort, StringTo<int>,
|
||||||
"[port]\n\tZmq port for data to be streamed out of the receiver. Also "
|
"[port]\n\tZmq port for data to be streamed out of the receiver. Also "
|
||||||
"restarts receiver zmq streaming if enabled. Default is 30001. "
|
"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). "
|
"client(gui). Must be different for every detector (and udp port). "
|
||||||
"Multi command will automatically increment for individual modules.");
|
"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>,
|
zmqport, getClientZmqPort, setClientZmqPort, StringTo<int>,
|
||||||
"[port]\n\tZmq port in client(gui) or intermediate process for data to "
|
"[port]\n\tZmq port in client(gui) or intermediate process for data to "
|
||||||
"be streamed to from receiver. Default connects to receiver zmq "
|
"be streamed to from receiver. Default connects to receiver zmq "
|
||||||
|
@ -87,7 +87,7 @@ void Detector::loadParameters(const std::vector<std::string> ¶meters) {
|
|||||||
for (const auto ¤t_line : parameters) {
|
for (const auto ¤t_line : parameters) {
|
||||||
parser.Parse(current_line);
|
parser.Parse(current_line);
|
||||||
proxy.Call(parser.command(), parser.arguments(), parser.detector_id(),
|
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) {
|
if (name.size() == 1) {
|
||||||
pimpl->Parallel(&Module::setReceiverHostname, {}, name[0]);
|
pimpl->Parallel(&Module::setReceiverHostname, {}, name[0]);
|
||||||
} else {
|
} else {
|
||||||
if ((int)name.size() != size()) {
|
/*if ((int)name.size() != size()) {
|
||||||
throw RuntimeError(
|
throw RuntimeError(
|
||||||
"Receiver hostnames size " + std::to_string(name.size()) +
|
"Receiver hostnames size " + std::to_string(name.size()) +
|
||||||
" does not match detector size " + std::to_string(size()));
|
" does not match detector size " + std::to_string(size()));
|
||||||
}
|
}*/
|
||||||
// set each rx_hostname
|
// set each rx_hostname
|
||||||
for (int idet = 0; idet < size(); ++idet) {
|
for (int idet = 0; idet < size(); ++idet) {
|
||||||
pimpl->Parallel(&Module::setReceiverHostname, {idet}, name[idet]);
|
pimpl->Parallel(&Module::setReceiverHostname, {idet}, name[idet]);
|
||||||
|
@ -1281,8 +1281,7 @@ void Module::setReceiverHostname(const std::string &receiverIP) {
|
|||||||
std::vector<std::string> list;
|
std::vector<std::string> list;
|
||||||
// many rx hostames concatenated with + (RR)
|
// many rx hostames concatenated with + (RR)
|
||||||
if (receiverIP.find('+') != std::string::npos) {
|
if (receiverIP.find('+') != std::string::npos) {
|
||||||
auto t = sls::split(receiverIP, '+');
|
list = sls::split(receiverIP, '+');
|
||||||
list.push_back(t);
|
|
||||||
} else {
|
} else {
|
||||||
list.push_back(receiverIP);
|
list.push_back(receiverIP);
|
||||||
}
|
}
|
||||||
@ -1294,8 +1293,9 @@ void Module::setReceiverHostname(const std::string &receiverIP) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// start updating
|
// start updating
|
||||||
for (int i = 0; i != list.size(); ++i) {
|
for (size_t i = 0; i != list.size(); ++i) {
|
||||||
std::string host = receiverIP;
|
LOG(logINFOBLUE) << i << ": " << list[i];
|
||||||
|
std::string host = list[i];
|
||||||
auto res = sls::split(host, ':');
|
auto res = sls::split(host, ':');
|
||||||
if (res.size() > 1) {
|
if (res.size() > 1) {
|
||||||
host = res[0];
|
host = res[0];
|
||||||
@ -1319,6 +1319,8 @@ void Module::setReceiverHostname(const std::string &receiverIP) {
|
|||||||
|
|
||||||
sls::MacAddr retvals[2];
|
sls::MacAddr retvals[2];
|
||||||
sendToReceiver(i, F_SETUP_RECEIVER, retval, retvals);
|
sendToReceiver(i, F_SETUP_RECEIVER, retval, retvals);
|
||||||
|
|
||||||
|
if (i == 0) {
|
||||||
// update Modules with dest mac
|
// update Modules with dest mac
|
||||||
if (retval.udp_dstmac == 0 && retvals[0] != 0) {
|
if (retval.udp_dstmac == 0 && retvals[0] != 0) {
|
||||||
LOG(logINFO) << "Setting destination udp mac of "
|
LOG(logINFO) << "Setting destination udp mac of "
|
||||||
@ -1332,6 +1334,7 @@ void Module::setReceiverHostname(const std::string &receiverIP) {
|
|||||||
<< moduleIndex << " to " << retvals[1];
|
<< moduleIndex << " to " << retvals[1];
|
||||||
sendToDetector(F_SET_DEST_UDP_MAC2, retvals[1], nullptr);
|
sendToDetector(F_SET_DEST_UDP_MAC2, retvals[1], nullptr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
shm()->numUDPInterfaces = retval.udpInterfaces;
|
shm()->numUDPInterfaces = retval.udpInterfaces;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user