The alm object turns raw conditions into managed alarms: each fault has a
group, a title, a priority, a trigger delay (the condition must hold this long
before the alarm activates) and an optional automatic-clear behaviour. State
changes are automatically recorded in the event log, including the fault's
attached value.
Priority constants β used by alm.e() and the extended form of log():
Constant
Meaning
alm.ok
Normal / no alarm
alm.info
Informational
alm.warn
Warning
alm.crit
Critical
Custom numeric priorities (0β255) can be used as well.
Typical pattern β set the group, evaluate each condition every loop, then
read the aggregate state:
while(run()){
alm.g("UV"); // current alarm group
alm.e(alm.crit, "Reactor A Run Failure", pressure > limit, 5, true, 0, pressure);
let worst = alm.max(); // highest active priority overall
waitMS(1000);
}
See the Alarm Conditions example for a complete script including resets and
acknowledgement.
Functions
alm.g() β Sets the current alarm group; subsequent alm.e() evaluations register under it.
alm.e() β Evaluates an alarm condition with trigger/clear delays; returns the alarmβs current priority, or 0 when not alarming.
alm.v() β Returns the highest-priority active alarm within the given group(s).
alm.fV() β Returns the value of one specific fault.
alm.list() β Returns the status of every registered alarm, organised by group.
alm.max() β Returns the highest active alarm priority across all groups.
alm.rst() β Resets all faults, or one specific fault.
alm.ack() β Acknowledges all faults, or one specific fault; pass false to cancel an acknowledgement.
Sets the current alarm group; subsequent alm.e() evaluations register under it.
Alarms are organised into named groups (e.g. one per machine or subsystem).
Call alm.g() before evaluating conditions to select which group the
following alm.e() calls belong to.
Arguments
Name
Type
Required
Default
Description
group
string
yes
β
Group name, e.g. "UV".
Example
alm.g("UV"); // conditions evaluated next belong to the "UV" group
alm.e(priority, title, condition, triggerDelay, clearable, clearDelay, [value]) β number
Evaluates an alarm condition with trigger/clear delays; returns the alarmβs current priority, or 0 when not alarming.
Registers and evaluates one fault under the current group (alm.g()). Call it
every loop iteration with the live condition β alm.e() handles the
debouncing, state tracking and event-log records for you:
The condition must stay true for triggerDelay seconds before the alarm
activates.
If clearable is true, the alarm clears automatically once the condition
has been false for clearDelay seconds; otherwise it stays latched until
reset with alm.rst().
The optional value (e.g. a reservoir level or pressure) is included in the
log messages automatically recorded when the fault changes state.
Returns the alarm's current priority while active, or 0 when not alarming.
Arguments
Name
Type
Required
Default
Description
priority
number | alm constant
yes
β
Alarm priority β alm.ok/alm.info/alm.warn/alm.crit or 0β255.
title
string
yes
β
Alarm title, unique within the group.
condition
boolean
yes
β
The live fault condition, evaluated every call.
triggerDelay
number (s)
yes
β
Condition must be true this many seconds before the alarm activates.
clearable
boolean
yes
β
Whether the alarm may clear automatically when the condition recovers.
clearDelay
number (s)
yes
β
Condition must be false (and the alarm clearable) this many seconds before it auto-clears.
value
number
optional
β
Current value attached to the fault (e.g. level, pressure) β recorded in state-change log entries.
Returns
number
Current priority of the alarm while active, 0 when not alarming.
Example
let startTime = now();
while(run()){
alm.g("UV"); // current alarm group
let value = alm.e(
alm.crit, // priority
"Reactor A Run Failure", // title
startTime.sAgo() > 5 && startTime.sAgo() < 12, // condition
5, // trigger delay (s)
true, // automatically clearable?
0, // clearing delay (s)
startTime // optional attached value, logged on state changes
);
print("Run Time:", startTime.sAgo(), " Fault Value:", value);
waitMS(1000);
}
Returns the highest-priority active alarm within the given group(s).
If multiple faults exist in a group, returns the priority of the highest
active one. Additional groups can be passed as extra arguments to aggregate
across them.
Arguments
Name
Type
Required
Default
Description
groupβ¦
string
yes
β
One or more group names.
Returns
number
Highest active priority in the group(s), 0 if none alarming.
With no arguments, resets every registered fault. Pass a group and title to
reset a single fault (e.g. a latched, non-clearable alarm after the cause has
been fixed).
Arguments
Name
Type
Required
Default
Description
group
string
optional
β
Group of the fault to reset. Omit to reset everything.
title
string
optional
β
Title of the fault to reset.
Example
alm.rst(); // reset all faults
alm.rst("UV", "Reactor A Run Failure"); // reset one fault
Acknowledges all faults, or one specific fault; pass false to cancel an acknowledgement.
With no arguments, acknowledges every fault. Pass a group and title to
acknowledge a single fault. An optional false appended as the last argument
cancels the acknowledgement.
Arguments
Name
Type
Required
Default
Description
group
string
optional
β
Group of the fault. Omit to acknowledge everything.
title
string
optional
β
Title of the fault.
cancel
boolean
optional
true
Pass false to cancel the acknowledgement.
Example
alm.ack(); // acknowledge all faults
alm.ack("UV", "Reactor A Run Failure"); // acknowledge one fault
alm.ack("UV", "Reactor A Run Failure", false); // cancel the acknowledgement