gcode: A set temperature request should use the heater name, not the gcode id

When setting a temperature, lookup the heater via
self.heaters.lookup_heater() and do not use the gcode ids.  This fixes
temperature setting when multiple extruders share the same heater.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-02-25 20:12:32 -05:00
parent 13b2e091b8
commit cf6c5e6f18
2 changed files with 8 additions and 17 deletions

View File

@ -389,22 +389,18 @@ class GCodeParser:
eventtime = self.reactor.pause(eventtime + 1.) eventtime = self.reactor.pause(eventtime + 1.)
def set_temp(self, params, is_bed=False, wait=False): def set_temp(self, params, is_bed=False, wait=False):
temp = self.get_float('S', params, 0.) temp = self.get_float('S', params, 0.)
heater = None
if is_bed: if is_bed:
heater = self.heaters.get_heater_by_gcode_id('B') heater_name = 'heater_bed'
elif 'T' in params:
index = self.get_int('T', params, minval=0)
heater = self.heaters.get_heater_by_gcode_id('T%d' % (index,))
else: else:
heater = self.heaters.get_heater_by_gcode_id('T0') index = self.get_int('T', params, 0, minval=0)
if heater is None: heater_name = 'extruder%d' % (index,)
if temp > 0.:
self.respond_error("Heater not configured")
return
print_time = self.toolhead.get_last_move_time() print_time = self.toolhead.get_last_move_time()
try: try:
heater = self.heaters.lookup_heater(heater_name)
heater.set_temp(print_time, temp) heater.set_temp(print_time, temp)
except heater.error as e: except heater.error as e:
if not temp:
return
raise error(str(e)) raise error(str(e))
if wait and temp: if wait and temp:
self.bg_temp(heater) self.bg_temp(heater)

View File

@ -265,18 +265,13 @@ class PrinterHeaters:
raise self.printer.config_error("Unknown temperature sensor '%s'" % ( raise self.printer.config_error("Unknown temperature sensor '%s'" % (
sensor_type,)) sensor_type,))
return self.sensors[sensor_type](config) return self.sensors[sensor_type](config)
def get_all_heaters(self):
return self.heaters.values()
cmd_TURN_OFF_HEATERS_help = "Turn off all heaters" cmd_TURN_OFF_HEATERS_help = "Turn off all heaters"
def cmd_TURN_OFF_HEATERS(self, params): def cmd_TURN_OFF_HEATERS(self, params):
print_time = self.printer.lookup_object('toolhead').get_last_move_time() print_time = self.printer.lookup_object('toolhead').get_last_move_time()
for heater in self.heaters.values(): for heater in self.heaters.values():
heater.set_temp(print_time, 0.) heater.set_temp(print_time, 0.)
def get_all_heaters(self):
return self.heaters.values()
def get_heater_by_gcode_id(self, gcode_id):
if gcode_id in self.heaters_gcode_id:
heater_name = self.heaters_gcode_id[gcode_id]
return self.heaters[heater_name]
return None
def add_printer_objects(config): def add_printer_objects(config):
config.get_printer().add_object('heater', PrinterHeaters(config)) config.get_printer().add_object('heater', PrinterHeaters(config))