Fix the speed rate modify in the printing interface.
parent
68f1353e60
commit
2e01bbbe79
|
@ -296,10 +296,14 @@ class printWindow(wx.Frame):
|
||||||
|
|
||||||
def UpdateButtonStates(self):
|
def UpdateButtonStates(self):
|
||||||
self.connectButton.Enable(self.machineCom == None or self.machineCom.isClosedOrError())
|
self.connectButton.Enable(self.machineCom == None or self.machineCom.isClosedOrError())
|
||||||
#self.loadButton.Enable(self.printIdx == None)
|
#self.loadButton.Enable(self.machineCom == None or not (self.machineCom.isPrinting() or self.machineCom.isPaused()))
|
||||||
self.printButton.Enable(self.machineCom != None and self.machineCom.isOperational() and not (self.machineCom.isPrinting() or self.machineCome.isPaused()))
|
self.printButton.Enable(self.machineCom != None and self.machineCom.isOperational() and not (self.machineCom.isPrinting() or self.machineCom.isPaused()))
|
||||||
self.pauseButton.Enable(self.machineCom != None and (self.machineCom.isPrinting() or self.machineCome.isPaused()))
|
self.pauseButton.Enable(self.machineCom != None and (self.machineCom.isPrinting() or self.machineCom.isPaused()))
|
||||||
self.cancelButton.Enable(self.machineCom != None and (self.machineCom.isPrinting() or self.machineCome.isPaused()))
|
if self.machineCom != None and self.machineCom.isPaused():
|
||||||
|
self.pauseButton.SetLabel('Resume')
|
||||||
|
else:
|
||||||
|
self.pauseButton.SetLabel('Pause')
|
||||||
|
self.cancelButton.Enable(self.machineCom != None and (self.machineCom.isPrinting() or self.machineCom.isPaused()))
|
||||||
self.temperatureSelect.Enable(self.machineCom != None and self.machineCom.isOperational())
|
self.temperatureSelect.Enable(self.machineCom != None and self.machineCom.isOperational())
|
||||||
self.bedTemperatureSelect.Enable(self.machineCom != None and self.machineCom.isOperational())
|
self.bedTemperatureSelect.Enable(self.machineCom != None and self.machineCom.isOperational())
|
||||||
self.directControlPanel.Enable(self.machineCom != None and self.machineCom.isOperational())
|
self.directControlPanel.Enable(self.machineCom != None and self.machineCom.isOperational())
|
||||||
|
@ -367,10 +371,8 @@ class printWindow(wx.Frame):
|
||||||
def OnPause(self, e):
|
def OnPause(self, e):
|
||||||
if self.machineCom.isPaused():
|
if self.machineCom.isPaused():
|
||||||
self.machineCom.setPause(False)
|
self.machineCom.setPause(False)
|
||||||
self.pauseButton.SetLabel('Pause')
|
|
||||||
else:
|
else:
|
||||||
self.machineCom.setPause(True)
|
self.machineCom.setPause(True)
|
||||||
self.pauseButton.SetLabel('Resume')
|
|
||||||
|
|
||||||
def OnClose(self, e):
|
def OnClose(self, e):
|
||||||
global printWindowHandle
|
global printWindowHandle
|
||||||
|
@ -386,10 +388,12 @@ class printWindow(wx.Frame):
|
||||||
self.machineCom.sendCommand("M140 S%d" % (self.bedTemperatureSelect.GetValue()))
|
self.machineCom.sendCommand("M140 S%d" % (self.bedTemperatureSelect.GetValue()))
|
||||||
|
|
||||||
def OnSpeedChange(self, e):
|
def OnSpeedChange(self, e):
|
||||||
self.feedrateRatioOuterWall = self.outerWallSpeedSelect.GetValue() / 100.0
|
if self.machineCom == None:
|
||||||
self.feedrateRatioInnerWall = self.innerWallSpeedSelect.GetValue() / 100.0
|
return
|
||||||
self.feedrateRatioFill = self.fillSpeedSelect.GetValue() / 100.0
|
self.machineCom.setFeedrateModifier('WALL-OUTER', self.outerWallSpeedSelect.GetValue() / 100.0)
|
||||||
self.feedrateRatioSupport = self.supportSpeedSelect.GetValue() / 100.0
|
self.machineCom.setFeedrateModifier('WALL-INNER', self.innerWallSpeedSelect.GetValue() / 100.0)
|
||||||
|
self.machineCom.setFeedrateModifier('FILL', self.fillSpeedSelect.GetValue() / 100.0)
|
||||||
|
self.machineCom.setFeedrateModifier('SUPPORT', self.supportSpeedSelect.GetValue() / 100.0)
|
||||||
|
|
||||||
def AddTermLog(self, line):
|
def AddTermLog(self, line):
|
||||||
self.termLog.AppendText(unicode(line, 'utf-8', 'replace'))
|
self.termLog.AppendText(unicode(line, 'utf-8', 'replace'))
|
||||||
|
@ -422,9 +426,8 @@ class printWindow(wx.Frame):
|
||||||
if self.machineCom != None and self.machineCom.isPrinting():
|
if self.machineCom != None and self.machineCom.isPrinting():
|
||||||
return
|
return
|
||||||
#Send an initial M110 to reset the line counter to zero.
|
#Send an initial M110 to reset the line counter to zero.
|
||||||
lineType = 'CUSTOM'
|
prevLineType = lineType = 'CUSTOM'
|
||||||
gcodeList = ["M110"]
|
gcodeList = ["M110"]
|
||||||
typeList = [lineType]
|
|
||||||
for line in open(filename, 'r'):
|
for line in open(filename, 'r'):
|
||||||
if line.startswith(';TYPE:'):
|
if line.startswith(';TYPE:'):
|
||||||
lineType = line[6:].strip()
|
lineType = line[6:].strip()
|
||||||
|
@ -432,15 +435,17 @@ class printWindow(wx.Frame):
|
||||||
line = line[0:line.find(';')]
|
line = line[0:line.find(';')]
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if len(line) > 0:
|
if len(line) > 0:
|
||||||
|
if prevLineType != lineType:
|
||||||
|
gcodeList.append((line, lineType, ))
|
||||||
|
else:
|
||||||
gcodeList.append(line)
|
gcodeList.append(line)
|
||||||
typeList.append(lineType)
|
prevLineType = lineType
|
||||||
gcode = gcodeInterpreter.gcode()
|
gcode = gcodeInterpreter.gcode()
|
||||||
gcode.loadList(gcodeList)
|
gcode.loadList(gcodeList)
|
||||||
print "Loaded: %s (%d)" % (filename, len(gcodeList))
|
print "Loaded: %s (%d)" % (filename, len(gcodeList))
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
self.gcode = gcode
|
self.gcode = gcode
|
||||||
self.gcodeList = gcodeList
|
self.gcodeList = gcodeList
|
||||||
self.typeList = typeList
|
|
||||||
|
|
||||||
wx.CallAfter(self.progress.SetRange, len(gcodeList))
|
wx.CallAfter(self.progress.SetRange, len(gcodeList))
|
||||||
wx.CallAfter(self.UpdateButtonStates)
|
wx.CallAfter(self.UpdateButtonStates)
|
||||||
|
|
|
@ -68,6 +68,8 @@ class gcode(object):
|
||||||
currentPath.list[0].e = totalExtrusion
|
currentPath.list[0].e = totalExtrusion
|
||||||
currentLayer.append(currentPath)
|
currentLayer.append(currentPath)
|
||||||
for line in gcodeFile:
|
for line in gcodeFile:
|
||||||
|
if type(line) is tuple:
|
||||||
|
line = line[0]
|
||||||
if self.progressCallback != None:
|
if self.progressCallback != None:
|
||||||
if filePos != gcodeFile.tell():
|
if filePos != gcodeFile.tell():
|
||||||
filePos = gcodeFile.tell()
|
filePos = gcodeFile.tell()
|
||||||
|
|
|
@ -134,6 +134,7 @@ class MachineCom(object):
|
||||||
self._gcodePos = 0
|
self._gcodePos = 0
|
||||||
self._commandQueue = queue.Queue()
|
self._commandQueue = queue.Queue()
|
||||||
self._logQueue = queue.Queue(256)
|
self._logQueue = queue.Queue(256)
|
||||||
|
self._feedRateModifier = {}
|
||||||
|
|
||||||
if port == 'AUTO':
|
if port == 'AUTO':
|
||||||
programmer = stk500v2.Stk500v2()
|
programmer = stk500v2.Stk500v2()
|
||||||
|
@ -323,7 +324,7 @@ class MachineCom(object):
|
||||||
if ret == '':
|
if ret == '':
|
||||||
#self._log("Recv: TIMEOUT")
|
#self._log("Recv: TIMEOUT")
|
||||||
return ''
|
return ''
|
||||||
self._log("Recv: %s" % (unicode(ret, 'ascii', 'replace').rstrip()))
|
self._log("Recv: %s" % (unicode(ret, 'ascii', 'replace').encode('ascii', 'replace').rstrip()))
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def close(self, isError = False):
|
def close(self, isError = False):
|
||||||
|
@ -355,6 +356,17 @@ class MachineCom(object):
|
||||||
self._changeState(self.STATE_OPERATIONAL)
|
self._changeState(self.STATE_OPERATIONAL)
|
||||||
return
|
return
|
||||||
line = self._gcodeList[self._gcodePos]
|
line = self._gcodeList[self._gcodePos]
|
||||||
|
if type(line) is tuple:
|
||||||
|
self._printSection = line[1]
|
||||||
|
line = line[0]
|
||||||
|
try:
|
||||||
|
if line == 'M0' or line == 'M1':
|
||||||
|
self.setPause(True)
|
||||||
|
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)
|
||||||
|
except:
|
||||||
|
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)))
|
||||||
self._sendCommand("N%d%s*%d" % (self._gcodePos, line, checksum))
|
self._sendCommand("N%d%s*%d" % (self._gcodePos, line, checksum))
|
||||||
self._gcodePos += 1
|
self._gcodePos += 1
|
||||||
|
@ -372,6 +384,7 @@ class MachineCom(object):
|
||||||
return
|
return
|
||||||
self._gcodeList = gcodeList
|
self._gcodeList = gcodeList
|
||||||
self._gcodePos = 0
|
self._gcodePos = 0
|
||||||
|
self._printSection = 'CUSTOM'
|
||||||
self._changeState(self.STATE_PRINTING)
|
self._changeState(self.STATE_PRINTING)
|
||||||
for i in xrange(0, 6):
|
for i in xrange(0, 6):
|
||||||
self._sendNext()
|
self._sendNext()
|
||||||
|
@ -388,6 +401,9 @@ class MachineCom(object):
|
||||||
if pause and self.isPrinting():
|
if pause and self.isPrinting():
|
||||||
self._changeState(self.STATE_PAUSED)
|
self._changeState(self.STATE_PAUSED)
|
||||||
|
|
||||||
|
def setFeedrateModifier(self, type, value):
|
||||||
|
self._feedRateModifier[type] = value
|
||||||
|
|
||||||
def getExceptionString():
|
def getExceptionString():
|
||||||
locationInfo = traceback.extract_tb(sys.exc_info()[2])[0]
|
locationInfo = traceback.extract_tb(sys.exc_info()[2])[0]
|
||||||
return "%s: '%s' @ %s:%s:%d" % (str(sys.exc_info()[0].__name__), str(sys.exc_info()[1]), os.path.basename(locationInfo[0]), locationInfo[2], locationInfo[1])
|
return "%s: '%s' @ %s:%s:%d" % (str(sys.exc_info()[0].__name__), str(sys.exc_info()[1]), os.path.basename(locationInfo[0]), locationInfo[2], locationInfo[1])
|
||||||
|
|
Loading…
Reference in New Issue