From f77e1b67f64604ef48f4239b6db9c2fcc1ead0c5 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sun, 11 Feb 2018 13:52:20 -0500 Subject: [PATCH] gcode: Introduce request_restart() method Use request_restart() method instead of prep_restart() and motor_heater_off(). Signed-off-by: Kevin O'Connor --- klippy/gcode.py | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/klippy/gcode.py b/klippy/gcode.py index 3c03d212..5090a4c5 100644 --- a/klippy/gcode.py +++ b/klippy/gcode.py @@ -108,16 +108,6 @@ class GCodeParser: self.fd_handle = self.reactor.register_fd(self.fd, self.process_data) def reset_last_position(self): self.last_position = self.position_with_transform() - def motor_heater_off(self): - if self.toolhead is None: - return - self.toolhead.motor_off() - print_time = self.toolhead.get_last_move_time() - for heater in self.heaters: - if heater is not None: - heater.set_temp(print_time, 0.) - if self.fan is not None: - self.fan.set_speed(print_time, 0.) def dump_debug(self): out = [] out.append("Dumping gcode input %d blocks" % ( @@ -185,10 +175,7 @@ class GCodeParser: # Special handling for debug file input EOF if not data and self.is_fileinput: if not self.is_processing_data: - self.motor_heater_off() - if self.toolhead is not None: - self.toolhead.wait_moves() - self.printer.request_exit() + self.request_restart('exit') pending_commands.append("") # Handle case where multiple commands pending if self.is_processing_data or len(pending_commands) > 1: @@ -553,22 +540,27 @@ class GCodeParser: temp = self.get_float('S', params) heater.start_auto_tune(temp) self.bg_temp(heater) - def prep_restart(self): + def request_restart(self, result): if self.is_printer_ready: self.respond_info("Preparing to restart...") - self.motor_heater_off() + self.toolhead.motor_off() + print_time = self.toolhead.get_last_move_time() + for heater in self.heaters: + if heater is not None: + heater.set_temp(print_time, 0.) + if self.fan is not None: + self.fan.set_speed(print_time, 0.) self.toolhead.dwell(0.500) self.toolhead.wait_moves() + self.printer.request_exit(result) cmd_RESTART_when_not_ready = True cmd_RESTART_help = "Reload config file and restart host software" def cmd_RESTART(self, params): - self.prep_restart() - self.printer.request_exit('restart') + self.request_restart('restart') cmd_FIRMWARE_RESTART_when_not_ready = True cmd_FIRMWARE_RESTART_help = "Restart firmware, host, and reload config" def cmd_FIRMWARE_RESTART(self, params): - self.prep_restart() - self.printer.request_exit('firmware_restart') + self.request_restart('firmware_restart') cmd_ECHO_when_not_ready = True def cmd_ECHO(self, params): self.respond_info(params['#original'])