Skip to main content

Module mrft

Module mrft 

Source
Expand description

The MRFT (Modified Relay Feedback Test) engine: the pure, I/O-free relay-switching state machine at the heart of bhtune. See AGENTS.md’s “Key architectural decisions” for why this must never read a clock, perform network I/O, or touch a UI.

Scope is deliberately narrow: this module decides when to switch the MV and when the test is complete. It does not read or write OPC tags (bhtune-driver’s job) and it does not calculate PID constants from the collected peaks/troughs (core-tuning-math’s job) — it only hands them off via Action::Complete.

Structs§

InitialReadings
Initial readings the engine needs at construction time, taken once before the relay test starts (ReadInitialOPCvalues in the legacy app).
MrftCompat
Legacy-bug replication flags, for bug-for-bug replay validation against captured legacy traces (see core-bug-register). Every field defaults to false: the fixed, correct behavior. Set a field true only to intentionally reproduce that specific legacy defect, e.g. when asserting parity against a captured trace that has the bug baked in.
MrftEngine
The MRFT relay-feedback state machine. Construct with MrftEngine::new, then call MrftEngine::step once per PV sample.
MrftState
A snapshot of the engine’s observable state after a step() call — the fields a golden-master trace comparison checks against the legacy CSV log’s per-tick columns (Hysteresis, MvValueCurrent, MvSignNextStep, CounterAllSwitches).
Tick
One PV sample fed into the engine. The engine has no clock of its own — every timestamp it ever reasons about arrives through a Tick.

Enums§

Action
A side effect the caller must perform in response to a MrftEngine::step call.

Functions§

clamp_relay_amplitude
Computes the raw engineering-unit relay amplitude from a percentage of the MV range, and clamps it so neither relay step would drive the MV outside [mv_range_low, mv_range_high]. Pure port of CheckMVboundaries.