Files
brewpi/components/plant/plant_factory.py
T
jensandClaude Sonnet 4.6 ca1953c9ee sensor: model real temp sensor noise in TempSensorSim
Replaces the opaque variance/√12 formula with two explicit noise components:

  sigma (default 0.05 °C) — white Gaussian noise, calibrated against the
  20260628T184903 Sud-0010 log (detrended hold-phase tick-to-tick std ≈ 0.053 °C).

  stirrer_sigma / stirrer_tau — optional AR(1) low-frequency component for
  stirrer-induced fluctuations (off by default); steady-state std equals
  stirrer_sigma, correlation time equals stirrer_tau ticks.

plant_factory.py updated to use sigma=0.05 instead of the old variance=0.01
(which gave std ≈ 0.003 °C — far too quiet).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 19:17:48 +02:00

31 lines
1.2 KiB
Python

from components.actor import HeaterFactory
from components.sensor import TempSensorFactory
from components.plant.pot import Pot
from components.plant.pot_real import PotReal
class PlantFactory:
"""Builds the heater/pot/sensor trio together, as one consistent rig,
rather than each picked independently via its own *_name config key -
sim and real hardware are never actually mixed and matched in
practice, so Controller.plant_name alone now decides all three (see
server/brewpi.py).
Delegates the actual construction to HeaterFactory/TempSensorFactory
rather than importing HeaterHendi/TempSensor_max31865 directly, so
those classes' hardware-only deps (spidev, pyserial) stay lazily
imported - only actually needed when plant_name picks the real rig."""
@staticmethod
def create(plant_name, dt, heater_config):
if "sim" in plant_name:
heater = HeaterFactory.create("sim", heater_config)
pot = Pot(dt)
sensor = TempSensorFactory.create("sim", temp_offset=-0.15, sigma=0.05)
return heater, pot, sensor
heater = HeaterFactory.create("Hendi", heater_config)
pot = PotReal()
sensor = TempSensorFactory.create("max31865", temp_offset=-0.15)
return heater, pot, sensor