I’m try to add filtering and the ability to look at alarm history.
I have created a date selector and a couple of text boxes (for path and alarm filters)
I bound the Alerts property to this code:
if ({Root Container.Alarms.Options.DateRange.selected},
runscript("app.alarms.get_history_alarms()"),
runscript("app.alarms.get_current_alarms()"))
The code it calls (app.alarms.get_xxx_alarms()) is:
[code]def get_history_alarms():
import system
import app
options = app.alarms.get_options()
if options.getComponent(‘Device’).selected == 1:
filterpath = options.getComponent(‘Text Field’).text+’’
else:
filterpath = None
if options.getComponent(‘Point’).selected == 1:
filterpoint = options.getComponent(‘Text Field 1’).text+’’
else:
filterpoint = None
startdate = options.getComponent('StartDate').date
enddate = options.getComponent('EndDate').date
return system.alert.queryAlertHistory("AlertHistory", path=filterpath, stateName=filterpoint,
start=startdate, end=enddate,
activeAndAcked=1, clearAndAcked=1)
def get_current_alarms():
import system
import app
options = app.alarms.get_options()
if options.getComponent(‘Device’).selected == 1:
filterpath = options.getComponent(‘Text Field’).text+’’
else:
filterpath = None
if options.getComponent(‘Point’).selected == 1:
filterpoint = options.getComponent(‘Text Field 1’).text+’’
else:
filterpoint = None
return system.alert.queryAlertStatus(
path=filterpath,
stateName=filterpoint,
activeAndUnacked=1, activeAndAcked=1,
clearAndUnacked=1, clearAndAcked=0,
flatten=0)
def get_options():
import system
window = system.gui.getWindow(‘Alarm Summary’)
container = window.getRootContainer()
alarms = container.getComponent(‘Alarms’)
options = alarms.getComponent(‘Options’)
return options[/code]
However, it doesn’t seem to work. The control displays all current alerts regardless of the contents of the Alerts dataset. The documentation for the Alerts property says it’s read only and bindable