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
\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
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
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
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
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
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