Print each Sud step's number and description in the demo
Makes it easier to follow which schedule step is currently active when watching the demo run. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CgR9tPaSzFkAwRAUyeaaCD
This commit is contained in:
+3
-3
@@ -32,11 +32,11 @@ def _merge_defaults(default, override):
|
|||||||
return merged
|
return merged
|
||||||
|
|
||||||
|
|
||||||
def _build_step(defaults, raw_step):
|
def _build_step(number, defaults, raw_step):
|
||||||
"""Fills in a schedule step with default.step's values. A step is a
|
"""Fills in a schedule step with default.step's values. A step is a
|
||||||
ramp or a hold depending on which of those keys it specifies; the other
|
ramp or a hold depending on which of those keys it specifies; the other
|
||||||
is left out rather than synthesized from defaults."""
|
is left out rather than synthesized from defaults."""
|
||||||
step = {}
|
step = {'number': number}
|
||||||
for key in ('descr', 'user_message', 'user_wait_for_continue'):
|
for key in ('descr', 'user_message', 'user_wait_for_continue'):
|
||||||
step[key] = raw_step.get(key, defaults.get(key))
|
step[key] = raw_step.get(key, defaults.get(key))
|
||||||
for key in ('ramp', 'hold'):
|
for key in ('ramp', 'hold'):
|
||||||
@@ -55,7 +55,7 @@ class Sud(AttributeChange):
|
|||||||
self.description = data.get('Description', '')
|
self.description = data.get('Description', '')
|
||||||
|
|
||||||
step_defaults = data.get('default', {}).get('step', {})
|
step_defaults = data.get('default', {}).get('step', {})
|
||||||
self.schedule = [_build_step(step_defaults, raw) for raw in data['steps']]
|
self.schedule = [_build_step(i + 1, step_defaults, raw) for i, raw in enumerate(data['steps'])]
|
||||||
|
|
||||||
self.pot_mass = data.get('pot_mass', 0)
|
self.pot_mass = data.get('pot_mass', 0)
|
||||||
self.pot_material = data.get('pot_material')
|
self.pot_material = data.get('pot_material')
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
def on_step_changed(step):
|
def on_step_changed(step):
|
||||||
if step is not None:
|
if step is not None:
|
||||||
|
print(f"Step {step['number']}: {step['descr']}")
|
||||||
if 'ramp' in step:
|
if 'ramp' in step:
|
||||||
ctrl.set_theta_soll(step['ramp']['temp'])
|
ctrl.set_theta_soll(step['ramp']['temp'])
|
||||||
ctrl.set_heatrate_soll(step['ramp']['rate'])
|
ctrl.set_heatrate_soll(step['ramp']['rate'])
|
||||||
|
|||||||
Reference in New Issue
Block a user