Make Sud steps ramp based on the actual temperature gap, not a 'ramp' key
Previously, whether a schedule step ramped at all was decided purely by the presence of a 'ramp' key (components/sud.py's _advance()) - a hold-only step jumped straight into its hold countdown, assuming the plant was already at temperature. Now every step ramps toward 'temperature' first, for as long as the controller's own gap-tracking FSM (TempControllerBase, already distinguishing HEAT/COOL/HOLD) says the gap actually warrants it - via the new is_holding() (on APid and TempControllerBase), which replaces a separate, redundant TEMP_REACHED_TOLERANCE constant duplicated across tasks/sud.py, components/sud_forecast.py, and scripts/demos/sud/demo_sud.py. set_theta_soll() now recomputes the FSM eagerly so is_holding() can't read stale HOLD for a tick after a much-further-away target is pushed. components/sud.py's _build_step() always synthesizes a 'ramp' block from default.step.ramp (so 'rate' is always available), but leaves 'temperature' undefaulted - every real sude/*.json's default.step.temperature is inert template filler, and defaulting it would send hold-only steps chasing 0 degrees. SudTask/ SudForecastEstimator/the demo only push a new theta_soll/heatrate_soll when a step actually specifies its own temperature; otherwise the controller keeps whatever the previous step left running. Also fixes a related crash this surfaced: SudTask.remaining_schedule()'s synthetic mid-hold step dropped 'ramp' to signal "don't re-ramp" - now that every step always carries a 'ramp' dict, dropping it left 'rate' missing the moment the synthetic step was re-resolved by SudForecastEstimator. Drops 'temperature' instead, which is what actually signals "no new target" under the new model. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LhiQe64F74uHV8jzuoSa5K
This commit is contained in:
@@ -2,12 +2,6 @@ from components.plant import Pot
|
||||
from components.pid import PidFactory
|
||||
from components.sud import Sud, SudState
|
||||
|
||||
# Real schedules need real time to spin up each ramp and settle within this
|
||||
# tolerance before "reached" fires - matching tasks/sud.py's
|
||||
# TEMP_REACHED_TOLERANCE exactly is what makes this simulation's predicted
|
||||
# duration line up with the real run's.
|
||||
TEMP_REACHED_TOLERANCE = 0.2
|
||||
|
||||
# Safety cap so a schedule whose target a step can never actually reach
|
||||
# (e.g. a "hold" colder than ambient with no active cooling) can't hang the
|
||||
# simulation forever - the estimate is simply cut off there.
|
||||
@@ -65,10 +59,9 @@ class SudForecastEstimator:
|
||||
pot.set_thermal_params(params['M'], params['C'])
|
||||
if hasattr(tc, 'set_model_params'):
|
||||
tc.set_model_params(params['M'], params['C'])
|
||||
ramp = step.get('ramp')
|
||||
if sud.state == SudState.RAMPING and ramp is not None:
|
||||
if sud.state == SudState.RAMPING and step['temperature'] is not None:
|
||||
tc.set_theta_soll(step['temperature'])
|
||||
tc.set_heatrate_soll(ramp['rate'])
|
||||
tc.set_heatrate_soll(step['ramp']['rate'])
|
||||
sud.set_on_changed('step', on_step_changed)
|
||||
|
||||
t = [0.0]
|
||||
@@ -83,7 +76,7 @@ class SudForecastEstimator:
|
||||
pot.set_power(max(0, self.heater_max_power * tc.get_power()))
|
||||
|
||||
if sud.state == SudState.RAMPING:
|
||||
if abs(tc.get_theta_ist() - tc.get_theta_soll_set()) < TEMP_REACHED_TOLERANCE:
|
||||
if tc.is_holding():
|
||||
sud.temp_reached()
|
||||
elif sud.state == SudState.WAIT_USER:
|
||||
# A real user's confirm time isn't predictable - count it
|
||||
|
||||
Reference in New Issue
Block a user