From e84829391688a30405fc712437164a0234b08bf5 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Tue, 10 Sep 2024 15:19:08 +0200 Subject: [PATCH] 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 --- docs/src/commandline.rst | 6 +- docs/src/gendoc.cpp | 4 +- python/slsdet/detector.py | 25 ------ .../moenchExecutables/moenchZmqProcess.cpp | 7 +- slsDetectorGui/forms/form_tab_advanced.ui | 61 +------------- slsDetectorGui/include/qTabAdvanced.h | 3 - slsDetectorGui/src/qTabAdvanced.cpp | 35 -------- slsDetectorSoftware/generator/Caller.in.h | 4 +- .../autocomplete/bash_autocomplete.sh | 5 -- .../autocomplete/zsh_autocomplete.sh | 5 -- slsDetectorSoftware/generator/commands.yaml | 28 +++---- .../generator/extended_commands.yaml | 58 ++++++------- slsDetectorSoftware/src/Caller.cpp | 84 +++---------------- slsDetectorSoftware/src/Caller.h | 4 +- slsDetectorSoftware/src/CallerSpecial.cpp | 28 ++++++- slsDetectorSoftware/src/Detector.cpp | 13 --- slsDetectorSoftware/src/Module.cpp | 30 ++----- slsDetectorSoftware/src/Module.h | 4 +- slsDetectorSoftware/src/Pattern.cpp | 8 +- slsDetectorSoftware/src/inferAction.cpp | 14 +--- .../tests/Caller/test-Caller-pattern.cpp | 16 ++-- .../tests/Caller/test-Caller-rx.cpp | 20 ----- .../tests/Caller/test-Caller.cpp | 2 +- slsDetectorSoftware/tests/test-CmdParser.cpp | 2 +- slsReceiverSoftware/src/ClientInterface.cpp | 17 ---- slsReceiverSoftware/src/ClientInterface.h | 2 - slsReceiverSoftware/src/DataStreamer.cpp | 5 +- slsReceiverSoftware/src/DataStreamer.h | 3 +- slsReceiverSoftware/src/Implementation.cpp | 10 +-- slsReceiverSoftware/src/Implementation.h | 3 - slsSupportLib/include/sls/ZmqSocket.h | 21 ++--- slsSupportLib/include/sls/sls_detector_defs.h | 6 +- .../include/sls/sls_detector_funcs.h | 4 +- slsSupportLib/src/ZmqSocket.cpp | 45 +++++++--- slsSupportLib/tests/test-ZmqSocket.cpp | 12 +-- 35 files changed, 168 insertions(+), 426 deletions(-) diff --git a/docs/src/commandline.rst b/docs/src/commandline.rst index fb4e9f866..d7433c4d0 100644 --- a/docs/src/commandline.rst +++ b/docs/src/commandline.rst @@ -32,14 +32,14 @@ Commands .. include:: ../commands.rst -Depreciated commands +Deprecated commands ------------------------ .. note :: All the dac commands are preceded with the **dac** command. Use command **daclist** to get correct list of dac command arguments for current detector. -.. csv-table:: Depreciated commands - :file: ../depreciated.csv +.. csv-table:: Deprecated commands + :file: ../deprecated.csv :widths: 35, 35 :header-rows: 1 diff --git a/docs/src/gendoc.cpp b/docs/src/gendoc.cpp index 78c0520f3..86dc3a6ad 100644 --- a/docs/src/gendoc.cpp +++ b/docs/src/gendoc.cpp @@ -55,9 +55,9 @@ int main() { fs << '\t' << cmd << usage << help << "\n"; } - std::ofstream fs2("depreciated.csv"); + std::ofstream fs2("deprecated.csv"); fs2 << "Old, New\n"; - auto cmds = proxy.GetDepreciatedCommands(); + auto cmds = proxy.GetDeprecatedCommands(); for (auto it : cmds) { fs2 << it.first << ", " << it.second << '\n'; } diff --git a/python/slsdet/detector.py b/python/slsdet/detector.py index 29b5306e9..12dcc68f6 100755 --- a/python/slsdet/detector.py +++ b/python/slsdet/detector.py @@ -1210,31 +1210,6 @@ class Detector(CppDetectorApi): else: raise ValueError("Unknown argument type") - @property - @element - def rx_zmqip(self): - """ - Zmq Ip Address from which data is to be streamed out of the receiver. - - Note - ----- - Also restarts receiver zmq streaming if enabled. \n - Default is from rx_hostname. \n - Modified only when using an intermediate process after receiver. - - Example - ------- - >>> d.rx_zmqip - 192.168.0.101 - >>> d.rx_zmqip = '192.168.0.101' - """ - return self.getRxZmqIP() - - @rx_zmqip.setter - def rx_zmqip(self, ip): - ip = ut.make_ip(ip) #Convert from int or string to IpAddr - ut.set_using_dict(self.setRxZmqIP, ip) - @property @element def zmqip(self): diff --git a/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp b/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp index d2d43e005..8d20767cd 100644 --- a/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp +++ b/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp @@ -296,12 +296,11 @@ int main(int argc, char *argv[]) { if (send) { // receive socket try { - zmqsocket2 = new sls::ZmqSocket(portnum2, socketip2.c_str()); + zmqsocket2 = new sls::ZmqSocket(portnum2); } catch (...) { cprintf(RED, - "Error: Could not create Zmq sending socket on port %d and " - "ip %s\n", - portnum2, socketip2.c_str()); + "Error: Could not create Zmq sending socket on port %d\n", + portnum2); // delete zmqsocket2; // zmqsocket2=NULL; // delete zmqsocket; diff --git a/slsDetectorGui/forms/form_tab_advanced.ui b/slsDetectorGui/forms/form_tab_advanced.ui index 17fceaf8e..6659c9770 100755 --- a/slsDetectorGui/forms/form_tab_advanced.ui +++ b/slsDetectorGui/forms/form_tab_advanced.ui @@ -852,7 +852,7 @@ - <html><head/><body><p>Sets Listening ZMQ IP of client interface (packets streamed from receiver for gui)</p><p>#zmqip#</p><p><br/></p><p>Has to be same as rx_zmqip for gui</p></body></html> + <html><head/><body><p>Sets Listening ZMQ IP of client interface (packets streamed from receiver for gui)</p><p>#zmqip#</p><p><br/></p></body></html> Client ZMQ IP: @@ -886,7 +886,7 @@ - <html><head/><body><p>Sets Listening ZMQ IP of client interface (packets streamed from receiver for gui)</p><p>#zmqip#</p><p><br/></p><p>Has to be same as rx_zmqip for gui</p></body></html> + <html><head/><body><p>Sets Listening ZMQ IP of client interface (packets streamed from receiver for gui)</p><p>#zmqip#</p><p><br/></p></body></html> 0 @@ -948,28 +948,6 @@ - - - - - 0 - 0 - - - - - Cantarell - 10 - - - - <html><head/><body><p>Sets Publishing ZMQ IP of reciever (packets streamed from receiver for gui)</p><p>#rx_zmqip#</p><p>Has to be same as zmqip for gui</p></body></html> - - - Receiver ZMQ IP: - - - @@ -1121,40 +1099,6 @@ - - - - - 0 - 0 - - - - - 180 - 20 - - - - - 16777215 - 25 - - - - - Cantarell - 10 - - - - <html><head/><body><p>Sets Publishing ZMQ IP of reciever (packets streamed from receiver for gui)</p><p>#rx_zmqip#</p><p>Has to be same as zmqip for gui</p></body></html> - - - 0 - - - @@ -2312,7 +2256,6 @@ Exposure Time of a sub frame. Only for Eiger in 32 bit mode dispRxrUDPIP dispRxrUDPMAC spinRxrZMQPort - dispRxrZMQIP spinNumStoragecells spinSubExpTime comboSubExpTimeUnit diff --git a/slsDetectorGui/include/qTabAdvanced.h b/slsDetectorGui/include/qTabAdvanced.h index 50379d605..13d3100f0 100644 --- a/slsDetectorGui/include/qTabAdvanced.h +++ b/slsDetectorGui/include/qTabAdvanced.h @@ -38,8 +38,6 @@ class qTabAdvanced : public QWidget, private Ui::TabAdvancedObject { void SetRxrUDPMAC(bool force = false); void ForceSetRxrUDPMAC(); void SetRxrZMQPort(int port); - void SetRxrZMQIP(bool force = false); - void ForceSetRxrZMQIP(); void GetROI(); void ClearROI(); void SetROI(); @@ -68,7 +66,6 @@ class qTabAdvanced : public QWidget, private Ui::TabAdvancedObject { void GetRxrUDPIP(); void GetRxrUDPMAC(); void GetRxrZMQPort(); - void GetRxrZMQIP(); void GetAllTrimbits(); void GetNumStoragecells(); void GetSubExposureTime(); diff --git a/slsDetectorGui/src/qTabAdvanced.cpp b/slsDetectorGui/src/qTabAdvanced.cpp index ae3c2b39f..a00d518cc 100644 --- a/slsDetectorGui/src/qTabAdvanced.cpp +++ b/slsDetectorGui/src/qTabAdvanced.cpp @@ -113,9 +113,6 @@ void qTabAdvanced::Initialization() { SLOT(ForceSetRxrUDPMAC())); connect(spinRxrZMQPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrZMQPort(int))); - connect(dispRxrZMQIP, SIGNAL(editingFinished()), this, SLOT(SetRxrZMQIP())); - connect(dispRxrZMQIP, SIGNAL(returnPressed()), this, - SLOT(ForceSetRxrZMQIP())); // roi if (tab_roi->isEnabled()) { @@ -388,20 +385,6 @@ void qTabAdvanced::GetRxrZMQPort() { SLOT(SetRxrZMQPort(int))); } -void qTabAdvanced::GetRxrZMQIP() { - LOG(logDEBUG) << "Getting Receiver ZMQ IP"; - disconnect(dispRxrZMQIP, SIGNAL(editingFinished()), this, - SLOT(SetRxrZMQIP())); - - try { - auto retval = det->getRxZmqIP({comboDetector->currentIndex()})[0].str(); - dispRxrZMQIP->setText(QString(retval.c_str())); - } - CATCH_DISPLAY("Could not get receiver zmq ip.", "qTabAdvanced::GetRxrZMQIP") - - connect(dispRxrZMQIP, SIGNAL(editingFinished()), this, SLOT(SetRxrZMQIP())); -} - void qTabAdvanced::SetDetector() { LOG(logDEBUG) << "Set Detector: " << comboDetector->currentText().toLatin1().data(); @@ -418,7 +401,6 @@ void qTabAdvanced::SetDetector() { GetRxrUDPIP(); GetRxrUDPMAC(); GetRxrZMQPort(); - GetRxrZMQIP(); LOG(logDEBUG) << det->printRxConfiguration(); } @@ -588,23 +570,6 @@ void qTabAdvanced::SetRxrZMQPort(int port) { &qTabAdvanced::GetRxrZMQPort) } -void qTabAdvanced::SetRxrZMQIP(bool force) { - // return forces modification (inconsistency from command line) - if (dispRxrZMQIP->isModified() || force) { - dispRxrZMQIP->setModified(false); - std::string s = dispRxrZMQIP->text().toLatin1().constData(); - LOG(logINFO) << "Setting Receiver ZMQ IP:" << s; - try { - det->setRxZmqIP(IpAddr{s}, {comboDetector->currentIndex()}); - } - CATCH_HANDLE("Could not set Receiver ZMQ IP.", - "qTabAdvanced::SetRxrZMQIP", this, - &qTabAdvanced::GetRxrZMQIP) - } -} - -void qTabAdvanced::ForceSetRxrZMQIP() { SetRxrZMQIP(true); } - void qTabAdvanced::GetROI() { LOG(logDEBUG) << "Getting ROI"; try { diff --git a/slsDetectorSoftware/generator/Caller.in.h b/slsDetectorSoftware/generator/Caller.in.h index 89b633095..79043d514 100644 --- a/slsDetectorSoftware/generator/Caller.in.h +++ b/slsDetectorSoftware/generator/Caller.in.h @@ -66,7 +66,7 @@ class Caller { int rx_id{-1}; private: - bool ReplaceIfDepreciated(std::string &command); + bool ReplaceIfDeprecated(std::string &command); using FunctionMap = std::map; using StringMap = std::map; Detector *ptr; // pointer to the detector that executes the command @@ -81,7 +81,7 @@ class Caller { }; - StringMap depreciated_functions{ + StringMap deprecated_functions{ // THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE (3) diff --git a/slsDetectorSoftware/generator/autocomplete/bash_autocomplete.sh b/slsDetectorSoftware/generator/autocomplete/bash_autocomplete.sh index dc698ef1b..3dd017d99 100644 --- a/slsDetectorSoftware/generator/autocomplete/bash_autocomplete.sh +++ b/slsDetectorSoftware/generator/autocomplete/bash_autocomplete.sh @@ -2111,11 +2111,6 @@ return 0 } __rx_zmqip() { FCN_RETURN="" -if [[ ${IS_GET} -eq 0 ]]; then -if [[ "${cword}" == "2" ]]; then -FCN_RETURN="" -fi -fi return 0 } __rx_zmqport() { diff --git a/slsDetectorSoftware/generator/autocomplete/zsh_autocomplete.sh b/slsDetectorSoftware/generator/autocomplete/zsh_autocomplete.sh index 30f0b032f..fb05cadd1 100644 --- a/slsDetectorSoftware/generator/autocomplete/zsh_autocomplete.sh +++ b/slsDetectorSoftware/generator/autocomplete/zsh_autocomplete.sh @@ -2035,11 +2035,6 @@ return 0 } __rx_zmqip() { FCN_RETURN="" -if [[ ${IS_GET} -eq 0 ]]; then -if [[ "${cword}" == "2" ]]; then -FCN_RETURN="" -fi -fi return 0 } __rx_zmqport() { diff --git a/slsDetectorSoftware/generator/commands.yaml b/slsDetectorSoftware/generator/commands.yaml index e64c8a512..ccf52818e 100644 --- a/slsDetectorSoftware/generator/commands.yaml +++ b/slsDetectorSoftware/generator/commands.yaml @@ -1041,18 +1041,6 @@ rx_zmqstartfnum: PUT: function: setRxZmqStartingFrame -rx_zmqip: - help: "[x.x.x.x]\n\tZmq 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." - inherit_actions: INTEGER_COMMAND_VEC_ID - actions: - GET: - function: getRxZmqIP - PUT: - function: setRxZmqIP - input_types: [ IpAddr ] - input: [ 'IpAddr(args[0])' ] - cast_input: [ false ] - zmqip: help: "[x.x.x.x]\n\tIp Address to listen to zmq data streamed out from receiver or intermediate process. Default connects to receiver zmq Ip Address (from rx_hostname). Modified only when using an intermediate process between receiver and client(gui). Also restarts client zmq streaming if enabled." inherit_actions: INTEGER_COMMAND_VEC_ID @@ -2578,6 +2566,14 @@ rx_hostname: PUT: argc: -1 +rx_zmqip: + is_description: true + actions: + GET: + argc: 0 + PUT: + argc: -1 + rx_roi: is_description: true actions: @@ -3936,7 +3932,7 @@ patloop: output: [level,"' '" , "'['" , "ToStringHex(start, 4)" , '", "' , "ToStringHex(stop, 4)", "']'" ] patloop0: - help: "Depreciated command. Use patloop." + help: "Deprecated command. Use patloop." inherit_actions: patloop actions: GET: @@ -3983,7 +3979,7 @@ patnloop: output: [ level,"' '" , nloops ] patnloop0: - help: "Depreciated command. Use patnloop." + help: "Deprecated command. Use patnloop." inherit_actions: patnloop actions: GET: @@ -4029,7 +4025,7 @@ patwait: output: [level,"' '" , "ToStringHex(addr, 4)" ] patwait0: - help: "Depreciated command. Use patwait." + help: "Deprecated command. Use patwait." inherit_actions: patwait actions: GET: @@ -4075,7 +4071,7 @@ patwaittime: output: [level,"' '" , "waittime" ] patwaittime0: - help: "Depreciated command. Use patwaittime." + help: "Deprecated command. Use patwaittime." inherit_actions: patwaittime actions: GET: diff --git a/slsDetectorSoftware/generator/extended_commands.yaml b/slsDetectorSoftware/generator/extended_commands.yaml index e42756864..10e0577bb 100644 --- a/slsDetectorSoftware/generator/extended_commands.yaml +++ b/slsDetectorSoftware/generator/extended_commands.yaml @@ -5994,7 +5994,7 @@ patloop0: store_result_in_t: false command_name: patloop0 function_alias: patloop0 - help: Depreciated command. Use patloop. + help: Deprecated command. Use patloop. infer_action: true patloop1: actions: @@ -6063,7 +6063,7 @@ patloop1: store_result_in_t: false command_name: patloop1 function_alias: patloop1 - help: Depreciated command. Use patloop. + help: Deprecated command. Use patloop. infer_action: true patloop2: actions: @@ -6132,7 +6132,7 @@ patloop2: store_result_in_t: false command_name: patloop2 function_alias: patloop2 - help: Depreciated command. Use patloop. + help: Deprecated command. Use patloop. infer_action: true patmask: actions: @@ -6293,7 +6293,7 @@ patnloop0: store_result_in_t: false command_name: patnloop0 function_alias: patnloop0 - help: Depreciated command. Use patnloop. + help: Deprecated command. Use patnloop. infer_action: true patnloop1: actions: @@ -6351,7 +6351,7 @@ patnloop1: store_result_in_t: false command_name: patnloop1 function_alias: patnloop1 - help: Depreciated command. Use patnloop. + help: Deprecated command. Use patnloop. infer_action: true patnloop2: actions: @@ -6409,7 +6409,7 @@ patnloop2: store_result_in_t: false command_name: patnloop2 function_alias: patnloop2 - help: Depreciated command. Use patnloop. + help: Deprecated command. Use patnloop. infer_action: true patsetbit: actions: @@ -6616,7 +6616,7 @@ patwait0: store_result_in_t: false command_name: patwait0 function_alias: patwait0 - help: Depreciated command. Use patwait. + help: Deprecated command. Use patwait. infer_action: true patwait1: actions: @@ -6674,7 +6674,7 @@ patwait1: store_result_in_t: false command_name: patwait1 function_alias: patwait1 - help: Depreciated command. Use patwait. + help: Deprecated command. Use patwait. infer_action: true patwait2: actions: @@ -6732,7 +6732,7 @@ patwait2: store_result_in_t: false command_name: patwait2 function_alias: patwait2 - help: Depreciated command. Use patwait. + help: Deprecated command. Use patwait. infer_action: true patwaittime: actions: @@ -6853,7 +6853,7 @@ patwaittime0: store_result_in_t: false command_name: patwaittime0 function_alias: patwaittime0 - help: Depreciated command. Use patwaittime. + help: Deprecated command. Use patwaittime. infer_action: true patwaittime1: actions: @@ -6911,7 +6911,7 @@ patwaittime1: store_result_in_t: false command_name: patwaittime1 function_alias: patwaittime1 - help: Depreciated command. Use patwaittime. + help: Deprecated command. Use patwaittime. infer_action: true patwaittime2: actions: @@ -6969,7 +6969,7 @@ patwaittime2: store_result_in_t: false command_name: patwaittime2 function_alias: patwaittime2 - help: Depreciated command. Use patwaittime. + help: Deprecated command. Use patwaittime. infer_action: true patword: actions: @@ -9250,38 +9250,30 @@ rx_zmqip: cast_input: [] check_det_id: false convert_det_id: true - function: getRxZmqIP + function: '' input: [] input_types: [] - output: - - OutString(t) - require_det_id: true + output: [] + require_det_id: false store_result_in_t: true PUT: args: - - arg_types: - - IpAddr - argc: 1 - cast_input: - - false + - arg_types: [] + argc: -1 + cast_input: [] check_det_id: false convert_det_id: true - function: setRxZmqIP - input: - - IpAddr(args[0]) - input_types: - - IpAddr - output: - - args.front() - require_det_id: true + function: '' + input: [] + input_types: [] + output: [] + require_det_id: false store_result_in_t: false command_name: rx_zmqip function_alias: rx_zmqip - help: "[x.x.x.x]\n\tZmq 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." + help: '' infer_action: true - template: true + is_description: true rx_zmqport: actions: GET: diff --git a/slsDetectorSoftware/src/Caller.cpp b/slsDetectorSoftware/src/Caller.cpp index 3c1804d6e..ae76f403f 100644 --- a/slsDetectorSoftware/src/Caller.cpp +++ b/slsDetectorSoftware/src/Caller.cpp @@ -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{det_id}); - os << OutString(t) << '\n'; - } - } - - if (action == slsDetectorDefs::PUT_ACTION) { - if (args.size() == 1) { - det->setRxZmqIP(IpAddr(args[0]), std::vector{det_id}); - os << args.front() << '\n'; - } - } - - return os.str(); -} - std::string Caller::rx_zmqport(int action) { std::ostringstream os; diff --git a/slsDetectorSoftware/src/Caller.h b/slsDetectorSoftware/src/Caller.h index 55aba7968..1add3a590 100644 --- a/slsDetectorSoftware/src/Caller.h +++ b/slsDetectorSoftware/src/Caller.h @@ -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; using StringMap = std::map; 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"}, diff --git a/slsDetectorSoftware/src/CallerSpecial.cpp b/slsDetectorSoftware/src/CallerSpecial.cpp index 0b6599015..3a66053bf 100644 --- a/slsDetectorSoftware/src/CallerSpecial.cpp +++ b/slsDetectorSoftware/src/CallerSpecial.cpp @@ -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) { diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index d344703c0..a20a54c74 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -1483,19 +1483,6 @@ void Detector::setRxZmqPort(uint16_t port, int module_id) { } } -Result 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 Detector::getClientZmqPort(Positions pos) const { return pimpl->Parallel(&Module::getClientStreamingPort, pos); } diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index cdc753a6a..38fb7adf8 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -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(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() { diff --git a/slsDetectorSoftware/src/Module.h b/slsDetectorSoftware/src/Module.h index b8b73e3f4..a93ab4775 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -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 diff --git a/slsDetectorSoftware/src/Pattern.cpp b/slsDetectorSoftware/src/Pattern.cpp index 67b6d120b..3b7049b60 100644 --- a/slsDetectorSoftware/src/Pattern.cpp +++ b/slsDetectorSoftware/src/Pattern.cpp @@ -149,7 +149,7 @@ void Pattern::load(const std::string &fname) { level = StringTo(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(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(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(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 " + diff --git a/slsDetectorSoftware/src/inferAction.cpp b/slsDetectorSoftware/src/inferAction.cpp index cb0bdc28b..e320d92a9 100644 --- a/slsDetectorSoftware/src/inferAction.cpp +++ b/slsDetectorSoftware/src/inferAction.cpp @@ -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() { diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-pattern.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-pattern.cpp index 20637cd16..b6c05cc88 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-pattern.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller-pattern.cpp @@ -192,12 +192,12 @@ TEST_CASE("Caller::patloop", "[.cmdcall]") { std::string sLoop = ToString(iLoop); if (iLoop < 3) { std::string deprecatedCmd = "patloop" + sLoop; - { // depreciated + { // deprecated std::ostringstream oss; caller.call(deprecatedCmd, {"0x20", "0x5c"}, -1, PUT, oss); REQUIRE(oss.str() == deprecatedCmd + " [0x0020, 0x005c]\n"); } - { // depreciated + { // deprecated std::ostringstream oss; caller.call(deprecatedCmd, {}, -1, GET, oss); REQUIRE(oss.str() == deprecatedCmd + " [0x0020, 0x005c]\n"); @@ -241,12 +241,12 @@ TEST_CASE("Caller::patnloop", "[.cmdcall]") { std::string sLoop = ToString(iLoop); if (iLoop < 3) { std::string deprecatedCmd = "patnloop" + sLoop; - { // depreciated + { // deprecated std::ostringstream oss; caller.call(deprecatedCmd, {"5"}, -1, PUT, oss); REQUIRE(oss.str() == deprecatedCmd + " 5\n"); } - { // depreciated + { // deprecated std::ostringstream oss; caller.call(deprecatedCmd, {}, -1, GET, oss); REQUIRE(oss.str() == deprecatedCmd + " 5\n"); @@ -287,12 +287,12 @@ TEST_CASE("Caller::patwait", "[.cmdcall]") { std::string sLoop = ToString(iLoop); if (iLoop < 3) { std::string deprecatedCmd = "patwait" + sLoop; - { // depreciated + { // deprecated std::ostringstream oss; caller.call(deprecatedCmd, {"0x5c"}, -1, PUT, oss); REQUIRE(oss.str() == deprecatedCmd + " 0x005c\n"); } - { // depreciated + { // deprecated std::ostringstream oss; caller.call(deprecatedCmd, {}, -1, GET, oss); REQUIRE(oss.str() == deprecatedCmd + " 0x005c\n"); @@ -333,12 +333,12 @@ TEST_CASE("Caller::patwaittime", "[.cmdcall]") { std::string sLoop = ToString(iLoop); if (iLoop < 3) { std::string deprecatedCmd = "patwaittime" + sLoop; - { // depreciated + { // deprecated std::ostringstream oss; caller.call(deprecatedCmd, {"8589936640"}, -1, PUT, oss); REQUIRE(oss.str() == deprecatedCmd + " 8589936640\n"); } - { // depreciated + { // deprecated std::ostringstream oss; caller.call(deprecatedCmd, {}, -1, GET, oss); REQUIRE(oss.str() == deprecatedCmd + " 8589936640\n"); diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp index b2c86bfaa..24e6442b7 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp @@ -861,26 +861,6 @@ TEST_CASE("Caller::rx_zmqport", "[.cmdcall][.rx]") { } } -TEST_CASE("Caller::rx_zmqip", "[.cmdcall][.rx]") { - Detector det; - Caller caller(&det); - auto prev_val = det.getRxZmqIP(); - { - std::ostringstream oss; - caller.call("rx_zmqip", {"127.0.0.1"}, 0, PUT, oss); - REQUIRE(oss.str() == "rx_zmqip 127.0.0.1\n"); - std::cout << "ZMQIP: " << det.getRxZmqIP() << '\n'; - } - { - std::ostringstream oss; - caller.call("rx_zmqip", {}, 0, GET, oss); - REQUIRE(oss.str() == "rx_zmqip 127.0.0.1\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setRxZmqIP(prev_val[i], {i}); - } -} - TEST_CASE("Caller::rx_zmqhwm", "[.cmdcall]") { Detector det; Caller caller(&det); diff --git a/slsDetectorSoftware/tests/Caller/test-Caller.cpp b/slsDetectorSoftware/tests/Caller/test-Caller.cpp index 3582cb372..8502e3fa8 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller.cpp @@ -3083,7 +3083,7 @@ TEST_CASE("CALLER::zmqip", "[.cmdcall]") { REQUIRE(oss2.str() == "zmqip " + zmqip[0].str() + '\n'); for (int i = 0; i != det.size(); ++i) { - det.setRxZmqIP(zmqip[i], {i}); + det.setClientZmqIp(zmqip[i], {i}); } } diff --git a/slsDetectorSoftware/tests/test-CmdParser.cpp b/slsDetectorSoftware/tests/test-CmdParser.cpp index 84a4b1f6d..cec60358e 100644 --- a/slsDetectorSoftware/tests/test-CmdParser.cpp +++ b/slsDetectorSoftware/tests/test-CmdParser.cpp @@ -7,7 +7,7 @@ // tests to add // help for all docs -// command for all depreciated commands +// command for all deprecated commands namespace sls { diff --git a/slsReceiverSoftware/src/ClientInterface.cpp b/slsReceiverSoftware/src/ClientInterface.cpp index 273728f30..51a4e2bb2 100644 --- a/slsReceiverSoftware/src/ClientInterface.cpp +++ b/slsReceiverSoftware/src/ClientInterface.cpp @@ -168,8 +168,6 @@ int ClientInterface::functionTable(){ flist[F_GET_RECEIVER_FILE_FORMAT] = &ClientInterface::get_file_format; flist[F_SET_RECEIVER_STREAMING_PORT] = &ClientInterface::set_streaming_port; flist[F_GET_RECEIVER_STREAMING_PORT] = &ClientInterface::get_streaming_port; - flist[F_SET_RECEIVER_STREAMING_SRC_IP] = &ClientInterface::set_streaming_source_ip; - flist[F_GET_RECEIVER_STREAMING_SRC_IP] = &ClientInterface::get_streaming_source_ip; flist[F_SET_RECEIVER_SILENT_MODE] = &ClientInterface::set_silent_mode; flist[F_GET_RECEIVER_SILENT_MODE] = &ClientInterface::get_silent_mode; flist[F_RESTREAM_STOP_FROM_RECEIVER] = &ClientInterface::restream_stop; @@ -1084,21 +1082,6 @@ int ClientInterface::get_streaming_port(Interface &socket) { return socket.sendResult(retval); } -int ClientInterface::set_streaming_source_ip(Interface &socket) { - auto ip = socket.Receive(); - if (ip == 0) - throw RuntimeError("Invalid zmq ip " + ip.str()); - verifyIdle(socket); - impl()->setStreamingSourceIP(ip); - return socket.Send(OK); -} - -int ClientInterface::get_streaming_source_ip(Interface &socket) { - IpAddr retval = impl()->getStreamingSourceIP(); - LOG(logDEBUG1) << "streaming IP:" << retval; - return socket.sendResult(retval); -} - int ClientInterface::set_silent_mode(Interface &socket) { auto value = socket.Receive(); if (value < 0) { diff --git a/slsReceiverSoftware/src/ClientInterface.h b/slsReceiverSoftware/src/ClientInterface.h index 89b4ce7d6..b24dfbbbd 100644 --- a/slsReceiverSoftware/src/ClientInterface.h +++ b/slsReceiverSoftware/src/ClientInterface.h @@ -117,8 +117,6 @@ class ClientInterface : private virtual slsDetectorDefs { int get_file_format(ServerInterface &socket); int set_streaming_port(ServerInterface &socket); int get_streaming_port(ServerInterface &socket); - int set_streaming_source_ip(ServerInterface &socket); - int get_streaming_source_ip(ServerInterface &socket); int set_silent_mode(ServerInterface &socket); int get_silent_mode(ServerInterface &socket); int restream_stop(ServerInterface &socket); diff --git a/slsReceiverSoftware/src/DataStreamer.cpp b/slsReceiverSoftware/src/DataStreamer.cpp index a645246cd..aef93e984 100644 --- a/slsReceiverSoftware/src/DataStreamer.cpp +++ b/slsReceiverSoftware/src/DataStreamer.cpp @@ -84,11 +84,10 @@ void DataStreamer::RecordFirstIndex(uint64_t fnum, size_t firstImageIndex) { << ", First Streamer Index:" << fnum; } -void DataStreamer::CreateZmqSockets(uint16_t port, const IpAddr ip, int hwm) { +void DataStreamer::CreateZmqSockets(uint16_t port, int hwm) { uint16_t portnum = port + index; - std::string sip = ip.str(); try { - zmqSocket = new ZmqSocket(portnum, (ip != 0 ? sip.c_str() : nullptr)); + zmqSocket = new ZmqSocket(portnum); // set if custom if (hwm >= 0) { diff --git a/slsReceiverSoftware/src/DataStreamer.h b/slsReceiverSoftware/src/DataStreamer.h index 2e6f931af..b7cc94a5d 100644 --- a/slsReceiverSoftware/src/DataStreamer.h +++ b/slsReceiverSoftware/src/DataStreamer.h @@ -45,10 +45,9 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject { * Creates Zmq Sockets * (throws an exception if it couldnt create zmq sockets) * @param port streaming port start index - * @param ip streaming source ip * @param hwm streaming high water mark */ - void CreateZmqSockets(uint16_t port, const IpAddr ip, int hwm); + void CreateZmqSockets(uint16_t port, int hwm); void CloseZmqSocket(); void RestreamStop(); diff --git a/slsReceiverSoftware/src/Implementation.cpp b/slsReceiverSoftware/src/Implementation.cpp index 4245bd1ef..76573e527 100644 --- a/slsReceiverSoftware/src/Implementation.cpp +++ b/slsReceiverSoftware/src/Implementation.cpp @@ -210,8 +210,7 @@ void Implementation::SetupDataProcessor(int i) { void Implementation::SetupDataStreamer(int i) { dataStreamer[i]->SetFifo(fifo[i].get()); dataStreamer[i]->SetGeneralData(generalData); - dataStreamer[i]->CreateZmqSockets(streamingPort, streamingSrcIP, - streamingHwm); + dataStreamer[i]->CreateZmqSockets(streamingPort, streamingHwm); dataStreamer[i]->SetAdditionalJsonHeader(additionalJsonHeader); dataStreamer[i]->SetFileIndex(fileIndex); dataStreamer[i]->SetQuadEnable(quadEnable); @@ -1262,13 +1261,6 @@ void Implementation::setStreamingPort(const uint16_t i) { LOG(logINFO) << "Streaming Port: " << streamingPort; } -IpAddr Implementation::getStreamingSourceIP() const { return streamingSrcIP; } - -void Implementation::setStreamingSourceIP(const IpAddr ip) { - streamingSrcIP = ip; - LOG(logINFO) << "Streaming Source IP: " << streamingSrcIP; -} - int Implementation::getStreamingHwm() const { return streamingHwm; } void Implementation::setStreamingHwm(const int i) { diff --git a/slsReceiverSoftware/src/Implementation.h b/slsReceiverSoftware/src/Implementation.h index 7c41a91e6..45f1546bf 100644 --- a/slsReceiverSoftware/src/Implementation.h +++ b/slsReceiverSoftware/src/Implementation.h @@ -142,8 +142,6 @@ class Implementation : private virtual slsDetectorDefs { void setStreamingStartingFrameNumber(const uint32_t fnum); uint16_t getStreamingPort() const; void setStreamingPort(const uint16_t i); - IpAddr getStreamingSourceIP() const; - void setStreamingSourceIP(const IpAddr ip); int getStreamingHwm() const; void setStreamingHwm(const int i); std::map getAdditionalJsonHeader() const; @@ -346,7 +344,6 @@ class Implementation : private virtual slsDetectorDefs { uint32_t streamingTimerInMs{DEFAULT_STREAMING_TIMER_IN_MS}; uint32_t streamingStartFnum{0}; uint16_t streamingPort{0}; - IpAddr streamingSrcIP = IpAddr{}; int streamingHwm{-1}; std::map additionalJsonHeader; diff --git a/slsSupportLib/include/sls/ZmqSocket.h b/slsSupportLib/include/sls/ZmqSocket.h index 1e49d18f1..ba65d59ce 100644 --- a/slsSupportLib/include/sls/ZmqSocket.h +++ b/slsSupportLib/include/sls/ZmqSocket.h @@ -24,7 +24,7 @@ #include //json header in zmq stream #pragma GCC diagnostic pop -//#include +// #include class zmq_msg_t; namespace sls { @@ -38,6 +38,8 @@ namespace sls { #define DEFAULT_LOW_ZMQ_HWM_BUFFERSIZE (1024 * 1024) // 1MB #define DEFAULT_ZMQ_BUFFERSIZE (-1) // os default +#define ZMQ_PUBLISHER_IP "0.0.0.0" + /** zmq header structure */ struct zmqHeader { /** true if incoming data, false if end of acquisition */ @@ -98,22 +100,11 @@ class ZmqSocket { // use this to optimize if optimizing required eg. int value = -1; if // (zmq_setsockopt(socketDescriptor, ZMQ_LINGER, &value,sizeof(value))) { // Close(); - /** - * Constructor for a client - * Creates socket, context and connects to server - * @param hostname_or_ip hostname or ip of server - * @param portnumber port number - */ + /** Constructor for a subscriber socket */ ZmqSocket(const char *const hostname_or_ip, const uint16_t portnumber); - /** - * Constructor for a server - * Creates socket, context and connects to server - * socket option: keep alive added - * @param portnumber port number - * @param ethip is the ip of the ethernet interface to stream zmq from - */ - ZmqSocket(const uint16_t portnumber, const char *ethip); + /** Constructor for a publisher socket */ + ZmqSocket(const uint16_t portnumber); /** Returns high water mark for outbound messages */ int GetSendHighWaterMark(); diff --git a/slsSupportLib/include/sls/sls_detector_defs.h b/slsSupportLib/include/sls/sls_detector_defs.h index 96b1f8a43..10848abe7 100644 --- a/slsSupportLib/include/sls/sls_detector_defs.h +++ b/slsSupportLib/include/sls/sls_detector_defs.h @@ -181,9 +181,9 @@ class slsDetectorDefs { int ymin{-1}; int ymax{-1}; ROI() = default; - ROI(int xmin, int xmax) : xmin(xmin), xmax(xmax){}; + ROI(int xmin, int xmax) : xmin(xmin), xmax(xmax) {}; ROI(int xmin, int xmax, int ymin, int ymax) - : xmin(xmin), xmax(xmax), ymin(ymin), ymax(ymax){}; + : xmin(xmin), xmax(xmax), ymin(ymin), ymax(ymax) {}; constexpr std::array getIntArray() const { return std::array({xmin, xmax, ymin, ymax}); } @@ -234,7 +234,7 @@ typedef struct { int x{0}; int y{0}; xy() = default; - xy(int x, int y) : x(x), y(y){}; + xy(int x, int y) : x(x), y(y) {}; } __attribute__((packed)); #endif diff --git a/slsSupportLib/include/sls/sls_detector_funcs.h b/slsSupportLib/include/sls/sls_detector_funcs.h index 720452bf6..880c5ddd4 100755 --- a/slsSupportLib/include/sls/sls_detector_funcs.h +++ b/slsSupportLib/include/sls/sls_detector_funcs.h @@ -748,8 +748,8 @@ const char* getFunctionNameFromEnum(enum detFuncs func) { case F_GET_RECEIVER_FILE_FORMAT: return "F_GET_RECEIVER_FILE_FORMAT"; case F_SET_RECEIVER_STREAMING_PORT: return "F_SET_RECEIVER_STREAMING_PORT"; case F_GET_RECEIVER_STREAMING_PORT: return "F_GET_RECEIVER_STREAMING_PORT"; - case F_SET_RECEIVER_STREAMING_SRC_IP: return "F_SET_RECEIVER_STREAMING_SRC_IP"; - case F_GET_RECEIVER_STREAMING_SRC_IP: return "F_GET_RECEIVER_STREAMING_SRC_IP"; + case F_SET_RECEIVER_STREAMING_SRC_IP: return "F_SET_RECEIVER_STREAMING_SRC_IP - obsolete"; + case F_GET_RECEIVER_STREAMING_SRC_IP: return "F_GET_RECEIVER_STREAMING_SRC_IP - obsolete"; case F_SET_RECEIVER_SILENT_MODE: return "F_SET_RECEIVER_SILENT_MODE"; case F_GET_RECEIVER_SILENT_MODE: return "F_GET_RECEIVER_SILENT_MODE"; case F_RESTREAM_STOP_FROM_RECEIVER: return "F_RESTREAM_STOP_FROM_RECEIVER"; diff --git a/slsSupportLib/src/ZmqSocket.cpp b/slsSupportLib/src/ZmqSocket.cpp index 36cef68ac..2fafe4799 100644 --- a/slsSupportLib/src/ZmqSocket.cpp +++ b/slsSupportLib/src/ZmqSocket.cpp @@ -53,10 +53,19 @@ ZmqSocket::ZmqSocket(const char *const hostname_or_ip, } LOG(logDEBUG) << "Default receive high water mark:" << GetReceiveHighWaterMark(); + + // enable IPv6 addresses + int ipv6 = 1; + if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_IPV6, &ipv6, + sizeof(ipv6))) { + PrintError(); + throw ZmqSocketError("Could not set ZMQ_IPV6"); + } } -ZmqSocket::ZmqSocket(const uint16_t portnumber, const char *ethip) +ZmqSocket::ZmqSocket(const uint16_t portnumber) : portno(portnumber), sockfd(true) { + // create context sockfd.contextDescriptor = zmq_ctx_new(); if (sockfd.contextDescriptor == nullptr) @@ -72,32 +81,44 @@ ZmqSocket::ZmqSocket(const uint16_t portnumber, const char *ethip) // construct address, can be refactored with libfmt std::ostringstream oss; - oss << "tcp://" << ethip << ":" << portno; + oss << "tcp://" << ZMQ_PUBLISHER_IP << ":" << portno; sockfd.serverAddress = oss.str(); LOG(logDEBUG) << "zmq address: " << sockfd.serverAddress; + // enable IPv6 addresses + int ipv6 = 1; + if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_IPV6, &ipv6, + sizeof(ipv6))) { + PrintError(); + throw ZmqSocketError("Could not set ZMQ_IPV6"); + } + // Socket Options for keepalive // enable TCP keepalive int keepalive = 1; - if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_TCP_KEEPALIVE, &keepalive, sizeof(keepalive))) { + if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_TCP_KEEPALIVE, &keepalive, + sizeof(keepalive))) { PrintError(); throw ZmqSocketError("Could set socket opt ZMQ_TCP_KEEPALIVE"); } // set the number of keepalives before death keepalive = 10; - if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_TCP_KEEPALIVE_CNT, &keepalive, sizeof(keepalive))) { + if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_TCP_KEEPALIVE_CNT, + &keepalive, sizeof(keepalive))) { PrintError(); throw ZmqSocketError("Could set socket opt ZMQ_TCP_KEEPALIVE_CNT"); } // set the time before the first keepalive keepalive = 60; - if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_TCP_KEEPALIVE_IDLE, &keepalive, sizeof(keepalive))) { + if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_TCP_KEEPALIVE_IDLE, + &keepalive, sizeof(keepalive))) { PrintError(); throw ZmqSocketError("Could set socket opt ZMQ_TCP_KEEPALIVE_IDLE"); } // set the interval between keepalives keepalive = 1; - if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_TCP_KEEPALIVE_INTVL, &keepalive, sizeof(keepalive))) { + if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_TCP_KEEPALIVE_INTVL, + &keepalive, sizeof(keepalive))) { PrintError(); throw ZmqSocketError("Could set socket opt ZMQ_TCP_KEEPALIVE_INTVL"); } @@ -109,7 +130,7 @@ ZmqSocket::ZmqSocket(const uint16_t portnumber, const char *ethip) } // sleep to allow a slow-joiner std::this_thread::sleep_for(std::chrono::milliseconds(200)); -}; +} int ZmqSocket::GetSendHighWaterMark() { int value = 0; @@ -214,8 +235,9 @@ void ZmqSocket::SetReceiveBuffer(int limit) { } } -void ZmqSocket::Rebind() { // the purpose is to apply HWL changes, which are - // frozen at bind, which is in the constructor. +void ZmqSocket::Rebind() { + // the purpose is to apply HWL changes, which are + // frozen at bind, which is in the constructor. // unbbind if (zmq_unbind(sockfd.socketDescriptor, sockfd.serverAddress.c_str())) { @@ -498,8 +520,11 @@ void ZmqSocket::PrintError() { LOG(logERROR) << "No I/O thread is available to accomplish the task (zmq)"; break; + case ENOENT: + LOG(logERROR) << "The requested endpoint does not exist (zmq)"; + break; default: - LOG(logERROR) << "Unknown socket error (zmq)"; + LOG(logERROR) << "Unknown socket error (zmq). Error code: " << errno; break; } } diff --git a/slsSupportLib/tests/test-ZmqSocket.cpp b/slsSupportLib/tests/test-ZmqSocket.cpp index 8dba7fc8b..441ba9501 100644 --- a/slsSupportLib/tests/test-ZmqSocket.cpp +++ b/slsSupportLib/tests/test-ZmqSocket.cpp @@ -17,14 +17,14 @@ TEST_CASE("Get port number for sub") { TEST_CASE("Get port number for pub") { constexpr int port = 50001; - ZmqSocket pub(port, "*"); + ZmqSocket pub(port); REQUIRE(pub.GetPortNumber() == port); } TEST_CASE("Server address") { constexpr int port = 50001; - ZmqSocket pub(port, "*"); - REQUIRE(pub.GetZmqServerAddress() == std::string("tcp://*:50001")); + ZmqSocket pub(port); + REQUIRE(pub.GetZmqServerAddress() == std::string("tcp://0.0.0.0:50001")); } TEST_CASE("Send header on localhost") { @@ -32,7 +32,7 @@ TEST_CASE("Send header on localhost") { ZmqSocket sub("localhost", port); sub.Connect(); - ZmqSocket pub(port, "*"); + ZmqSocket pub(port); // Header to send zmqHeader header; @@ -67,7 +67,7 @@ TEST_CASE("Send serveral headers of different length") { ZmqSocket sub("localhost", port); sub.Connect(); - ZmqSocket pub(port, "*"); + ZmqSocket pub(port); zmqHeader header; header.data = false; // if true we wait for the data @@ -95,7 +95,7 @@ TEST_CASE("Send header and data") { ZmqSocket sub("localhost", port); sub.Connect(); - ZmqSocket pub(port, "*"); + ZmqSocket pub(port); std::vector data{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; const int nbytes = data.size() * sizeof(decltype(data)::value_type);