Add Z change reporting support, which fixes the timelaps movie recording. Add temperature requests every 5 seconds during printing.
This commit is contained in:
parent
2e01bbbe79
commit
894ced9820
2 changed files with 26 additions and 24 deletions
|
@ -456,29 +456,12 @@ class printWindow(wx.Frame):
|
||||||
return False
|
return False
|
||||||
line = self.gcodeList[lineNr]
|
line = self.gcodeList[lineNr]
|
||||||
try:
|
try:
|
||||||
if line == 'M0' or line == 'M1':
|
|
||||||
self.OnPause(None)
|
|
||||||
line = 'M105'
|
|
||||||
if ('M104' in line or 'M109' in line) and 'S' in line:
|
if ('M104' in line or 'M109' in line) and 'S' in line:
|
||||||
n = int(re.search('S([0-9]*)', line).group(1))
|
n = int(re.search('S([0-9]*)', line).group(1))
|
||||||
wx.CallAfter(self.temperatureSelect.SetValue, n)
|
wx.CallAfter(self.temperatureSelect.SetValue, n)
|
||||||
if ('M140' in line or 'M190' in line) and 'S' in line:
|
if ('M140' in line or 'M190' in line) and 'S' in line:
|
||||||
n = int(re.search('S([0-9]*)', line).group(1))
|
n = int(re.search('S([0-9]*)', line).group(1))
|
||||||
wx.CallAfter(self.bedTemperatureSelect.SetValue, n)
|
wx.CallAfter(self.bedTemperatureSelect.SetValue, n)
|
||||||
if self.typeList[lineNr] == 'WALL-OUTER':
|
|
||||||
line = re.sub('F([0-9]*)', lambda m: 'F' + str(int(int(m.group(1)) * self.feedrateRatioOuterWall)), line)
|
|
||||||
if self.typeList[lineNr] == 'WALL-INNER':
|
|
||||||
line = re.sub('F([0-9]*)', lambda m: 'F' + str(int(int(m.group(1)) * self.feedrateRatioInnerWall)), line)
|
|
||||||
if self.typeList[lineNr] == 'FILL':
|
|
||||||
line = re.sub('F([0-9]*)', lambda m: 'F' + str(int(int(m.group(1)) * self.feedrateRatioFill)), line)
|
|
||||||
if self.typeList[lineNr] == 'SUPPORT':
|
|
||||||
line = re.sub('F([0-9]*)', lambda m: 'F' + str(int(int(m.group(1)) * self.feedrateRatioSupport)), line)
|
|
||||||
if 'G1' in line and 'Z' in line:
|
|
||||||
z = float(re.search('Z([0-9\.]*)', line).group(1))
|
|
||||||
if self.cam != None and self.currentZ != z:
|
|
||||||
wx.CallAfter(self.cam.takeNewImage)
|
|
||||||
wx.CallAfter(self.camPage.Refresh)
|
|
||||||
self.currentZ = z
|
|
||||||
except:
|
except:
|
||||||
print "Unexpected error:", sys.exc_info()
|
print "Unexpected error:", sys.exc_info()
|
||||||
checksum = reduce(lambda x,y:x^y, map(ord, "N%d%s" % (lineNr, line)))
|
checksum = reduce(lambda x,y:x^y, map(ord, "N%d%s" % (lineNr, line)))
|
||||||
|
@ -501,6 +484,11 @@ class printWindow(wx.Frame):
|
||||||
def mcProgress(self, lineNr):
|
def mcProgress(self, lineNr):
|
||||||
wx.CallAfter(self.UpdateProgress)
|
wx.CallAfter(self.UpdateProgress)
|
||||||
|
|
||||||
|
def mcZChange(self, newZ):
|
||||||
|
if self.cam != None:
|
||||||
|
wx.CallAfter(self.cam.takeNewImage)
|
||||||
|
wx.CallAfter(self.camPage.Refresh)
|
||||||
|
|
||||||
class temperatureGraph(wx.Panel):
|
class temperatureGraph(wx.Panel):
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
super(temperatureGraph, self).__init__(parent)
|
super(temperatureGraph, self).__init__(parent)
|
||||||
|
|
|
@ -58,7 +58,7 @@ class VirtualPrinter():
|
||||||
pass
|
pass
|
||||||
if 'M105' in data:
|
if 'M105' in data:
|
||||||
self.readList.append("ok T:%.2f /%.2f B:%.2f /%.2f @:64\n" % (self.temp, self.targetTemp, self.bedTemp, self.bedTargetTemp))
|
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")
|
self.readList.append("ok\n")
|
||||||
|
|
||||||
def readline(self):
|
def readline(self):
|
||||||
|
@ -101,6 +101,9 @@ class MachineComPrintCallback(object):
|
||||||
def mcProgress(self, lineNr):
|
def mcProgress(self, lineNr):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def mcZChange(self, newZ):
|
||||||
|
pass
|
||||||
|
|
||||||
class MachineCom(object):
|
class MachineCom(object):
|
||||||
STATE_NONE = 0
|
STATE_NONE = 0
|
||||||
STATE_DETECT_BAUDRATE = 1
|
STATE_DETECT_BAUDRATE = 1
|
||||||
|
@ -135,6 +138,7 @@ class MachineCom(object):
|
||||||
self._commandQueue = queue.Queue()
|
self._commandQueue = queue.Queue()
|
||||||
self._logQueue = queue.Queue(256)
|
self._logQueue = queue.Queue(256)
|
||||||
self._feedRateModifier = {}
|
self._feedRateModifier = {}
|
||||||
|
self._currentZ = -1
|
||||||
|
|
||||||
if port == 'AUTO':
|
if port == 'AUTO':
|
||||||
programmer = stk500v2.Stk500v2()
|
programmer = stk500v2.Stk500v2()
|
||||||
|
@ -225,7 +229,7 @@ class MachineCom(object):
|
||||||
return self._bedTemp
|
return self._bedTemp
|
||||||
|
|
||||||
def _monitor(self):
|
def _monitor(self):
|
||||||
self._timeoutTime = time.time() + 5
|
timeout = time.time() + 5
|
||||||
while True:
|
while True:
|
||||||
line = self._readline()
|
line = self._readline()
|
||||||
if line == None:
|
if line == None:
|
||||||
|
@ -250,7 +254,7 @@ class MachineCom(object):
|
||||||
self._callback.mcMessage(line)
|
self._callback.mcMessage(line)
|
||||||
|
|
||||||
if self._state == self.STATE_DETECT_BAUDRATE:
|
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:
|
if len(self._baudrateDetectList) < 1:
|
||||||
self._log("No more baudrates to test, and no suitable baudrate found.")
|
self._log("No more baudrates to test, and no suitable baudrate found.")
|
||||||
self.close()
|
self.close()
|
||||||
|
@ -265,7 +269,7 @@ class MachineCom(object):
|
||||||
self._serial.timeout = 0.5
|
self._serial.timeout = 0.5
|
||||||
self._log("Trying baudrate: %d" % (baudrate))
|
self._log("Trying baudrate: %d" % (baudrate))
|
||||||
self._baudrateDetectRetry = 5
|
self._baudrateDetectRetry = 5
|
||||||
self._timeoutTime = time.time() + 5
|
timeout = time.time() + 5
|
||||||
self._serial.write('\n')
|
self._serial.write('\n')
|
||||||
self._sendCommand("M105")
|
self._sendCommand("M105")
|
||||||
except:
|
except:
|
||||||
|
@ -278,18 +282,23 @@ class MachineCom(object):
|
||||||
self._sendCommand("M105")
|
self._sendCommand("M105")
|
||||||
elif 'ok' in line:
|
elif 'ok' in line:
|
||||||
self._changeState(self.STATE_OPERATIONAL)
|
self._changeState(self.STATE_OPERATIONAL)
|
||||||
if time.time() > self._timeoutTime:
|
if time.time() > timeout:
|
||||||
self.close()
|
self.close()
|
||||||
elif self._state == self.STATE_OPERATIONAL:
|
elif self._state == self.STATE_OPERATIONAL:
|
||||||
#Request the temperature on comm timeout (every 2 seconds) when we are not printing.
|
#Request the temperature on comm timeout (every 2 seconds) when we are not printing.
|
||||||
if line == '':
|
if line == '':
|
||||||
self._sendCommand("M105")
|
self._sendCommand("M105")
|
||||||
|
tempRequestTimeout = time.time() + 5
|
||||||
elif self._state == self.STATE_PRINTING:
|
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")
|
self._log("Communication timeout during printing, forcing a line")
|
||||||
line = 'ok'
|
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:
|
if 'ok' in line:
|
||||||
self._timeoutTime = time.time() + 5
|
timeout = time.time() + 5
|
||||||
if not self._commandQueue.empty():
|
if not self._commandQueue.empty():
|
||||||
self._sendCommand(self._commandQueue.get())
|
self._sendCommand(self._commandQueue.get())
|
||||||
else:
|
else:
|
||||||
|
@ -365,6 +374,11 @@ class MachineCom(object):
|
||||||
line = 'M105' #Don't send the M0 or M1 to the machine, as M0 and M1 are handled as an LCD menu pause.
|
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:
|
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)
|
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:
|
except:
|
||||||
self._log("Unexpected error: %s" % (getExceptionString()))
|
self._log("Unexpected error: %s" % (getExceptionString()))
|
||||||
checksum = reduce(lambda x,y:x^y, map(ord, "N%d%s" % (self._gcodePos, line)))
|
checksum = reduce(lambda x,y:x^y, map(ord, "N%d%s" % (self._gcodePos, line)))
|
||||||
|
|
Loading…
Reference in a new issue