fix: stamp PlantParams with each logger's own elapsed, not Sud.elapsed
log_plant_params() stored whatever elapsed it was handed - always Sud.elapsed - regardless of which logger's own Samples.t timeline it needed to match. SudLogTask._elapsed() is Sud.elapsed, so its PlantParams lined up fine, but ServerLogTask._elapsed() is a separate tick counter since server startup - using Sud.elapsed there put PlantParams.t on a different scale than its own Samples.t entirely, causing utils/replay_sim.py to apply grain/water-mass changes at the wrong point when replaying a server-session log (spotted by comparing its output for log_latest.json vs log_latest_sud.json from the same session). Fixed by dropping the elapsed parameter - log_plant_params(params) now stamps with self._elapsed(), so each logger always uses its own correct timeline. Cascades into SudTask.set_on_plant_params()'s callback signature and its wiring in server/brewpi.py. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JFDeoTKBDkXRhPfnyDEoBt
This commit is contained in:
+8
-3
@@ -117,8 +117,13 @@ class SudTask(ATask):
|
||||
msg_handler.set_recv_handler(self.recv)
|
||||
|
||||
def set_on_plant_params(self, callback):
|
||||
"""Register a callback invoked whenever apply_plant_params() fires,
|
||||
so external observers (e.g. SudLogTask) can record each change."""
|
||||
"""Register a callback invoked with (params) whenever
|
||||
apply_plant_params() fires, so external observers (e.g.
|
||||
SudLogTask/ServerLogTask) can record each change. Deliberately
|
||||
doesn't pass elapsed - Sud.elapsed is meaningful for a SudLogTask
|
||||
(its own Samples' 't' timeline) but not a ServerLogTask (a
|
||||
separate timeline since server startup); each logger stamps its
|
||||
own _elapsed() itself (see ServerLogTask.log_plant_params())."""
|
||||
self._on_plant_params = callback
|
||||
|
||||
def set_on_reanchor(self, callback):
|
||||
@@ -148,7 +153,7 @@ class SudTask(ATask):
|
||||
self.pot.set_plant_params(params)
|
||||
self.tc.set_model_plant_params(params)
|
||||
if self._on_plant_params:
|
||||
self._on_plant_params(self.sud.elapsed, params)
|
||||
self._on_plant_params(params)
|
||||
|
||||
def apply_stirrer(self, phase):
|
||||
stirrer_cfg = phase.get('stirrer', {})
|
||||
|
||||
Reference in New Issue
Block a user