Alarm buffer also seems to act as an alarm historian?

At a customer request, when a shelved alarm has been cleared and reset, the alarm must be unshelved and acknowledged so that it disappears.

I have created this functionality via scripting using the system.alarm.queryStatus

to cover all possible alarms (some will only go to cleared after a user action and others will go to cleared automatically) I also have to search the cleared alarms, some of which might be shelved.

alarms = system.alarm.queryStatus(state = [0,1,2],displaypath = [tag[0].value + '*'],includeShelved = True)

The issue I now have is it that this returns alarms from months ago. in time this might be hundreds of alarms and will cause performance issues. In other words, the alarm buffer also acts as an alarm journal, which I find strange.

Since we also have a proper alarm journal with SQL database setup, I wonder how to make sure that cleared, acknowledged alarms are removed entirely from the alarm buffer ?

I am not entirely clear on the use-case for the script, but if we take a step back the expected behavior for "live" alarm events is:

  • Alarms start in the State: Active, Unacknowledged.
  • Alarms will attempt to remain in the live event (your alarm buffer) system while they are either: Active or Unacknowledged.
  • Once an Alarm becomes Cleared and Acknowledged it will leave the buffer if either: A new instance of that Active alarm occurs, or it is not the most recent instance of the Cleared,Acked alarm. In this way, the alarm status system always has a record of the most recent single alarm event for any alarm that has gone active.
  • Finally we can't forget - alarms can be pushed out, regardless of their State, if the live event limit is reached. It defaults to 5. This means by default a new alarm will have 5 active records before it starts to drop the oldest record. In this way, you do maintain the history of the X most recent active or unacked events where X is your live event limit.

So this is likely somewhat expected, if you are running a queryStatus() for all alarms that are cleared/acked, you will be picking up an ever growing list of alarms as you add more to the system. Using more specific filtering would potentially resolve the issue.

The below is from the system.alarm.queryStatus documentation


The state = [0,1,2] in your script is looking for

  • Cleared and unacknowledged alarms
  • Cleared and acknowledged alarms
  • Active and unacknowledged alarms

If you wish to exclude 'Cleared and acknowledged alarms' replace state = [0,1,2] with state = [0,2]. This will include only unacknowledged alarms

I have to search the cleared and unacked alarms because if hey are shelved, they stay in the alarm buffer until they are unshelved

The use case is that alarm has to leave the buffer when it is cleared and acknowledged, including shelved alarms. shelved alarms do not disappear until they are unshelved. So I have to unshelve them if they are cleared via scripting (script on a tag which the PLC sets to 1 or 0). thats why I have to search them with [0,1,2] and includeShelved = True

the live event limit functionality will do, at least it will not fill up the buffer with identical alarms.

is there a way to clear the entire buffer at once ?

Alarms live in memory, and there is no way (that I know of) to eliminate those references to the most recent alarm instance.

Why do you want remove the older alarms? If they are showing up in calculations or reports elsewhere, then those areas need to filter them out.