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.
Available alarm state flags:

  • In Alarm (1)
  • Reporting Alarm (2)
  • Unacknowledged (4)
  • Disabled (8)
  • Shelved (16)
  • Out Of Service (32)
  • Suppressed By Design (64)
  • Requires Acknowledge (256)
  • Audible Alarm (512)

A single state is tested with the bitwise & operator. For example, ({{@AlarmStateFlags}} & 4) == 4 is true while the alarm is unacknowledged. The common use is an escalation rule, such as “unacknowledged for 30 minutes goes to HIHI”, which combines this test with @CurrentActiveDuration in a condition rule.

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.
It can be used to raise the severity if the alarm re-alarms a certain number of times without resolution.

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.
Writer's note: Add link to the topic that documents this setting.

@CurrentActiveDuration

The time elapsed between the alarm's Active Time (the timestamp displayed by alarm viewers) and the moment of evaluation.
It can be used to elevate the severity of an alarm that has been active for a long time with no response.

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; totalseconds, totalminutes, and totalhours convert it to a number.
In a condition rule that uses a periodic time trigger, this value functions as a continuously running timer. For example, in the HI rule:
<p>IF {{Value}} <= {{HiLimit}} THEN 0</p> <p>ELSE IF ({{@AlarmStateFlags}} & 4) == 4 &&</p> <p>totalminutes({{@CurrentActiveDuration}}) >= 30</p> <p>THEN 2</p> <p>ELSE 1</p>
where 2 represents the HIHI alarm state. An unacknowledged HI alarm escalates to HIHI at the first trigger evaluation that occurs after it has been active for 30 minutes. The alarm transitions to the HIHI severity without requiring re-acknowledgement or reactivation. If the alarm is acknowledged before the 30-minute threshold is reached, it remains in the HI state.
In the Normal condition fields, after the alarm returns to normal, this value represents the total time the alarm remained active.

@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.
After Normal to HI the value equals 0 (Normal). After an escalation from LO to LOLO it equals the LO code. For a source that has not left any condition yet, it reads 0.

@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 {{@PreviousSeverity}} produces return-to-normal events carrying the ended alarm's severity.
It reads 0 if there is no previous condition, or the previous condition has never reported fields.

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.