From b96e0eaf4f9ab81d56171d5990298dccadb30879 Mon Sep 17 00:00:00 2001
From: Thomas Juerges <4-jurges@users.noreply.git.astron.nl>
Date: Tue, 13 Apr 2021 16:47:55 +0200
Subject: [PATCH] Add helper funcs to add/remove attribute archiving

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

diff --git a/lib/archiver.py b/lib/archiver.py
new file mode 100755
index 000000000..70f43d88a
--- /dev/null
+++ b/lib/archiver.py
@@ -0,0 +1,20 @@
+#! /usr/bin/env python3
+
+from .lofar2_config import configure_logging
+from tango import DeviceProxy
+
+
+def add_attribute_to_archiver(attribute: str, polling_period: float, event_period: float, archive_manager: str = 'archiving/hdbpp/confmanager01', archiver: str = 'archiving/hdbpp/eventsubscriber01'):
+    am = DeviceProxy(archive_manager)
+    am.write_attribute('SetAttributeName', attribute)
+    am.write_attribute('SetArchiver', archiver)
+    am.write_attribute('SetStrategy', 'ALWAYS')
+    am.write_attribute('SetPollingPeriod', int(polling_period))
+    am.write_attribute('SetPeriodEvent', int(event_period))
+    am.AttributeAdd()
+    am.AttributeStart(attribute)
+
+def remove_attribute_from_archiver(attribute: str, archive_manager: str = 'archiving/hdbpp/confmanager01'):
+    am = DeviceProxy(archive_manager)
+    am.AttributeStop(attribute)
+    am.AttributeRemove(attribute)
-- 
GitLab