Skip to content
This repository has been archived by the owner on Mar 24, 2022. It is now read-only.

Commit

Permalink
Set state/quality to FAULT/INVALID when alarms fail
Browse files Browse the repository at this point in the history
  • Loading branch information
sergirubio committed Oct 18, 2016
1 parent 4b66064 commit 129fda9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions panic/ds/PyAlarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#
# project : TANGO Device Server
#
# $Author: sergi_rubio at cells$
# $Author: srubio at cells$
#
# $Revision: $
#
Expand Down Expand Up @@ -183,7 +183,9 @@ def alarm_attr_read(self,attr,fire_event=True):
self.debug('PyAlarm(%s).read_alarm_attribute(%s) is %s; Active Alarms: %s' % (self.get_name(),tag_name,value,self.get_active_alarms()))

self.quality=PyTango.AttrQuality.ATTR_WARNING
if(self.Alarms[tag_name].severity=='DEBUG'):
if tag_name in self.FailedAlarms or self.CheckDisabled(tag_name):
self.quality=PyTango.AttrQuality.ATTR_INVALID
elif(self.Alarms[tag_name].severity=='DEBUG'):
self.quality=PyTango.AttrQuality.ATTR_VALID
elif(self.Alarms[tag_name].severity=='WARNING'):
self.quality=PyTango.AttrQuality.ATTR_WARNING
Expand Down Expand Up @@ -1152,6 +1154,8 @@ def always_executed_hook(self):
status+='%s:%s:\n\t%s\n\tSeverity:%s\n\tSent to:%s\n' % (time.ctime(date),tag_name,self.Alarms[tag_name].description,self.Alarms[tag_name].severity,self.Alarms[tag_name].receivers)
if self.FailedAlarms:
status+='\n%d alarms couldnt be evaluated:\n%s'%(len(self.FailedAlarms),','.join(str(t) for t in self.FailedAlarms.items()))
if float(len(self.FailedAlarms))/len(self.Alarms) > 0.1:
self.set_state(PyTango.DevState.FAULT)
if self.Uncatched:
status+='\nUncatched exceptions:\n%s'%self.Uncatched
status += '\n\n' + 'EvalTimes are: \n %s\n'%(self.EvalTimes)
Expand Down

0 comments on commit 129fda9

Please sign in to comment.