chiark / gitweb /
Update on the machine checkup wizard, better indicate what is happening.
authordaid303 <daid303@gmail.com>
Wed, 3 Oct 2012 08:55:58 +0000 (10:55 +0200)
committerdaid303 <daid303@gmail.com>
Wed, 3 Oct 2012 08:55:58 +0000 (10:55 +0200)
Cura/example/Attribution.txt
Cura/gui/configWizard.py
Cura/images/attention.png [new file with mode: 0644]
Cura/images/busy-0.png [new file with mode: 0644]
Cura/images/busy-1.png [new file with mode: 0644]
Cura/images/busy-2.png [new file with mode: 0644]
Cura/images/busy-3.png [new file with mode: 0644]
Cura/images/error.png [new file with mode: 0644]
Cura/images/ready.png [new file with mode: 0644]

index 1ff46805a91d4d517494d3a9228bdfc05ec28745..27be0baaf54574847745f030c6aa3e6c1100fe0e 100644 (file)
@@ -9,4 +9,4 @@ The below models are shared under the CC BY-NC 3.0 license (http://creativecommo
 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
+  http://www.thingiverse.com/thing:22819\r
index 0d49af3014218c9825a9d660121a81c96177338d..105e77f8df64f1d147676f8538736d0c92b42e9c 100644 (file)
@@ -9,6 +9,70 @@ from gui import toolbarUtil
 from util import machineCom\r
 from util import profile\r
 \r
+class InfoBox(wx.Panel):\r
+       def __init__(self, parent):\r
+               super(InfoBox, self).__init__(parent)\r
+               self.SetBackgroundColour('#FFFF80')\r
+               \r
+               self.sizer = wx.GridBagSizer(5, 5)\r
+               self.SetSizer(self.sizer)\r
+               \r
+               self.attentionBitmap = toolbarUtil.getBitmapImage('attention.png')\r
+               self.errorBitmap = toolbarUtil.getBitmapImage('error.png')\r
+               self.readyBitmap = toolbarUtil.getBitmapImage('ready.png')\r
+               self.busyBitmap = [toolbarUtil.getBitmapImage('busy-0.png'), toolbarUtil.getBitmapImage('busy-1.png'), toolbarUtil.getBitmapImage('busy-2.png'), toolbarUtil.getBitmapImage('busy-3.png')]\r
+               \r
+               self.bitmap = wx.StaticBitmap(self, -1, wx.EmptyBitmapRGBA(24, 24, red=255, green=255, blue=255, alpha=1))\r
+               self.text = wx.StaticText(self, -1, '')\r
+               self.sizer.Add(self.bitmap, pos=(0,0), flag=wx.ALL, border=5)\r
+               self.sizer.Add(self.text, pos=(0,1), flag=wx.TOP|wx.BOTTOM|wx.ALIGN_CENTER_VERTICAL, border=5)\r
+               \r
+               self.busyState = None\r
+               self.timer = wx.Timer(self)\r
+               self.Bind(wx.EVT_TIMER, self.doBusyUpdate, self.timer)\r
+               self.timer.Start(100)\r
+\r
+       def SetInfo(self, info):\r
+               self.SetBackgroundColour('#FFFF80')\r
+               self.text.SetLabel(info)\r
+               self.Refresh()\r
+\r
+       def SetError(self, info):\r
+               self.SetBackgroundColour('#FF8080')\r
+               self.text.SetLabel(info)\r
+               self.SetErrorIndicator()\r
+               self.Refresh()\r
+       \r
+       def SetAttention(self, info):\r
+               self.SetBackgroundColour('#FFFF80')\r
+               self.text.SetLabel(info)\r
+               self.SetAttentionIndicator()\r
+               self.Refresh()\r
+       \r
+       def SetBusyIndicator(self):\r
+               self.busyState = 0\r
+               self.bitmap.SetBitmap(self.busyBitmap[self.busyState])\r
+       \r
+       def doBusyUpdate(self, e):\r
+               if self.busyState == None:\r
+                       return\r
+               self.busyState += 1\r
+               if self.busyState >= len(self.busyBitmap):\r
+                       self.busyState = 0\r
+               self.bitmap.SetBitmap(self.busyBitmap[self.busyState])\r
+       \r
+       def SetReadyIndicator(self):\r
+               self.busyState = None\r
+               self.bitmap.SetBitmap(self.readyBitmap)\r
+       \r
+       def SetErrorIndicator(self):\r
+               self.busyState = None\r
+               self.bitmap.SetBitmap(self.errorBitmap)\r
+       \r
+       def SetAttentionIndicator(self):\r
+               self.busyState = None\r
+               self.bitmap.SetBitmap(self.attentionBitmap)\r
+\r
 class InfoPage(wx.wizard.WizardPageSimple):\r
        def __init__(self, parent, title):\r
                wx.wizard.WizardPageSimple.__init__(self, parent)\r
@@ -37,6 +101,12 @@ class InfoPage(wx.wizard.WizardPageSimple):
        \r
        def AddHiddenSeperator(self):\r
                self.AddText('')\r
+\r
+       def AddInfoBox(self):\r
+               infoBox = InfoBox(self)\r
+               self.GetSizer().Add(infoBox, pos=(self.rowNr, 0), span=(1,2), flag=wx.LEFT|wx.RIGHT|wx.EXPAND)\r
+               self.rowNr += 1\r
+               return infoBox\r
        \r
        def AddRadioButton(self, label, style = 0):\r
                radio = wx.RadioButton(self, -1, label, style=style)\r
@@ -221,9 +291,16 @@ class UltimakerCheckupPage(InfoPage):
                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.infoBox = self.AddInfoBox()\r
                self.machineState = self.AddText('')\r
                self.temperatureLabel = self.AddText('')\r
+               self.AddSeperator()\r
+               self.xMinState = self.AddCheckmark('X stop left:', self.unknownBitmap)\r
+               self.xMaxState = self.AddCheckmark('X stop right:', self.unknownBitmap)\r
+               self.yMinState = self.AddCheckmark('Y stop front:', self.unknownBitmap)\r
+               self.yMaxState = self.AddCheckmark('Y stop back:', self.unknownBitmap)\r
+               self.zMinState = self.AddCheckmark('Z stop top:', self.unknownBitmap)\r
+               self.zMaxState = self.AddCheckmark('Z stop bottom:', self.unknownBitmap)\r
                self.comm = None\r
                self.xMinStop = False\r
                self.xMaxStop = False\r
@@ -232,6 +309,10 @@ class UltimakerCheckupPage(InfoPage):
                self.zMinStop = False\r
                self.zMaxStop = False\r
 \r
+       def __del__(self):\r
+               if self.comm != None:\r
+                       self.comm.close()\r
+       \r
        def AllowNext(self):\r
                return False\r
        \r
@@ -242,7 +323,8 @@ class UltimakerCheckupPage(InfoPage):
                if self.comm != None:\r
                        self.comm.close()\r
                        del self.comm\r
-               wx.CallAfter(self.checkState.SetLabel, 'Connecting to machine.')\r
+               self.infoBox.SetInfo('Connecting to machine.')\r
+               self.infoBox.SetBusyIndicator()\r
                self.commState.SetBitmap(self.unknownBitmap)\r
                self.tempState.SetBitmap(self.unknownBitmap)\r
                self.stopState.SetBitmap(self.unknownBitmap)\r
@@ -250,56 +332,60 @@ class UltimakerCheckupPage(InfoPage):
                self.comm = machineCom.MachineCom(callbackObject=self)\r
 \r
        def mcLog(self, message):\r
-               print message\r
+               pass\r
 \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
+                               wx.CallAfter(self.infoBox.SetInfo, '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
+                               wx.CallAfter(self.infoBox.SetInfo, '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
+                               wx.CallAfter(self.infoBox.SetInfo, 'Checking the heater and temperature sensor.')\r
                                self.comm.sendCommand('M104 S200')\r
                                self.comm.sendCommand('M104 S200')\r
                elif self.checkupState == 2:\r
+                       print "WARNING, TEMPERATURE TEST DISABLED FOR TESTING!"\r
                        if temp > self.startTemp:# + 40:\r
                                self.checkupState = 3\r
-                               wx.CallAfter(self.checkState.SetLabel, 'Testing the endstops...')\r
+                               wx.CallAfter(self.infoBox.SetAttention, 'Please make sure none of the endstops are pressed.')\r
                                self.comm.sendCommand('M104 S0')\r
                                self.comm.sendCommand('M104 S0')\r
                                self.comm.sendCommand('M119')\r
-                               self.tempState.SetBitmap(self.checkBitmap)\r
+                               wx.CallAfter(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
+                                       wx.CallAfter(self.tempState.SetBitmap, self.crossBitmap)\r
+                                       wx.CallAfter(self.infoBox.SetError, '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
        def mcStateChange(self, state):\r
+               if self.comm == None:\r
+                       return\r
                if self.comm.isOperational():\r
-                       self.commState.SetBitmap(self.checkBitmap)\r
+                       wx.CallAfter(self.commState.SetBitmap, self.checkBitmap)\r
                elif self.comm.isError():\r
-                       self.commState.SetBitmap(self.crossBitmap)\r
+                       wx.CallAfter(self.commState.SetBitmap, self.crossBitmap)\r
+                       wx.CallAfter(self.infoBox.SetError, 'Failed to establish connection with the printer.')\r
                wx.CallAfter(self.machineState.SetLabel, 'Communication State: %s' % (self.comm.getStateString()))\r
        \r
        def mcMessage(self, message):\r
-               if self.checkupState >= 3 and 'x_min' in message:\r
+               if self.checkupState >= 3 and self.checkupState < 10 and 'x_min' in message:\r
                        for data in message.split(' '):\r
                                if ':' in data:\r
                                        tag, value = data.split(':', 2)\r
@@ -316,6 +402,64 @@ class UltimakerCheckupPage(InfoPage):
                                        if tag == 'z_max':\r
                                                self.zMaxStop = (value == 'H')\r
                        self.comm.sendCommand('M119')\r
+                       \r
+                       if self.xMinStop:\r
+                               self.xMinState.SetBitmap(self.checkBitmap)\r
+                       else:\r
+                               self.xMinState.SetBitmap(self.crossBitmap)\r
+                       if self.xMaxStop:\r
+                               self.xMaxState.SetBitmap(self.checkBitmap)\r
+                       else:\r
+                               self.xMaxState.SetBitmap(self.crossBitmap)\r
+                       if self.yMinStop:\r
+                               self.yMinState.SetBitmap(self.checkBitmap)\r
+                       else:\r
+                               self.yMinState.SetBitmap(self.crossBitmap)\r
+                       if self.yMaxStop:\r
+                               self.yMaxState.SetBitmap(self.checkBitmap)\r
+                       else:\r
+                               self.yMaxState.SetBitmap(self.crossBitmap)\r
+                       if self.zMinStop:\r
+                               self.zMinState.SetBitmap(self.checkBitmap)\r
+                       else:\r
+                               self.zMinState.SetBitmap(self.crossBitmap)\r
+                       if self.zMaxStop:\r
+                               self.zMaxState.SetBitmap(self.checkBitmap)\r
+                       else:\r
+                               self.zMaxState.SetBitmap(self.crossBitmap)\r
+                       \r
+                       if self.checkupState == 3:\r
+                               if not self.xMinStop and not self.xMaxStop and not self.yMinStop and not self.yMaxStop and not self.zMinStop and not self.zMaxStop:\r
+                                       self.checkupState = 4\r
+                                       wx.CallAfter(self.infoBox.SetAttention, 'Please press the left X endstop.')\r
+                       elif self.checkupState == 4:\r
+                               if self.xMinStop and not self.xMaxStop and not self.yMinStop and not self.yMaxStop and not self.zMinStop and not self.zMaxStop:\r
+                                       self.checkupState = 5\r
+                                       wx.CallAfter(self.infoBox.SetAttention, 'Please press the right X endstop.')\r
+                       elif self.checkupState == 5:\r
+                               if not self.xMinStop and self.xMaxStop and not self.yMinStop and not self.yMaxStop and not self.zMinStop and not self.zMaxStop:\r
+                                       self.checkupState = 6\r
+                                       wx.CallAfter(self.infoBox.SetAttention, 'Please press the front Y endstop.')\r
+                       elif self.checkupState == 6:\r
+                               if not self.xMinStop and not self.xMaxStop and self.yMinStop and not self.yMaxStop and not self.zMinStop and not self.zMaxStop:\r
+                                       self.checkupState = 7\r
+                                       wx.CallAfter(self.infoBox.SetAttention, 'Please press the back Y endstop.')\r
+                       elif self.checkupState == 7:\r
+                               if not self.xMinStop and not self.xMaxStop and not self.yMinStop and self.yMaxStop and not self.zMinStop and not self.zMaxStop:\r
+                                       self.checkupState = 8\r
+                                       wx.CallAfter(self.infoBox.SetAttention, 'Please press the top Z endstop.')\r
+                       elif self.checkupState == 8:\r
+                               if not self.xMinStop and not self.xMaxStop and not self.yMinStop and not self.yMaxStop and self.zMinStop and not self.zMaxStop:\r
+                                       self.checkupState = 9\r
+                                       wx.CallAfter(self.infoBox.SetAttention, 'Please press the bottom Z endstop.')\r
+                       elif self.checkupState == 9:\r
+                               if not self.xMinStop and not self.xMaxStop and not self.yMinStop and not self.yMaxStop and not self.zMinStop and self.zMaxStop:\r
+                                       self.checkupState = 10\r
+                                       self.comm.close()\r
+                                       wx.CallAfter(self.infoBox.SetInfo, 'Checkup finished')\r
+                                       wx.CallAfter(self.infoBox.SetReadyIndicator)\r
+                                       wx.CallAfter(self.stopState.SetBitmap, self.checkBitmap)\r
+                                       wx.CallAfter(self.OnSkipClick, None)\r
 \r
        def mcProgress(self, lineNr):\r
                pass\r
diff --git a/Cura/images/attention.png b/Cura/images/attention.png
new file mode 100644 (file)
index 0000000..6856987
Binary files /dev/null and b/Cura/images/attention.png differ
diff --git a/Cura/images/busy-0.png b/Cura/images/busy-0.png
new file mode 100644 (file)
index 0000000..dfb9142
Binary files /dev/null and b/Cura/images/busy-0.png differ
diff --git a/Cura/images/busy-1.png b/Cura/images/busy-1.png
new file mode 100644 (file)
index 0000000..1a917f4
Binary files /dev/null and b/Cura/images/busy-1.png differ
diff --git a/Cura/images/busy-2.png b/Cura/images/busy-2.png
new file mode 100644 (file)
index 0000000..9de5bd8
Binary files /dev/null and b/Cura/images/busy-2.png differ
diff --git a/Cura/images/busy-3.png b/Cura/images/busy-3.png
new file mode 100644 (file)
index 0000000..d61f905
Binary files /dev/null and b/Cura/images/busy-3.png differ
diff --git a/Cura/images/error.png b/Cura/images/error.png
new file mode 100644 (file)
index 0000000..997964e
Binary files /dev/null and b/Cura/images/error.png differ
diff --git a/Cura/images/ready.png b/Cura/images/ready.png
new file mode 100644 (file)
index 0000000..6366220
Binary files /dev/null and b/Cura/images/ready.png differ