Apply a loaded Sud's plant params immediately, not just once a run starts
on_step_changed() only re-applies plant params (pot mass/material, L, Td, grain/water mass) once Sud.step actually changes to a real step - which doesn't happen on Load (Sud.load() resets step to None), so the controller kept using whatever the previously loaded Sud (or the generic startup baseline) had until Start. SudTask.recv()'s Load handler now calls apply_plant_params() against the new schedule's first step right away, so the controller already matches the expected plant the moment a Sud is loaded. Also replaces server/brewpi.py's hardcoded DEFAULT_PLANT_PARAMS with a baseline derived from Sud's own (still-unloaded) generic defaults (EMPTY_SUD's pot_mass/L/Td), used only for the brief startup window before any real Sud is ever loaded - numerically identical to the old constant. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DkkuG48uHFCGKe6dPSERFk
This commit is contained in:
+13
-1
@@ -61,7 +61,10 @@ class SudTask(ATask):
|
||||
from it (constant for the whole brew), while M/C also fold in the
|
||||
step's grain_mass/water_mass, which vary over the brew's course
|
||||
(malt going in, water boiling off) - mirrors demo_sud.py's
|
||||
apply_plant_params()."""
|
||||
apply_plant_params(). Called both on every real step transition
|
||||
(via on_step_changed()) and once immediately on Load (see recv()),
|
||||
so the controller's behavior already matches the expected plant
|
||||
as soon as a Sud is loaded, not just once a run actually starts."""
|
||||
params = self.sud.derive_plant_params(step.get('grain_mass', 0), step.get('water_mass', 0))
|
||||
self.pot.set_plant_params(params)
|
||||
if hasattr(self.tc, 'set_model_plant_params'):
|
||||
@@ -258,6 +261,15 @@ class SudTask(ATask):
|
||||
if self.sud.load(pair[1]):
|
||||
await self.send({'Name': self.sud.name, 'Description': self.sud.description})
|
||||
await self.send({'Json': pair[1]})
|
||||
# on_step_changed() only re-applies plant params once a
|
||||
# real step starts (Start) - apply them right away too,
|
||||
# so the controller already matches this Sud's own pot/
|
||||
# L/Td (and its first step's expected grain/water mass)
|
||||
# from the moment it's loaded, rather than whatever the
|
||||
# previously loaded Sud (or the generic startup
|
||||
# baseline - see server/brewpi.py) left behind.
|
||||
if self.sud.schedule:
|
||||
self.apply_plant_params(self.sud.schedule[0])
|
||||
await self.send_forecast(pair[1])
|
||||
else:
|
||||
# Sud.load() refuses while a run is in progress (state
|
||||
|
||||
Reference in New Issue
Block a user