Allow access to the current printed file position

This commit is contained in:
Gina Häußge 2016-11-15 10:28:14 +01:00
parent 06f7abdb2d
commit e04bdb3571
2 changed files with 20 additions and 3 deletions

View file

@ -405,6 +405,15 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
self._setProgressData(completion=0)
self._setCurrentZ(None)
def get_file_position(self):
if self._comm is None:
return None
if self._selectedFile is None:
return None
return self._comm.getFilePosition()
def start_print(self, pos=None):
"""
Starts the currently loaded print job.

View file

@ -939,15 +939,23 @@ class MachineCom(object):
##~~ record aborted file positions
def _recordFilePosition(self):
def getFilePosition(self):
if self._currentFile is None:
return
return None
origin = self._currentFile.getFileLocation()
filename = self._currentFile.getFilename()
pos = self._currentFile.getFilepos()
self._callback.on_comm_record_fileposition(origin, filename, pos)
return dict(origin=origin,
filename=filename,
pos=pos)
def _recordFilePosition(self):
if self._currentFile is None:
return
data = self.getFilePosition()
self._callback.on_comm_record_fileposition(data["origin"], data["filename"], data["pos"])
##~~ communication monitoring and handling