Expand description
Tuning-constant math: turns a completed MRFT run’s peaks/troughs/switch-times into Kp/Ti/Td
for all three ResponseLevels, then into the PID parameters in whatever
representation/units a DCS/PLC template expects.
Pure port of TuningConstantsCalc (measure_oscillation + calculate_tuning_result)
and CalculatePIDparameters (calculate_pid_parameters), split the same way the legacy
app split them. Like core-mrft, this module does no I/O and reads no clock — every
timestamp it reasons about is already inside switch_times, taken from a completed
crate::mrft::Action::Complete.
Structs§
- Checked
Tuning Result - A checked result for one response level.
- OpcWrite
Values - The literal values to write back to the DCS/PLC for one
PidParameters— seeopc_write_values. Distinct fromPidParametersbecause integral/derivative may differ from the calculated values for controller types that don’t use one or both terms. - Oscillation
- Oscillation measurements derived from a completed MRFT run, before applying any
response-level-specific Kp multiplier. Pure port of the period/frequency/amplitude portion
of
TuningConstantsCalc. - PidParameters
- The final PID parameters in a DCS/PLC template’s own representation (e.g. proportional
band instead of gain, reset rate instead of reset time, seconds instead of minutes) — pure
port of
CalculatePIDparameters, applied to oneTuningResult. - Tuning
Math Compat - Legacy-bug replication flags for this module, mirroring
crate::mrft::MrftCompat’s pattern (seecore-bug-register). Every field defaults tofalse: the fixed, correct behavior. - Tuning
Result - Calculated Kp/Ti/Td for one
ResponseLevel, before DCS-specific unit conversion. Pure port of the Kp/Ti/Td portion ofTuningConstantsCalc.ti_minutes/td_minutesare identical across all three response levels for a given run — onlykpvaries — sinceC2/C3don’t vary by response level (seecrate::constants::lookup).
Enums§
- Tuning
Result Invalid Reason - Why a calculated response-level result was marked invalid.
- Tuning
Result Status - Whether a calculated response-level result contains values that are safe to use.
Functions§
- calculate_
all - The top-level entry point: computes the PID parameters for all three response levels from
a completed MRFT run, in one call. Composes
measure_oscillation(once) withcalculate_tuning_resultandcalculate_pid_parameters(once perResponseLevel). Pure port ofMRFTcompletionActions’s call intoTuningConstantsCalc+CalculatePIDparameters. - calculate_
all_ checked - Checked counterpart to
calculate_all. - calculate_
pid_ parameters - Converts a
TuningResultinto the PID parameters a specific DCS/PLC template expects. Pure port ofCalculatePIDparameters. - calculate_
tuning_ result - Applies one
ResponseLevel’s tuning constants to anOscillation, producing Kp/Ti/Td. Pure port of the per-response-level portion ofTuningConstantsCalc. - measure_
oscillation - 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, whichcalculate_tuning_resulthandles. - opc_
write_ values - The literal integral/derivative values to write back to the DCS/PLC for one
PidParameters, given the controller type the run was configured for. Pure port of the controller-type-conditional part ofWritePIDparametersToOPCtags— proportional is alwayspid.proportional, so this only exists to decide integral/derivative, whichControllerType::P/ControllerType::Pialgorithms don’t use: