alm.e()

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

NameTypeRequiredDefaultDescription
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);
}