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:
@@ -11,10 +11,14 @@ class TempController(TempControllerBase):
|
||||
|
||||
# Fast model: same plant model but with zero transport delay, used
|
||||
# to predict the current temperature without the dead time.
|
||||
self.model = Pot(dt, {**model_params, 'Td': 0}, theta_amb)
|
||||
self.model = Pot(dt)
|
||||
self.model.set_plant_params({**model_params, 'Td': 0})
|
||||
self.model.set_ambient_temperature(theta_amb)
|
||||
# Delayed model: keeps the plant's assumed transport delay, so it
|
||||
# can be compared like-for-like against the real (delayed) measurement.
|
||||
self.model_delay = Pot(dt, model_params, theta_amb)
|
||||
self.model_delay = Pot(dt)
|
||||
self.model_delay.set_plant_params(model_params)
|
||||
self.model_delay.set_ambient_temperature(theta_amb)
|
||||
|
||||
self.theta_ist_plant = 0
|
||||
self.theta_ist_model = 0
|
||||
|
||||
Reference in New Issue
Block a user