pub struct MrftEngine { /* private fields */ }Expand description
The MRFT relay-feedback state machine. Construct with MrftEngine::new, then call
MrftEngine::step once per PV sample.
Deliberately has no knowledge of --mrftDelayTime pre/post padding: the caller decides
when to start calling step() at all, rather than the engine accepting an internal
“delay active” no-op flag. That keeps this type’s only job “given a PV sample, decide
whether to switch” — nothing else.
Implementations§
Source§impl MrftEngine
impl MrftEngine
Sourcepub fn new(
config: LoopConfig,
direction: ControllerDirection,
beta: f32,
initial: InitialReadings,
start_time: DateTime<Utc>,
compat: MrftCompat,
) -> MrftEngine
pub fn new( config: LoopConfig, direction: ControllerDirection, beta: f32, initial: InitialReadings, start_time: DateTime<Utc>, compat: MrftCompat, ) -> MrftEngine
Builds a new engine and performs the one-time setup MRFTstart does before the
relay-switching loop begins: resolves the action multiplier from direction, clamps
the relay amplitude to the MV range, and seeds the peak/trough trackers from the
initial PV reading.
start_time seeds time_previous_switch (TimePreviousSwitch = DateTime.Now in the
legacy MRFTinitializeVariables) — pass the timestamp of the first Tick that will
be given to step, or whatever timestamp the caller considers “test start”.
beta is the hysteresis multiplier for this (process type, controller type)
combination — see crate::constants::lookup. It is response-level-invariant, so
any crate::constants::ResponseLevel passed to lookup yields the same beta.
Sourcepub fn step(&mut self, tick: Tick) -> Vec<Action>
pub fn step(&mut self, tick: Tick) -> Vec<Action>
Feeds one PV sample through the engine. Returns the actions the caller must perform:
zero or one Action::WriteMv (mirrors MRFTswitchIsNeeded + MRFTperformSwitch),
followed by Action::Complete at most once, on the tick that satisfies the
completion condition.
Calling step again after Complete has been returned is a no-op that returns an
empty Vec — the engine has nothing left to do.
Sourcepub fn state(&self) -> MrftState
pub fn state(&self) -> MrftState
A snapshot of the fields a golden-master comparison checks per tick.
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Whether the completion condition has been reached. Pure port of MRFTisComplete.
Trait Implementations§
Source§impl Clone for MrftEngine
impl Clone for MrftEngine
Source§fn clone(&self) -> MrftEngine
fn clone(&self) -> MrftEngine
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more