const qualified multi calls, python fixes

This commit is contained in:
Erik Frojdh
2019-03-18 12:06:39 +01:00
parent c0d5303b70
commit 4036e6af8d
8 changed files with 100 additions and 62 deletions

View File

@ -441,7 +441,7 @@ class Detector:
@property
def api_compatibility(self):
Compatibility = namedtuple('Compatibility', ['client_detector', 'client_receiver'])
c = Compatibility(self._api.isClientAndDetecorCompatible(), self._api.isClientAndReceiverCompatible())
c = Compatibility(self._api.isClientAndDetectorCompatible(), self._api.isClientAndReceiverCompatible())
return c
@property
@ -1022,18 +1022,15 @@ class Detector:
def rx_hostname(self):
"""
Receiver hostname
TODO! setting of individual hostnames, now done with API call
"""
s = self._api.getNetworkParameter('rx_hostname')
return element_if_equal(s)
return self._api.getReceiverHostname()
@rx_hostname.setter
@error_handling
def rx_hostname(self, names):
# if we pass a list join the list
if isinstance(names, list):
names = '+'.join(n for n in names)+'+'
self._api.setNetworkParameter('rx_hostname', names, -1)
def rx_hostname(self, name):
self._api.setReceiverHostname(name)
@property
@ -1042,16 +1039,16 @@ class Detector:
"""
Receiver UDP ip
"""
s = self._api.getNetworkParameter('rx_udpip')
return element_if_equal(s)
return self._api.getReceiverUDPIP(-1)
@rx_udpip.setter
def rx_udpip(self, ip):
if isinstance(ip, list):
for i, addr in enumerate(ip):
self._api.setNetworkParameter('rx_udpip', addr, i)
self._api.setReceiverUDPIP(addr, i)
else:
self._api.setNetworkParameter('rx_udpip', ip, -1)
self._api.setReceiverUDPIP(ip, -1)
@property

View File

@ -89,6 +89,22 @@ class Detector {
return det.getReceiverCurrentFrameIndex();
}
std::string getReceiverHostname(int det_id = -1) const {
return det.getReceiverHostname(det_id);
}
void setReceiverHostname(const std::string &hostname, int det_id = -1) {
det.setReceiverHostname(hostname, det_id);
}
std::string getReceiverUDPIP(int det_id = -1) const {
return det.getReceiverUDPIP(det_id);
}
void setReceiverUDPIP(const std::string &ip, int det_id = -1) {
det.setReceiverUDPIP(ip, det_id);
}
void startReceiver() { det.startReceiver(); }
void stopReceiver() { det.stopReceiver(); }
@ -352,15 +368,15 @@ class Detector {
return mp;
}
bool isClientAndDetecorCompatible() {
auto r = det.checkDetectorVersionCompatibility(slsDetectorDefs::CONTROL_PORT);
bool isClientAndDetectorCompatible() {
auto r = det.checkDetectorVersionCompatibility();
if (r == 0)
return true;
else
return false;
}
bool isClientAndReceiverCompatible() {
auto r = det.checkReceiverVersionCompatibility(slsDetectorDefs::DATA_PORT);
auto r = det.checkReceiverVersionCompatibility();
if (r == 0)
return true;
else
@ -663,14 +679,13 @@ class Detector {
return vec;
}
void setReceiverUDPPort(int port, int det_id){
void setReceiverUDPPort(int port, int det_id) {
det.setReceiverUDPPort(port, det_id);
}
void setReceiverUDPPort2(int port, int det_id){
void setReceiverUDPPort2(int port, int det_id) {
det.setReceiverUDPPort2(port, det_id);
}
// //Set network parameter for all modules if det_id == -1 otherwise the module
// //specified with det_id.
// void setDetectorNetworkParameter(std::string par_name, std::string par, const int det_id) {

View File

@ -178,10 +178,16 @@ PYBIND11_MODULE(_sls_detector, m)
.def("setRxDataStreamStatus", &Detector::setRxDataStreamStatus)
//Network stuff
.def("getReceiverHostname", &Detector::getReceiverHostname)
.def("setReceiverHostname", &Detector::setReceiverHostname)
.def("getReceiverStreamingPort", &Detector::getReceiverStreamingPort)
.def("setReceiverStreamingPort", &Detector::setReceiverStreamingPort)
.def("getReceiverUDPPort", &Detector::getReceiverUDPPort)
.def("getReceiverUDPPort2", &Detector::getReceiverUDPPort2)
.def("setReceiverUDPPort", &Detector::setReceiverUDPPort)
.def("setReceiverUDPPort2", &Detector::setReceiverUDPPort2)
.def("setReceiverUDPIP", &Detector::setReceiverUDPIP)
.def("getReceiverUDPIP", &Detector::getReceiverUDPIP)
.def("getReceiverPort", &Detector::getReceiverPort)
.def("setReceiverPort", &Detector::setReceiverPort)
@ -207,7 +213,7 @@ PYBIND11_MODULE(_sls_detector, m)
.def("getReceiverPartialFramesPadding", &Detector::getReceiverPartialFramesPadding)
.def("getUserDetails", &Detector::getUserDetails)
.def("isClientAndDetecorCompatible", &Detector::isClientAndDetecorCompatible)
.def("isClientAndDetectorCompatible", &Detector::isClientAndDetectorCompatible)
.def("isClientAndReceiverCompatible", &Detector::isClientAndReceiverCompatible)
.def("getMeasuredPeriod", &Detector::getMeasuredPeriod)
.def("getMeasuredSubPeriod", &Detector::getMeasuredSubPeriod)
@ -276,7 +282,9 @@ py::class_<multiSlsDetector> multiDetectorApi(m, "multiDetectorApi");
py::cpp_function(&multiSlsDetector::setAcquiringFlag))
.def_property_readonly("rx_tcpport",
py::cpp_function(&multiSlsDetector::getReceiverPort))
// .def_property_readonly("rx_udpip",
// py::cpp_function(&multiSlsDetector::getReceiverUDPIP), py::arg("det_id")=1)
// .def("_setReceiverUDPIP", &multiSlsDetector::setReceiverUDPIP)
;