Add set_model_power no-op stub to TempControllerBase

The Normal controller had no set_model_power(), causing callers to
guard with hasattr() instead of relying on a stable interface. Adding a
no-op stub to the base class means all controllers have the method;
TempControllerSmith overrides it to actually update its internal model.
Remove the now-redundant hasattr guards at both call sites.

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:19:33 +02:00
co-authored by Claude Sonnet 4.6
parent 740fe8eee9
commit 2f2067d2b9
3 changed files with 5 additions and 5 deletions
+3
View File
@@ -89,6 +89,9 @@ class TempControllerBase(APid):
def post_pid(self): def post_pid(self):
pass pass
def set_model_power(self, power):
pass
def set_theta_ist(self, value): def set_theta_ist(self, value):
self.theta_ist_set = value self.theta_ist_set = value
if self.is_startup: if self.is_startup:
+1 -2
View File
@@ -181,8 +181,7 @@ class SudForecastEstimator:
tc.process() tc.process()
power = actuate(tc.get_power()) power = actuate(tc.get_power())
pot.set_power(power) pot.set_power(power)
if hasattr(tc, 'set_model_power'): tc.set_model_power(power)
tc.set_model_power(power)
if sud.state == SudState.RAMPING: if sud.state == SudState.RAMPING:
if tc.is_holding(): if tc.is_holding():
+1 -3
View File
@@ -148,9 +148,7 @@ if __name__ == '__main__':
# Assign temp. sensor readings to tc # Assign temp. sensor readings to tc
sensor_task.set_on_changed("temp", ChangedFloat(tc.set_theta_ist, prec=2).set) sensor_task.set_on_changed("temp", ChangedFloat(tc.set_theta_ist, prec=2).set)
# Assign heater power set to tc model - "Normal" has no internal model heater.set_on_changed("power_set", tc.set_model_power)
if hasattr(tc, "set_model_power"):
heater.set_on_changed("power_set", tc.set_model_power)
# For simulation - the sim sensor has no real plant to read, so it # For simulation - the sim sensor has no real plant to read, so it
# just reports back whatever the modeled Pot's own temperature is. # just reports back whatever the modeled Pot's own temperature is.