aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/toolhead.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-01-19 22:49:27 -0500
committerKevin O'Connor <kevin@koconnor.net>2018-01-28 12:19:26 -0500
commitd3665699f168bc1b1413fa8dddba318d6adbdf87 (patch)
tree7fff975a7465983d8b19eed382c27f166c122450 /klippy/toolhead.py
parent81013ba5c8638dd42932bd893e1b3115b1b98041 (diff)
downloadkutter-d3665699f168bc1b1413fa8dddba318d6adbdf87.tar.gz
kutter-d3665699f168bc1b1413fa8dddba318d6adbdf87.tar.xz
kutter-d3665699f168bc1b1413fa8dddba318d6adbdf87.zip
klippy: Support generic printer_state() and stats() callbacks
Instead of hardcoding which objects are called on state transitions, allow any "printer object" to be invoked if it has a printer_state() method. Convert connect, ready, shutdown, and disconnect callbacks to this mechanism. Similarly, allow all printer objects to provide a stats() callback. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/toolhead.py')
-rw-r--r--klippy/toolhead.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/klippy/toolhead.py b/klippy/toolhead.py
index 83357732..19d8b689 100644
--- a/klippy/toolhead.py
+++ b/klippy/toolhead.py
@@ -369,12 +369,13 @@ class ToolHead:
buffer_time = max(0., self.print_time - est_print_time)
return "print_time=%.3f buffer_time=%.3f print_stall=%d" % (
self.print_time, buffer_time, self.print_stall)
- def do_shutdown(self):
- try:
- self.move_queue.reset()
- self.reset_print_time()
- except:
- logging.exception("Exception in do_shutdown")
+ 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 get_kinematics(self):
return self.kin
def get_max_velocity(self):