Avoid error on estimate on the last line

parent d71d05a8
...@@ -724,7 +724,9 @@ class GCode(object): ...@@ -724,7 +724,9 @@ 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
......
...@@ -216,7 +216,7 @@ def add_extra_controls(self, root, parentpanel, extra_buttons = None, mini_mode ...@@ -216,7 +216,7 @@ def add_extra_controls(self, root, parentpanel, extra_buttons = None, mini_mode
root.htemp.SetValue(i) root.htemp.SetValue(i)
if '(' not in root.ctemp.Value: if '(' not in root.ctemp.Value:
root.btemp.SetValue(root.ctemp.Value + ' (user)') root.ctemp.SetValue(root.ctemp.Value + ' (user)')
if '(' not in root.btemp.Value: if '(' not in root.btemp.Value:
root.btemp.SetValue(root.btemp.Value + ' (user)') root.btemp.SetValue(root.btemp.Value + ' (user)')
if '(' not in root.htemp.Value: if '(' not in root.htemp.Value:
......
...@@ -264,11 +264,11 @@ class pronsole(cmd.Cmd): ...@@ -264,11 +264,11 @@ class pronsole(cmd.Cmd):
return False return False
def log(self, *msg): def log(self, *msg):
msg = u"".join(unicode(i) for i in msg) msg = u"".join(unicode(i).encode('utf-8', 'ignore') for i in msg)
logging.info(msg) logging.info(msg)
def logError(self, *msg): def logError(self, *msg):
msg = u"".join(unicode(i) for i in msg) msg = u"".join(unicode(i).encode('utf-8', 'ignore') for i in msg)
logging.error(msg) logging.error(msg)
if not self.settings.error_command: if not self.settings.error_command:
return return
......
...@@ -173,6 +173,8 @@ class RemainingTimeEstimator(object): ...@@ -173,6 +173,8 @@ class RemainingTimeEstimator(object):
if idx == self.last_idx: if idx == self.last_idx:
return self.last_estimate return self.last_estimate
layer, line = self.gcode.idxs(idx) layer, line = self.gcode.idxs(idx)
if layer is None or line is None:
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
estimate = self.drift * remaining estimate = self.drift * remaining
......
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