New POSITION_UPDATE event for responses to M114

This commit is contained in:
Gina Häußge 2016-10-26 18:11:00 +02:00
parent 728172136a
commit 3f0bfa0fc8
3 changed files with 17 additions and 0 deletions

View file

@ -78,6 +78,7 @@ class Events(object):
CONVEYOR = "Conveyor"
EJECT = "Eject"
E_STOP = "EStop"
POSITION_UPDATE = "PositionUpdate"
REGISTERED_MESSAGE_RECEIVED = "RegisteredMessageReceived"
# Timelapse

View file

@ -956,6 +956,9 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
def on_comm_temperature_update(self, temp, bedTemp):
self._addTemperatureData(copy.deepcopy(temp), copy.deepcopy(bedTemp))
def on_comm_position_update(self, position):
eventManager().fire(Events.POSITION_UPDATE, position)
def on_comm_state_change(self, state):
"""
Callback method for the comm object, called if the connection state changes.

View file

@ -220,6 +220,14 @@ class PositionRecord(object):
self.f = other.f
self.t = other.t
def as_dict(self):
return dict(x=self.x,
y=self.y,
z=self.z,
e=self.e,
t=self.t,
f=self.f)
class MachineCom(object):
STATE_NONE = 0
STATE_OPEN_SERIAL = 1
@ -1130,6 +1138,8 @@ class MachineCom(object):
self._pause_position.copy_from(self._last_position)
self._pause_preparation_done()
self._callback.on_comm_position_update(self._last_position.as_dict())
# temperature processing
elif ' T:' in line or line.startswith('T:') or ' T0:' in line or line.startswith('T0:') or ((' B:' in line or line.startswith('B:')) and not 'A:' in line):
if not disable_external_heatup_detection and not line.strip().startswith("ok") and not self._heating:
@ -2341,6 +2351,9 @@ class MachineComPrintCallback(object):
def on_comm_temperature_update(self, temp, bedTemp):
pass
def on_comm_position_update(self, position):
pass
def on_comm_state_change(self, state):
pass