changed from eventManager to callback.on_comm_pos_update

This commit is contained in:
make-ing 2015-09-23 14:08:00 +02:00
parent 6fd68e0df0
commit 53ad230461
3 changed files with 19 additions and 14 deletions

View file

@ -867,13 +867,13 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
def _add_position_data(self, MPos, WPos):
if MPos is None or WPos is None:
MPosString = WPosString = "-"
else:
MPosString = "X: %.4f Y: %.4f Z: %.4f" % ( MPos[0], MPos[1], MPos[2] )
WPosString = "X: %.4f Y: %.4f Z: %.4f" % ( WPos[0], WPos[1], WPos[2] )
MPos = WPos = [0, 0, 0]
#else:
#MPosString = "X: %.4f Y: %.4f Z: %.4f" % ( MPos[0], MPos[1], MPos[2] )
#WPosString = "X: %.4f Y: %.4f Z: %.4f" % ( WPos[0], WPos[1], WPos[2] )
self._stateMonitor.setWorkPosition(WPosString)
self._stateMonitor.setMachinePosition(MPosString)
self._stateMonitor.setWorkPosition(WPos)
self._stateMonitor.setMachinePosition(MPos)
class StateMonitor(object):

View file

@ -123,6 +123,7 @@ $(function() {
self._processProgressData(data.progress);
self._processZData(data.currentZ);
self._processBusyFiles(data.busyFiles);
self.currentPos({x: data.workPosition[0], y: data.workPosition[1]});
};
self._processStateData = function(data) {
var prevPaused = self.isPaused();

View file

@ -266,7 +266,7 @@ class MachineCom(object):
self._temperature_timer = RepeatedTimer(0.2, self._poll_temperature, run_first=True)
self._temperature_timer.start()
else:
if self._temperature_timer != None:
if self._temperature_timer is not None:
self._temperature_timer.cancel()
if newState == self.STATE_CLOSED or newState == self.STATE_CLOSED_WITH_ERROR:
@ -1990,10 +1990,10 @@ class MachineCom(object):
# line example:
# <Idle,MPos:-434.000,-596.000,0.000,WPos:0.000,0.000,0.000,S:0,laser off:0>
try:
#idx_mx_begin = line.index('MPos:') + 5
#idx_mx_end = line.index('.', idx_mx_begin) + 2
#idx_my_begin = line.index(',', idx_mx_end) + 1
#idx_my_end = line.index('.', idx_my_begin) + 2
idx_mx_begin = line.index('MPos:') + 5
idx_mx_end = line.index('.', idx_mx_begin) + 2
idx_my_begin = line.index(',', idx_mx_end) + 1
idx_my_end = line.index('.', idx_my_begin) + 2
#idx_mz_begin = line.index(',', idx_my_end) + 1
#idx_mz_end = line.index('.', idx_mz_begin) + 2
@ -2011,8 +2011,8 @@ class MachineCom(object):
#idx_laserstate_end = line.index(':', idx_laserstate_begin)
payload = {
#"mx": line[idx_mx_begin:idx_mx_end],
#"my": line[idx_my_begin:idx_my_end],
"mx": line[idx_mx_begin:idx_mx_end],
"my": line[idx_my_begin:idx_my_end],
#"mz": line[idx_mz_begin:idx_mz_end],
"wx": line[idx_wx_begin:idx_wx_end],
"wy": line[idx_wy_begin:idx_wy_end],
@ -2020,7 +2020,8 @@ class MachineCom(object):
#"laser": line[idx_laserstate_begin:idx_laserstate_end],
#"intensity": line[idx_intensity_begin:idx_intensity_end]
}
eventManager().fire(Events.RT_STATE, payload)
self._callback.on_comm_pos_update([mx, my, 0], [wx, wy, 0])
#eventManager().fire(Events.RT_STATE, payload)
except ValueError:
pass
@ -2129,6 +2130,9 @@ class MachineComPrintCallback(object):
def on_comm_force_disconnect(self):
pass
def on_comm_pos_update(self, MPos, WPos):
pass
### Printing file information classes ##################################################################################
class PrintingFileInformation(object):