pub fn measure_oscillation(
peaks: &[f32],
troughs: &[f32],
switch_times: &[DateTime<Utc>],
mv_sign_init: i8,
direction: ControllerDirection,
config: LoopConfig,
pv_range: PvRange,
compat: TuningMathCompat,
) -> OscillationExpand description
Computes oscillation measurements (period, frequency, PV amplitude) from a completed MRFT
run’s recorded peaks/troughs/switch-times. Pure port of TuningConstantsCalc’s
period/frequency/amplitude math — everything before the per-response-level Kp/Ti/Td split,
which calculate_tuning_result handles.
peaks/troughs/switch_times/mv_sign_init come directly from a completed
crate::mrft::Action::Complete; direction and config.num_cycles_count must be the
same values the crate::mrft::MrftEngine that produced them was built with.
§Panics
Panics if switch_times has fewer than 2 entries, or if peaks/troughs don’t have the
lengths a real Action::Complete for config.num_cycles_count cycles always has (one of
them num_cycles_count, the other num_cycles_count + 1, alternating from the first
recorded switch’s direction). Both are impossible outputs from crate::mrft::MrftEngine
and indicate a caller bug, not a runtime data problem.