Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
kglovern committed Mar 8, 2024
2 parents a750549 + 10b4d3c commit f683254
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 76 deletions.
74 changes: 20 additions & 54 deletions src/app/lib/GCodeVirtualizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,6 @@ class GCodeVirtualizer extends EventEmitter {
];
feedrateCounter = 0;

hasSetV1 = false;

handlers = {
// G0: Rapid Linear Move
'G0': (params) => {
Expand Down Expand Up @@ -244,19 +242,11 @@ class GCodeVirtualizer extends EventEmitter {
this.updateBounds(targetPosition);
this.setPosition(targetPosition.x, targetPosition.y, targetPosition.z, targetPosition.a);

if (!this.hasSetV1) {
this.data[this.totalLines].lineData = {
v1: this.offsetG92(v1),
v2: this.offsetG92(v2),
shouldUseAddCurve: isCurvedLine && angleDiff > ANGLE_THRESHOLD,
};
this.hasSetV1 = true;
} else {
this.data[this.totalLines].lineData = {
v2: this.offsetG92(v2),
shouldUseAddCurve: isCurvedLine && angleDiff > ANGLE_THRESHOLD,
};
}
this.data[this.totalLines].lineData = {
v1: this.offsetG92(v1),
v2: this.offsetG92(v2),
shouldUseAddCurve: isCurvedLine && angleDiff > ANGLE_THRESHOLD,
};
},
// G1: Linear Move
// Usage
Expand Down Expand Up @@ -307,19 +297,11 @@ class GCodeVirtualizer extends EventEmitter {
this.updateBounds(targetPosition);
this.setPosition(targetPosition.x, targetPosition.y, targetPosition.z, targetPosition.a);

if (!this.hasSetV1) {
this.data[this.totalLines].lineData = {
v1: this.offsetG92(v1),
v2: this.offsetG92(v2),
shouldUseAddCurve: isCurvedLine && angleDiff > ANGLE_THRESHOLD,
};
this.hasSetV1 = true;
} else {
this.data[this.totalLines].lineData = {
v2: this.offsetG92(v2),
shouldUseAddCurve: isCurvedLine && angleDiff > ANGLE_THRESHOLD,
};
}
this.data[this.totalLines].lineData = {
v1: this.offsetG92(v1),
v2: this.offsetG92(v2),
shouldUseAddCurve: isCurvedLine && angleDiff > ANGLE_THRESHOLD,
};
},
// G2 & G3: Controlled Arc Move
// Usage
Expand Down Expand Up @@ -410,19 +392,11 @@ class GCodeVirtualizer extends EventEmitter {
this.updateBounds(targetPosition);
this.setPosition(targetPosition.x, targetPosition.y, targetPosition.z);

if (!this.hasSetV1) {
this.data[this.totalLines].lineData = {
v1: this.offsetG92(v1),
v2: this.offsetG92(v2),
v0: this.offsetG92(v0)
};
this.hasSetV1 = true;
} else {
this.data[this.totalLines].lineData = {
v2: this.offsetG92(v2),
v0: this.offsetG92(v0)
};
}
this.data[this.totalLines].lineData = {
v1: this.offsetG92(v1),
v2: this.offsetG92(v2),
v0: this.offsetG92(v0)
};
},
'G3': (params) => {
if (this.modal.motion !== 'G3') {
Expand Down Expand Up @@ -494,19 +468,11 @@ class GCodeVirtualizer extends EventEmitter {
this.updateBounds(targetPosition);
this.setPosition(targetPosition.x, targetPosition.y, targetPosition.z);

if (!this.hasSetV1) {
this.data[this.totalLines].lineData = {
v1: this.offsetG92(v1),
v2: this.offsetG92(v2),
v0: this.offsetG92(v0)
};
this.hasSetV1 = true;
} else {
this.data[this.totalLines].lineData = {
v2: this.offsetG92(v2),
v0: this.offsetG92(v0)
};
}
this.data[this.totalLines].lineData = {
v1: this.offsetG92(v1),
v2: this.offsetG92(v2),
v0: this.offsetG92(v0)
};
},
// G4: Dwell
// Parameters
Expand Down
13 changes: 11 additions & 2 deletions src/app/sagas/controllerSagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,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';
Expand Down Expand Up @@ -617,14 +618,22 @@ 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);
}
// if (isElectron() && (alarmReg.test(error.type) || errorReg.test(error.type))) {
// 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) => {
Expand All @@ -648,7 +657,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.',
Expand Down
12 changes: 8 additions & 4 deletions src/app/widgets/Visualizer/Visualizer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ class Visualizer extends Component {

vizualization = null;

colorsWorker = null;

renderCallback = null;

machineProfile = store.get('workspace.machineProfile');
Expand Down Expand Up @@ -829,6 +831,7 @@ class Visualizer extends Component {
pubsub.subscribe('colors:load', (_, data) => {
const { colorArray, savedColors } = data;
this.handleSceneRender(this.vizualization, colorArray, savedColors, this.renderCallback);
this.colorsWorker.terminate();
})
];
this.pubsubTokens = this.pubsubTokens.concat(tokens);
Expand Down Expand Up @@ -1764,15 +1767,16 @@ class Visualizer extends Component {
const shouldRenderVisualization = liteMode ? !disabledLite : !disabled;

if (shouldRenderVisualization) {
console.log(vizualization);
this.vizualization = vizualization;
this.renderCallback = callback;
let colorsWorker = new ColorsWorker();
colorsWorker.onmessage = colorsResponse;
colorsWorker.postMessage({
this.colorsWorker = new ColorsWorker();
this.colorsWorker.onmessage = colorsResponse;
this.colorsWorker.postMessage({
colors: vizualization.colors,
frames: vizualization.frames,
spindleSpeeds: vizualization.spindleSpeeds,
isLazer: vizualization.isLazer,
isLaser: vizualization.isLaser,
spindleChanges: vizualization.spindleChanges,
theme: currentTheme
});
Expand Down
15 changes: 2 additions & 13 deletions src/app/workers/Visualize.worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,21 +406,10 @@ onmessage = function({ data }) {

const entry = data[i];
if (entry.lineData) {
const { v2, v0, shouldUseAddCurve } = entry.lineData;
// use previous v2 as v1 unless there is no previous entry
let v1 = entry.lineData.v1;
if (!v1) {
// sometimes the last line doesn't have movements, so we must search for the last line with a movement
for (let x = i - 1; x >= 0; x--) {
if (data[x].lineData && data[x].lineData.v2) {
v1 = data[x].lineData.v2;
break;
}
}
}
const { v1, v2, v0, shouldUseAddCurve, dwellTime } = entry.lineData;

if (modal.motion === 'G4') {
vm.addToTotalTime(entry.lineData.dwellTime);
vm.addToTotalTime(dwellTime);
} else {
const targetPosition = { x: v2.x, y: v2.y, z: v2.z };
if (modal.motion === 'G1' || modal.motion === 'G0') {
Expand Down
4 changes: 2 additions & 2 deletions src/server/controllers/Grbl/GrblController.js
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ class GrblController {
this.sender.unhold();
}
this.sender.ack();
this.sender.next();
this.sender.next({ isOk: true });
return;
}

Expand All @@ -716,7 +716,7 @@ class GrblController {
log.debug(`Stop sending G-code: hold=${hold}, sent=${sent}, received=${received + 1}`);
}
this.sender.ack();
this.sender.next();
this.sender.next({ isOk: true });
return;
}

Expand Down
6 changes: 5 additions & 1 deletion src/server/controllers/Grblhal/GrblHalController.js
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,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,
Expand All @@ -828,7 +832,7 @@ class GrblHalController {
lineNumber: isFileError ? received + 1 : '',
origin: errorOrigin,
controller: GRBLHAL,
});
}, isRunning);
// Force propogation of current state on alarm
this.state = this.runner.state;

Expand Down

0 comments on commit f683254

Please sign in to comment.