Alarms have variables and functions that allow programmatic access.
First, here are the variables and functions that are global to all alarms. These all begin with Alarm..
FiredCountAdvisory : returns the total count of Advisory alarms fired and not acknowledged.
FiredCountCritical : returns the total count of Critical alarms fired and not acknowledged.
FiredCountLog : returns the total count of Log alarms fired and not acknowledged.
FiredCountTotal : returns the total count of all alarms fired and not acknowledged.
FiredCountWarning : returns the total count of Warning alarms fired and not acknowledged.
strLatestAlarm : returns the name of the last alarm to fire.
LatestAlarmColor : returns the default color, based on the priority, of the last alarm to fire.
LatestAlarmAcked : return 0 or 1 on the acknowledge state of the last alarm to fire.
strLatestLogAlarm : returns the name of the last alarm with LogOnly priority level to fire.
LatestLogAlarmAcked : returns 0 or 1 on the acknowledge state of the last LogOnly priority alarm to fire.
strLatestAdvisoryAlarm : returns the name of the last alarm with Advisory priority level to fire.
LatestAdvisoryAlarmAcked : returns 0 or 1 on the acknowledge state of the last Advisory priority alarm to fire.
strLatestWarningAlarm : returns the name of the last alarm with Warning priority level to fire.
LatestWarningAlarmAcked : returns 0 or 1 on the acknowledge state of the last Warning priority alarm to fire.
strLatestCriticalAlarm : returns the name of the last alarm with Critical priority level to fire.
LatestCriticalAlarmAcked : returns 0 or 1 on the acknowledge state of the last Critical priority alarm to fire.
Paused: this will pause the checking of alarms. If you have a lot of alarms, your acquisition loops can be slowed because all alarms are normally checked every time a new value comes in. To give you control, you can pause the alarm checking while you acquire data in your loop, and then resume it when done. Use this in conjunction with the Alarm.CheckAlarms() function below. There are typically two ways you can implement this:
1) You can pause alarm checking in an auto-start sequence, leaving it paused, and then manually check alarms. This is probably the preferred way. You can either create a separate sequence to check alarms at a fixed interval, or put the CheckAlarms() at the end of your polling loop.
2) You can pause alarm checking while acquiring data in a polling loop and then unpause and check alarms after completing the loop. This is typically done with acquisition done with function calls and the AddValue() function:
try
Alarm.Paused = 1
... Acquire data and call addvalue() to put it into channels...
Alarm.Paused = 0
catch()
Alarm.Paused = 0
endcatch
Alarm.CheckAlarms()
You'll want to use the try/catch block to ensure that Alarm.Pause gets set back to 0 in case of error.
ResetCountAdvisory : returns the total count of Advisory alarms reset and not acknowledged.
ResetCountCritical : returns the total count of Critical alarms reset and not acknowledged.
ResetCountLog : returns the total count of Log alarms reset and not acknowledged.
ResetCountTotal : returns the total count of all alarms reset and not acknowledged.
ResetCountWarning : returns the total count of Warning alarms reset and not acknowledged.
AckAllAlarms() : acknowledges all alarms. This is the same as clicking the Acknowledge All button in the alarm summary view.
Ack(Alarm Name) : acknowledges the given alarm only. For example: Alarm.Ack("MyAlarm")
CheckAlarms(): manually checks all alarms. Alarms are normally checked whenever a new data point arrives on any channel. You can also trigger the checking of alarms manually using this function. This is typically used with the Alarm.Paused variable.
DisplayAlarms(): displays the same list of alarms you would get if you clicked on ALARMS: in the workspace, except, if in runtime mode, the Add, Set Logging File, Export and Import buttons are not visible.
ListAll(): returns an array of strings with the names of each of your alarms.
strResetCondition : a string containing the expression
strDescription : a string with the description
Priority : a number corresponding to the priority of the alarm: 1 = Log Only, 2 = Advisory, 3 = Warning and 4 = Critical
strHelp : a string with the help information
Enabled : 0 or 1
strSound : a string with the path to the .wav file
TimeFired : the last time the alarm fired.
TimeReset : the last time the alarm was reset. This resets to 0 when the alarm fires.
TimeAcked : the last time the alarm was acked. This resets to 0 when the alarm fires.
Fired : 0 or 1. If 1, then the alarm has fired, but hasn't been reset.
Acked : 0 or 1. If 1, then the alarm has fired and been acked.
For the above two parameters:
Fired = 0, Acked = 1: alarm is enabled, but not fired.
Fired = 0, Acked = 0: alarm has fired and been reset, but not acked.
Fired = 1, Acked = 0: alarm has fired but not reset nor acked.
Fired = 1, Acked = 1: alarm has fired and been acked, but not reset.