fix: embed dt and startup plant params in server log; open-loop replay_sim
server/brewpi.py: pass physics DT to ServerLogTask (not wall-clock DT_TASK) so logs carry the correct integration timestep; log startup plant params as the first PlantParams event so replay_sim can reconstruct them even when no Sud is ever loaded (previously fell back to hardcoded defaults, causing ~3°C temperature offset in replay). tasks/server_log.py: accept and embed dt in log JSON; switch log_plant_params() to wall-clock monotonic time (same base as sample t), since the elapsed argument was simulated time and not comparable. utils/replay_sim.py: switch to open-loop replay (plant driven by logged power_eff, not sim controller output); use PidFactory so Smith vs Normal controller type is honoured; set Td=0 in replay plant for Smith mode (logged temp_ist is already Smith-corrected); feed Smith predictor's internal model with real power; apply embedded PlantParams mid-run; prefer embedded dt over sample-based fallback; clamp sim power ≥ 0; replace meaningless sim-power trace in power subplot with power_set vs power_eff from the log. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+4
-1
@@ -110,6 +110,7 @@ if __name__ == '__main__':
|
||||
# the kettle at startup (e.g. strike water pre-filled). A loaded sud's
|
||||
# own apply_plant_params() will override this on the first step.
|
||||
startup_water = config.get('Pot', {}).get('water_mass', 0)
|
||||
startup_params = None
|
||||
if startup_water > 0:
|
||||
startup_params = sud.derive_plant_params(0, startup_water)
|
||||
pot.set_plant_params(startup_params)
|
||||
@@ -131,8 +132,10 @@ if __name__ == '__main__':
|
||||
|
||||
# Continuous server-session log - records from startup to shutdown
|
||||
# regardless of Sud state; written to logs/log_{date_time}.json on exit.
|
||||
server_log_task = ServerLogTask(tc, heater, heater_task, DT_TASK, args.logdir, config=config)
|
||||
server_log_task = ServerLogTask(tc, heater, heater_task, DT_TASK, args.logdir, config=config, dt=DT)
|
||||
sud_task.set_on_plant_params(server_log_task.log_plant_params)
|
||||
if startup_params is not None:
|
||||
server_log_task.log_plant_params(0, startup_params)
|
||||
taskmgr.add(server_log_task)
|
||||
|
||||
# Assign data flow
|
||||
|
||||
Reference in New Issue
Block a user