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:
@@ -7,9 +7,6 @@ from components.plant.pot import Pot
|
||||
from components.actor.stirrersim import StirrerSim
|
||||
from components.actor.heater_sim import HeaterSim
|
||||
|
||||
# Mirrors tasks/sud.py's SudTask, but driven synchronously for a demo run.
|
||||
TEMP_REACHED_TOLERANCE = 0.2
|
||||
|
||||
# A real user would click "Confirm" in the GUI; auto-confirm after this many
|
||||
# simulated seconds so the demo can run to completion unattended.
|
||||
WAIT_USER_AUTO_CONFIRM_S = 30.0
|
||||
@@ -85,11 +82,11 @@ if __name__ == '__main__':
|
||||
# sud.state tells us which phase is currently active.
|
||||
if step is not None:
|
||||
ramping = sud.state == SudState.RAMPING
|
||||
phase = step['ramp'] if ramping and 'ramp' in step else step.get('hold', {})
|
||||
phase = step['ramp'] if ramping else step.get('hold', {})
|
||||
|
||||
print(f"Step {step['number']}: {step['descr']}")
|
||||
apply_plant_params(step)
|
||||
if ramping and 'ramp' in step:
|
||||
if ramping and step['temperature'] is not None:
|
||||
ctrl.set_theta_soll(step['temperature'])
|
||||
ctrl.set_heatrate_soll(step['ramp']['rate'])
|
||||
apply_stirrer(phase)
|
||||
@@ -138,7 +135,7 @@ if __name__ == '__main__':
|
||||
stirrer.process()
|
||||
|
||||
if sud.state == SudState.RAMPING:
|
||||
if abs(ctrl.get_theta_ist() - ctrl.get_theta_soll_set()) < TEMP_REACHED_TOLERANCE:
|
||||
if ctrl.is_holding():
|
||||
sud.temp_reached()
|
||||
|
||||
if sud.state == SudState.WAIT_USER:
|
||||
|
||||
Reference in New Issue
Block a user