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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019qvu5giu7gvRCyEWzf2Vpx
This commit is contained in:
2026-06-24 19:09:30 +02:00
co-authored by Claude Sonnet 4.6
parent 6e19162c16
commit fb2a5ce05a
3 changed files with 14 additions and 6 deletions
+1 -1
View File
@@ -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}}}`).
-2
View File
@@ -1,8 +1,6 @@
{
"ambient_temperature": 20,
"Controller" : {
"dt": 1,
"sim_warp_factor": 50.0,
"stirrer_name": "sim",
"plant_name": "sim",
"pid_type": "Smith"
+13 -3
View File
@@ -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