From 17d6e416ed2dd3e350eefa61032c042f08c126ae Mon Sep 17 00:00:00 2001 From: Sophia Beluli Date: Thu, 15 Feb 2024 14:55:44 -0500 Subject: [PATCH] added disconnect recovery for alarms; if job is running when alarm happens, force workflow stop --- src/app/sagas/controllerSagas.js | 13 +++++++++++-- src/server/controllers/Grblhal/GrblHalController.js | 6 +++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/app/sagas/controllerSagas.js b/src/app/sagas/controllerSagas.js index 04f48a357..4b9acfc9e 100644 --- a/src/app/sagas/controllerSagas.js +++ b/src/app/sagas/controllerSagas.js @@ -59,6 +59,7 @@ import { ERROR, JOB_TYPES, JOB_STATUS, + GRBL, } from 'app/constants'; import { connectToLastDevice } from 'app/containers/Firmware/utils/index'; import { updateWorkspaceMode } from 'app/lib/rotary'; @@ -616,7 +617,9 @@ export function* initialize() { pubsub.publish('firmware:update', status); }); - controller.addListener('error', (error) => { + controller.addListener('error', (error, wasRunning) => { + const homingEnabled = _get(reduxStore.getState(), 'controller.settings.settings.$22'); + if (ALARM_ERROR_TYPES.includes(error.type)) { updateAlarmsErrors(error); } @@ -624,6 +627,12 @@ export function* initialize() { // window.ipcRenderer.send('logError:electron', error); // } pubsub.publish('error', error); + + // set need recovery for start from line when alarm happens + if (error.type === ALARM && wasRunning) { + console.log(error.lineNumber); + pubsub.publish('disconnect:recovery', error.lineNumber, homingEnabled); + } }); controller.addListener('wizard:next', (stepIndex, substepIndex) => { @@ -647,7 +656,7 @@ export function* initialize() { } } - if (type === FILE_TYPE.FOUR_AXIS && controller.type === 'Grbl') { + if (type === FILE_TYPE.FOUR_AXIS && controller.type === GRBL) { Confirm({ title: '4 Axis File Loaded', content: 'G-Code contains 4 simultaneous axis commands which are not supported at this time and cannot be run.', diff --git a/src/server/controllers/Grblhal/GrblHalController.js b/src/server/controllers/Grblhal/GrblHalController.js index bb1edd439..dc32e380c 100644 --- a/src/server/controllers/Grblhal/GrblHalController.js +++ b/src/server/controllers/Grblhal/GrblHalController.js @@ -816,6 +816,10 @@ class GrblHalController { if (alarm) { // Grbl v1.1 + const isRunning = this.workflow.isRunning(); + if (isRunning) { + this.workflow.stop(); + } this.emit('serialport:read', `ALARM:${code} (${alarm.message})`); this.emit('error', { type: ALARM, @@ -825,7 +829,7 @@ class GrblHalController { lineNumber: isFileError ? received + 1 : '', origin: errorOrigin, controller: GRBLHAL, - }); + }, isRunning); // Force propogation of current state on alarm this.state = this.runner.state;