mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-30 01:40:04 +02:00
rx_hostname can be added with port and also concatenated
This commit is contained in:
parent
272a8bfaf1
commit
16d5321885
@ -492,10 +492,13 @@ class Detector {
|
|||||||
* Validates and sets the receiver.
|
* Validates and sets the receiver.
|
||||||
* Updates local receiver cache parameters
|
* Updates local receiver cache parameters
|
||||||
* Configures the detector to the receiver as UDP destination
|
* Configures the detector to the receiver as UDP destination
|
||||||
* @param receiver receiver hostname or IP address
|
* @param receiver receiver hostname or IP address, can include tcp port eg. hostname:port
|
||||||
*/
|
*/
|
||||||
void setRxHostname(const std::string &receiver, Positions pos = {});
|
void setRxHostname(const std::string &receiver, Positions pos = {});
|
||||||
|
|
||||||
|
/** multiple rx hostnames (same as setRxHostname) */
|
||||||
|
void setRxHostname(const std::vector<std::string> &name);
|
||||||
|
|
||||||
Result<int> getRxPort(Positions pos = {}) const;
|
Result<int> getRxPort(Positions pos = {}) const;
|
||||||
|
|
||||||
/** Receiver TCP port (for client communication with Receiver)
|
/** Receiver TCP port (for client communication with Receiver)
|
||||||
|
@ -147,7 +147,6 @@ std::string CmdProxy::Hostname(int action) {
|
|||||||
det->setHostname(args);
|
det->setHostname(args);
|
||||||
os << ToString(args) << '\n';
|
os << ToString(args) << '\n';
|
||||||
}
|
}
|
||||||
auto t = det->getHostname({det_id});
|
|
||||||
} else {
|
} else {
|
||||||
throw sls::RuntimeError("Unknown action");
|
throw sls::RuntimeError("Unknown action");
|
||||||
}
|
}
|
||||||
@ -849,6 +848,61 @@ std::string CmdProxy::UDPDestinationIP2(int action) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Receiver Config */
|
/* Receiver Config */
|
||||||
|
std::string CmdProxy::ReceiveHostname(int action) {
|
||||||
|
std::ostringstream os;
|
||||||
|
os << cmd << ' ';
|
||||||
|
if (action == defs::HELP_ACTION) {
|
||||||
|
os << "[hostname or ip address]\n\t"
|
||||||
|
"[hostname or ip address]:[tcp port]\n\t"
|
||||||
|
"[hostname1]:[tcp_port1]+[hostname2]:[tcp_port2]+\n\t"
|
||||||
|
"Receiver hostname or IP. If port included, then the receiver tcp port.\n\t"
|
||||||
|
"Used for TCP control communication between client and receiver "
|
||||||
|
"to configure receiver. Also updates receiver with detector parameters."
|
||||||
|
<< '\n';
|
||||||
|
} else if (action == defs::GET_ACTION) {
|
||||||
|
if (!args.empty()) {
|
||||||
|
WrongNumberOfParameters(0);
|
||||||
|
}
|
||||||
|
auto t = det->getRxHostname({det_id});
|
||||||
|
os << OutString(t) << '\n';
|
||||||
|
} else if (action == defs::PUT_ACTION) {
|
||||||
|
if (args.size() < 1) {
|
||||||
|
WrongNumberOfParameters(1);
|
||||||
|
}
|
||||||
|
// multiple arguments
|
||||||
|
if (args.size() > 1) {
|
||||||
|
// multiple in mulitple
|
||||||
|
if (args[0].find('+') != std::string::npos) {
|
||||||
|
throw sls::RuntimeError("Cannot add multiple receivers at module level");
|
||||||
|
}
|
||||||
|
if (det_id != -1) {
|
||||||
|
throw sls::RuntimeError("Cannot add multiple receivers at module level");
|
||||||
|
}
|
||||||
|
det->setRxHostname(args);
|
||||||
|
os << ToString(args) << '\n';
|
||||||
|
}
|
||||||
|
// single argument
|
||||||
|
else {
|
||||||
|
// multiple receivers concatenated with +
|
||||||
|
if (args[0].find('+') != std::string::npos) {
|
||||||
|
if (det_id != -1) {
|
||||||
|
throw sls::RuntimeError("Cannot add multiple receivers at module level");
|
||||||
|
}
|
||||||
|
auto t = sls::split(args[0], '+');
|
||||||
|
det->setRxHostname(t);
|
||||||
|
os << ToString(t) << '\n';
|
||||||
|
}
|
||||||
|
// single receiver
|
||||||
|
else {
|
||||||
|
det->setRxHostname(args[0], {det_id});
|
||||||
|
os << ToString(args) << '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw sls::RuntimeError("Unknown action");
|
||||||
|
}
|
||||||
|
return os.str();
|
||||||
|
}
|
||||||
/* File */
|
/* File */
|
||||||
/* ZMQ Streaming Parameters (Receiver<->Client) */
|
/* ZMQ Streaming Parameters (Receiver<->Client) */
|
||||||
/* Eiger Specific */
|
/* Eiger Specific */
|
||||||
|
@ -89,10 +89,10 @@
|
|||||||
if (action == slsDetectorDefs::HELP_ACTION) \
|
if (action == slsDetectorDefs::HELP_ACTION) \
|
||||||
os << HLPSTR << '\n'; \
|
os << HLPSTR << '\n'; \
|
||||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||||
auto t = det->GETFCN({det_id}); \
|
|
||||||
if (args.size() != 0) { \
|
if (args.size() != 0) { \
|
||||||
WrongNumberOfParameters(0); \
|
WrongNumberOfParameters(0); \
|
||||||
} \
|
} \
|
||||||
|
auto t = det->GETFCN({det_id}); \
|
||||||
os << OutString(t) << '\n'; \
|
os << OutString(t) << '\n'; \
|
||||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||||
if (args.size() != 1) { \
|
if (args.size() != 1) { \
|
||||||
@ -115,10 +115,10 @@
|
|||||||
if (action == slsDetectorDefs::HELP_ACTION) \
|
if (action == slsDetectorDefs::HELP_ACTION) \
|
||||||
os << HLPSTR << '\n'; \
|
os << HLPSTR << '\n'; \
|
||||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||||
auto t = det->GETFCN({det_id}); \
|
|
||||||
if (args.size() != 0) { \
|
if (args.size() != 0) { \
|
||||||
WrongNumberOfParameters(0); \
|
WrongNumberOfParameters(0); \
|
||||||
} \
|
} \
|
||||||
|
auto t = det->GETFCN({det_id}); \
|
||||||
os << OutStringHex(t) << '\n'; \
|
os << OutStringHex(t) << '\n'; \
|
||||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||||
if (args.size() != 1) { \
|
if (args.size() != 1) { \
|
||||||
@ -141,10 +141,10 @@
|
|||||||
if (action == slsDetectorDefs::HELP_ACTION) \
|
if (action == slsDetectorDefs::HELP_ACTION) \
|
||||||
os << HLPSTR << '\n'; \
|
os << HLPSTR << '\n'; \
|
||||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||||
auto t = det->GETFCN({det_id}); \
|
|
||||||
if (args.size() != 0) { \
|
if (args.size() != 0) { \
|
||||||
WrongNumberOfParameters(0); \
|
WrongNumberOfParameters(0); \
|
||||||
} \
|
} \
|
||||||
|
auto t = det->GETFCN({det_id}); \
|
||||||
os << OutString(t) << '\n'; \
|
os << OutString(t) << '\n'; \
|
||||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||||
if (args.size() != 1) { \
|
if (args.size() != 1) { \
|
||||||
@ -170,10 +170,10 @@
|
|||||||
if (action == slsDetectorDefs::HELP_ACTION) \
|
if (action == slsDetectorDefs::HELP_ACTION) \
|
||||||
os << HLPSTR << '\n'; \
|
os << HLPSTR << '\n'; \
|
||||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||||
auto t = det->GETFCN(); \
|
|
||||||
if (args.size() != 0) { \
|
if (args.size() != 0) { \
|
||||||
WrongNumberOfParameters(0); \
|
WrongNumberOfParameters(0); \
|
||||||
} \
|
} \
|
||||||
|
auto t = det->GETFCN(); \
|
||||||
os << OutString(t) << '\n'; \
|
os << OutString(t) << '\n'; \
|
||||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||||
if (args.size() != 1) { \
|
if (args.size() != 1) { \
|
||||||
@ -196,10 +196,10 @@
|
|||||||
if (action == slsDetectorDefs::HELP_ACTION) \
|
if (action == slsDetectorDefs::HELP_ACTION) \
|
||||||
os << HLPSTR << '\n'; \
|
os << HLPSTR << '\n'; \
|
||||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||||
auto t = det->GETFCN(INDEX, {det_id}); \
|
|
||||||
if (args.size() != 0) { \
|
if (args.size() != 0) { \
|
||||||
WrongNumberOfParameters(0); \
|
WrongNumberOfParameters(0); \
|
||||||
} \
|
} \
|
||||||
|
auto t = det->GETFCN(INDEX, {det_id}); \
|
||||||
os << OutString(t) << '\n'; \
|
os << OutString(t) << '\n'; \
|
||||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||||
if (args.size() != 1) { \
|
if (args.size() != 1) { \
|
||||||
@ -721,7 +721,7 @@ class CmdProxy {
|
|||||||
{"txndelay_right", &CmdProxy::txndelay_right},
|
{"txndelay_right", &CmdProxy::txndelay_right},
|
||||||
|
|
||||||
/* Receiver Config */
|
/* Receiver Config */
|
||||||
{"rx_hostname", &CmdProxy::rx_hostname},
|
{"rx_hostname", &CmdProxy::ReceiveHostname},
|
||||||
{"rx_tcpport", &CmdProxy::rx_tcpport},
|
{"rx_tcpport", &CmdProxy::rx_tcpport},
|
||||||
{"rx_fifodepth", &CmdProxy::rx_fifodepth},
|
{"rx_fifodepth", &CmdProxy::rx_fifodepth},
|
||||||
{"rx_silent", &CmdProxy::rx_silent},
|
{"rx_silent", &CmdProxy::rx_silent},
|
||||||
@ -939,6 +939,7 @@ class CmdProxy {
|
|||||||
std::string UDPDestinationIP(int action);
|
std::string UDPDestinationIP(int action);
|
||||||
std::string UDPDestinationIP2(int action);
|
std::string UDPDestinationIP2(int action);
|
||||||
/* Receiver Config */
|
/* Receiver Config */
|
||||||
|
std::string ReceiveHostname(int action);
|
||||||
/* File */
|
/* File */
|
||||||
/* ZMQ Streaming Parameters (Receiver<->Client) */
|
/* ZMQ Streaming Parameters (Receiver<->Client) */
|
||||||
/* Eiger Specific */
|
/* Eiger Specific */
|
||||||
@ -1434,9 +1435,6 @@ class CmdProxy {
|
|||||||
|
|
||||||
/* Receiver Config */
|
/* Receiver Config */
|
||||||
|
|
||||||
STRING_COMMAND(rx_hostname, getRxHostname, setRxHostname,
|
|
||||||
"[hostname or ip address]\n\tReceiver hostname or IP. Used for TCP control communication between client and receiver to configure receiver. Also updates receiver with detector parameters.");
|
|
||||||
|
|
||||||
INTEGER_COMMAND(rx_tcpport, getRxPort, setRxPort, std::stoi,
|
INTEGER_COMMAND(rx_tcpport, getRxPort, setRxPort, std::stoi,
|
||||||
"[port]\n\tTCP port for client-receiver communication. Default is 1954. Must be different if multiple receivers on same pc. Must be first command to set a receiver parameter. Multi command will automatically increment for individual modules.");
|
"[port]\n\tTCP port for client-receiver communication. Default is 1954. Must be different if multiple receivers on same pc. Must be first command to set a receiver parameter. Multi command will automatically increment for individual modules.");
|
||||||
|
|
||||||
|
@ -656,6 +656,23 @@ void Detector::setRxHostname(const std::string &receiver, Positions pos) {
|
|||||||
pimpl->Parallel(&Module::setReceiverHostname, pos, receiver);
|
pimpl->Parallel(&Module::setReceiverHostname, pos, receiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Detector::setRxHostname(const std::vector<std::string> &name) {
|
||||||
|
// set all to same rx_hostname
|
||||||
|
if (name.size() == 1) {
|
||||||
|
pimpl->Parallel(&Module::setReceiverHostname, {}, name[0]);
|
||||||
|
} else {
|
||||||
|
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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Result<int> Detector::getRxPort(Positions pos) const {
|
Result<int> Detector::getRxPort(Positions pos) const {
|
||||||
return pimpl->Parallel(&Module::getReceiverPort, pos);
|
return pimpl->Parallel(&Module::getReceiverPort, pos);
|
||||||
}
|
}
|
||||||
|
@ -1679,7 +1679,13 @@ std::string Module::setReceiverHostname(const std::string &receiverIP) {
|
|||||||
updateCachedDetectorVariables();
|
updateCachedDetectorVariables();
|
||||||
|
|
||||||
// start updating
|
// start updating
|
||||||
sls::strcpy_safe(shm()->rxHostname, receiverIP.c_str());
|
std::string host = receiverIP;
|
||||||
|
auto res = sls::split(host, ':');
|
||||||
|
if (res.size() > 1) {
|
||||||
|
host = res[0];
|
||||||
|
shm()->rxTCPPort = std::stoi(res[1]);
|
||||||
|
}
|
||||||
|
sls::strcpy_safe(shm()->rxHostname, host.c_str());
|
||||||
shm()->useReceiverFlag = true;
|
shm()->useReceiverFlag = true;
|
||||||
checkReceiverVersionCompatibility();
|
checkReceiverVersionCompatibility();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user