From 28277b42c718d9e324cc9caf0db06c9f9c4c5492 Mon Sep 17 00:00:00 2001
From: Thomas Juerges <4-jurges@users.noreply.git.astron.nl>
Date: Fri, 2 Apr 2021 13:04:20 +0200
Subject: [PATCH] Add a convenience func to retrieve the internal attr. hist.

---
 lib/get_internal_attribute_history.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100755 lib/get_internal_attribute_history.py

diff --git a/lib/get_internal_attribute_history.py b/lib/get_internal_attribute_history.py
new file mode 100755
index 000000000..0d5f79e73
--- /dev/null
+++ b/lib/get_internal_attribute_history.py
@@ -0,0 +1,17 @@
+#! /usr/bin/env python3
+
+
+from tango import DeviceProxy
+from numpy import array, transpose
+
+
+def get_internal_attribute_history(device: DeviceProxy, attribute_name: str, depth: int = 10):
+    try:
+        history = array(device.attribute_history(attr_name = attribute_name, depth = depth))
+    except Exception as e:
+        raise ValueError("An exception was raised when attempting to access the internal history of the attribute '{}/{}'.".format(device.name(), attribute_name)) from e
+
+    history_values = array([entry.value for entry in history])
+    history_values_transposed = history_values.transpose()
+    values = array([vals for vals in history_values_transposed])
+    return values
-- 
GitLab