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§
- Initial
Readings - Initial readings the engine needs at construction time, taken once before the relay test
starts (
ReadInitialOPCvaluesin the legacy app). - Mrft
Compat - Legacy-bug replication flags, for bug-for-bug replay validation against captured legacy
traces (see
core-bug-register). Every field defaults tofalse: the fixed, correct behavior. Set a fieldtrueonly to intentionally reproduce that specific legacy defect, e.g. when asserting parity against a captured trace that has the bug baked in. - Mrft
Engine - The MRFT relay-feedback state machine. Construct with
MrftEngine::new, then callMrftEngine::steponce per PV sample. - Mrft
State - 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::stepcall.
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 ofCheckMVboundaries.