return False\r
line = self.gcodeList[lineNr]\r
try:\r
- if line == 'M0' or line == 'M1':\r
- self.OnPause(None)\r
- line = 'M105'\r
if ('M104' in line or 'M109' in line) and 'S' in line:\r
n = int(re.search('S([0-9]*)', line).group(1))\r
wx.CallAfter(self.temperatureSelect.SetValue, n)\r
if ('M140' in line or 'M190' in line) and 'S' in line:\r
n = int(re.search('S([0-9]*)', line).group(1))\r
wx.CallAfter(self.bedTemperatureSelect.SetValue, n)\r
- if self.typeList[lineNr] == 'WALL-OUTER':\r
- line = re.sub('F([0-9]*)', lambda m: 'F' + str(int(int(m.group(1)) * self.feedrateRatioOuterWall)), line)\r
- if self.typeList[lineNr] == 'WALL-INNER':\r
- line = re.sub('F([0-9]*)', lambda m: 'F' + str(int(int(m.group(1)) * self.feedrateRatioInnerWall)), line)\r
- if self.typeList[lineNr] == 'FILL':\r
- line = re.sub('F([0-9]*)', lambda m: 'F' + str(int(int(m.group(1)) * self.feedrateRatioFill)), line)\r
- if self.typeList[lineNr] == 'SUPPORT':\r
- line = re.sub('F([0-9]*)', lambda m: 'F' + str(int(int(m.group(1)) * self.feedrateRatioSupport)), line)\r
- if 'G1' in line and 'Z' in line:\r
- z = float(re.search('Z([0-9\.]*)', line).group(1))\r
- if self.cam != None and self.currentZ != z:\r
- wx.CallAfter(self.cam.takeNewImage)\r
- wx.CallAfter(self.camPage.Refresh)\r
- self.currentZ = z\r
except:\r
print "Unexpected error:", sys.exc_info()\r
checksum = reduce(lambda x,y:x^y, map(ord, "N%d%s" % (lineNr, line)))\r
\r
def mcProgress(self, lineNr):\r
wx.CallAfter(self.UpdateProgress)\r
+ \r
+ def mcZChange(self, newZ):\r
+ if self.cam != None:\r
+ wx.CallAfter(self.cam.takeNewImage)\r
+ wx.CallAfter(self.camPage.Refresh)\r
\r
class temperatureGraph(wx.Panel):\r
def __init__(self, parent):\r
pass
if 'M105' in data:
self.readList.append("ok T:%.2f /%.2f B:%.2f /%.2f @:64\n" % (self.temp, self.targetTemp, self.bedTemp, self.bedTargetTemp))
- else:
+ elif len(data.strip()) > 0:
self.readList.append("ok\n")
def readline(self):
def mcProgress(self, lineNr):
pass
+
+ def mcZChange(self, newZ):
+ pass
class MachineCom(object):
STATE_NONE = 0
self._commandQueue = queue.Queue()
self._logQueue = queue.Queue(256)
self._feedRateModifier = {}
+ self._currentZ = -1
if port == 'AUTO':
programmer = stk500v2.Stk500v2()
return self._bedTemp
def _monitor(self):
- self._timeoutTime = time.time() + 5
+ timeout = time.time() + 5
while True:
line = self._readline()
if line == None:
self._callback.mcMessage(line)
if self._state == self.STATE_DETECT_BAUDRATE:
- if line == '' or time.time() > self._timeoutTime:
+ if line == '' or time.time() > timeout:
if len(self._baudrateDetectList) < 1:
self._log("No more baudrates to test, and no suitable baudrate found.")
self.close()
self._serial.timeout = 0.5
self._log("Trying baudrate: %d" % (baudrate))
self._baudrateDetectRetry = 5
- self._timeoutTime = time.time() + 5
+ timeout = time.time() + 5
self._serial.write('\n')
self._sendCommand("M105")
except:
self._sendCommand("M105")
elif 'ok' in line:
self._changeState(self.STATE_OPERATIONAL)
- if time.time() > self._timeoutTime:
+ if time.time() > timeout:
self.close()
elif self._state == self.STATE_OPERATIONAL:
#Request the temperature on comm timeout (every 2 seconds) when we are not printing.
if line == '':
self._sendCommand("M105")
+ tempRequestTimeout = time.time() + 5
elif self._state == self.STATE_PRINTING:
- if line == '' and time.time() > self._timeoutTime:
+ if line == '' and time.time() > timeout:
self._log("Communication timeout during printing, forcing a line")
line = 'ok'
+ #Even when printing request the temperture every 5 seconds.
+ if time.time() > tempRequestTimeout:
+ self._commandQueue.put("M105")
+ tempRequestTimeout = time.time() + 5
if 'ok' in line:
- self._timeoutTime = time.time() + 5
+ timeout = time.time() + 5
if not self._commandQueue.empty():
self._sendCommand(self._commandQueue.get())
else:
line = 'M105' #Don't send the M0 or M1 to the machine, as M0 and M1 are handled as an LCD menu pause.
if self._printSection in self._feedRateModifier:
line = re.sub('F([0-9]*)', lambda m: 'F' + str(int(int(m.group(1)) * self._feedRateModifier[self._printSection])), line)
+ if ('G0' in line or 'G1' in line) and 'Z' in line:
+ z = float(re.search('Z([0-9\.]*)', line).group(1))
+ if self._currentZ != z:
+ self._currentZ = z
+ self._callback.mcZChange(z)
except:
self._log("Unexpected error: %s" % (getExceptionString()))
checksum = reduce(lambda x,y:x^y, map(ord, "N%d%s" % (self._gcodePos, line)))