Commit e0e0f8c4 authored by Guillaume Seguin's avatar Guillaume Seguin

Make ETA estimation more stable

parent 15fb7f7d
...@@ -79,11 +79,19 @@ class RemainingTimeEstimator(object): ...@@ -79,11 +79,19 @@ class RemainingTimeEstimator(object):
self.current_layer_estimate = self.gcode.all_layers[layer].duration self.current_layer_estimate = self.gcode.all_layers[layer].duration
self.current_layer_lines = len(self.gcode.all_layers[layer].lines) self.current_layer_lines = len(self.gcode.all_layers[layer].lines)
self.remaining_layers_estimate -= self.current_layer_estimate self.remaining_layers_estimate -= self.current_layer_estimate
self.last_idx = -1
self.last_estimate = None
def __call__(self, idx): def __call__(self, idx, printtime):
if not self.current_layer_lines: if not self.current_layer_lines:
return 0 return 0
if idx == self.last_idx:
return self.last_estimate
layer, line = self.gcode.idxs(idx) layer, line = self.gcode.idxs(idx)
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
return self.drift * remaining estimate = self.drift * remaining
total = estimate + printtime
self.last_idx = idx
self.last_estimate = (estimate, total)
return self.last_estimate
...@@ -1181,8 +1181,7 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -1181,8 +1181,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
string += _(" Line# %d of %d lines |" ) % (self.p.queueindex, len(self.p.mainqueue)) string += _(" Line# %d of %d lines |" ) % (self.p.queueindex, len(self.p.mainqueue))
if self.p.queueindex > 0: if self.p.queueindex > 0:
secondselapsed = int(time.time() - self.starttime + self.extra_print_time) secondselapsed = int(time.time() - self.starttime + self.extra_print_time)
secondsremain = self.compute_eta(self.p.queueindex) secondsremain, secondsestimate = self.compute_eta(self.p.queueindex, secondselapsed)
secondsestimate = secondselapsed + secondsremain
string += _(" Est: %s of %s remaining | ") % (format_duration(secondsremain), string += _(" Est: %s of %s remaining | ") % (format_duration(secondsremain),
format_duration(secondsestimate)) format_duration(secondsestimate))
string += _(" Z: %.3f mm") % self.curlayer string += _(" Z: %.3f mm") % self.curlayer
......
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