From 3e910d9860bd220d15970efed72dfd4c3c0d181d Mon Sep 17 00:00:00 2001 From: stedif <stefano.difrischia@inaf.it> Date: Tue, 5 Oct 2021 11:40:32 +0200 Subject: [PATCH] L2SS-375: get attribute frequency --- devices/toolkit/archiver.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/devices/toolkit/archiver.py b/devices/toolkit/archiver.py index 0991b05c6..9f77bc39e 100644 --- a/devices/toolkit/archiver.py +++ b/devices/toolkit/archiver.py @@ -276,6 +276,20 @@ class Archiver(): else: return len(es.AttributeList or []) + def get_attribute_freq(self,attribute_name:str): + """ + Return the attribute archiving frequency in events/minute + """ + if (len(attribute_name.split('/'))!=4): + raise AttributeFormatException + if self.is_attribute_archived(attribute_name): + freq_dict = dict((a,r) for a,r in zip(self.es.AttributeList,self.es.AttributeRecordFreqList)) + for f in freq_dict: + if attribute_name in f: + return freq_dict.get(f,0.) + else: + logger.warning(f"Attribute {attribute_name} not found!") + class AttributeFormatException(Exception): """ Exception that handles wrong attribute naming -- GitLab