aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/lookahead.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2016-07-07 16:01:58 -0400
committerKevin O'Connor <kevin@koconnor.net>2016-07-10 22:49:01 -0400
commit9bb1ae079fe54f7af3259eadaaff910df909629f (patch)
treed844ad31b9396ef1d344fbff287f07c8e71372a7 /klippy/lookahead.py
parente0a9a1b8003d8ccb2d0bcb11da372cbaae90f4cc (diff)
downloadkutter-9bb1ae079fe54f7af3259eadaaff910df909629f.tar.gz
kutter-9bb1ae079fe54f7af3259eadaaff910df909629f.tar.xz
kutter-9bb1ae079fe54f7af3259eadaaff910df909629f.zip
toolhead: Merge lookahead.py into toolhead.py
Remove the lookahead.py file and move its code directly into toolhead.py. The MoveQueue() class is small and tightly coupled to the toolhead code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/lookahead.py')
-rw-r--r--klippy/lookahead.py50
1 files changed, 0 insertions, 50 deletions
diff --git a/klippy/lookahead.py b/klippy/lookahead.py
deleted file mode 100644
index 9e377463..00000000
--- a/klippy/lookahead.py
+++ /dev/null
@@ -1,50 +0,0 @@
-# Move queue look-ahead
-#
-# Copyright (C) 2016 Kevin O'Connor <kevin@koconnor.net>
-#
-# This file may be distributed under the terms of the GNU GPLv3 license.
-
-class MoveQueue:
- def __init__(self, dummy_move):
- self.dummy_move = dummy_move
- self.queue = []
- self.prev_junction_max = 0.
- self.junction_flush = 0.
- def prev_move(self):
- if self.queue:
- return self.queue[-1]
- return self.dummy_move
- def flush(self, lazy=False):
- next_junction_max = 0.
- can_flush = not lazy
- flush_count = len(self.queue)
- junction_end = [None] * flush_count
- for i in range(len(self.queue)-1, -1, -1):
- move = self.queue[i]
- junction_end[i] = next_junction_max
- if not can_flush:
- flush_count -= 1
- next_junction_max = next_junction_max + move.junction_delta
- if next_junction_max >= move.junction_start_max:
- next_junction_max = move.junction_start_max
- can_flush = True
- prev_junction_max = self.prev_junction_max
- for i in range(flush_count):
- move = self.queue[i]
- next_junction_max = min(prev_junction_max + move.junction_delta
- , junction_end[i])
- move.process(prev_junction_max, next_junction_max)
- prev_junction_max = next_junction_max
- del self.queue[:flush_count]
- self.prev_junction_max = prev_junction_max
- self.junction_flush = 0.
- if self.queue:
- self.junction_flush = self.queue[-1].junction_max
- def add_move(self, move):
- self.queue.append(move)
- if len(self.queue) == 1:
- self.junction_flush = move.junction_max
- return
- self.junction_flush -= move.junction_delta
- if self.junction_flush <= 0.:
- self.flush(lazy=True)