added multi passes support in backend
This commit is contained in:
parent
9c822b7e93
commit
3201053e16
1 changed files with 26 additions and 5 deletions
|
|
@ -84,6 +84,8 @@ class MachineCom(object):
|
|||
self._actual_intensity = None
|
||||
self._feedrate_dict = {}
|
||||
self._intensity_dict = {}
|
||||
self._passes = 1
|
||||
self._finished_passes = 0
|
||||
|
||||
# regular expressions
|
||||
self._regex_command = re.compile("^\s*\$?([GM]\d+|[TH])")
|
||||
|
|
@ -164,8 +166,15 @@ class MachineCom(object):
|
|||
if cmd is not None:
|
||||
self.sendCommand(cmd)
|
||||
self._callback.on_comm_progress()
|
||||
elif len(self._acc_line_buffer) == 0:
|
||||
self._set_print_finished()
|
||||
else:
|
||||
if self._finished_passes >= self._passes:
|
||||
if len(self._acc_line_buffer) == 0:
|
||||
self._set_print_finished()
|
||||
self._currentFile.resetToBeginning()
|
||||
cmd = self._getNext()
|
||||
if cmd is not None:
|
||||
self.sendCommand(cmd)
|
||||
self._callback.on_comm_progress()
|
||||
|
||||
self._sendCommand()
|
||||
self._send_event.wait(1)
|
||||
|
|
@ -311,7 +320,9 @@ class MachineCom(object):
|
|||
if self._finished_currentFile is False:
|
||||
line = self._currentFile.getNext()
|
||||
if line is None:
|
||||
self._finished_currentFile = True
|
||||
self._finished_passes += 1
|
||||
if self._finished_passes >= self._passes:
|
||||
self._finished_currentFile = True
|
||||
return line
|
||||
else:
|
||||
return None
|
||||
|
|
@ -824,6 +835,8 @@ class MachineCom(object):
|
|||
if self._currentFile is None:
|
||||
raise ValueError("No file selected for printing")
|
||||
|
||||
self._passes = 1
|
||||
|
||||
try:
|
||||
# ensure fan is on whatever gcode follows.
|
||||
self.sendCommand("M08")
|
||||
|
|
@ -894,10 +907,12 @@ class MachineCom(object):
|
|||
eventManager().fire(Events.PRINT_PAUSED, payload)
|
||||
|
||||
def increasePasses(self):
|
||||
self._log("increase Passes")
|
||||
self._passes += 1
|
||||
self._log("increased Passes to %d" % self._passes)
|
||||
|
||||
def degreasePasses(self):
|
||||
self._log("degrease Passes")
|
||||
self._passes -= 1
|
||||
self._log("degrease Passes to %d" % self._passes)
|
||||
|
||||
def getStateString(self):
|
||||
if self._state == self.STATE_NONE:
|
||||
|
|
@ -1161,6 +1176,12 @@ class PrintingGcodeFileInformation(PrintingFileInformation):
|
|||
pass
|
||||
self._handle = None
|
||||
|
||||
def resetToBeginning(self):
|
||||
"""
|
||||
resets the file handle so you can read from the beginning again.
|
||||
"""
|
||||
self._handle = open(self._filename, "r")
|
||||
|
||||
def getNext(self):
|
||||
"""
|
||||
Retrieves the next line for printing.
|
||||
|
|
|
|||
Loading…
Reference in a new issue