Refactor sud JSON pot params under a nested 'pot' key
Top-level pot_mass/pot_material/L/Td/grain_mass/water_mass and their per-step overrides are now grouped under a 'pot' sub-object, matching the structure already applied to sud_0010.json's parent level. Updated all sude/*.json files and the parsing/consuming code in components/sud.py, tasks/sud.py, components/sud_forecast.py, and scripts/demos/sud/demo_sud.py. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T52JH848ojhXXHn1bAzdC3
This commit is contained in:
+26
-22
@@ -47,8 +47,9 @@ def _build_step(number, defaults, raw_step):
|
||||
its own, so it's left None, telling SudTask not to push a new
|
||||
theta_soll and just keep whatever the previous step left running."""
|
||||
step = {'number': number}
|
||||
for key in ('descr', 'user_message', 'user_wait_for_continue', 'grain_mass', 'water_mass'):
|
||||
for key in ('descr', 'user_message', 'user_wait_for_continue'):
|
||||
step[key] = raw_step.get(key, defaults.get(key))
|
||||
step['pot'] = _merge_defaults(defaults.get('pot', {}), raw_step.get('pot', {}))
|
||||
step['temperature'] = raw_step.get('temperature')
|
||||
step['ramp'] = _merge_defaults(defaults.get('ramp', {}), raw_step.get('ramp', {}))
|
||||
if 'hold' in raw_step:
|
||||
@@ -59,21 +60,23 @@ def _build_step(number, defaults, raw_step):
|
||||
EMPTY_SUD = {
|
||||
'Name': '',
|
||||
'Description': '',
|
||||
'pot_mass': 0,
|
||||
'pot_material': None,
|
||||
# Pot energy loss coefficient [W/(kg*K)] and transport propagation
|
||||
# delay [s] - see derive_plant_params(). Defaults match the generic
|
||||
# values brewpi.py used to hardcode for every brew alike.
|
||||
'L': 0.2,
|
||||
'Td': 30,
|
||||
# Initial grain_mass/water_mass - what's actually in the pot before
|
||||
# the brew starts (e.g. water added but no malt yet), as opposed to
|
||||
# default.step's grain_mass/water_mass, which is just inert template
|
||||
# filler for steps that don't override it. Lets a caller derive
|
||||
# starting plant params directly (see SudTask.recv()'s Load handler)
|
||||
# without having to parse the first step out of the schedule.
|
||||
'grain_mass': 0,
|
||||
'water_mass': 0,
|
||||
'pot': {
|
||||
'mass': 0,
|
||||
'material': None,
|
||||
# Pot energy loss coefficient [W/(kg*K)] and transport propagation
|
||||
# delay [s] - see derive_plant_params(). Defaults match the generic
|
||||
# values brewpi.py used to hardcode for every brew alike.
|
||||
'L': 0.2,
|
||||
'Td': 30,
|
||||
# Initial grain_mass/water_mass - what's actually in the pot before
|
||||
# the brew starts (e.g. water added but no malt yet), as opposed to
|
||||
# default.step's pot.grain_mass/pot.water_mass, which is just inert
|
||||
# template filler for steps that don't override it. Lets a caller
|
||||
# derive starting plant params directly (see SudTask.recv()'s Load
|
||||
# handler) without having to parse the first step out of the schedule.
|
||||
'grain_mass': 0,
|
||||
'water_mass': 0,
|
||||
},
|
||||
'steps': [],
|
||||
}
|
||||
|
||||
@@ -107,12 +110,13 @@ class Sud(AttributeChange):
|
||||
step_defaults = data.get('default', {}).get('step', {})
|
||||
schedule = [_build_step(i + 1, step_defaults, raw) for i, raw in enumerate(data['steps'])]
|
||||
|
||||
pot_mass = data.get('pot_mass', 0)
|
||||
pot_material = data.get('pot_material')
|
||||
L = data.get('L', EMPTY_SUD['L'])
|
||||
Td = data.get('Td', EMPTY_SUD['Td'])
|
||||
grain_mass = data.get('grain_mass', EMPTY_SUD['grain_mass'])
|
||||
water_mass = data.get('water_mass', EMPTY_SUD['water_mass'])
|
||||
pot_data = data.get('pot', {})
|
||||
pot_mass = pot_data.get('mass', 0)
|
||||
pot_material = pot_data.get('material')
|
||||
L = pot_data.get('L', EMPTY_SUD['pot']['L'])
|
||||
Td = pot_data.get('Td', EMPTY_SUD['pot']['Td'])
|
||||
grain_mass = pot_data.get('grain_mass', EMPTY_SUD['pot']['grain_mass'])
|
||||
water_mass = pot_data.get('water_mass', EMPTY_SUD['pot']['water_mass'])
|
||||
|
||||
return name, description, schedule, pot_mass, pot_material, L, Td, grain_mass, water_mass
|
||||
|
||||
|
||||
@@ -156,7 +156,8 @@ class SudForecastEstimator:
|
||||
# re-assigns self.step to retrigger it) - only the *first* call
|
||||
# for a given index is its actual start.
|
||||
step_starts.setdefault(sud.index, t[-1])
|
||||
params = sud.derive_plant_params(step.get('grain_mass', 0), step.get('water_mass', 0))
|
||||
pot = step.get('pot', {})
|
||||
params = sud.derive_plant_params(pot.get('grain_mass', 0), pot.get('water_mass', 0))
|
||||
pot.set_plant_params(params)
|
||||
tc.set_model_plant_params(params)
|
||||
if sud.state == SudState.RAMPING and step['temperature'] is not None:
|
||||
|
||||
Reference in New Issue
Block a user