Pot: require plant params and ambient temperature via setters, not the constructor

Pot.__init__ now only takes dt; set_plant_params() and set_ambient_temperature()
must be called before process(), which now raises RuntimeError if either is
missing instead of silently computing on whatever the constructor happened to
default to. set_ambient_temperature() only seeds the plant's starting
temperature the first time it's called, so changing ambient mid-run still
can't clobber an in-progress simulated temperature. Updates all callers
(server/brewpi.py, TempController(Smith)'s two internal models,
SudForecastEstimator, and the plant/pid/sud demo scripts) to call the setters
right after construction.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DkkuG48uHFCGKe6dPSERFk
This commit is contained in:
2026-06-22 18:15:08 +02:00
co-authored by Claude Sonnet 4.6
parent e0bd3acc26
commit 296d3a333d
8 changed files with 67 additions and 31 deletions
+3 -1
View File
@@ -61,7 +61,9 @@ class SudForecastEstimator:
if not sud.load(doc) or not sud.schedule:
return [0.0], [start_theta], SudState.DONE, []
pot = Pot(self.dt, self.plant_params, self.theta_amb)
pot = Pot(self.dt)
pot.set_plant_params(self.plant_params)
pot.set_ambient_temperature(self.theta_amb)
pot.initial(start_theta)
tc = PidFactory.create(self.pid_type, self.dt, self.tempctrl_params, self.plant_params, theta_amb=self.theta_amb)
tc.set_enabled(True)