From 982ad9d829cbf7aa4c1a509a24f12cddff3aef46 Mon Sep 17 00:00:00 2001 From: daid Date: Fri, 16 Mar 2012 15:41:39 +0100 Subject: [PATCH] Add print time estimate --- SkeinPyPy/newui/gcodeInterpreter.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/SkeinPyPy/newui/gcodeInterpreter.py b/SkeinPyPy/newui/gcodeInterpreter.py index acea228..750a663 100644 --- a/SkeinPyPy/newui/gcodeInterpreter.py +++ b/SkeinPyPy/newui/gcodeInterpreter.py @@ -13,6 +13,7 @@ class gcode(): currentE = 0.0 totalExtrusion = 0.0 maxExtrusion = 0.0 + totalMoveTimeMinute = 0.0 pathList = [] scale = 1.0 posAbs = True @@ -34,6 +35,7 @@ class gcode(): z = self.getCodeFloat(line, 'Z') e = self.getCodeFloat(line, 'E') f = self.getCodeFloat(line, 'F') + oldPos = pos.copy() if x is not None: if posAbs: pos.x = x * scale @@ -45,15 +47,16 @@ class gcode(): else: pos.y += y * scale if z is not None: - oldZ = pos.z if posAbs: pos.z = z * scale else: pos.z += z * scale - if oldZ != pos.z and startCodeDone: + if oldPos.z != pos.z and startCodeDone: layerNr += 1 if f is not None: feedRate = f + if x is not None or y is not None or z is not None: + totalMoveTimeMinute += (oldPos - pos).vsize() / feedRate moveType = 'move' if e is not None: if posAbs: @@ -138,7 +141,9 @@ class gcode(): self.layerCount = layerNr self.pathList = pathList self.extrusionAmount = maxExtrusion + self.totalMoveTimeMinute = totalMoveTimeMinute print "Extruded a total of: %d mm of filament" % (self.extrusionAmount) + print "Estimated print duration: %.2f minutes" % (self.totalMoveTimeMinute) def getCodeInt(self, str, id): m = re.search(id + '([^\s]+)', str)