chiark / gitweb /
Improve the first run wizard with the communication error log, and add info buttons...
authordaid303 <daid303@gmail.com>
Tue, 4 Dec 2012 07:56:15 +0000 (08:56 +0100)
committerdaid303 <daid303@gmail.com>
Tue, 4 Dec 2012 07:56:15 +0000 (08:56 +0100)
Cura/gui/configWizard.py
Cura/util/machineCom.py

index 740832f6006c6b6b5110c172e5e823e814f3224f..50f6f8b709ac8ec88b4af5e2b1741eaeff8b7b04 100644 (file)
@@ -6,6 +6,7 @@ import wx.wizard
 \r
 from gui import firmwareInstall\r
 from gui import toolbarUtil\r
+from gui import printWindow\r
 from util import machineCom\r
 from util import profile\r
 \r
@@ -24,28 +25,40 @@ class InfoBox(wx.Panel):
                \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.extraInfoButton = wx.Button(self, -1, 'i', style=wx.BU_EXACTFIT)\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
+               self.sizer.Add(self.extraInfoButton, pos=(0,2), flag=wx.ALL|wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, border=5)\r
+               self.sizer.AddGrowableCol(1)\r
                \r
+               self.extraInfoButton.Show(False)\r
+               \r
+               self.extraInfoUrl = ''\r
                self.busyState = None\r
                self.timer = wx.Timer(self)\r
                self.Bind(wx.EVT_TIMER, self.doBusyUpdate, self.timer)\r
+               self.Bind(wx.EVT_BUTTON, self.doExtraInfo, self.extraInfoButton)\r
                self.timer.Start(100)\r
 \r
        def SetInfo(self, info):\r
                self.SetBackgroundColour('#FFFF80')\r
                self.text.SetLabel(info)\r
+               self.extraInfoButton.Show(False)\r
                self.Refresh()\r
 \r
-       def SetError(self, info):\r
+       def SetError(self, info, extraInfoUrl):\r
+               self.extraInfoUrl = extraInfoUrl\r
                self.SetBackgroundColour('#FF8080')\r
                self.text.SetLabel(info)\r
+               self.extraInfoButton.Show(True)\r
+               self.Layout()\r
                self.SetErrorIndicator()\r
                self.Refresh()\r
        \r
        def SetAttention(self, info):\r
                self.SetBackgroundColour('#FFFF80')\r
                self.text.SetLabel(info)\r
+               self.extraInfoButton.Show(False)\r
                self.SetAttentionIndicator()\r
                self.Refresh()\r
        \r
@@ -61,6 +74,9 @@ class InfoBox(wx.Panel):
                        self.busyState = 0\r
                self.bitmap.SetBitmap(self.busyBitmap[self.busyState])\r
        \r
+       def doExtraInfo(self, e):\r
+               webbrowser.open(self.extraInfoUrl)\r
+       \r
        def SetReadyIndicator(self):\r
                self.busyState = None\r
                self.bitmap.SetBitmap(self.readyBitmap)\r
@@ -310,6 +326,8 @@ class UltimakerCheckupPage(InfoPage):
                self.infoBox = self.AddInfoBox()\r
                self.machineState = self.AddText('')\r
                self.temperatureLabel = self.AddText('')\r
+               self.errorLogButton = self.AddButton('Show error log')\r
+               self.errorLogButton.Show(False)\r
                self.AddSeperator()\r
                self.endstopBitmap = self.AddBitmap(self.endStopNoneBitmap)\r
                self.comm = None\r
@@ -319,6 +337,8 @@ class UltimakerCheckupPage(InfoPage):
                self.yMaxStop = False\r
                self.zMinStop = False\r
                self.zMaxStop = False\r
+               \r
+               self.Bind(wx.EVT_BUTTON, self.OnErrorLog, self.errorLogButton)\r
 \r
        def __del__(self):\r
                if self.comm != None:\r
@@ -332,6 +352,7 @@ class UltimakerCheckupPage(InfoPage):
                self.GetParent().FindWindowById(wx.ID_FORWARD).Enable()\r
        \r
        def OnCheckClick(self, e = None):\r
+               self.errorLogButton.Show(False)\r
                if self.comm != None:\r
                        self.comm.close()\r
                        del self.comm\r
@@ -345,6 +366,9 @@ class UltimakerCheckupPage(InfoPage):
                self.stopState.SetBitmap(self.unknownBitmap)\r
                self.checkupState = 0\r
                self.comm = machineCom.MachineCom(callbackObject=self)\r
+       \r
+       def OnErrorLog(self, e):\r
+               printWindow.LogWindow('\n'.join(self.comm.getLog()))\r
 \r
        def mcLog(self, message):\r
                pass\r
@@ -388,7 +412,7 @@ class UltimakerCheckupPage(InfoPage):
                                if self.tempCheckTimeout < 1:\r
                                        self.checkupState = -1\r
                                        wx.CallAfter(self.tempState.SetBitmap, self.crossBitmap)\r
-                                       wx.CallAfter(self.infoBox.SetError, 'Temperature measurement FAILED!')\r
+                                       wx.CallAfter(self.infoBox.SetError, 'Temperature measurement FAILED!', 'http://wiki.ultimaker.com/Cura/Temperature_measurement_problems')\r
                                        self.comm.sendCommand('M104 S0')\r
                                        self.comm.sendCommand('M104 S0')\r
                wx.CallAfter(self.temperatureLabel.SetLabel, 'Head temperature: %d' % (temp))\r
@@ -398,11 +422,16 @@ class UltimakerCheckupPage(InfoPage):
                        return\r
                if self.comm.isOperational():\r
                        wx.CallAfter(self.commState.SetBitmap, self.checkBitmap)\r
+                       wx.CallAfter(self.machineState.SetLabel, 'Communication State: %s' % (self.comm.getStateString()))\r
                elif self.comm.isError():\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.infoBox.SetError, 'Failed to establish connection with the printer.', 'http://wiki.ultimaker.com/Cura/Connection_problems')\r
                        wx.CallAfter(self.endstopBitmap.Show, False)\r
-               wx.CallAfter(self.machineState.SetLabel, 'Communication State: %s' % (self.comm.getStateString()))\r
+                       wx.CallAfter(self.machineState.SetLabel, '%s' % (self.comm.getErrorString()))\r
+                       wx.CallAfter(self.errorLogButton.Show, True)\r
+                       wx.CallAfter(self.Layout)\r
+               else:\r
+                       wx.CallAfter(self.machineState.SetLabel, 'Communication State: %s' % (self.comm.getStateString()))\r
        \r
        def mcMessage(self, message):\r
                if self.checkupState >= 3 and self.checkupState < 10 and 'x_min' in message:\r
index 1dec1a132100c4c9340572a3457037f4bdd41f7f..5f1f301e0fba968e90737bed7b26c27b6e33aa63 100644 (file)
@@ -207,6 +207,9 @@ class MachineCom(object):
                if len(self._errorValue) < 20:
                        return self._errorValue
                return self._errorValue[:20] + "..."
+
+       def getErrorString(self):
+               return self._errorValue
        
        def isClosedOrError(self):
                return self._state == self.STATE_ERROR or self._state == self.STATE_CLOSED_WITH_ERROR or self._state == self.STATE_CLOSED