From 2f2ad64b520d8dd1e4996ddb56628e7ea1560f2d Mon Sep 17 00:00:00 2001 From: daid Date: Mon, 2 Dec 2013 15:55:09 +0100 Subject: [PATCH 1/1] Fix temperature graph in printwindow2. Add CURA_PROFILE_STRING to UM2 GCode. Add direct-commands to Doodle3D connection. Fix print order. --- Cura/gui/printWindow2.py | 11 +++++++++ Cura/util/objectScene.py | 2 +- .../util/printerConnection/doodle3dConnect.py | 23 +++++++++++++++---- Cura/util/profile.py | 2 +- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/Cura/gui/printWindow2.py b/Cura/gui/printWindow2.py index 271bab80..0c304ace 100644 --- a/Cura/gui/printWindow2.py +++ b/Cura/gui/printWindow2.py @@ -296,6 +296,9 @@ class printWindow(wx.Frame): def _doPrinterConnectionUpdate(self, connection, extraInfo = None): wx.CallAfter(self.__doPrinterConnectionUpdate, connection, extraInfo) + temp = [connection.getTemperature(0)] + self.temperatureGraph.addPoint(temp, [0], connection.getBedTemperature(), 0) + def __doPrinterConnectionUpdate(self, connection, extraInfo): t = time.time() if self.lastUpdateTime + 0.5 > t: @@ -487,6 +490,14 @@ class TemperatureGraph(wx.Panel): self._points.pop(0) def addPoint(self, temp, tempSP, bedTemp, bedTempSP): + if time.time() - self._points[-1][4] < 0.5: + return + for n in xrange(0, len(temp)): + if temp[n] is None: + temp[n] = 0 + for n in xrange(0, len(tempSP)): + if tempSP[n] is None: + tempSP[n] = 0 if bedTemp is None: bedTemp = 0 if bedTempSP is None: diff --git a/Cura/util/objectScene.py b/Cura/util/objectScene.py index ab9319ab..f7388b2a 100644 --- a/Cura/util/objectScene.py +++ b/Cura/util/objectScene.py @@ -82,7 +82,7 @@ class _objectOrderFinder(object): def _checkHit(self, addIdx, idx): obj = self._scene._objectList[idx] addObj = self._scene._objectList[addIdx] - return polygon.polygonCollision(obj._headAreaHull + obj.getPosition(), addObj._boundaryHull + addObj.getPosition()) + return polygon.polygonCollision(obj._boundaryHull + obj.getPosition(), addObj._headAreaHull + addObj.getPosition()) class Scene(object): def __init__(self): diff --git a/Cura/util/printerConnection/doodle3dConnect.py b/Cura/util/printerConnection/doodle3dConnect.py index 5fa69f64..1cad17e3 100644 --- a/Cura/util/printerConnection/doodle3dConnect.py +++ b/Cura/util/printerConnection/doodle3dConnect.py @@ -22,6 +22,7 @@ class doodle3dConnect(printerConnectionBase.printerConnectionBase): self._isAvailable = False self._printing = False self._fileBlocks = [] + self._commandList = [] self._blockIndex = None self._lineCount = 0 self._progressLine = 0 @@ -91,14 +92,24 @@ class doodle3dConnect(printerConnectionBase.printerConnectionBase): def isAvailable(self): return self._isAvailable + #Are we able to send a direct coammand with sendCommand at this moment in time. + def isAbleToSendDirectCommand(self): + return self._isAvailable and not self._printing + + #Directly send a command to the printer. + def sendCommand(self, command): + if not self._isAvailable or self._printing: + return + self._commandList.append(command) + # Get the connection status string. This is displayed to the user and can be used to communicate # various information to the user. def getStatusString(self): if not self._isAvailable: return "Doodle3D box not found" if self._printing: - if self._fileIndex < len(self._fileBlocks): - return "Sending GCode: %.1f" % (float(self._fileIndex) / float(len(self._fileBlocks))) + if self._blockIndex < len(self._fileBlocks): + return "Sending GCode: %.1f" % (float(self._blockIndex) / float(len(self._fileBlocks))) return "TODO" #Get the temperature of an extruder, returns None is no temperature is known for this extruder @@ -164,7 +175,11 @@ class doodle3dConnect(printerConnectionBase.printerConnectionBase): else: self._printing = False else: - time.sleep(5) + if len(self._commandList) > 0: + if self._request('POST', '/d3dapi/printer/print', {'gcode': self._commandList[0], 'start': 'True', 'first': 'True'}): + self._commandList.pop(0) + else: + time.sleep(5) elif stateReply['data']['state'] == 'printing': if self._printing: if self._blockIndex < len(self._fileBlocks): @@ -181,7 +196,7 @@ class doodle3dConnect(printerConnectionBase.printerConnectionBase): self._progressLine = stateReply['data']['current_line'] else: #Got a printing state without us having send the print file, set the state to printing, but make sure we never send anything. - if 'current_line' in stateReply['data'] and 'total_lines' in stateReply['data']: + if 'current_line' in stateReply['data'] and 'total_lines' in stateReply['data'] and stateReply['data']['total_lines'] > 2: self._printing = True self._blockIndex = len(self._fileBlocks) self._progressLine = stateReply['data']['current_line'] diff --git a/Cura/util/profile.py b/Cura/util/profile.py index 475f9655..65128f0d 100644 --- a/Cura/util/profile.py +++ b/Cura/util/profile.py @@ -961,7 +961,7 @@ def getAlterationFileContents(filename, extruderCount = 1): alterationContents = getAlterationFile(filename) if getMachineSetting('gcode_flavor') == 'UltiGCode': if filename == 'end.gcode': - return 'M25 ;Stop reading from this point on.\n' + return 'M25 ;Stop reading from this point on.\n;CURA_PROFILE_STRING:%s\n' % (getProfileString()) return '' if filename == 'start.gcode': if extruderCount > 1: -- 2.30.2