mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 21:37:13 +02:00
Dev/zmq stream all ipv6 adn remove rx_zmqip (#958)
* enable ipv6 in zmq socket * removed rx_zmqip API and field in gui, changed client updaterxrzip to updateclientzmqip to have the rx_hostname ip if 0. * updated command line for rx_zmqip to give a warning. * Replaced 'depreciated' to 'deprecated' everywhere * switching from * to 0.0.0.0 works for rebinding zmq sockets * fixed help in command line for rx_zmqip * to 0.0.0.0 and removed cmd in python * remove publisher zmq socket ip also for moench post processing * fixed tests * publisher zmq ip macros to be reused
This commit is contained in:
@ -7921,7 +7921,7 @@ std::string Caller::patloop0(int action) {
|
||||
// print help
|
||||
if (action == slsDetectorDefs::HELP_ACTION) {
|
||||
os << "Command: patloop0" << std::endl;
|
||||
os << R"V0G0N(Depreciated command. Use patloop. )V0G0N" << std::endl;
|
||||
os << R"V0G0N(Deprecated command. Use patloop. )V0G0N" << std::endl;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
@ -7976,7 +7976,7 @@ std::string Caller::patloop1(int action) {
|
||||
// print help
|
||||
if (action == slsDetectorDefs::HELP_ACTION) {
|
||||
os << "Command: patloop1" << std::endl;
|
||||
os << R"V0G0N(Depreciated command. Use patloop. )V0G0N" << std::endl;
|
||||
os << R"V0G0N(Deprecated command. Use patloop. )V0G0N" << std::endl;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
@ -8031,7 +8031,7 @@ std::string Caller::patloop2(int action) {
|
||||
// print help
|
||||
if (action == slsDetectorDefs::HELP_ACTION) {
|
||||
os << "Command: patloop2" << std::endl;
|
||||
os << R"V0G0N(Depreciated command. Use patloop. )V0G0N" << std::endl;
|
||||
os << R"V0G0N(Deprecated command. Use patloop. )V0G0N" << std::endl;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
@ -8205,7 +8205,7 @@ std::string Caller::patnloop0(int action) {
|
||||
// print help
|
||||
if (action == slsDetectorDefs::HELP_ACTION) {
|
||||
os << "Command: patnloop0" << std::endl;
|
||||
os << R"V0G0N(Depreciated command. Use patnloop. )V0G0N" << std::endl;
|
||||
os << R"V0G0N(Deprecated command. Use patnloop. )V0G0N" << std::endl;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
@ -8258,7 +8258,7 @@ std::string Caller::patnloop1(int action) {
|
||||
// print help
|
||||
if (action == slsDetectorDefs::HELP_ACTION) {
|
||||
os << "Command: patnloop1" << std::endl;
|
||||
os << R"V0G0N(Depreciated command. Use patnloop. )V0G0N" << std::endl;
|
||||
os << R"V0G0N(Deprecated command. Use patnloop. )V0G0N" << std::endl;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
@ -8311,7 +8311,7 @@ std::string Caller::patnloop2(int action) {
|
||||
// print help
|
||||
if (action == slsDetectorDefs::HELP_ACTION) {
|
||||
os << "Command: patnloop2" << std::endl;
|
||||
os << R"V0G0N(Depreciated command. Use patnloop. )V0G0N" << std::endl;
|
||||
os << R"V0G0N(Deprecated command. Use patnloop. )V0G0N" << std::endl;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
@ -8562,7 +8562,7 @@ std::string Caller::patwait0(int action) {
|
||||
// print help
|
||||
if (action == slsDetectorDefs::HELP_ACTION) {
|
||||
os << "Command: patwait0" << std::endl;
|
||||
os << R"V0G0N(Depreciated command. Use patwait. )V0G0N" << std::endl;
|
||||
os << R"V0G0N(Deprecated command. Use patwait. )V0G0N" << std::endl;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
@ -8614,7 +8614,7 @@ std::string Caller::patwait1(int action) {
|
||||
// print help
|
||||
if (action == slsDetectorDefs::HELP_ACTION) {
|
||||
os << "Command: patwait1" << std::endl;
|
||||
os << R"V0G0N(Depreciated command. Use patwait. )V0G0N" << std::endl;
|
||||
os << R"V0G0N(Deprecated command. Use patwait. )V0G0N" << std::endl;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
@ -8666,7 +8666,7 @@ std::string Caller::patwait2(int action) {
|
||||
// print help
|
||||
if (action == slsDetectorDefs::HELP_ACTION) {
|
||||
os << "Command: patwait2" << std::endl;
|
||||
os << R"V0G0N(Depreciated command. Use patwait. )V0G0N" << std::endl;
|
||||
os << R"V0G0N(Deprecated command. Use patwait. )V0G0N" << std::endl;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
@ -8773,8 +8773,7 @@ std::string Caller::patwaittime0(int action) {
|
||||
// print help
|
||||
if (action == slsDetectorDefs::HELP_ACTION) {
|
||||
os << "Command: patwaittime0" << std::endl;
|
||||
os << R"V0G0N(Depreciated command. Use patwaittime. )V0G0N"
|
||||
<< std::endl;
|
||||
os << R"V0G0N(Deprecated command. Use patwaittime. )V0G0N" << std::endl;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
@ -8826,8 +8825,7 @@ std::string Caller::patwaittime1(int action) {
|
||||
// print help
|
||||
if (action == slsDetectorDefs::HELP_ACTION) {
|
||||
os << "Command: patwaittime1" << std::endl;
|
||||
os << R"V0G0N(Depreciated command. Use patwaittime. )V0G0N"
|
||||
<< std::endl;
|
||||
os << R"V0G0N(Deprecated command. Use patwaittime. )V0G0N" << std::endl;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
@ -8879,8 +8877,7 @@ std::string Caller::patwaittime2(int action) {
|
||||
// print help
|
||||
if (action == slsDetectorDefs::HELP_ACTION) {
|
||||
os << "Command: patwaittime2" << std::endl;
|
||||
os << R"V0G0N(Depreciated command. Use patwaittime. )V0G0N"
|
||||
<< std::endl;
|
||||
os << R"V0G0N(Deprecated command. Use patwaittime. )V0G0N" << std::endl;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
@ -12114,63 +12111,6 @@ std::string Caller::rx_zmqhwm(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string Caller::rx_zmqip(int action) {
|
||||
|
||||
std::ostringstream os;
|
||||
// print help
|
||||
if (action == slsDetectorDefs::HELP_ACTION) {
|
||||
os << "Command: rx_zmqip" << std::endl;
|
||||
os << R"V0G0N([x.x.x.x]
|
||||
Zmq Ip Address from which data is to be streamed out of the receiver. Also restarts receiver zmq streaming if enabled. Default is from rx_hostname. Modified only when using an intermediate process between receiver. )V0G0N"
|
||||
<< std::endl;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
// check if action and arguments are valid
|
||||
if (action == slsDetectorDefs::GET_ACTION) {
|
||||
if (1 && args.size() != 0) {
|
||||
throw RuntimeError("Wrong number of arguments for action GET");
|
||||
}
|
||||
|
||||
if (args.size() == 0) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else if (action == slsDetectorDefs::PUT_ACTION) {
|
||||
if (1 && args.size() != 1) {
|
||||
throw RuntimeError("Wrong number of arguments for action PUT");
|
||||
}
|
||||
|
||||
if (args.size() == 1) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
throw RuntimeError("INTERNAL ERROR: Invalid action: supported actions "
|
||||
"are ['GET', 'PUT']");
|
||||
}
|
||||
|
||||
// generate code for each action
|
||||
if (action == slsDetectorDefs::GET_ACTION) {
|
||||
if (args.size() == 0) {
|
||||
auto t = det->getRxZmqIP(std::vector<int>{det_id});
|
||||
os << OutString(t) << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
if (action == slsDetectorDefs::PUT_ACTION) {
|
||||
if (args.size() == 1) {
|
||||
det->setRxZmqIP(IpAddr(args[0]), std::vector<int>{det_id});
|
||||
os << args.front() << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string Caller::rx_zmqport(int action) {
|
||||
|
||||
std::ostringstream os;
|
||||
|
@ -392,7 +392,7 @@ class Caller {
|
||||
int rx_id{-1};
|
||||
|
||||
private:
|
||||
bool ReplaceIfDepreciated(std::string &command);
|
||||
bool ReplaceIfDeprecated(std::string &command);
|
||||
using FunctionMap = std::map<std::string, std::string (Caller::*)(int)>;
|
||||
using StringMap = std::map<std::string, std::string>;
|
||||
Detector *ptr; // pointer to the detector that executes the command
|
||||
@ -734,7 +734,7 @@ class Caller {
|
||||
|
||||
};
|
||||
|
||||
StringMap depreciated_functions{
|
||||
StringMap deprecated_functions{
|
||||
|
||||
{"detectorversion", "firmwareversion"},
|
||||
{"softwareversion", "detectorserverversion"},
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "Caller.h"
|
||||
#include "sls/ZmqSocket.h"
|
||||
#include "sls/bit_utils.h"
|
||||
#include "sls/file_utils.h"
|
||||
#include "sls/logger.h"
|
||||
@ -22,7 +23,7 @@ void Caller::call(const std::string &command,
|
||||
std::string temp;
|
||||
while (temp != cmd) {
|
||||
temp = cmd;
|
||||
ReplaceIfDepreciated(cmd);
|
||||
ReplaceIfDeprecated(cmd);
|
||||
}
|
||||
|
||||
det_id = detector_id;
|
||||
@ -37,9 +38,9 @@ void Caller::call(const std::string &command,
|
||||
}
|
||||
}
|
||||
|
||||
bool Caller::ReplaceIfDepreciated(std::string &command) {
|
||||
auto d_it = depreciated_functions.find(command);
|
||||
if (d_it != depreciated_functions.end()) {
|
||||
bool Caller::ReplaceIfDeprecated(std::string &command) {
|
||||
auto d_it = deprecated_functions.find(command);
|
||||
if (d_it != deprecated_functions.end()) {
|
||||
|
||||
// insert old command into arguments (for dacs)
|
||||
if (d_it->second == "dac") {
|
||||
@ -648,6 +649,25 @@ std::string Caller::rx_hostname(int action) {
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
std::string Caller::rx_zmqip(int action) {
|
||||
std::string helpMessage =
|
||||
"\n\t[deprecated] The receiver zmq socket (publisher) will "
|
||||
"listen to all interfaces ('tcp://0.0.0.0:[port]'to all interfaces "
|
||||
"(from v9.0.0). This command does nothing and will be removed "
|
||||
"(from v10.0.0). This change makes no difference to the user.\n";
|
||||
std::ostringstream os;
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << helpMessage << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
os << ZMQ_PUBLISHER_IP << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
LOG(logWARNING) << helpMessage << '\n';
|
||||
os << ZMQ_PUBLISHER_IP << '\n';
|
||||
} else {
|
||||
throw RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
std::string Caller::rx_roi(int action) {
|
||||
std::ostringstream os;
|
||||
if (action == defs::HELP_ACTION) {
|
||||
|
@ -1483,19 +1483,6 @@ void Detector::setRxZmqPort(uint16_t port, int module_id) {
|
||||
}
|
||||
}
|
||||
|
||||
Result<IpAddr> Detector::getRxZmqIP(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getReceiverStreamingIP, pos);
|
||||
}
|
||||
|
||||
void Detector::setRxZmqIP(const IpAddr ip, Positions pos) {
|
||||
bool previouslyReceiverStreaming = getRxZmqDataStream(pos).squash(false);
|
||||
pimpl->Parallel(&Module::setReceiverStreamingIP, pos, ip);
|
||||
if (previouslyReceiverStreaming) {
|
||||
setRxZmqDataStream(false, pos);
|
||||
setRxZmqDataStream(true, pos);
|
||||
}
|
||||
}
|
||||
|
||||
Result<uint16_t> Detector::getClientZmqPort(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getClientStreamingPort, pos);
|
||||
}
|
||||
|
@ -1429,8 +1429,8 @@ void Module::setReceiverHostname(const std::string &hostname,
|
||||
|
||||
shm()->numUDPInterfaces = retval.udpInterfaces;
|
||||
|
||||
// to use rx_hostname if empty and also update client zmqip
|
||||
updateReceiverStreamingIP();
|
||||
// to use rx_hostname if empty
|
||||
updateClientStreamingIP();
|
||||
}
|
||||
|
||||
uint16_t Module::getReceiverPort() const { return shm()->rxTCPPort; }
|
||||
@ -1656,21 +1656,6 @@ void Module::setReceiverStreamingPort(uint16_t port) {
|
||||
sendToReceiver(F_SET_RECEIVER_STREAMING_PORT, port, nullptr);
|
||||
}
|
||||
|
||||
IpAddr Module::getReceiverStreamingIP() const {
|
||||
return sendToReceiver<IpAddr>(F_GET_RECEIVER_STREAMING_SRC_IP);
|
||||
}
|
||||
|
||||
void Module::setReceiverStreamingIP(const IpAddr ip) {
|
||||
if (ip == 0) {
|
||||
throw RuntimeError("Invalid receiver zmq ip address");
|
||||
}
|
||||
// if client zmqip is empty, update it
|
||||
if (shm()->zmqip == 0) {
|
||||
shm()->zmqip = ip;
|
||||
}
|
||||
sendToReceiver(F_SET_RECEIVER_STREAMING_SRC_IP, ip, nullptr);
|
||||
}
|
||||
|
||||
uint16_t Module::getClientStreamingPort() const { return shm()->zmqport; }
|
||||
|
||||
void Module::setClientStreamingPort(uint16_t port) { shm()->zmqport = port; }
|
||||
@ -3613,18 +3598,19 @@ void Module::receiveModule(sls_detector_module *myMod, ClientSocket &client) {
|
||||
LOG(level) << myMod->nchan << " chans received";
|
||||
}
|
||||
|
||||
void Module::updateReceiverStreamingIP() {
|
||||
auto ip = getReceiverStreamingIP();
|
||||
void Module::updateClientStreamingIP() {
|
||||
auto ip = getClientStreamingIP();
|
||||
if (ip == 0) {
|
||||
// Hostname could be ip try to decode otherwise look up the hostname
|
||||
ip = IpAddr{shm()->rxHostname};
|
||||
if (ip == 0) {
|
||||
ip = HostnameToIp(shm()->rxHostname);
|
||||
}
|
||||
LOG(logINFO) << "Setting default receiver " << moduleIndex
|
||||
<< " streaming zmq ip to " << ip;
|
||||
LOG(logINFO) << "Setting default module " << moduleIndex
|
||||
<< " zmq ip to " << ip;
|
||||
|
||||
setClientStreamingIP(ip);
|
||||
}
|
||||
setReceiverStreamingIP(ip);
|
||||
}
|
||||
|
||||
void Module::updateRateCorrection() {
|
||||
|
@ -351,8 +351,6 @@ class Module : public virtual slsDetectorDefs {
|
||||
void setReceiverStreamingStartingFrame(int fnum);
|
||||
uint16_t getReceiverStreamingPort() const;
|
||||
void setReceiverStreamingPort(uint16_t port);
|
||||
IpAddr getReceiverStreamingIP() const;
|
||||
void setReceiverStreamingIP(const IpAddr ip);
|
||||
uint16_t getClientStreamingPort() const;
|
||||
void setClientStreamingPort(uint16_t port);
|
||||
IpAddr getClientStreamingIP() const;
|
||||
@ -766,7 +764,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
sls_detector_module getModule();
|
||||
void sendModule(sls_detector_module *myMod, ClientSocket &client);
|
||||
void receiveModule(sls_detector_module *myMod, ClientSocket &client);
|
||||
void updateReceiverStreamingIP();
|
||||
void updateClientStreamingIP();
|
||||
|
||||
void updateRateCorrection();
|
||||
/** Template function to do linear interpolation between two points (Eiger
|
||||
|
@ -149,7 +149,7 @@ void Pattern::load(const std::string &fname) {
|
||||
level = StringTo<int>(args[iArg++]);
|
||||
} else {
|
||||
LOG(logWARNING)
|
||||
<< "Depreciated command. Please use patloop next time.";
|
||||
<< "Deprecated command. Please use patloop next time.";
|
||||
if (nargs != 2) {
|
||||
throw RuntimeError("Invalid arguments for " +
|
||||
ToString(args));
|
||||
@ -174,7 +174,7 @@ void Pattern::load(const std::string &fname) {
|
||||
}
|
||||
level = StringTo<int>(args[iArg++]);
|
||||
} else {
|
||||
LOG(logWARNING) << "Depreciated command. Please use "
|
||||
LOG(logWARNING) << "Deprecated command. Please use "
|
||||
"patnloop next time.";
|
||||
if (nargs != 1) {
|
||||
throw RuntimeError("Invalid arguments for " +
|
||||
@ -198,7 +198,7 @@ void Pattern::load(const std::string &fname) {
|
||||
level = StringTo<int>(args[iArg++]);
|
||||
} else {
|
||||
LOG(logWARNING)
|
||||
<< "Depreciated command. Please use patwait next time.";
|
||||
<< "Deprecated command. Please use patwait next time.";
|
||||
if (nargs != 1) {
|
||||
throw RuntimeError("Invalid arguments for " +
|
||||
ToString(args));
|
||||
@ -220,7 +220,7 @@ void Pattern::load(const std::string &fname) {
|
||||
}
|
||||
level = StringTo<int>(args[iArg++]);
|
||||
} else {
|
||||
LOG(logWARNING) << "Depreciated command. Please use "
|
||||
LOG(logWARNING) << "Deprecated command. Please use "
|
||||
"patwaittime next time.";
|
||||
if (nargs != 1) {
|
||||
throw RuntimeError("Invalid arguments for " +
|
||||
|
@ -2993,18 +2993,8 @@ int InferAction::rx_zmqhwm() {
|
||||
|
||||
int InferAction::rx_zmqip() {
|
||||
|
||||
if (args.size() == 0) {
|
||||
return slsDetectorDefs::GET_ACTION;
|
||||
}
|
||||
|
||||
if (args.size() == 1) {
|
||||
return slsDetectorDefs::PUT_ACTION;
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
throw RuntimeError("Could not infer action: Wrong number of arguments");
|
||||
}
|
||||
throw RuntimeError("sls_detector is disabled for command: rx_zmqip. Use "
|
||||
"sls_detector_get or sls_detector_put");
|
||||
}
|
||||
|
||||
int InferAction::rx_zmqport() {
|
||||
|
Reference in New Issue
Block a user