[pytango] 468/483: Implement feature-request #110

Sandor Bodo-Merle sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:15:13 UTC 2017


This is an automated email from the git hooks/post-receive script.

sbodomerle-guest pushed a commit to annotated tag bliss_8.10
in repository pytango.

commit 56538110a606f626cfd25461eca482a5b04b78f7
Author: coutinho <coutinho at esrf.fr>
Date:   Fri Apr 17 12:47:18 2015 +0200

    Implement feature-request #110
---
 doc/revision.rst                  |  9 +++++++--
 src/boost/python/device_server.py | 16 ++++++++++++----
 src/boost/python/server.py        | 19 ++++++++++++++++++-
 3 files changed, 37 insertions(+), 7 deletions(-)

diff --git a/doc/revision.rst b/doc/revision.rst
index c1a094f..1ad8aac 100644
--- a/doc/revision.rst
+++ b/doc/revision.rst
@@ -83,9 +83,10 @@ Document revisions
 +----------+----------------------------------------------------------------------------------+-----------------------------------------------------+-----------------------+
 | 01/10/14 | `8.21 <http://www.tango-controls.org/static/PyTango/v815/doc/html/index.html>`_  | Update to PyTango 8.1.5                             | T\. Coutinho          |
 +----------+----------------------------------------------------------------------------------+-----------------------------------------------------+-----------------------+
-| 05/02/15 | `8.22 <http://www.tango-controls.org/static/PyTango/v815/doc/html/index.html>`_  | Update to PyTango 8.1.6                             | T\. Coutinho          |
+| 05/02/15 | `8.22 <http://www.tango-controls.org/static/PyTango/v816/doc/html/index.html>`_  | Update to PyTango 8.1.6                             | T\. Coutinho          |
++----------+----------------------------------------------------------------------------------+-----------------------------------------------------+-----------------------+
+| --/04/15 | `8.23 <http://www.tango-controls.org/static/PyTango/v817/doc/html/index.html>`_  | Update to PyTango 8.1.6                             | T\. Coutinho          |
 +----------+----------------------------------------------------------------------------------+-----------------------------------------------------+-----------------------+
-
 
 .. _pytango-version-history:
 
@@ -95,6 +96,10 @@ Version history
 +----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 | version  | Changes                                                                                                                                                               |
 +==========+=======================================================================================================================================================================+
+| 8.1.7    | Features:                                                                                                                                                             |
+|          |                                                                                                                                                                       |
+|          |     - `110:  device property with auto update in database <https://sourceforge.net/p/tango-cs/feature-requests/110>`_                                                 |
++----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 | 8.1.6    | Bug fixes:                                                                                                                                                            |
 |          |                                                                                                                                                                       |
 |          |     - `698: PyTango.Util discrepancy <https://sourceforge.net/p/tango-cs/bugs/698>`_                                                                                  |
diff --git a/src/boost/python/device_server.py b/src/boost/python/device_server.py
index 068b567..e71a49b 100644
--- a/src/boost/python/device_server.py
+++ b/src/boost/python/device_server.py
@@ -292,10 +292,18 @@ def __DeviceImpl__get_device_properties(self, ds_class = None):
         self.device_property_list = copy.deepcopy(ds_class.device_property_list)
         class_prop = ds_class.class_property_list
         pu.get_device_properties(self, class_prop, self.device_property_list)
-        for prop_name in class_prop:
-            setattr(self, prop_name, pu.get_property_values(prop_name, class_prop))
-        for prop_name in self.device_property_list:
-            setattr(self, prop_name, self.prop_util.get_property_values(prop_name, self.device_property_list))
+        if hasattr(self, "_tango_properties"):
+            for prop_name in class_prop:
+                value = pu.get_property_values(prop_name, class_prop)
+                self._tango_properties[prop_name] = value
+            for prop_name in self.device_property_list:
+                value = self.prop_util.get_property_values(prop_name, self.device_property_list)
+                self._tango_properties[prop_name] = value
+        else:
+            for prop_name in class_prop:
+                setattr(self, prop_name, pu.get_property_values(prop_name, class_prop))
+            for prop_name in self.device_property_list:
+                setattr(self, prop_name, self.prop_util.get_property_values(prop_name, self.device_property_list))
     except DevFailed as df:
         print(80*"-")
         print(df)
diff --git a/src/boost/python/server.py b/src/boost/python/server.py
index 2a9203c..4b92413 100644
--- a/src/boost/python/server.py
+++ b/src/boost/python/server.py
@@ -711,19 +711,24 @@ def command(f=None, dtype_in=None, dformat_in=None, doc_in="",
 
 class _BaseProperty(object):
 
-    def __init__(self, dtype, doc='', default_value=None):
+    def __init__(self, dtype, doc='', default_value=None, update_db=False):
         self.name = None
         self.__value = None
         dtype = from_typeformat_to_type(*_get_tango_type_format(dtype))
         self.dtype = dtype
         self.doc = doc
         self.default_value = default_value
+        self.update_db = update_db
 
     def __get__(self, obj, objtype):
         return obj._tango_properties.get(self.name)
 
     def __set__(self, obj, value):
         obj._tango_properties[self.name] = value
+        if self.update_db:
+            import PyTango
+            db = PyTango.Util.instance().get_database()
+            db.put_device_property(obj.get_name(), {self.name: value})
 
     def __delete__(self, obj):
         del obj._tango_properties[self.name]
@@ -747,6 +752,12 @@ class device_property(_BaseProperty):
     :param dtype: Data type (see :ref:`pytango-data-types`)
     :param doc: property documentation (optional)
     :param default_value: default value for the property (optional)
+    :param update_db: tells if set value should write the value to database.
+                     [default: False]
+    :type update_db: bool
+
+    .. versionadded:: 8.1.7
+        added update_db option
     """
     pass
 
@@ -769,6 +780,12 @@ class class_property(_BaseProperty):
     :param dtype: Data type (see :ref:`pytango-data-types`)
     :param doc: property documentation (optional)
     :param default_value: default value for the property (optional)
+    :param update_db: tells if set value should write the value to database.
+                     [default: False]
+    :type update_db: bool
+
+    .. versionadded:: 8.1.7
+        added update_db option
     """
     pass
 

-- 
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