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