Condition
pub struct Condition
The alarm band, an optional warning band, and their temporal shaping.
Every limit is in the unit Limits describes: on a temperature,
the SDK's temperature unit, with the hysteresis a difference in it.
Condition — fields
compare: Compare
How the value is compared against the limits.
alarm: Limits
The alarm band.
warning: Option<Limits>
The pre-alarm band, if there is one.
Evaluated with the same compare, and an alarm always overrides
a warning.
on_delay: Duration
Consecutive qualifying frames before the state rises.
Zero reacts on the first frame, which on a noisy signal is how a single stray pixel rings an alarm.
Carried to the camera as whole milliseconds, rounded, and never
down to zero: any non-zero delay debounces at least one frame,
so only Duration::ZERO reacts on the first one.
off_delay: Duration
Consecutive non-qualifying frames before it falls.
Set independently of on_delay, so an alarm can be slow
to raise and quick to clear, or the reverse.
latching: bool
Stay active until acknowledged.
Acknowledging a condition that still holds does not silence it,
see crate::Camera::acknowledge_alarm.
Condition — methods
pub fn new() -> Self
The SDK's defaults, comparing above zero.
pub fn above(high: f32, hysteresis: f32) -> Self
Alarm when the signal rises above high.
hysteresis is how far it must fall back before the alarm
clears.
pub fn below(low: f32, hysteresis: f32) -> Self
Alarm when the signal falls below low.
pub fn outside(low: f32, high: f32, hysteresis: f32) -> Self
Alarm when the signal leaves the band low..=high.
pub fn with_warning(mut self, warning: Limits) -> Self
Add a warning band, evaluated with the same comparison.
pub fn with_on_delay(mut self, delay: Duration) -> Self
Require the condition to hold this long before rising.
The cheapest way to stop single-frame sensor noise ringing an alarm. A duration, not a frame count: the camera converts it from the frame interval it is actually producing, so a mode change re-derives it. A delay shorter than one frame interval debounces one frame, not zero.
pub fn with_off_delay(mut self, delay: Duration) -> Self
Require the condition to stop holding this long before falling.
pub fn latching(mut self, yes: bool) -> Self
Stay active until acknowledged.