pub struct Hysteresis { /* private fields */ }Expand description
The hysteresis state of one pressure signal.
Deliberately a concrete, inspectable struct rather than a closure or a counter hidden inside the engine: §11.3 calls for hysteresis as behaviour that can be tested, and the tests in this file are what guarantee the radar is stable.
Implementations§
Source§impl Hysteresis
impl Hysteresis
Sourcepub fn new(thresholds: &Thresholds) -> Self
pub fn new(thresholds: &Thresholds) -> Self
Builds tracker state from sanitized thresholds.
thresholds must already be Thresholds::sanitized; the engine does that
once at construction so every tracker inherits a window at least as wide as
the sample count it needs.
Sourcepub fn observe(
&mut self,
candidate: PressureState,
elapsed: Duration,
) -> MetricState<PressureState>
pub fn observe( &mut self, candidate: PressureState, elapsed: Duration, ) -> MetricState<PressureState>
Feeds one candidate state derived from the current sample.
elapsed is the measured interval since the previous sample (§8.1); it is
only used to accumulate Self::held_for, never to decide a state.
Returns MetricState::WarmingUp until sustained_samples observations
exist, because below that no sustained claim is possible (§11.3).
Sourcepub const fn held_for(&self) -> Option<Duration>
pub const fn held_for(&self) -> Option<Duration>
How long the current state has been held, once it means anything.
None while warming up: a duration for a state that has not been
established would be a fabricated number.
Sourcepub const fn state(&self) -> Option<PressureState>
pub const fn state(&self) -> Option<PressureState>
The state currently held, or None while warming up.
Sourcepub fn observations(&self) -> usize
pub fn observations(&self) -> usize
How many observations are retained.
Sourcepub fn remaining_samples(&self) -> usize
pub fn remaining_samples(&self) -> usize
How many observations are still needed before a state can be derived.
Trait Implementations§
Source§impl Clone for Hysteresis
impl Clone for Hysteresis
Source§fn clone(&self) -> Hysteresis
fn clone(&self) -> Hysteresis
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more