From: Youness Alaoui Date: Thu, 5 Nov 2015 20:34:14 +0000 (-0500) Subject: Add a print progress status text to the print window and show current Z X-Git-Tag: lulzbot-17.14~12 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=2e1f01617a41c16e187e5c35b8ea23280c5f33e2;p=cura.git Add a print progress status text to the print window and show current Z This shows current percentage, currnet line and Z in the print window. --- diff --git a/Cura/gui/printWindow.py b/Cura/gui/printWindow.py index b21b79e1..3fe5331c 100644 --- a/Cura/gui/printWindow.py +++ b/Cura/gui/printWindow.py @@ -392,7 +392,11 @@ class printWindowPlugin(wx.Frame): isPrinting = connection.isPrinting() or connection.isPaused() if self._progressBar is not None: if isPrinting: - self._progressBar.SetValue(connection.getPrintProgress() * 1000) + (current, total, z) = connection.getPrintProgress() + progress = 0.0 + if total > 0: + progress = float(current) / float(total) + self._progressBar.SetValue(progress * 1000) else: self._progressBar.SetValue(0) info = connection.getStatusString() @@ -539,7 +543,11 @@ class printWindowBasic(wx.Frame): self._updateButtonStates() onGoingPrint = connection.isPrinting() or connection.isPaused() if onGoingPrint: - self.progress.SetValue(connection.getPrintProgress() * 1000) + (current, total, z) = connection.getPrintProgress() + progress = 0.0 + if total > 0: + progress = float(current) / float(total) + self.progress.SetValue(progress * 1000) else: self.progress.SetValue(0) info = connection.getStatusString() @@ -665,6 +673,7 @@ class printWindowAdvanced(wx.Frame): self.temperatureBedField = TemperatureField(self.panel, self._setBedTemperature) self.temperatureGraph = TemperatureGraph(self.panel) self.temperatureGraph.SetMinSize((250, 100)) + self.printStatus = wx.StaticText(parent=self.panel, id=-1, label=""); self.progress = wx.Gauge(self.panel, -1, range=1000) f = wx.Font(8, wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False) @@ -692,7 +701,8 @@ class printWindowAdvanced(wx.Frame): self.sizer.Add(self.temperatureBedField, pos=(5, 2)) self.sizer.Add(self._termLog, pos=(0, 3), span=(5, 3), flag=wx.EXPAND|wx.RIGHT, border=5) self.sizer.Add(self._termInput, pos=(5, 3), span=(1, 3), flag=wx.EXPAND|wx.RIGHT, border=5) - self.sizer.Add(self.progress, pos=(6, 0), span=(1, 6), flag=wx.EXPAND|wx.BOTTOM) + self.sizer.Add(self.printStatus, pos=(6, 0), span=(1, 6), flag=wx.EXPAND|wx.BOTTOM|wx.TOP, border=5) + self.sizer.Add(self.progress, pos=(7, 0), span=(1, 6), flag=wx.EXPAND|wx.BOTTOM) self.Bind(wx.EVT_SIZE, self.OnSize) self.Bind(wx.EVT_CLOSE, self.OnClose) @@ -937,7 +947,12 @@ class printWindowAdvanced(wx.Frame): self._updateButtonStates() isPrinting = connection.isPrinting() or connection.isPaused() if isPrinting: - self.progress.SetValue(connection.getPrintProgress() * 1000) + (current, total, z) = connection.getPrintProgress() + progress = 0.0 + if total > 0: + progress = float(current) / float(total) + self.progress.SetValue(progress * 1000) + self.printStatus.SetLabel(_("Printing %.2f%% | Line %d of %d lines | Z: %.3f mm") % (progress * 100, current, total, z)) else: self.progress.SetValue(0) info = connection.getStatusString() diff --git a/Cura/serialCommunication.py b/Cura/serialCommunication.py index 4add5f23..1b095484 100644 --- a/Cura/serialCommunication.py +++ b/Cura/serialCommunication.py @@ -48,7 +48,7 @@ class serialComm(object): sys.stdout.write('progress:%d\n' % (lineNr)) def mcZChange(self, newZ): - pass + sys.stdout.write('changeZ:%f\n' % (newZ)) def monitorStdin(self): while not (self._comm.isClosed() or sys.stdin.closed): diff --git a/Cura/util/printerConnection/dummyConnection.py b/Cura/util/printerConnection/dummyConnection.py index cf148f69..37124bff 100644 --- a/Cura/util/printerConnection/dummyConnection.py +++ b/Cura/util/printerConnection/dummyConnection.py @@ -80,9 +80,7 @@ class dummyConnection(printerConnectionBase.printerConnectionBase): #Amount of progression of the current print file. 0.0 to 1.0 def getPrintProgress(self): - if self._lineCount < 1: - return 0.0 - return float(self._progressLine) / float(self._lineCount) + return (self._progressLine, self._lineCount, 0.0) # Return if the printer with this connection type is available def isAvailable(self): diff --git a/Cura/util/printerConnection/printerConnectionBase.py b/Cura/util/printerConnection/printerConnectionBase.py index 207131ce..15581ce6 100644 --- a/Cura/util/printerConnection/printerConnectionBase.py +++ b/Cura/util/printerConnection/printerConnectionBase.py @@ -65,9 +65,9 @@ class printerConnectionBase(object): def isPrinting(self): return False - #Amount of progression of the current print file. 0.0 to 1.0 + #Amount of progression of the current print file. Returns (current line, total lines, current Z position) def getPrintProgress(self): - return 0.0 + return (0, 0, 0.0) #Returns true if we need to establish an active connection. # Depending on the type of the connection some types do not need an active connection (Doodle3D WiFi Box for example) diff --git a/Cura/util/printerConnection/serialConnection.py b/Cura/util/printerConnection/serialConnection.py index dccaaed8..a2ecf76f 100644 --- a/Cura/util/printerConnection/serialConnection.py +++ b/Cura/util/printerConnection/serialConnection.py @@ -67,6 +67,8 @@ class serialConnection(printerConnectionBase.printerConnectionBase): self._commState = None self._commStateString = None self._gcodeData = [] + self._printProgress = 0 + self._ZPosition = 0 #Load the data into memory for printing, returns True on success def loadGCodeData(self, dataStream): @@ -94,6 +96,7 @@ class serialConnection(printerConnectionBase.printerConnectionBase): self._process.stdin.write('G:%s\n' % (line)) self._process.stdin.write('START\n') self._printProgress = 0 + self._ZPosition = 0 def coolDown(self): cooldown_toolhead = "M104 S0" @@ -130,13 +133,14 @@ class serialConnection(printerConnectionBase.printerConnectionBase): def pause(self, value): if not (self.isPrinting() or self.isPaused()) or self._process is None: return - self._process.stdin.write('PAUSE\n' if value else "RESUME\n") + if value: + self._process.stdin.write("PAUSE\n") + else: + self._process.stdin.write("RESUME\n") #Amount of progression of the current print file. 0.0 to 1.0 def getPrintProgress(self): - if len(self._gcodeData) < 1: - return 0.0 - return float(self._printProgress) / float(len(self._gcodeData)) + return (self._printProgress, len(self._gcodeData), self._ZPosition) # Return if the printer with this connection type is available def isAvailable(self): @@ -240,6 +244,9 @@ class serialConnection(printerConnectionBase.printerConnectionBase): elif line[0] == 'progress': self._printProgress = int(line[1]) self._doCallback() + elif line[0] == 'changeZ': + self._ZPosition = float(line[1]) + self._doCallback() else: print line line = self._process.stdout.readline()