Skip to content
This repository was archived by the owner on Sep 6, 2022. It is now read-only.

Commit 191bdef

Browse files
committed
Add methods for check/restart of HDB++ attributes
1 parent 9f1ea21 commit 191bdef

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

PyTangoArchiving/hdbpp/config.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ def add_attribute(self,attribute,archiver,period=0,
373373
if per_event not in (None,-1):
374374
d.write_attribute('SetPeriodEvent',per_event)
375375

376-
if not any((abs_event,rel_event)):
376+
if not any((abs_event,rel_event,code_event)):
377377
if re.search("short|long",data_type.lower()):
378378
abs_event = 1
379379
elif not re.search("bool|string",data_type.lower()):
@@ -763,6 +763,32 @@ def get_attribute_rows(self,attribute,start_date=0,stop_date=0):
763763
% ( table, aid) + where)
764764
return r[0][0] if r else 0
765765

766+
def get_failed_attributes(self,t=7200):
767+
vals = self.load_last_values(self.get_attributes())
768+
nones = [k for k,v in vals.items()
769+
if (not v or v[1] is None)]
770+
nones = [k for k in nones if fn.read_attribute(k) is not None]
771+
lost = [k for k,v in vals.items()
772+
if k not in nones and v[0] < fn.now()-t]
773+
lost = [k for k in lost if fn.read_attribute(k) is not None]
774+
failed = nones+lost
775+
return sorted(failed)
776+
777+
def restart_attribute(self,attr):
778+
d = self.get_attribute_archiver(attr)
779+
print('%s.restart_attribute(%s)' % (d,attr))
780+
dp = fn.get_device(d,keep=True)
781+
dp.AttributeStop(attr)
782+
fn.wait(.1)
783+
dp.AttributeStart(attr)
784+
785+
def restart_attributes(self,attributes=None):
786+
if attributes is None:
787+
attributes = self.get_failed_attributes()
788+
789+
for a in sorted(attributes):
790+
self.restart_attribute(a)
791+
766792
def check_attributes(self,attrs = '', load = False, t0 = 0):
767793

768794
db,t0,result,vals = self,t0 or fn.now(),{},{}

0 commit comments

Comments
 (0)