Alarm Server Context Variables
When working with alarm types in expressions, fields, or values, in addition to any inputs you define, you can use context variables to enhance the logic of your alarm. The variables can be used in condition rules and in field expressions (Message Text, Severity, custom fields). Type settings and adjustable-input validation do not accept them.
Context Variables Description and Use
The following context variables are available for alarms:
|
Variable Name |
Description |
Details |
|---|---|---|
|
@AlarmStateFlags |
An integer that carries the alarm’s current state as a bit mask. It is the sum of the values of every flag that applies at the moment the expression is evaluated.
|
A single state is tested with the bitwise & operator. For example, It is a sum, so you must test bits, not compare the entire value. It is only as fresh as the last evaluation. In a field, it is as of the last field rebuild, unless the alarm type enables Refresh Fields on State Change or Refresh Fields on Every Evaluation. |
|
@RealarmCount |
An integer that counts how many times the alarm has re-alarmed since it became active. A re-alarm re-raises an acknowledged alarm that is still active, which means that the alarm state goes from In Alarm/Acknowledged back to Unacknowledged if the condition does not return to Normal within the defined period. |
The period for the alarm to return to normal after being acknowledged is defined in the ReAlarm delay setting. Without that setting, the variable is permanently 0, so it is only useful in alarm types that use that delay. |
|
@CurrentActiveDuration |
The time elapsed between the alarm's Active Time (the timestamp displayed by alarm viewers) and the moment of evaluation. The value follows the alarm type's Active Time Behavior setting because it is calculated from the Active Time determined by that setting. |
The value is 0 while the alarm has no Active Time; |
|
@PreviousConditionCode |
The immediately preceding condition on a limit alarm with HI and LO conditions. |
When the alarm state returns to the normal condition, this variable allows to determine which alarm condition has ended: after HI to Normal the variable equals the HI condition code, after LO to Normal it equals the LO condition code. |
|
@PreviousSeverity |
The last reported severity of the limit that triggered the alarm (HI or LO). |
After HI to Normal, the Normal condition sees the last reported HI severity, such as 700 when the HI Severity is 700, and 300 after a LO to Normal with LO Severity 300. A Normal condition with the severity expression |
Values Refresh
In a condition rule, variable values reflect the state at the time of each trigger evaluation. Rules are evaluated only when a trigger occurs. Actions such as acknowledging, shelving, or re-alarming an alarm can change its state without causing the rule to be evaluated. Any resulting state changes become visible to the rule at the next trigger evaluation.
In a field expression, variable values reflect the state at the most recent field rebuild. Fields are rebuilt when the condition or subcondition changes, including when the alarm returns to normal, when an acknowledged alarm is re-alarmed, or when shelving, an out-of-service period, or a latch ends. Acknowledging an alarm, a trigger that produces the same condition, and the passage of time do not cause fields to be rebuilt.
Restart and Redundancy
The previous condition, previous severity, and Active Time are preserved across an Alarm Server restart when state storage is enabled. For example, if an HI alarm becomes active, the server is restarted, and the alarm later returns to normal, the Normal condition fields report HI as the previous condition, HI's severity as the previous severity, and the full active duration, including the server downtime.
The same behavior applies after a failover in a redundant pair when both servers are running this release.
If one server in the redundant pair is running an earlier release, state synchronization continues to operate as in previous versions. After a failover from the older server, @PreviousConditionCode and @PreviousSeverity return 0 until the alarm source undergoes its next condition change. The active duration is preserved and remains unaffected.