From fb2a5ce05ac243371e8f6fbbd614615f14163da0 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Wed, 24 Jun 2026 19:09:30 +0200 Subject: [PATCH] Move dt/sim_warp_factor from config.json to CLI flags Both are run-mode knobs (how fast to drive this particular process), not config.json material (a plant/hardware description that stays the same regardless of how a run happens to be invoked) - --dt and --sim-warp-factor, defaulting to 1.0 each (real time, 1-simulated- second ticks) unless a dev/test run asks for a faster warp explicitly. Co-Authored-By: Claude Sonnet 4.6 Claude-Session: https://claude.ai/code/session_019qvu5giu7gvRCyEWzf2Vpx --- README.md | 2 +- config.json.templ | 2 -- server/brewpi.py | 16 +++++++++++++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 10dde9b..db513e0 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ callbacks, e.g.: real, unmodeled kettle, has no model to feed) Each component runs inside its own `ATask` at a configurable interval -(`Controller.dt`, scaled by `sim_warp_factor`) and pushes state changes onto a +(`--dt`, scaled by `--sim-warp-factor`) and pushes state changes onto a keyed WebSocket channel that any connected client can subscribe to and send commands back on (e.g. `{"TempCtrl": {"Soll": {"Temp": 65}}}`). diff --git a/config.json.templ b/config.json.templ index 7f5e5ce..d975d5b 100644 --- a/config.json.templ +++ b/config.json.templ @@ -1,8 +1,6 @@ { "ambient_temperature": 20, "Controller" : { - "dt": 1, - "sim_warp_factor": 50.0, "stirrer_name": "sim", "plant_name": "sim", "pid_type": "Smith" diff --git a/server/brewpi.py b/server/brewpi.py index 2a70a26..aed1c82 100755 --- a/server/brewpi.py +++ b/server/brewpi.py @@ -39,6 +39,16 @@ if __name__ == '__main__': parser = ap.ArgumentParser() parser.add_argument("-c", "--config", default="config.json") parser.add_argument("-m", "--logdir", default="logs") + # Simulated seconds per tick, and how many of those fit into one real + # second - run-mode knobs (how fast to drive this particular process), + # not config.json material (a *plant/hardware* description that stays + # the same regardless of how this run happens to be invoked) - see + # tasks/sud_forecast.py's SudForecastEstimator and every *Task's own + # dt/interval split for where these actually end up. Defaulting both + # to 1.0 means real time, 1-simulated-second ticks unless asked + # otherwise - e.g. a much higher --sim-warp-factor for dev/testing. + parser.add_argument("--dt", type=float, default=1.0) + parser.add_argument("--sim-warp-factor", type=float, default=1.0) args = parser.parse_args() @@ -54,8 +64,8 @@ if __name__ == '__main__': server = WsServerMultiUser(listener=dispatcher) taskmgr = TaskManager() - DT = config['Controller']['dt'] - DT_TASK = 1.0 / config['Controller']['sim_warp_factor'] + DT = args.dt + DT_TASK = 1.0 / args.sim_warp_factor theta_amb = config['ambient_temperature'] plant_sim = "sim" in config['Controller']['plant_name'] @@ -113,7 +123,7 @@ if __name__ == '__main__': # see components/sud_forecast.py. forecast_estimator = SudForecastEstimator( DT, theta_amb, config['Controller']['pid_type'], config['TempCtrl'], - heater.get_powers(), config['Controller']['sim_warp_factor']) + heater.get_powers(), args.sim_warp_factor) sud_task = SudTask(sud, tc, stirrer, pot, DT, DT_TASK, dispatcher.msgio_get("Sud"), forecast_estimator) taskmgr.add(sud_task) # Records every Sud run's measured data and forecast to their own