Fixed a disconnect but, and unhoming on failed probe

This commit is contained in:
David Carley
2021-10-21 19:25:27 -07:00
parent 2571475700
commit 3710a3e1f6
6 changed files with 61 additions and 29 deletions

View File

@@ -10,6 +10,7 @@
"jstransformer-escape-html": "",
"jstransformer-stylus": "",
"lodash.merge": "4.6.2",
"lodash.omit": "^4.5.0",
"pug-cli": ""
}
}

View File

@@ -27,9 +27,10 @@
'use strict'
var api = require('./api');
var cookie = require('./cookie')('bbctrl-');
var Sock = require('./sock');
const api = require('./api');
const cookie = require('./cookie')('bbctrl-');
const Sock = require('./sock');
const omit = require('lodash.omit');
function is_newer_version(current, latest) {
const pattern = /(\d+)\.(\d+)\.(\d+)(.*)/;
@@ -385,10 +386,10 @@ module.exports = new Vue({
}
if ('log' in e.data) {
if (this.state.probing_active && e.data.log.msg === "Switch not found") {
if (e.data.log.msg === "Switch not found") {
this.$broadcast('probing_failed');
} else {
this.$broadcast('log', JSON.stringify(e.data.log, null, 4));
this.$broadcast('log', e.data.log);
}
delete e.data.log;
@@ -407,6 +408,25 @@ module.exports = new Vue({
}
}
// Set this to true to get console output of changes to the state
const debugStateChanges = false;
if (debugStateChanges) {
const data = omit(e.data, [
'vdd',
'vin',
'vout',
'motor',
'temp',
'heartbeat',
'load1',
'load2',
'rpi_temp'
]);
if (Object.keys(data).length > 0) {
console.log(JSON.stringify(data, null, 4));
}
}
update_object(this.state, e.data, false);
if (this.state.pw === 0) {

View File

@@ -182,7 +182,7 @@ html(lang="en")
p This process should take less than 5 minutes. If it takes longer than this, please restart the controller and try via USB.
div(slot="footer")
message(v-if="popupMessages.length", :show="true")
message(v-if="popupMessages.length", show=true)
h3(slot="header") GCode message
div(slot="body")

View File

@@ -136,7 +136,7 @@ class Mach(Comm):
def process_log(self, log):
# Detect when a probe has failed, and reset the planner
if log['msg'] == 'Switch not found':
self.planner.reset(False)
self.planner.reset(stop = False, resetState = False)
def _update(self, update):
@@ -152,7 +152,7 @@ class Mach(Comm):
# Handle EStop
if state_changed and state == 'ESTOPPED':
self.planner.reset(False)
self.planner.reset(stop = False)
# Exit cycle if state changed to READY
if (state_changed and self._get_cycle() != 'idle' and
@@ -201,9 +201,6 @@ class Mach(Comm):
self.unpausing = True
def _reset(self): self.planner.reset()
def _i2c_block(self, block):
super().i2c_command(block[0], block = block[1:])
@@ -218,12 +215,13 @@ class Mach(Comm):
@overrides(Comm)
def comm_error(self): self._reset()
def comm_error(self):
self.planner.reset()
@overrides(Comm)
def connect(self):
self._reset()
self.planner.reset()
super().connect()
@@ -246,6 +244,7 @@ class Mach(Comm):
def mdi(self, cmd, with_limits = True):
try:
if not len(cmd): return
if cmd[0] == '$': self._query_var(cmd)
elif cmd[0] == '\\': super().queue_command(cmd[1:])
@@ -253,7 +252,9 @@ class Mach(Comm):
self._begin_cycle('mdi')
self.planner.mdi(cmd, with_limits)
super().resume()
except BaseException as err:
self.mlog.info("Exception during MDI: %s" % err)
pass
def set(self, code, value):
super().queue_command('${}={}'.format(code, value))
@@ -312,7 +313,7 @@ class Mach(Comm):
def clear(self):
if self._is_estopped():
self._reset()
self.planner.reset()
super().clear()

View File

@@ -64,7 +64,7 @@ class Planner():
ctrl.state.add_listener(self._update)
self.reset(False)
self.reset(stop = False)
self._report_time()
@@ -324,8 +324,11 @@ class Planner():
self.planner.set_logger(None)
def reset(self, stop = True):
if stop: self.ctrl.mach.stop()
def reset(self, *args, **kwargs):
stop = kwargs.get('stop', True)
if stop:
self.ctrl.mach.stop()
self.planner = gplan.Planner()
self.planner.set_resolver(self._get_var_cb)
# TODO logger is global and will not work correctly in demo mode
@@ -333,6 +336,9 @@ class Planner():
self._position_dirty = True
self.cmdq.clear()
self.reset_times()
resetState = kwargs.get('resetState', True)
if resetState:
self.ctrl.state.reset()

View File

@@ -441,7 +441,8 @@ class ClientConnection(object):
self.app.closed(self.ctrl)
def on_message(self, data): self.ctrl.mach.mdi(data)
def on_message(self, data):
self.ctrl.mach.mdi(data)
# Used by CAMotics
@@ -451,8 +452,11 @@ class WSConnection(ClientConnection, tornado.websocket.WebSocketHandler):
tornado.websocket.WebSocketHandler.__init__(
self, app, request, **kwargs)
def send(self, msg): self.write_message(msg)
def open(self): self.on_open()
def send(self, msg):
self.write_message(msg)
def open(self):
self.on_open()
# Used by Web frontend