From 536be9473efc2354b94fc8ee568731e67e7de5a8 Mon Sep 17 00:00:00 2001
From: Romain Broucquart <romain.broucquart@synchrotron-soleil.fr>
Date: Wed, 13 Oct 2021 15:43:55 +0200
Subject: [PATCH] Add captureattr util function

---
 OpUtils.py | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/OpUtils.py b/OpUtils.py
index 302aae6..571e948 100644
--- a/OpUtils.py
+++ b/OpUtils.py
@@ -27,6 +27,32 @@ def searchattr(prx, attr, ignorecase=True):
     else:
         return [a for a in prx.get_attribute_list() if attr in a]
 
+def captureattr(prx):
+    """
+    Capture all attributes in the device, return a python dict.
+
+    PARAMETERS
+    ----------
+    prx: tango.DeviceProxy
+        Proxy to the device.
+
+    RETURN
+    ------
+    attrs: dict
+        keys are attributes names, values are values.
+    """
+
+    attrs=dict()
+    attrlist=prx.get_attribute_list()
+
+    R= prx.read_attributes(attrlist, wait=True)
+    for r in R:
+        attrs[r.name.lower()]=r.value
+
+    return attrs
+
+
+
 ###############################################################################
 # FUNCTIONS ON TANGO DATABASE
 ###############################################################################
-- 
GitLab