Skip to main content

MrftEngine

Struct MrftEngine 

Source
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

Source

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.

Source

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.

Source

pub fn state(&self) -> MrftState

A snapshot of the fields a golden-master comparison checks per tick.

Source

pub fn is_complete(&self) -> bool

Whether the completion condition has been reached. Pure port of MRFTisComplete.

Trait Implementations§

Source§

impl Clone for MrftEngine

Source§

fn clone(&self) -> MrftEngine

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MrftEngine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.