heater: Rename add_sensor() to add_sensor_factory()
Signed-off-by: Douglas Hammond <wizhippo@gmail.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
cf6c5e6f18
commit
bb4fab5570
|
@ -191,7 +191,7 @@ def load_config(config):
|
||||||
for sensor_type, params in [("AD595", AD595), ("PT100 INA826", PT100)]:
|
for sensor_type, params in [("AD595", AD595), ("PT100 INA826", PT100)]:
|
||||||
func = (lambda config, params=params:
|
func = (lambda config, params=params:
|
||||||
PrinterADCtoTemperature(config, LinearVoltage(config, params)))
|
PrinterADCtoTemperature(config, LinearVoltage(config, params)))
|
||||||
pheater.add_sensor(sensor_type, func)
|
pheater.add_sensor_factory(sensor_type, func)
|
||||||
|
|
||||||
def load_config_prefix(config):
|
def load_config_prefix(config):
|
||||||
if config.get("resistance1", None) is None:
|
if config.get("resistance1", None) is None:
|
||||||
|
@ -199,4 +199,4 @@ def load_config_prefix(config):
|
||||||
else:
|
else:
|
||||||
custom_sensor = CustomLinearResistance(config)
|
custom_sensor = CustomLinearResistance(config)
|
||||||
pheater = config.get_printer().lookup_object("heater")
|
pheater = config.get_printer().lookup_object("heater")
|
||||||
pheater.add_sensor(custom_sensor.name, custom_sensor.create)
|
pheater.add_sensor_factory(custom_sensor.name, custom_sensor.create)
|
||||||
|
|
|
@ -342,4 +342,4 @@ def load_config(config):
|
||||||
# Register sensors
|
# Register sensors
|
||||||
pheater = config.get_printer().lookup_object("heater")
|
pheater = config.get_printer().lookup_object("heater")
|
||||||
for name, klass in Sensors.items():
|
for name, klass in Sensors.items():
|
||||||
pheater.add_sensor(name, klass)
|
pheater.add_sensor_factory(name, klass)
|
||||||
|
|
|
@ -117,9 +117,9 @@ def load_config(config):
|
||||||
pheater = config.get_printer().lookup_object("heater")
|
pheater = config.get_printer().lookup_object("heater")
|
||||||
for sensor_type, params in Sensors.items():
|
for sensor_type, params in Sensors.items():
|
||||||
func = (lambda config, params=params: PrinterThermistor(config, params))
|
func = (lambda config, params=params: PrinterThermistor(config, params))
|
||||||
pheater.add_sensor(sensor_type, func)
|
pheater.add_sensor_factory(sensor_type, func)
|
||||||
|
|
||||||
def load_config_prefix(config):
|
def load_config_prefix(config):
|
||||||
thermistor = CustomThermistor(config)
|
thermistor = CustomThermistor(config)
|
||||||
pheater = config.get_printer().lookup_object("heater")
|
pheater = config.get_printer().lookup_object("heater")
|
||||||
pheater.add_sensor(thermistor.name, thermistor.create)
|
pheater.add_sensor_factory(thermistor.name, thermistor.create)
|
||||||
|
|
|
@ -228,15 +228,15 @@ class ControlPID:
|
||||||
class PrinterHeaters:
|
class PrinterHeaters:
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
self.printer = config.get_printer()
|
self.printer = config.get_printer()
|
||||||
self.sensors = {}
|
self.sensor_factories = {}
|
||||||
self.heaters = {}
|
self.heaters = {}
|
||||||
self.heaters_gcode_id = {}
|
self.heaters_gcode_id = {}
|
||||||
# Register TURN_OFF_HEATERS command
|
# Register TURN_OFF_HEATERS command
|
||||||
gcode = self.printer.lookup_object('gcode')
|
gcode = self.printer.lookup_object('gcode')
|
||||||
gcode.register_command("TURN_OFF_HEATERS", self.cmd_TURN_OFF_HEATERS,
|
gcode.register_command("TURN_OFF_HEATERS", self.cmd_TURN_OFF_HEATERS,
|
||||||
desc=self.cmd_TURN_OFF_HEATERS_help)
|
desc=self.cmd_TURN_OFF_HEATERS_help)
|
||||||
def add_sensor(self, sensor_type, sensor_factory):
|
def add_sensor_factory(self, sensor_type, sensor_factory):
|
||||||
self.sensors[sensor_type] = sensor_factory
|
self.sensor_factories[sensor_type] = sensor_factory
|
||||||
def setup_heater(self, config, gcode_id):
|
def setup_heater(self, config, gcode_id):
|
||||||
heater_name = config.get_name().split()[-1]
|
heater_name = config.get_name().split()[-1]
|
||||||
if heater_name == 'extruder':
|
if heater_name == 'extruder':
|
||||||
|
@ -261,10 +261,10 @@ class PrinterHeaters:
|
||||||
self.printer.try_load_module(config, "adc_temperature")
|
self.printer.try_load_module(config, "adc_temperature")
|
||||||
self.printer.try_load_module(config, "spi_temperature")
|
self.printer.try_load_module(config, "spi_temperature")
|
||||||
sensor_type = config.get('sensor_type')
|
sensor_type = config.get('sensor_type')
|
||||||
if sensor_type not in self.sensors:
|
if sensor_type not in self.sensor_factories:
|
||||||
raise self.printer.config_error("Unknown temperature sensor '%s'" % (
|
raise self.printer.config_error(
|
||||||
sensor_type,))
|
"Unknown temperature sensor '%s'" % (sensor_type,))
|
||||||
return self.sensors[sensor_type](config)
|
return self.sensor_factories[sensor_type](config)
|
||||||
def get_all_heaters(self):
|
def get_all_heaters(self):
|
||||||
return self.heaters.values()
|
return self.heaters.values()
|
||||||
cmd_TURN_OFF_HEATERS_help = "Turn off all heaters"
|
cmd_TURN_OFF_HEATERS_help = "Turn off all heaters"
|
||||||
|
|
Loading…
Reference in New Issue