Expand description
Alarm lifecycle: latch on START, clear on STOP, acknowledge, and history.
§The trap this crate exists to close
Camera events come in pairs. Code=VideoMotion;action=Start is followed,
eventually, by action=Stop. Code that treats every event as “something
happened” latches every alarm on forever, and an operator faced with a
panel that is permanently red learns to ignore it — which is worse than
having no panel.
So AlarmRegistry models the pair explicitly:
START ────────────▶ Active ────── STOP ──────▶ Cleared
│
└── auto_clear elapsed ──▶ Cleared (timed out)A STOP is not guaranteed. The camera reboots mid-incident, the link
drops, a firmware bug swallows the edge. So every active alarm also carries
an auto-clear deadline, and an alarm that outlives it is cleared with
ClearReason::Timeout — recorded distinctly, because “the condition
ended” and “we stopped believing the condition” are different facts and an
operator needs to tell them apart.
§No background task
Expiry is evaluated lazily, when events arrive or the registry is read, against a clock the caller supplies. That is deliberate: the workspace budget allows no feature more than one task per camera, and the event link already spends it. A timer wheel here would spend a second.
§Safety
An alarm raised by camera analytics is an operator aid and is not
safety-rated. The absence of an alarm means nothing. See SAFETY.md at
the workspace root.
Structs§
- Alarm
- A latched condition on one camera.
- Alarm
Config - Tuning for
AlarmRegistry. - Alarm
Registry - Tracks which conditions are currently latched, and what happened before.
Enums§
- Alarm
Change - What changed as a result of feeding in an event.
- Clear
Reason - Why an alarm stopped being active.
Constants§
- DEFAULT_
AUTO_ CLEAR - How long an active alarm survives without a matching STOP.