From fb7fe282c80854ba06defa1cb4b49f1c9942f450 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Tue, 8 Jan 2019 09:15:40 -0500 Subject: klippy: Convert printer_state("shutdown") to an event handler Convert all users of the printer_state("shutdown") handler to register a "klippy:shutdown" event handler instead. Signed-off-by: Kevin O'Connor --- klippy/toolhead.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'klippy/toolhead.py') diff --git a/klippy/toolhead.py b/klippy/toolhead.py index 458d5c51..cae280c7 100644 --- a/klippy/toolhead.py +++ b/klippy/toolhead.py @@ -205,6 +205,8 @@ class ToolHead: self.mcu = self.all_mcus[0] self.move_queue = MoveQueue() self.commanded_pos = [0., 0., 0., 0.] + self.printer.register_event_handler("klippy:shutdown", + self._handle_shutdown) # Velocity and acceleration control self.max_velocity = config.getfloat('max_velocity', above=0.) self.max_accel = config.getfloat('max_accel', above=0.) @@ -412,13 +414,9 @@ class ToolHead: return { 'status': status, 'print_time': print_time, 'estimated_print_time': estimated_print_time, 'printing_time': print_time - last_print_start_time } - def printer_state(self, state): - if state == 'shutdown': - try: - self.move_queue.reset() - self.reset_print_time() - except: - logging.exception("Exception in toolhead shutdown") + def _handle_shutdown(self): + self.move_queue.reset() + self.reset_print_time() def get_kinematics(self): return self.kin def get_max_velocity(self): -- cgit v1.2.3-70-g09d2