Add set_ambient_temperature and set_model_plant_params stubs to TempControllerBase

Same pattern as set_model_power: these methods only existed on the Smith
controller, forcing five hasattr guards at call sites. No-op stubs on the
base class give all controllers a stable interface; Smith overrides them.
Remove the now-redundant hasattr guards.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tqxrk8uj4M3w3d3eXm3xK8
This commit is contained in:
2026-06-25 20:22:33 +02:00
co-authored by Claude Sonnet 4.6
parent 2f2067d2b9
commit 6e696f44e4
4 changed files with 11 additions and 10 deletions
+6
View File
@@ -89,6 +89,12 @@ class TempControllerBase(APid):
def post_pid(self):
pass
def set_ambient_temperature(self, theta_amb):
pass
def set_model_plant_params(self, model_params):
pass
def set_model_power(self, power):
pass
-2
View File
@@ -108,7 +108,6 @@ class SudForecastEstimator:
pot.initial(start_theta)
tc = PidFactory.create(self.pid_type, self.dt)
tc.set_params(self.tempctrl_params)
if hasattr(tc, 'set_ambient_temperature'):
tc.set_ambient_temperature(self.theta_amb)
tc.set_enabled(True)
tc.set_theta_ist(pot.get_temperature())
@@ -159,7 +158,6 @@ class SudForecastEstimator:
step_starts.setdefault(sud.index, t[-1])
params = sud.derive_plant_params(step.get('grain_mass', 0), step.get('water_mass', 0))
pot.set_plant_params(params)
if hasattr(tc, 'set_model_plant_params'):
tc.set_model_plant_params(params)
if sud.state == SudState.RAMPING and step['temperature'] is not None:
tc.set_theta_soll(step['temperature'])
-2
View File
@@ -118,7 +118,6 @@ if __name__ == '__main__':
# ever coming from a Sud's own doc.
tc = PidFactory.create(config['Controller']['pid_type'], DT)
tc.set_params(config['TempCtrl'])
if hasattr(tc, 'set_ambient_temperature'):
tc.set_ambient_temperature(theta_amb)
tc_task = TcTask(tc, DT_TASK, dispatcher.msgio_get("TempCtrl"))
taskmgr.add(tc_task)
@@ -171,7 +170,6 @@ if __name__ == '__main__':
if 'AmbientTemp' in data:
theta_amb = data['AmbientTemp']
pot.set_ambient_temperature(theta_amb)
if hasattr(tc, 'set_ambient_temperature'):
tc.set_ambient_temperature(theta_amb)
forecast_estimator.set_ambient_temperature(theta_amb)
await msg_system.send({'AmbientTemp': theta_amb})
-1
View File
@@ -124,7 +124,6 @@ class SudTask(ATask):
not just once a run actually starts."""
params = self.sud.derive_plant_params(grain_mass, water_mass)
self.pot.set_plant_params(params)
if hasattr(self.tc, 'set_model_plant_params'):
self.tc.set_model_plant_params(params)
def apply_stirrer(self, phase):