aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-01-12 16:24:47 -0500
committerKevin O'Connor <kevin@koconnor.net>2018-01-12 16:56:31 -0500
commit0d8ddcadbbbbe059559618db56a88d3e06d578e9 (patch)
tree6aa7fb158c4c1e0091a83061e29a063a8f45f9b6
parentd3eda337a9a8a0a5a5e9e85406d21769fb8a76e4 (diff)
downloadkutter-0d8ddcadbbbbe059559618db56a88d3e06d578e9.tar.gz
kutter-0d8ddcadbbbbe059559618db56a88d3e06d578e9.tar.xz
kutter-0d8ddcadbbbbe059559618db56a88d3e06d578e9.zip
toolhead: Improve tracking of print_stall
The previous code increases print_stall if a move is proactively flushed due to buffer_time_low and a follow up move is ready to send before the existing moves are fully retired. However, this would not track the case where a move is proactively flushed and it takes an extended amount of time to get sufficient moves to refill the queue. Change the code so that print_stall increases anytime a new move is queued after a proactive flush and there are existing moves not yet fully retired. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--klippy/toolhead.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/klippy/toolhead.py b/klippy/toolhead.py
index d1c40e16..ce9db286 100644
--- a/klippy/toolhead.py
+++ b/klippy/toolhead.py
@@ -208,7 +208,7 @@ class ToolHead:
self.need_check_stall = -1.
self.print_stall = 0
self.sync_print_time = True
- self.last_flush_from_idle = False
+ self.idle_flush_print_time = 0.
self.flush_timer = self.reactor.register_timer(self._flush_handler)
self.move_queue.set_flush_time(self.buffer_time_high)
# Motor off tracking
@@ -234,11 +234,8 @@ class ToolHead:
if not self.sync_print_time:
return self.print_time
self.sync_print_time = False
- est_print_time = self.mcu.estimated_print_time(self.reactor.monotonic())
- if self.last_flush_from_idle and self.print_time > est_print_time:
- self.print_stall += 1
- self.last_flush_from_idle = False
self.need_motor_off = True
+ est_print_time = self.mcu.estimated_print_time(self.reactor.monotonic())
self.print_time = max(
self.print_time, est_print_time + self.buffer_time_start)
self.reactor.update_timer(self.flush_timer, self.reactor.NOW)
@@ -246,7 +243,7 @@ class ToolHead:
def _flush_lookahead(self, must_sync=False):
sync_print_time = self.sync_print_time
self.move_queue.flush()
- self.last_flush_from_idle = False
+ self.idle_flush_print_time = 0.
if sync_print_time or must_sync:
self.sync_print_time = True
self.move_queue.set_flush_time(self.buffer_time_high)
@@ -265,6 +262,11 @@ class ToolHead:
eventtime = self.reactor.monotonic()
if self.sync_print_time:
# Building initial queue - make sure to flush on idle input
+ if self.idle_flush_print_time:
+ est_print_time = self.mcu.estimated_print_time(eventtime)
+ if est_print_time < self.idle_flush_print_time:
+ self.print_stall += 1
+ self.idle_flush_print_time = 0.
self.reactor.update_timer(self.flush_timer, eventtime + 0.100)
return
# Check if there are lots of queued moves and stall if so
@@ -289,7 +291,7 @@ class ToolHead:
# Under ran low buffer mark - flush lookahead queue
self._flush_lookahead(must_sync=True)
if print_time != self.print_time:
- self.last_flush_from_idle = True
+ self.idle_flush_print_time = self.print_time
except:
logging.exception("Exception in flush_handler")
self.printer.invoke_shutdown("Exception in flush_handler")