Skip to content

Commit

Permalink
Override control commands should be properly handled in accordance wi…
Browse files Browse the repository at this point in the history
…th the firmware version (resolves #160)
  • Loading branch information
cheton committed Jun 14, 2017
1 parent 4502b06 commit b96c51d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
14 changes: 8 additions & 6 deletions src/app/controllers/TinyG/TinyG.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,23 +139,24 @@ class TinyGParserResultSystemSettings {

class TinyGParserResultOverrides {
static parse(data) {
const footer = _.get(data, 'f') || [];
const statusCode = footer[1];
const mfo = _.get(data, 'r.mfo');
const mto = _.get(data, 'r.mto');
const sso = _.get(data, 'r.sso');
const payload = {};

if (!mfo && !mto && !sso) {
if ((typeof mfo === 'undefined') && (typeof mto === 'undefined') && (typeof sso === 'undefined')) {
return null;
}

const payload = {};

if (mfo) {
if (mfo && statusCode === 0) {
payload.mfo = mfo;
}
if (mto) {
if (mto && statusCode === 0) {
payload.mto = mto;
}
if (sso) {
if (sso && statusCode === 0) {
payload.sso = sso;
}

Expand Down Expand Up @@ -410,6 +411,7 @@ class TinyG extends events.EventEmitter {
mto = this.settings.mto,
sso = this.settings.sso
} = payload;

this.settings = { // enforce change
...this.settings,
mfo,
Expand Down
15 changes: 11 additions & 4 deletions src/web/widgets/TinyG/TinyG.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,17 @@ class TinyG extends PureComponent {
const { state, actions } = this.props;
const none = '–';
const controllerState = state.controller.state;
const { mfo, mto, sso } = state.controller.settings;
const ovF = Math.round(mfo * 100) || 0;
const ovS = Math.round(sso * 100) || 0;
const ovT = Math.round(mto * 100) || 0;
const controllerSettings = state.controller.settings;
const { fv, mfo, mto, sso } = controllerSettings;
// https://github.com/cncjs/cncjs/issues/160
// Firmware | mfo | sso | mto
// -------- | --- | --- | ----
// 0.97 | No | No | No
// 0.98 | No | Yes | No
// 0.99 | Yes | Yes | Yes
const ovF = (fv >= 0.99) ? Math.round(mfo * 100) || 0 : 0;
const ovS = (fv >= 0.98) ? Math.round(sso * 100) || 0 : 0;
const ovT = (fv >= 0.99) ? Math.round(mto * 100) || 0 : 0;
const machineState = _.get(controllerState, 'sr.machineState');
const machineStateText = {
[TINYG_MACHINE_STATE_INITIALIZING]: i18n.t('controller:TinyG.machineState.initializing'),
Expand Down

0 comments on commit b96c51d

Please sign in to comment.