From 3d0e6339832a3f429349108bf22b94168cbdb6d8 Mon Sep 17 00:00:00 2001 From: daid303 Date: Tue, 4 Dec 2012 08:56:15 +0100 Subject: [PATCH] Improve the first run wizard with the communication error log, and add info buttons to the Ultimaker wiki when steps fail. --- Cura/gui/configWizard.py | 37 +++++++++++++++++++++++++++++++++---- Cura/util/machineCom.py | 3 +++ 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/Cura/gui/configWizard.py b/Cura/gui/configWizard.py index 740832f6..50f6f8b7 100644 --- a/Cura/gui/configWizard.py +++ b/Cura/gui/configWizard.py @@ -6,6 +6,7 @@ import wx.wizard from gui import firmwareInstall from gui import toolbarUtil +from gui import printWindow from util import machineCom from util import profile @@ -24,28 +25,40 @@ class InfoBox(wx.Panel): self.bitmap = wx.StaticBitmap(self, -1, wx.EmptyBitmapRGBA(24, 24, red=255, green=255, blue=255, alpha=1)) self.text = wx.StaticText(self, -1, '') + self.extraInfoButton = wx.Button(self, -1, 'i', style=wx.BU_EXACTFIT) self.sizer.Add(self.bitmap, pos=(0,0), flag=wx.ALL, border=5) self.sizer.Add(self.text, pos=(0,1), flag=wx.TOP|wx.BOTTOM|wx.ALIGN_CENTER_VERTICAL, border=5) + self.sizer.Add(self.extraInfoButton, pos=(0,2), flag=wx.ALL|wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, border=5) + self.sizer.AddGrowableCol(1) + self.extraInfoButton.Show(False) + + self.extraInfoUrl = '' self.busyState = None self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.doBusyUpdate, self.timer) + self.Bind(wx.EVT_BUTTON, self.doExtraInfo, self.extraInfoButton) self.timer.Start(100) def SetInfo(self, info): self.SetBackgroundColour('#FFFF80') self.text.SetLabel(info) + self.extraInfoButton.Show(False) self.Refresh() - def SetError(self, info): + def SetError(self, info, extraInfoUrl): + self.extraInfoUrl = extraInfoUrl self.SetBackgroundColour('#FF8080') self.text.SetLabel(info) + self.extraInfoButton.Show(True) + self.Layout() self.SetErrorIndicator() self.Refresh() def SetAttention(self, info): self.SetBackgroundColour('#FFFF80') self.text.SetLabel(info) + self.extraInfoButton.Show(False) self.SetAttentionIndicator() self.Refresh() @@ -61,6 +74,9 @@ class InfoBox(wx.Panel): self.busyState = 0 self.bitmap.SetBitmap(self.busyBitmap[self.busyState]) + def doExtraInfo(self, e): + webbrowser.open(self.extraInfoUrl) + def SetReadyIndicator(self): self.busyState = None self.bitmap.SetBitmap(self.readyBitmap) @@ -310,6 +326,8 @@ class UltimakerCheckupPage(InfoPage): self.infoBox = self.AddInfoBox() self.machineState = self.AddText('') self.temperatureLabel = self.AddText('') + self.errorLogButton = self.AddButton('Show error log') + self.errorLogButton.Show(False) self.AddSeperator() self.endstopBitmap = self.AddBitmap(self.endStopNoneBitmap) self.comm = None @@ -319,6 +337,8 @@ class UltimakerCheckupPage(InfoPage): self.yMaxStop = False self.zMinStop = False self.zMaxStop = False + + self.Bind(wx.EVT_BUTTON, self.OnErrorLog, self.errorLogButton) def __del__(self): if self.comm != None: @@ -332,6 +352,7 @@ class UltimakerCheckupPage(InfoPage): self.GetParent().FindWindowById(wx.ID_FORWARD).Enable() def OnCheckClick(self, e = None): + self.errorLogButton.Show(False) if self.comm != None: self.comm.close() del self.comm @@ -345,6 +366,9 @@ class UltimakerCheckupPage(InfoPage): self.stopState.SetBitmap(self.unknownBitmap) self.checkupState = 0 self.comm = machineCom.MachineCom(callbackObject=self) + + def OnErrorLog(self, e): + printWindow.LogWindow('\n'.join(self.comm.getLog())) def mcLog(self, message): pass @@ -388,7 +412,7 @@ class UltimakerCheckupPage(InfoPage): if self.tempCheckTimeout < 1: self.checkupState = -1 wx.CallAfter(self.tempState.SetBitmap, self.crossBitmap) - wx.CallAfter(self.infoBox.SetError, 'Temperature measurement FAILED!') + wx.CallAfter(self.infoBox.SetError, 'Temperature measurement FAILED!', 'http://wiki.ultimaker.com/Cura/Temperature_measurement_problems') self.comm.sendCommand('M104 S0') self.comm.sendCommand('M104 S0') wx.CallAfter(self.temperatureLabel.SetLabel, 'Head temperature: %d' % (temp)) @@ -398,11 +422,16 @@ class UltimakerCheckupPage(InfoPage): return if self.comm.isOperational(): wx.CallAfter(self.commState.SetBitmap, self.checkBitmap) + wx.CallAfter(self.machineState.SetLabel, 'Communication State: %s' % (self.comm.getStateString())) elif self.comm.isError(): wx.CallAfter(self.commState.SetBitmap, self.crossBitmap) - wx.CallAfter(self.infoBox.SetError, 'Failed to establish connection with the printer.') + wx.CallAfter(self.infoBox.SetError, 'Failed to establish connection with the printer.', 'http://wiki.ultimaker.com/Cura/Connection_problems') wx.CallAfter(self.endstopBitmap.Show, False) - wx.CallAfter(self.machineState.SetLabel, 'Communication State: %s' % (self.comm.getStateString())) + wx.CallAfter(self.machineState.SetLabel, '%s' % (self.comm.getErrorString())) + wx.CallAfter(self.errorLogButton.Show, True) + wx.CallAfter(self.Layout) + else: + wx.CallAfter(self.machineState.SetLabel, 'Communication State: %s' % (self.comm.getStateString())) def mcMessage(self, message): if self.checkupState >= 3 and self.checkupState < 10 and 'x_min' in message: diff --git a/Cura/util/machineCom.py b/Cura/util/machineCom.py index 1dec1a13..5f1f301e 100644 --- a/Cura/util/machineCom.py +++ b/Cura/util/machineCom.py @@ -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 -- 2.30.2