Adapt Sud/SudTask/demo to the new flat heat/hold schedule schema

sude/sud_0010.json moved from a list of combined ramp+hold+wait
"Rasten" with global stirrer constants to a flat "schedule" list of
explicit {"type": "heat"|"hold", ...} steps, each carrying its own
stirrer_speed/stirrer_time_on/stirrer_time_off and an optional
user_wait_for_continue (+ user_message).

- components/sud.py: Sud now tracks the current `step` instead of
  `rast`; "heat" steps enter RAMPING (advanced externally via
  temp_reached()), "hold" steps enter HOLDING and count down
  `duration` minutes (0 if omitted). Either step type can pause in
  WAIT_USER via user_wait_for_continue, surfaced through the new
  user_message attribute.
- tasks/sud.py: SudTask only pushes theta_soll/heatrate_soll on
  "heat" steps, converts each step's stirrer_time_on/off into a
  duty_cycle/cycle_time on every step change (replacing the old
  state-based RAMPING/HOLDING stirrer switching), and broadcasts
  user_message changes. Stirring is now fully schedule-driven instead
  of implicitly stopped on WAIT_USER/DONE (DONE still stops it, since
  there's no step left to read settings from).
- scripts/demos/sud/demo_sud.py: mirrors the same step-driven wiring.
- README's Mash schedules section rewritten for the new schema.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-19 19:09:43 +02:00
co-authored by Claude Sonnet 4.6
parent 2845051350
commit b33f89a569
5 changed files with 176 additions and 96 deletions
+27 -17
View File
@@ -52,24 +52,34 @@ if __name__ == '__main__':
heater.set_on_changed('power_set', ctrl.set_model_power)
heater.set_on_changed('power_eff', plant.set_power)
def on_rast_changed(rast):
if rast is not None:
ctrl.set_theta_soll(rast['temp'])
ctrl.set_heatrate_soll(rast['heatRate'])
def apply_stirrer(step):
speed = step.get('stirrer_speed', 0)
on = step.get('stirrer_time_on', 0)
off = step.get('stirrer_time_off', 0)
cycle = on + off
if cycle > 0:
duty = on / cycle
else:
cycle = 1.0
duty = 1.0 if speed > 0 else 0.0
stirrer.set_cycle_time(cycle)
stirrer.set_duty_cycle(duty)
stirrer.set_speed(speed)
def on_step_changed(step):
if step is not None:
if step['type'] == 'heat':
ctrl.set_theta_soll(step['temp'])
ctrl.set_heatrate_soll(step['rate'])
apply_stirrer(step)
def on_state_changed(state):
if state == SudState.RAMPING:
stirrer.set_duty_cycle(1.0)
stirrer.set_speed(sud.stirr_speed_heat)
elif state == SudState.HOLDING:
stirrer.set_cycle_time(sud.stirr_cycle_time)
stirrer.set_duty_cycle(sud.stirr_duty_rast)
stirrer.set_speed(sud.stirr_speed_rast)
elif state in (SudState.WAIT_USER, SudState.DONE):
if state == SudState.DONE:
stirrer.set_duty_cycle(1.0)
stirrer.set_speed(0)
sud.set_on_changed('rast', on_rast_changed)
sud.set_on_changed('step', on_step_changed)
sud.set_on_changed('state', on_state_changed)
sud.start()
@@ -80,7 +90,7 @@ if __name__ == '__main__':
_heatrate_ist = []
_heatrate_soll = []
_sud_state = []
_rast_index = []
_step_index = []
_stirrer_speed = []
_stirrer_duty = []
_heater_power_set = []
@@ -121,7 +131,7 @@ if __name__ == '__main__':
_heatrate_ist.append(ctrl.get_heatrate_ist())
_heatrate_soll.append(ctrl.get_heatrate_soll())
_sud_state.append(sud.state.value)
_rast_index.append(sud.index)
_step_index.append(sud.index)
_stirrer_speed.append(stirrer.speed * stirrer.isOn)
_stirrer_duty.append(stirrer.dutyCycle * 100)
_heater_power_set.append(heater.power_set)
@@ -157,8 +167,8 @@ if __name__ == '__main__':
legend(["Sud state"])
grid(True)
subplot(3, 1, 2)
step(_t_min, _rast_index, where='post', color='k')
legend(["Rast index"])
step(_t_min, _step_index, where='post', color='k')
legend(["Step index"])
grid(True)
subplot(3, 1, 3)
plot(_t_min, _stirrer_speed, '-g', _t_min, _stirrer_duty, '-c', linewidth=1)