Rest of last commit. Renderer js

This commit is contained in:
sixteenmillimeter 2020-09-29 13:57:59 -04:00
parent 8672b6584a
commit 7c9543239e
4 changed files with 18 additions and 5 deletions

View File

@ -25,7 +25,7 @@ const KNOWN = [
* Class representing the arduino communication features
**/
class Arduino {
constructor() {
constructor(errorState) {
this.path = {};
this.known = KNOWN;
this.alias = {};
@ -35,6 +35,7 @@ class Arduino {
this.timer = 0;
this.lock = false;
this.locks = {};
this.errorState = errorState;
this.init();
}
async init() {
@ -169,6 +170,11 @@ class Arduino {
eventEmitter.emit('arduino_end', data);
delete this.queue[data];
}
else if (data === 'E') {
//error state
//stop sequence
//throw error in ui
}
else {
//console.log('Received stray "' + data + '"'); //silent to user
}
@ -391,10 +397,10 @@ class Arduino {
}
}
if (typeof module !== 'undefined' && module.parent) {
module.exports = function (c, ee) {
module.exports = function (c, ee, errorState) {
eventEmitter = ee;
cfg = c;
arduino = new Arduino();
arduino = new Arduino(errorState);
return arduino;
};
}

File diff suppressed because one or more lines are too long

View File

@ -23,6 +23,7 @@ class Devices {
listen() {
ipcRenderer.on('ready', this.ready.bind(this));
ipcRenderer.on('intval', this.intvalCb.bind(this));
ipcRenderer.on('error_state', this.errorState.bind(this));
}
ready(event, arg) {
return __awaiter(this, void 0, void 0, function* () {
@ -173,6 +174,12 @@ class Devices {
$('#intval').removeClass('active');
}
}
errorState() {
gui.spinner(false);
gui.overlay(false);
gui.notify('DEVICES', `Hardware error detected`);
gui.warn('Error', 'Hardware error detected. Please address before continuing.');
}
}
devices = new Devices();
module.exports = devices;

File diff suppressed because one or more lines are too long