From: Joseph Coffland Date: Thu, 27 Jun 2019 22:13:11 +0000 (-0700) Subject: Fix bug were fast clicks could cause jog commands to arrive out of order X-Git-Url: https://git.buildbotics.com/?a=commitdiff_plain;h=a7d7199d58ff2b4a5096959a3a7295d80f095c93;p=bbctrl-firmware Fix bug were fast clicks could cause jog commands to arrive out of order --- diff --git a/src/js/control-view.js b/src/js/control-view.js index 7244eea..6ba4fcf 100644 --- a/src/js/control-view.js +++ b/src/js/control-view.js @@ -182,7 +182,7 @@ module.exports = { events: { jog: function (axis, power) { - var data = {}; + var data = {ts: new Date().getTime()}; data[axis] = power; api.put('jog', data); } diff --git a/src/py/bbctrl/Web.py b/src/py/bbctrl/Web.py index a0dd6c8..891bdce 100644 --- a/src/py/bbctrl/Web.py +++ b/src/py/bbctrl/Web.py @@ -390,7 +390,21 @@ class ModbusWriteHandler(bbctrl.APIHandler): class JogHandler(bbctrl.APIHandler): - def put_ok(self): self.get_ctrl().mach.jog(self.json) + def put_ok(self): + # Handle possible out of order jog command processing + if 'ts' in self.json: + ts = self.json['ts'] + id = self.get_cookie('client-id') + + if not hasattr(self.app, 'last_jog'): + self.app.last_jog = {} + + last = self.app.last_jog.get(id, 0) + self.app.last_jog[id] = ts + + if ts < last: return # Out of order + + self.get_ctrl().mach.jog(self.json) # Base class for Web Socket connections