chiark / gitweb /
Large update to the config wizard, new style machine check (unfinished)
authordaid303 <daid303@gmail.com>
Tue, 2 Oct 2012 14:06:47 +0000 (16:06 +0200)
committerdaid303 <daid303@gmail.com>
Tue, 2 Oct 2012 14:06:47 +0000 (16:06 +0200)
Cura/example/Attribution.txt
Cura/example/UltimakerHandle.stl [new file with mode: 0644]
Cura/gui/configWizard.py
Cura/gui/preview3d.py
Cura/gui/printWindow.py
Cura/gui/projectPlanner.py
Cura/images/checkmark.png [new file with mode: 0644]
Cura/images/cross.png [new file with mode: 0644]
Cura/images/question.png [new file with mode: 0644]
Cura/util/machineCom.py

index 09c83d601c3fcaf80d69a03a7ca867640421b3db..1ff46805a91d4d517494d3a9228bdfc05ec28745 100644 (file)
@@ -1,8 +1,12 @@
-All the models in this example directory can be found on Thingiverse (www.thingiverse.com), a site for sharing digital designs for physical objects.  Sharing is fun!
-
-The below models are shared under the CC BY-NC 3.0 license (http://creativecommons.org/licenses/by-nc/3.0/), and can be shared and used freely for none-commercial purposes:
-
-* UltimakerRobotCourseMesh.stl: Ultimaker Robot Low Poly by polymaker
-  http://www.thingiverse.com/thing:14472
-    Derivative of Ultimaker Robot by Martijn: http://www.thingiverse.com/thing:11551
-
+All the models in this example directory can be found on Thingiverse (www.thingiverse.com), a site for sharing digital designs for physical objects.  Sharing is fun!\r
+\r
+The below models are shared under the CC BY-NC 3.0 license (http://creativecommons.org/licenses/by-nc/3.0/), and can be shared and used freely for none-commercial purposes as long as attribution is added:\r
+\r
+* UltimakerRobotCourseMesh.stl: Ultimaker Robot Low Poly by polymaker\r
+  http://www.thingiverse.com/thing:14472\r
+  Derivative of Ultimaker Robot by Martijn: http://www.thingiverse.com/thing:11551\r
+\r
+The below models are shared under the CC BY-SA 3.0 license (http://creativecommons.org/licenses/by-sa/3.0/), and can be shared and used freely as long as attribution is added:\r
+\r
+* UltimakerHandle.stl: Ultimaker handle by Silvius\r
+  http://www.thingiverse.com/thing:22819
\ No newline at end of file
diff --git a/Cura/example/UltimakerHandle.stl b/Cura/example/UltimakerHandle.stl
new file mode 100644 (file)
index 0000000..b8251cc
Binary files /dev/null and b/Cura/example/UltimakerHandle.stl differ
index 21dd54c8eaae861956c3c195cea3b674ce7fec9f..0d49af3014218c9825a9d660121a81c96177338d 100644 (file)
@@ -5,6 +5,7 @@ import wx, os, platform, types, webbrowser, threading, time, re
 import wx.wizard\r
 \r
 from gui import firmwareInstall\r
+from gui import toolbarUtil\r
 from util import machineCom\r
 from util import profile\r
 \r
@@ -87,6 +88,14 @@ class InfoPage(wx.wizard.WizardPageSimple):
                self.GetSizer().Add(button, pos=(self.rowNr, 1), span=(1,1), flag=wx.LEFT)\r
                self.rowNr += 1\r
                return text, button\r
+\r
+       def AddCheckmark(self, label, bitmap):\r
+               check = wx.StaticBitmap(self, -1, bitmap)\r
+               text = wx.StaticText(self, -1, label)\r
+               self.GetSizer().Add(text, pos=(self.rowNr, 0), span=(1,1), flag=wx.LEFT|wx.RIGHT)\r
+               self.GetSizer().Add(check, pos=(self.rowNr, 1), span=(1,2), flag=wx.ALL)\r
+               self.rowNr += 1\r
+               return check\r
                \r
        def AllowNext(self):\r
                return True\r
@@ -102,7 +111,8 @@ class FirstInfoPage(InfoPage):
                self.AddText('This wizard will help you with the following steps:')\r
                self.AddText('* Configure Cura for your machine')\r
                self.AddText('* Upgrade your firmware')\r
-               self.AddText('* Calibrate your machine')\r
+               self.AddText('* Check if your machine is working safely')\r
+               #self.AddText('* Calibrate your machine')\r
                #self.AddText('* Do your first print')\r
 \r
 class RepRapInfoPage(InfoPage):\r
@@ -204,8 +214,24 @@ class UltimakerCheckupPage(InfoPage):
                b1.Bind(wx.EVT_BUTTON, self.OnCheckClick)\r
                b2.Bind(wx.EVT_BUTTON, self.OnSkipClick)\r
                self.AddSeperator()\r
-               self.checkPanel = None\r
-       \r
+               self.checkBitmap = toolbarUtil.getBitmapImage('checkmark.png')\r
+               self.crossBitmap = toolbarUtil.getBitmapImage('cross.png')\r
+               self.unknownBitmap = toolbarUtil.getBitmapImage('question.png')\r
+               self.commState = self.AddCheckmark('Communication:', self.unknownBitmap)\r
+               self.tempState = self.AddCheckmark('Temperature:', self.unknownBitmap)\r
+               self.stopState = self.AddCheckmark('Endstops:', self.unknownBitmap)\r
+               self.AddSeperator()\r
+               self.checkState = self.AddText('')\r
+               self.machineState = self.AddText('')\r
+               self.temperatureLabel = self.AddText('')\r
+               self.comm = None\r
+               self.xMinStop = False\r
+               self.xMaxStop = False\r
+               self.yMinStop = False\r
+               self.yMaxStop = False\r
+               self.zMinStop = False\r
+               self.zMaxStop = False\r
+\r
        def AllowNext(self):\r
                return False\r
        \r
@@ -213,152 +239,89 @@ class UltimakerCheckupPage(InfoPage):
                self.GetParent().FindWindowById(wx.ID_FORWARD).Enable()\r
        \r
        def OnCheckClick(self, e):\r
-               if self.checkPanel != None:\r
-                       self.checkPanel.Destroy()\r
-               self.checkPanel = wx.Panel(self)\r
-               self.checkPanel.SetSizer(wx.BoxSizer(wx.VERTICAL))\r
-               self.GetSizer().Add(self.checkPanel, 0, wx.LEFT|wx.RIGHT, 5)\r
-               threading.Thread(target=self.OnRun).start()\r
-\r
-       def AddProgressText(self, info):\r
-               text = wx.StaticText(self.checkPanel, -1, info)\r
-               self.checkPanel.GetSizer().Add(text, 0)\r
-               self.checkPanel.Layout()\r
-               self.Layout()\r
-       \r
-       def OnRun(self):\r
-               wx.CallAfter(self.AddProgressText, "Connecting to machine...")\r
-               self.comm = machineCom.MachineCom()\r
-               \r
-               if not self.comm.isOpen():\r
-                       wx.CallAfter(self.AddProgressText, "Error: Failed to open serial port to machine")\r
-                       wx.CallAfter(self.AddProgressText, "If this keeps happening, try disconnecting and reconnecting the USB cable")\r
-                       return\r
-\r
-               wx.CallAfter(self.AddProgressText, "Checking start message...")\r
-               if self.DoCommCommandWithTimeout(None, 'start') == False:\r
-                       wx.CallAfter(self.AddProgressText, "Error: Missing start message.")\r
+               if self.comm != None:\r
                        self.comm.close()\r
-                       return\r
-               \r
-               #Wait 3 seconds for the SD card init to timeout if we have SD in our firmware but there is no SD card found.\r
-               time.sleep(3)\r
-               \r
-               wx.CallAfter(self.AddProgressText, "Disabling step motors...")\r
-               if self.DoCommCommandWithTimeout('M84') == False:\r
-                       wx.CallAfter(self.AddProgressText, "Error: Missing reply to Deactivate steppers (M84).")\r
-                       self.comm.close()\r
-                       return\r
+                       del self.comm\r
+               wx.CallAfter(self.checkState.SetLabel, 'Connecting to machine.')\r
+               self.commState.SetBitmap(self.unknownBitmap)\r
+               self.tempState.SetBitmap(self.unknownBitmap)\r
+               self.stopState.SetBitmap(self.unknownBitmap)\r
+               self.checkupState = 0\r
+               self.comm = machineCom.MachineCom(callbackObject=self)\r
 \r
-               if self.DoCommCommandWithTimeout("M104 S0") == False:\r
-                       wx.CallAfter(self.AddProgressText, "Failed to set temperature")\r
-                       self.comm.close()\r
-                       return\r
-\r
-               wx.MessageBox('Please move the printer head to the center of the machine\nalso move the platform so it is not at the highest or lowest position,\nand make sure the machine is powered on.', 'Machine check', wx.OK | wx.ICON_INFORMATION)\r
-               \r
-               idleTemp = self.readTemp()\r
-               if idleTemp > 40:\r
-                       wx.CallAfter(self.AddProgressText, "Waiting for head to cool down before temperature test...")\r
-                       while idleTemp > 40:\r
-                               idleTemp = self.readTemp()\r
-                               time.sleep(1)\r
-               \r
-               wx.CallAfter(self.AddProgressText, "Checking heater and temperature sensor...")\r
-               wx.CallAfter(self.AddProgressText, "(This takes about 30 seconds)")\r
-               if self.DoCommCommandWithTimeout("M104 S100") == False:\r
-                       wx.CallAfter(self.AddProgressText, "Failed to set temperature")\r
-                       self.comm.close()\r
-                       return\r
-               \r
-               time.sleep(25)\r
-               tempInc = self.readTemp() - idleTemp\r
-               \r
-               if self.DoCommCommandWithTimeout("M104 S0") == False:\r
-                       wx.CallAfter(self.AddProgressText, "Failed to set temperature")\r
-                       self.comm.close()\r
-                       return\r
-               \r
-               if tempInc < 15:\r
-                       wx.CallAfter(self.AddProgressText, "Your temperature sensor or heater is not working!")\r
-                       self.comm.close()\r
-                       return\r
-               wx.CallAfter(self.AddProgressText, "Heater and temperature sensor working\nWarning: head might still be hot!")\r
+       def mcLog(self, message):\r
+               print message\r
 \r
-               wx.CallAfter(self.AddProgressText, "Checking endstops")\r
-               if self.DoCommCommandWithTimeout('M119', 'x_min') != "x_min:L x_max:L y_min:L y_max:L z_min:L z_max:L":\r
-                       wx.CallAfter(self.AddProgressText, "Error: There is a problem in your endstops!\nOne of them seems to be pressed while it shouldn't\ncheck the cable connections and the switches themselfs.")\r
-                       self.comm.close()\r
-                       return\r
-               wx.CallAfter(self.AddProgressText, "Please press the X end switch in the front left corner.")\r
-               if not self.DoCommCommandAndWaitForReply('M119', 'x_min', "x_min:H x_max:L y_min:L y_max:L z_min:L z_max:L"):\r
-                       wx.CallAfter(self.AddProgressText, "Failed to check the x_min endstop!")\r
-                       self.comm.close()\r
-                       return\r
-               wx.CallAfter(self.AddProgressText, "Please press the X end switch in the front right corner.")\r
-               if not self.DoCommCommandAndWaitForReply('M119', 'x_min', "x_min:L x_max:H y_min:L y_max:L z_min:L z_max:L"):\r
-                       wx.CallAfter(self.AddProgressText, "Failed to check the x_max endstop!")\r
-                       self.comm.close()\r
-                       return\r
-               wx.CallAfter(self.AddProgressText, "Please press the Y end switch in the front left corner.")\r
-               if not self.DoCommCommandAndWaitForReply('M119', 'x_min', "x_min:L x_max:L y_min:H y_max:L z_min:L z_max:L"):\r
-                       wx.CallAfter(self.AddProgressText, "Failed to check the x_max endstop!")\r
-                       self.comm.close()\r
-                       return\r
-               wx.CallAfter(self.AddProgressText, "Please press the Y end switch in the back left corner.")\r
-               if not self.DoCommCommandAndWaitForReply('M119', 'x_min', "x_min:L x_max:L y_min:L y_max:H z_min:L z_max:L"):\r
-                       wx.CallAfter(self.AddProgressText, "Failed to check the x_max endstop!")\r
-                       self.comm.close()\r
-                       return\r
-               wx.CallAfter(self.AddProgressText, "Please press the Z end switch in the top.")\r
-               if not self.DoCommCommandAndWaitForReply('M119', 'x_min', "x_min:L x_max:L y_min:L y_max:L z_min:H z_max:L"):\r
-                       wx.CallAfter(self.AddProgressText, "Failed to check the x_max endstop!")\r
-                       self.comm.close()\r
-                       return\r
-               wx.CallAfter(self.AddProgressText, "Please press the Z end switch in the bottom.")\r
-               if not self.DoCommCommandAndWaitForReply('M119', 'x_min', "x_min:L x_max:L y_min:L y_max:L z_min:L z_max:H"):\r
-                       wx.CallAfter(self.AddProgressText, "Failed to check the x_max endstop!")\r
-                       self.comm.close()\r
-                       return\r
-               wx.CallAfter(self.AddProgressText, "End stops are working.")\r
+       def mcTempUpdate(self, temp, bedTemp):\r
+               if self.checkupState == 0:\r
+                       self.tempCheckTimeout = 20\r
+                       if temp > 70:\r
+                               self.checkupState = 1\r
+                               wx.CallAfter(self.checkState.SetLabel, 'Cooldown before temperature check.')\r
+                               self.comm.sendCommand('M104 S0')\r
+                               self.comm.sendCommand('M104 S0')\r
+                       else:\r
+                               self.startTemp = temp\r
+                               self.checkupState = 2\r
+                               wx.CallAfter(self.checkState.SetLabel, 'Checking the heater and temperature sensor.')\r
+                               self.comm.sendCommand('M104 S200')\r
+                               self.comm.sendCommand('M104 S200')\r
+               elif self.checkupState == 1:\r
+                       if temp < 60:\r
+                               self.startTemp = temp\r
+                               self.checkupState = 2\r
+                               wx.CallAfter(self.checkState.SetLabel, 'Checking the heater and temperature sensor.')\r
+                               self.comm.sendCommand('M104 S200')\r
+                               self.comm.sendCommand('M104 S200')\r
+               elif self.checkupState == 2:\r
+                       if temp > self.startTemp:# + 40:\r
+                               self.checkupState = 3\r
+                               wx.CallAfter(self.checkState.SetLabel, 'Testing the endstops...')\r
+                               self.comm.sendCommand('M104 S0')\r
+                               self.comm.sendCommand('M104 S0')\r
+                               self.comm.sendCommand('M119')\r
+                               self.tempState.SetBitmap(self.checkBitmap)\r
+                       else:\r
+                               self.tempCheckTimeout -= 1\r
+                               if self.tempCheckTimeout < 1:\r
+                                       self.checkupState = -1\r
+                                       self.tempState.SetBitmap(self.crossBitmap)\r
+                                       wx.CallAfter(self.checkState.SetLabel, 'Temperature measurement FAILED!')\r
+                                       self.comm.sendCommand('M104 S0')\r
+                                       self.comm.sendCommand('M104 S0')\r
+               wx.CallAfter(self.temperatureLabel.SetLabel, 'Head temperature: %d' % (temp))\r
 \r
-               wx.CallAfter(self.AddProgressText, "Done!")\r
-               wx.CallAfter(self.GetParent().FindWindowById(wx.ID_FORWARD).Enable)\r
-               self.comm.close()\r
-               \r
-       def readTemp(self):\r
-               line = self.DoCommCommandWithTimeout("M105", "ok T:")\r
-               if line == False:\r
-                       return -1\r
-               return int(re.search('T:([0-9]*)', line).group(1))\r
-       \r
-       def DoCommCommandAndWaitForReply(self, cmd, replyStart, reply):\r
-               while True:\r
-                       ret = self.DoCommCommandWithTimeout(cmd, replyStart)\r
-                       if ret == reply:\r
-                               return True\r
-                       if ret == False:\r
-                               return False\r
-                       time.sleep(1)\r
+       def mcStateChange(self, state):\r
+               if self.comm.isOperational():\r
+                       self.commState.SetBitmap(self.checkBitmap)\r
+               elif self.comm.isError():\r
+                       self.commState.SetBitmap(self.crossBitmap)\r
+               wx.CallAfter(self.machineState.SetLabel, 'Communication State: %s' % (self.comm.getStateString()))\r
        \r
-       def DoCommCommandWithTimeout(self, cmd = None, replyStart = 'ok'):\r
-               if cmd != None:\r
-                       self.comm.sendCommand(cmd)\r
-               t = threading.Timer(5, self.OnSerialTimeout)\r
-               t.start()\r
-               while True:\r
-                       line = self.comm.readline()\r
-                       if line == '' or line == None:\r
-                               self.comm.close()\r
-                               return False\r
-                       print line.rstrip()\r
-                       if replyStart in line:\r
-                               break\r
-               t.cancel()\r
-               return line.rstrip()\r
+       def mcMessage(self, message):\r
+               if self.checkupState >= 3 and 'x_min' in message:\r
+                       for data in message.split(' '):\r
+                               if ':' in data:\r
+                                       tag, value = data.split(':', 2)\r
+                                       if tag == 'x_min':\r
+                                               self.xMinStop = (value == 'H')\r
+                                       if tag == 'x_max':\r
+                                               self.xMaxStop = (value == 'H')\r
+                                       if tag == 'y_min':\r
+                                               self.yMinStop = (value == 'H')\r
+                                       if tag == 'y_max':\r
+                                               self.yMaxStop = (value == 'H')\r
+                                       if tag == 'z_min':\r
+                                               self.zMinStop = (value == 'H')\r
+                                       if tag == 'z_max':\r
+                                               self.zMaxStop = (value == 'H')\r
+                       self.comm.sendCommand('M119')\r
+\r
+       def mcProgress(self, lineNr):\r
+               pass\r
        \r
-       def OnSerialTimeout(self):\r
-               self.comm.close()\r
+       def mcZChange(self, newZ):\r
+               pass\r
 \r
 class UltimakerCalibrationPage(InfoPage):\r
        def __init__(self, parent):\r
index ac7668c845b3376357d565dfd4f1dcaa966536fa..229c520b166e07cd80eccd8457c0a5e473f5f2fd 100644 (file)
@@ -428,6 +428,7 @@ class PreviewGLCanvas(glcanvas.GLCanvas):
                self.objColor[3] = profile.getPreferenceColour('model_colour3')\r
 \r
        def OnMouseMotion(self,e):\r
+               cursorXY = 100000\r
                if self.parent.objectsMaxV != None:\r
                        size = (self.parent.objectsMaxV - self.parent.objectsMinV)\r
                        sizeXY = math.sqrt((size[0] * size[0]) + (size[1] * size[1]))\r
index 2846d5298a146c36495e6f82fe2d4cf826a57937..4eb91444057d93b7398a07bd72aaebf7c028d93f 100644 (file)
@@ -353,7 +353,10 @@ class printWindow(wx.Frame):
                        if self.currentZ > 0:\r
                                status += 'Height: %0.1f\n' % (self.currentZ)\r
                        status += 'Print time: %02d:%02d\n' % (int(printTime / 60), int(printTime % 60))\r
-                       status += 'Print time left: %02d:%02d\n' % (int(printTimeLeft / 60), int(printTimeLeft % 60))\r
+                       if printTime < 1:\r
+                               status += 'Print time left: Unknown\n'\r
+                       else:\r
+                               status += 'Print time left: %02d:%02d\n' % (int(printTimeLeft / 60), int(printTimeLeft % 60))\r
                        self.progress.SetValue(self.machineCom.getPrintPos())\r
                if self.machineCom != None:\r
                        if self.machineCom.getTemp() > 0:\r
index b9652659ccb475ca5fa11ba182fbd4ab8154a355..43ac4197934c6c7a0abef38c3727e227e911003b 100644 (file)
@@ -320,7 +320,7 @@ class projectPlanner(wx.Frame):
        def _saveCombinedSTL(self, filename):\r
                totalCount = 0\r
                for item in self.list:\r
-                       totalCount += item.vertexCount\r
+                       totalCount += item.mesh.vertexCount\r
                output = mesh.mesh()\r
                output._prepareVertexCount(totalCount)\r
                for item in self.list:\r
diff --git a/Cura/images/checkmark.png b/Cura/images/checkmark.png
new file mode 100644 (file)
index 0000000..87957b1
Binary files /dev/null and b/Cura/images/checkmark.png differ
diff --git a/Cura/images/cross.png b/Cura/images/cross.png
new file mode 100644 (file)
index 0000000..6c4386e
Binary files /dev/null and b/Cura/images/cross.png differ
diff --git a/Cura/images/question.png b/Cura/images/question.png
new file mode 100644 (file)
index 0000000..a916d6b
Binary files /dev/null and b/Cura/images/question.png differ
index 521804e530b5d62834c2a3ed4c69049308cc2423..3e3b1f7e873fce1b1a948d61c5ba2ce41a5dc4a4 100644 (file)
@@ -101,7 +101,7 @@ class VirtualPrinter():
 
 class MachineComPrintCallback(object):
        def mcLog(self, message):
-               print(message)
+               pass
        
        def mcTempUpdate(self, temp, bedTemp):
                pass
@@ -212,15 +212,15 @@ class MachineCom(object):
        def isPrinting(self):
                return self._state == self.STATE_PRINTING
        
+       def isPaused(self):
+               return self._state == self.STATE_PAUSED
+
        def getPrintPos(self):
                return self._gcodePos
        
        def getPrintTime(self):
                return time.time() - self._printStartTime - self._heatupWaitTimeLost
        
-       def isPaused(self):
-               return self._state == self.STATE_PAUSED
-       
        def getTemp(self):
                return self._temp
        
@@ -306,7 +306,7 @@ class MachineCom(object):
                                        t = time.time()
                                        self._heatupWaitTimeLost = t - self._heatupWaitStartTime
                                        self._heatupWaitStartTime = t
-                       elif line.strip() != 'ok' and self.isOperational():
+                       elif line.strip() != '' and line.strip() != 'ok' and self.isOperational():
                                self._callback.mcMessage(line)
 
                        if self._state == self.STATE_DETECT_BAUDRATE: