aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/toolhead.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2019-01-08 09:15:40 -0500
committerKevin O'Connor <kevin@koconnor.net>2019-01-08 10:59:43 -0500
commitfb7fe282c80854ba06defa1cb4b49f1c9942f450 (patch)
treefcc3098dd798ddd75d75ea854b0c1f4d6dae6b60 /klippy/toolhead.py
parentb2d5a8e65bfb4d5c9250a8cfb72e0b1923c8355d (diff)
downloadkutter-fb7fe282c80854ba06defa1cb4b49f1c9942f450.tar.gz
kutter-fb7fe282c80854ba06defa1cb4b49f1c9942f450.tar.xz
kutter-fb7fe282c80854ba06defa1cb4b49f1c9942f450.zip
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 <kevin@koconnor.net>
Diffstat (limited to 'klippy/toolhead.py')
-rw-r--r--klippy/toolhead.py12
1 files changed, 5 insertions, 7 deletions
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):