log: Sud lifecycle transitions and stirrer/heater connect state

Logs load/start/pause/continue/stop/entering-step/wait-user/finished
on Sud (components/sud.py) and connected/disconnected on
StirrerTask/HeaterTask, using the self.log added earlier.

SudForecastEstimator.estimate() (components/sud_forecast.py) drives its
own throwaway Sud through an entire schedule in a tight loop (no real
waiting) to predict its duration, and re-runs that on every real step
transition too - since it's still a Sud, it logged through the exact
same "Sud" logger as the real, server-driven one, making an instant
internal forecast run indistinguishable in the log from an actual
brew. Gave it its own "SudForecastEstimator" logger, silenced to
WARNING by default, so only the real Sud's transitions show up.
This commit is contained in:
2026-07-10 22:28:01 +02:00
parent a1864a5257
commit ce5eb3bc23
4 changed files with 20 additions and 0 deletions
+10
View File
@@ -1,3 +1,4 @@
import logging
from components.plant import Pot
from components.pid import PidFactory
from components.sud import Sud, SudState
@@ -7,6 +8,14 @@ from components.sud import Sud, SudState
# simulation forever - the estimate is simply cut off there.
MAX_TICKS = 200000
# estimate() below drives a throwaway Sud through an entire schedule in a
# tight loop (no real waiting) purely to predict its duration - since it's
# still a Sud, it would otherwise log through the exact same "Sud" logger
# the real, server-driven one uses (components/sud.py's self.log), making
# an instant internal forecast run indistinguishable in the log from an
# actual brew. Quiet by default; raise this logger's own level to see it.
logging.getLogger('SudForecastEstimator').setLevel(logging.WARNING)
# Mirrors tasks/heater.py's own pulse_period_s - HeaterTask duty-cycles its
# device's discrete power steps over a rolling window this many *real*
# seconds wide, regardless of warp factor (see estimate()'s actuate()
@@ -95,6 +104,7 @@ class SudForecastEstimator:
start_theta = self.theta_amb
sud = Sud(self.pot_config)
sud.log = logging.getLogger('SudForecastEstimator')
if not sud.load(doc) or not sud.schedule:
return [0.0], [start_theta], SudState.DONE, {}