Revert last change and fix another way the timing

parent 4584cef1
...@@ -724,9 +724,7 @@ class GCode(object): ...@@ -724,9 +724,7 @@ class GCode(object):
self.duration = totaltime self.duration = totaltime
def idxs(self, i): def idxs(self, i):
if i in self.layer_idxs and i in self.line_idxs:
return self.layer_idxs[i], self.line_idxs[i] return self.layer_idxs[i], self.line_idxs[i]
return None, None
def estimate_duration(self): def estimate_duration(self):
return self.layers_count, self.duration return self.layers_count, self.duration
......
...@@ -551,10 +551,7 @@ class printcore(): ...@@ -551,10 +551,7 @@ class printcore():
if self.preprintsendcb: if self.preprintsendcb:
if self.queueindex + 1 < len(self.mainqueue): if self.queueindex + 1 < len(self.mainqueue):
(next_layer, next_line) = self.mainqueue.idxs(self.queueindex + 1) (next_layer, next_line) = self.mainqueue.idxs(self.queueindex + 1)
try:
next_gline = self.mainqueue.all_layers[next_layer][next_line] next_gline = self.mainqueue.all_layers[next_layer][next_line]
except:
next_gline = None
else: else:
next_gline = None next_gline = None
gline = self.preprintsendcb(gline, next_gline) gline = self.preprintsendcb(gline, next_gline)
......
...@@ -172,8 +172,10 @@ class RemainingTimeEstimator(object): ...@@ -172,8 +172,10 @@ class RemainingTimeEstimator(object):
return (0, 0) return (0, 0)
if idx == self.last_idx: if idx == self.last_idx:
return self.last_estimate return self.last_estimate
try:
layer, line = self.gcode.idxs(idx) layer, line = self.gcode.idxs(idx)
if layer is None or line is None: except:
self.last_idx = idx
return (0, total) return (0, total)
layer_progress = (1 - (float(line + 1) / self.current_layer_lines)) layer_progress = (1 - (float(line + 1) / self.current_layer_lines))
remaining = layer_progress * self.current_layer_estimate + self.remaining_layers_estimate remaining = layer_progress * self.current_layer_estimate + self.remaining_layers_estimate
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment