refactor: replace plant_name with per-component type keys in config
PlantFactory.create() no longer takes plant_name; sim vs real is derived from Heater.type. StirrerFactory is wired from Stirrer.type. HeaterFactory registry key lowercased to "hendi" to match config. Controller.plant_name removed from both config templates. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+7
-10
@@ -77,20 +77,17 @@ if __name__ == '__main__':
|
||||
DT = args.dt
|
||||
DT_TASK = 1.0 / args.sim_warp_factor
|
||||
theta_amb = config['ambient_temperature']
|
||||
plant_sim = "sim" in config['Controller']['plant_name']
|
||||
plant_sim = config['Heater'].get('type', 'sim') == 'sim'
|
||||
|
||||
# Mash schedule - starts out empty; a client loads one of sude/*.json's
|
||||
# several schedules onto it later (see components/sud.py's Sud).
|
||||
sud = Sud()
|
||||
|
||||
# Heater/Pot/Sensor - built together as one consistent rig by a single
|
||||
# Controller.plant_name, rather than three independently-named
|
||||
# components that in practice are never actually mixed and matched
|
||||
# (see components/plant/plant_factory.py): "sim" gets HeaterSim/Pot
|
||||
# (the modeled plant)/TempSensorSim; anything else gets HeaterHendi/
|
||||
# PotReal (no model - the real kettle does its own physics)/
|
||||
# TempSensor_max31865.
|
||||
heater, pot, sensor = PlantFactory.create(config['Controller']['plant_name'], DT, config['Heater'], config.get('TempSensor', {}))
|
||||
# Heater/Pot/Sensor - built together as one consistent rig; each
|
||||
# component's type comes from its own config section. Heater.type==sim
|
||||
# gets HeaterSim/Pot (the modelled plant)/TempSensorSim; anything else
|
||||
# (e.g. hendi) gets HeaterHendi/PotReal/whatever TempSensor.type names.
|
||||
heater, pot, sensor = PlantFactory.create(DT, config['Heater'], config.get('TempSensor', {}))
|
||||
|
||||
sensor_task = TempSensorTask(sensor, DT_TASK, dispatcher.msgio_get("Sensor"))
|
||||
taskmgr.add(sensor_task)
|
||||
@@ -123,7 +120,7 @@ if __name__ == '__main__':
|
||||
taskmgr.add(tc_task)
|
||||
|
||||
# Stirrer
|
||||
stirrer = StirrerFactory.create(config['Controller']['stirrer_name'], DT, config['Stirrer'])
|
||||
stirrer = StirrerFactory.create(config['Stirrer']['type'], DT, config['Stirrer'])
|
||||
stirrer_task = StirrerTask(stirrer, DT_TASK, dispatcher.msgio_get("Stirrer"))
|
||||
taskmgr.add(stirrer_task)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user