Include position in PrintPaused and PrintCancelled events

If available. Updated docs accordingly.
This commit is contained in:
Gina Häußge committed 2016-11-15 11:56:30 +01:00
1 parent a8ff23abe4
commit cc5f119f1b
2 files changed
+36 -9

No files matched your search

+22
View File
@@ -308,6 +308,17 @@ PrintCancelled
* ``name``: the file's name
* ``path``: the file's path within its storage location
* ``origin``: the origin storage location of the file, either ``local`` or ``sdcard``
* ``position``: the print head position at the time of cancelling, if available
* ``position.x``: x coordinate, as reported back from the firmware through `M114`
* ``position.y``: y coordinate, as reported back from the firmware through `M114`
* ``position.z``: z coordinate, as reported back from the firmware through `M114`
* ``position.e``: e coordinate (of currently selected extruder), as reported back from the firmware through `M114`
* ``position.t``: last tool selected *through OctoPrint* (note that if you did change the printer's selected
tool outside of OctoPrint, e.g. through the printer controller, or if you are printing from SD, this will NOT
be accurate)
* ``position.f``: last feedrate for move commands **sent through OctoPrint** (note that if you modified the
feedrate outside of OctoPrint, e.g. through the printer controller, or if you are printing from SD, this will
NOT be accurate)
.. deprecated:: 1.3.0
@@ -324,6 +335,17 @@ PrintPaused
* ``name``: the file's name
* ``path``: the file's path within its storage location
* ``origin``: the origin storage location of the file, either ``local`` or ``sdcard``
* ``position``: the print head position at the time of pausing, if available
* ``position.x``: x coordinate, as reported back from the firmware through `M114`
* ``position.y``: y coordinate, as reported back from the firmware through `M114`
* ``position.z``: z coordinate, as reported back from the firmware through `M114`
* ``position.e``: e coordinate (of currently selected extruder), as reported back from the firmware through `M114`
* ``position.t``: last tool selected *through OctoPrint* (note that if you did change the printer's selected
tool outside of OctoPrint, e.g. through the printer controller, or if you are printing from SD, this will NOT
be accurate)
* ``position.f``: last feedrate for move commands **sent through OctoPrint** (note that if you modified the
feedrate outside of OctoPrint, e.g. through the printer controller, or if you are printing from SD, this will
NOT be accurate)
.. deprecated:: 1.3.0
+14 -9
View File
@@ -1077,7 +1077,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
eventManager().fire(Events.PRINT_FAILED, payload)
def on_comm_print_job_cancelled(self):
payload = self._payload_for_print_job_event()
payload = self._payload_for_print_job_event(position=self._comm.cancel_position.as_dict() if self._comm and self._comm.cancel_position else None)
if payload:
eventManager().fire(Events.PRINT_CANCELLED, payload)
self.script("afterPrintCancelled",
@@ -1085,7 +1085,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
must_be_set=False)
def on_comm_print_job_paused(self):
payload = self._payload_for_print_job_event()
payload = self._payload_for_print_job_event(position=self._comm.pause_position.as_dict() if self._comm and self._comm.pause_position else None)
if payload:
eventManager().fire(Events.PRINT_PAUSED, payload)
self.script("afterPrintPaused",
@@ -1131,7 +1131,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
except:
self._logger.exception("Error while trying to persist print recovery data")
def _payload_for_print_job_event(self, location=None, print_job_file=None):
def _payload_for_print_job_event(self, location=None, print_job_file=None, position=None):
if print_job_file is None:
selected_file = self._selectedFile
if not selected_file:
@@ -1156,13 +1156,18 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
_, name = self._fileManager.split_path(FileDestinations.LOCAL, path)
origin = FileDestinations.LOCAL
return dict(name=name,
path=path,
origin=origin,
result= dict(name=name,
path=path,
origin=origin,
# TODO deprecated, remove in 1.4.0
file=full_path,
filename=name)
# TODO deprecated, remove in 1.4.0
file=full_path,
filename=name)
if position is not None:
result["position"] = position
return result
class StateMonitor(object):