mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-04 00:50:42 +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:
parent
15e8c0d9f1
commit
e848293916
@ -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
|
||||
|
||||
|
@ -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';
|
||||
}
|
||||
|
@ -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):
|
||||
|
@ -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;
|
||||
|
@ -852,7 +852,7 @@
|
||||
</font>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><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></string>
|
||||
<string><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></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Client ZMQ IP:</string>
|
||||
@ -886,7 +886,7 @@
|
||||
</font>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><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></string>
|
||||
<string><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></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
@ -948,28 +948,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="3">
|
||||
<widget class="QLabel" name="label_16">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Cantarell</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><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></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Receiver ZMQ IP:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="sizePolicy">
|
||||
@ -1121,40 +1099,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="4">
|
||||
<widget class="QLineEdit" name="dispRxrZMQIP">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>180</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Cantarell</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><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></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="sizePolicy">
|
||||
@ -2312,7 +2256,6 @@ Exposure Time of a sub frame. Only for Eiger in 32 bit mode
|
||||
<tabstop>dispRxrUDPIP</tabstop>
|
||||
<tabstop>dispRxrUDPMAC</tabstop>
|
||||
<tabstop>spinRxrZMQPort</tabstop>
|
||||
<tabstop>dispRxrZMQIP</tabstop>
|
||||
<tabstop>spinNumStoragecells</tabstop>
|
||||
<tabstop>spinSubExpTime</tabstop>
|
||||
<tabstop>comboSubExpTimeUnit</tabstop>
|
||||
|
@ -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();
|
||||
|
@ -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 {
|
||||
|
@ -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<std::string, std::string (Caller::*)(int)>;
|
||||
using StringMap = std::map<std::string, std::string>;
|
||||
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)
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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() {
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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() {
|
||||
|
@ -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");
|
||||
|
@ -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);
|
||||
|
@ -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});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
// tests to add
|
||||
// help for all docs
|
||||
// command for all depreciated commands
|
||||
// command for all deprecated commands
|
||||
|
||||
namespace sls {
|
||||
|
||||
|
@ -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<IpAddr>();
|
||||
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<int>();
|
||||
if (value < 0) {
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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<std::string, std::string> 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<std::string, std::string> additionalJsonHeader;
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <rapidjson/document.h> //json header in zmq stream
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
//#include <zmq.h>
|
||||
// #include <zmq.h>
|
||||
|
||||
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();
|
||||
|
@ -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<int, 4> getIntArray() const {
|
||||
return std::array<int, 4>({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
|
||||
|
||||
|
@ -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";
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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<int> data{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
||||
const int nbytes = data.size() * sizeof(decltype(data)::value_type);
|
||||
|
Loading…
x
Reference in New Issue
Block a user