Perspective alarm status table - get number of alarms

Is there any way to retrieve the number of alarms currently being shown in a perspective alarm status table? I have a simple alarm banner in a dock, which has no filtering (and no ability for the user to filter) - it just shows all the alarms for the relevant area based on a source filter passed in at runtime. I would like to set up an event script to close the alarm dock when the number of alarms shown in it goes from > 0 to 0.

I’ve made it work by setting up a custom property which uses system.alarm.queryStatus and gets all the parameters for the query from the table, but I’d like to think there’s an easier way, since the alarm status table tells me “n active alarms” in the header - but I can’t find anywhere in the properties that makes that value available to me.

If I understand properly, you have an alarm status table in a dock, and you want to hide it when it’s empty.

The AlarmStatusTable has a property that enables it to write back its contents to another property:

You can set the filter.results.enabled property to true then use to see if there’s anything in your table.

1 Like

Ah, so I have to enable it. I see that the doc you linked warns of a performance decline when enabling this property. Any developers here able to give a little context as to how large a performance hit we’re talking about? What would be the more significant performance impact, enabling that property, or running the script below every time the “Active and Unacknowledged Alarms Count” tag from the gateway system tags changes?

#determine which alarm priorities to count, based on what is being shown in the alarm table
filteredPriorities = self.getChild("root").getChild("AlarmStatusTable")
priorities = []
for key, value in filteredPriorities.items():
	if value: priorities.append(key)
#determine which alarm states to count, based on what is being shown in the alarm table
filteredStates = self.getChild("root").getChild("AlarmStatusTable")
states = []
for key, value in filteredStates.items():
	if value: states.append(key)
#determine with alarm sources to query, based on what is being shown in the alarm table
sources = self.getChild("root").getChild("AlarmStatusTable")
#query alarms
alarmStatusInfo = system.alarm.queryStatus(priority=priorities, state=states, source=sources)
return len(alarmStatusInfo)

There’s probably a larger performance hit by calling system.alarm.queryStatus for every client that’s open than there is by writing the alarm info to that property. I guess it depends how many alarms you have active at a time


I’ve been using this ‘write back’ method on several different tables and didn’t notice any significant performance hit.

1 Like

Thanks everyone. I’ll go that route.