[pytango] 17/37: Implement write_read_attributes
Sandor Bodo-Merle
sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:16:56 UTC 2017
This is an automated email from the git hooks/post-receive script.
sbodomerle-guest pushed a commit to annotated tag v9.2.0b
in repository pytango.
commit 28c97d4bb343384723b61cbe2dbf9c0128f881a6
Author: Jose Tiago Coutinho Macara <tiago.coutinho at esrf.fr>
Date: Tue Dec 1 09:11:32 2015 +0100
Implement write_read_attributes
---
src/boost/cpp/device_proxy.cpp | 38 ++++++++++++++++++++++++++++---
src/boost/python/device_proxy.py | 48 ++++++++++++++++++++++++++++++++++++++--
2 files changed, 81 insertions(+), 5 deletions(-)
diff --git a/src/boost/cpp/device_proxy.cpp b/src/boost/cpp/device_proxy.cpp
index 08c5f03..aa2adf1 100644
--- a/src/boost/cpp/device_proxy.cpp
+++ b/src/boost/cpp/device_proxy.cpp
@@ -145,14 +145,41 @@ namespace PyDeviceProxy
// Do the actual write_read_attribute thing...
{
AutoPythonAllowThreads guard;
- r_dev_attr.reset(new Tango::DeviceAttribute(self.write_read_attribute(w_dev_attr)));
+ Tango::DeviceAttribute da = self.write_read_attribute(w_dev_attr);
+ r_dev_attr.reset(new Tango::DeviceAttribute(da));
}
// Convert the result back to python
return PyDeviceAttribute::convert_to_python(r_dev_attr.release(), self, extract_as);
}
- static inline bopy::object
+ static bopy::object
+ write_read_attributes(Tango::DeviceProxy& self,
+ bopy::object py_name_val_list,
+ bopy::object py_attr_names,
+ PyTango::ExtractAs extract_as)
+ {
+ // Convert write
+ std::vector<Tango::DeviceAttribute> dev_attrs;
+ pylist_to_devattrs(self, py_name_val_list, dev_attrs);
+
+ // Convert read
+ CSequenceFromPython<StdStringVector> attr_names(py_attr_names);
+ PyDeviceAttribute::AutoDevAttrVector dev_attr_vec;
+
+ // Do the actual write_read_attributes thing...
+ {
+ AutoPythonAllowThreads guard;
+ dev_attr_vec.reset(self.write_read_attributes(dev_attrs,
+ *attr_names));
+ }
+
+ // Convert the result back to python
+ return PyDeviceAttribute::convert_to_python(dev_attr_vec, self,
+ extract_as);
+ }
+
+ static bopy::object
command_history(Tango::DeviceProxy& self, const std::string& cmd_name, int depth)
{
std::vector<Tango::DeviceDataHistory>* device_data_hist = NULL;
@@ -573,7 +600,12 @@ void export_device_proxy()
.def("_write_read_attribute",
&PyDeviceProxy::write_read_attribute,
- ( arg_("self"), arg_("attr_name"), arg_("value"), arg_("extract_as")=PyTango::ExtractAsNumpy ) )
+ ( arg_("self"), arg_("attr_name"), arg_("value"), arg_("extract_as")=PyTango::ExtractAsNumpy ) )
+
+ .def("_write_read_attributes",
+ &PyDeviceProxy::write_read_attributes,
+ ( arg_("self"), arg_("attr_in"), arg_("attr_read_names"),
+ arg_("extract_as")=PyTango::ExtractAsNumpy ) )
//
// history methods
diff --git a/src/boost/python/device_proxy.py b/src/boost/python/device_proxy.py
index bd43fb7..f33d335 100644
--- a/src/boost/python/device_proxy.py
+++ b/src/boost/python/device_proxy.py
@@ -384,8 +384,16 @@ def __DeviceProxy__write_attribute_asynch(self, attr_name, value, cb=None):
"""
return self.write_attributes_asynch([(attr_name, value)], cb)
-def __DeviceProxy__write_read_attribute(self, attr_name, value, extract_as=ExtractAs.Numpy):
- return __check_read_attribute(self._write_read_attribute(attr_name, value, extract_as))
+def __DeviceProxy__write_read_attribute(self, attr_name, value,
+ extract_as=ExtractAs.Numpy):
+ result = self._write_read_attribute(attr_name, value, extract_as)
+ return __check_read_attribute(result)
+
+def __DeviceProxy__write_read_attributes(self, name_val,
+ attr_read_names,
+ extract_as=ExtractAs.Numpy):
+ return self._write_read_attributes(name_val, attr_read_names,
+ extract_as)
def __DeviceProxy__get_property(self, propname, value=None):
"""
@@ -1091,6 +1099,7 @@ def __init_DeviceProxy():
DeviceProxy.write_attribute = green(__DeviceProxy__write_attribute)
DeviceProxy.write_attributes = green(__DeviceProxy__write_attributes)
DeviceProxy.write_read_attribute = green(__DeviceProxy__write_read_attribute)
+ DeviceProxy.write_read_attributes = green(__DeviceProxy__write_read_attributes)
DeviceProxy.read_attributes_asynch = __DeviceProxy__read_attributes_asynch
DeviceProxy.read_attribute_asynch = __DeviceProxy__read_attribute_asynch
@@ -1567,6 +1576,41 @@ def __doc_DeviceProxy():
*timeout* parameter.
""")
+ document_method("write_read_attributes", """
+ write_read_attributes(self, name_val, attr_names, extract_as=ExtractAs.Numpy, green_mode=None, wait=True, timeout=None) -> DeviceAttribute
+
+ Write then read attribute(s) in a single network call. By
+ default (serialisation by device), the execution of this
+ call in the server can't be interrupted by other clients.
+ On the server side, attribute(s) are first written and
+ if no exception has been thrown during the write phase,
+ attributes will be read.
+
+ Parameters :
+ - name_val: A list of pairs (attr_name, value). See write_attribute
+ - attr_names : (sequence<str>) A list of attributes to read.
+ - extract_as : (ExtractAs) Defaults to numpy.
+ - green_mode : (GreenMode) Defaults to the current DeviceProxy GreenMode.
+ (see :meth:`~PyTango.DeviceProxy.get_green_mode` and
+ :meth:`~PyTango.DeviceProxy.set_green_mode`).
+ - wait : (bool) whether or not to wait for result. If green_mode
+ is *Synchronous*, this parameter is ignored as it always
+ waits for the result.
+ Ignored when green_mode is Synchronous (always waits).
+ - timeout : (float) The number of seconds to wait for the result.
+ If None, then there is no limit on the wait time.
+ Ignored when green_mode is Synchronous or wait is False.
+
+ Return : (sequence<DeviceAttribute>)
+
+ Throws : ConnectionFailed, CommunicationFailed, DeviceUnlocked,
+ DevFailed from device, WrongData
+ TimeoutError (green_mode == Futures) If the future didn't finish executing before the given timeout.
+ Timeout (green_mode == Gevent) If the async result didn't finish executing before the given timeout.
+
+ New in PyTango 9.0.0
+ """)
+
#-------------------------------------
# History methods
#-------------------------------------
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/pytango.git
More information about the debian-science-commits
mailing list