Refactor send command gcode handlers into individual functions. Very little gain if any.
parent
b1c5c58f02
commit
cb30d1fdd0
|
@ -418,6 +418,7 @@ class MachineCom(object):
|
|||
# print job
|
||||
self._currentFile = None
|
||||
|
||||
|
||||
def _changeState(self, newState):
|
||||
if self._state == newState:
|
||||
return
|
||||
|
@ -917,30 +918,43 @@ class MachineCom(object):
|
|||
|
||||
if gcode in gcodeToEvent:
|
||||
eventManager().fire(gcodeToEvent[gcode])
|
||||
try:
|
||||
cmd = getattr(self, '_gcode_' + gcode)(cmd) or cmd
|
||||
except:
|
||||
pass
|
||||
|
||||
if (gcode == "G0" or gcode == "G1") and 'Z' in cmd:
|
||||
|
||||
if cmd != "":
|
||||
self._doSend(cmd, sendChecksum)
|
||||
|
||||
def _gcode_G0(self, cmd):
|
||||
if 'Z' in cmd:
|
||||
z = float(re.search('Z([0-9\.]*)', cmd).group(1))
|
||||
if self._currentZ != z:
|
||||
self._currentZ = z
|
||||
self._callback.mcZChange(z)
|
||||
elif gcode == "M0" or gcode == "M1":
|
||||
_gcode_G1 = _gcode_G0
|
||||
|
||||
def _gcode_M0(self, cmd):
|
||||
self.setPause(True)
|
||||
cmd = "M105" # Don't send the M0 or M1 to the machine, as M0 and M1 are handled as an LCD menu pause.
|
||||
return "M105" # Don't send the M0 or M1 to the machine, as M0 and M1 are handled as an LCD menu pause.
|
||||
_gcode_M0M1 = _gcode_M0
|
||||
|
||||
elif gcode == "M109" or gcode == "M190":
|
||||
self._heatupWaitStartTime = time.time()
|
||||
elif gcode == "M104" or gcode == "M109":
|
||||
try:
|
||||
def _gcode_M104(self, cmd):
|
||||
self._targetTemp = float(re.search('S([0-9]+)', cmd).group(1))
|
||||
except:
|
||||
pass
|
||||
elif gcode == "M140" or gcode == "M190":
|
||||
try:
|
||||
self._bedTargetTemp = float(re.search('S([0-9]+)', cmd).group(1))
|
||||
except:
|
||||
pass
|
||||
|
||||
elif gcode == "M110":
|
||||
def _gcode_M140(self, cmd):
|
||||
self._bedTargetTemp = float(re.search('S([0-9]+)', cmd).group(1))
|
||||
|
||||
def _gcode_M109(self, cmd):
|
||||
self._heatupWaitStartTime = time.time()
|
||||
self._gcode_M104(cmd)
|
||||
|
||||
def _gcode_M190(self, cmd):
|
||||
self._heatupWaitStartTime = time.time()
|
||||
self._gcode_M140(cmd)
|
||||
|
||||
def _gcode_M110(self, cmd):
|
||||
newLineNumber = None
|
||||
if " N" in cmd:
|
||||
try:
|
||||
|
@ -957,8 +971,7 @@ class MachineCom(object):
|
|||
# after a reset of the line number we have no way to determine what line exactly the printer now wants
|
||||
self._lastLines.clear()
|
||||
self._resendDelta = None
|
||||
return
|
||||
self._doSend(cmd, sendChecksum)
|
||||
return ""
|
||||
|
||||
def _addToLastLines(self, cmd):
|
||||
self._lastLines.append(cmd)
|
||||
|
|
Loading…
Reference in New Issue