Work towards issue #52. Adds a statement within the arduino.end() method that watches for an 'E' char byte and will alert the UI while pausing a running sequence. Needs to be in place for firmware to be able to throw errors to UI.
This commit is contained in:
parent
c5d7f9c91f
commit
8672b6584a
10
app/main.js
10
app/main.js
|
@ -68,6 +68,14 @@ var createWindow = function () {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var errorState = function () {
|
||||||
|
if (seq && seq.running) {
|
||||||
|
//pause sequence if running
|
||||||
|
seq.pause();
|
||||||
|
}
|
||||||
|
mainWindow.webContents.send('error_state', { stop : true });
|
||||||
|
}
|
||||||
|
|
||||||
var init = async function () {
|
var init = async function () {
|
||||||
log = await require('log')({})
|
log = await require('log')({})
|
||||||
|
|
||||||
|
@ -85,7 +93,7 @@ var init = async function () {
|
||||||
display = require('display')(SYSTEM)
|
display = require('display')(SYSTEM)
|
||||||
ffmpeg = require('ffmpeg')(SYSTEM)
|
ffmpeg = require('ffmpeg')(SYSTEM)
|
||||||
ffprobe = require('ffprobe')(SYSTEM)
|
ffprobe = require('ffprobe')(SYSTEM)
|
||||||
arduino = require('arduino')(cfg, ee)
|
arduino = require('arduino')(cfg, ee, errorState)
|
||||||
|
|
||||||
dev = require('devices')(arduino, settings, mainWindow)
|
dev = require('devices')(arduino, settings, mainWindow)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "mcopy-app",
|
"name": "mcopy-app",
|
||||||
"version": "1.6.5",
|
"version": "1.6.6",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "mcopy-app",
|
"name": "mcopy-app",
|
||||||
"version": "1.6.5",
|
"version": "1.6.6",
|
||||||
"description": "GUI for the mcopy small gauge film optical printer platform",
|
"description": "GUI for the mcopy small gauge film optical printer platform",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -19,6 +19,7 @@ class Devices {
|
||||||
listen () {
|
listen () {
|
||||||
ipcRenderer.on('ready', this.ready.bind(this));
|
ipcRenderer.on('ready', this.ready.bind(this));
|
||||||
ipcRenderer.on('intval', this.intvalCb.bind(this));
|
ipcRenderer.on('intval', this.intvalCb.bind(this));
|
||||||
|
ipcRenderer.on('error_state', this.errorState.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
async ready (event : any, arg : any) {
|
async ready (event : any, arg : any) {
|
||||||
|
@ -172,6 +173,13 @@ class Devices {
|
||||||
$('#intval').removeClass('active');
|
$('#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();
|
devices = new Devices();
|
||||||
|
|
|
@ -25,7 +25,7 @@ const KNOWN = [
|
||||||
* Class representing the arduino communication features
|
* Class representing the arduino communication features
|
||||||
**/
|
**/
|
||||||
class Arduino {
|
class Arduino {
|
||||||
constructor() {
|
constructor(errorState) {
|
||||||
this.path = {};
|
this.path = {};
|
||||||
this.known = KNOWN;
|
this.known = KNOWN;
|
||||||
this.alias = {};
|
this.alias = {};
|
||||||
|
@ -35,6 +35,7 @@ class Arduino {
|
||||||
this.timer = 0;
|
this.timer = 0;
|
||||||
this.lock = false;
|
this.lock = false;
|
||||||
this.locks = {};
|
this.locks = {};
|
||||||
|
this.errorState = errorState;
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
async init() {
|
async init() {
|
||||||
|
@ -169,6 +170,11 @@ class Arduino {
|
||||||
eventEmitter.emit('arduino_end', data);
|
eventEmitter.emit('arduino_end', data);
|
||||||
delete this.queue[data];
|
delete this.queue[data];
|
||||||
}
|
}
|
||||||
|
else if (data === 'E') {
|
||||||
|
//error state
|
||||||
|
//stop sequence
|
||||||
|
//throw error in ui
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
//console.log('Received stray "' + data + '"'); //silent to user
|
//console.log('Received stray "' + data + '"'); //silent to user
|
||||||
}
|
}
|
||||||
|
@ -391,10 +397,10 @@ class Arduino {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (typeof module !== 'undefined' && module.parent) {
|
if (typeof module !== 'undefined' && module.parent) {
|
||||||
module.exports = function (c, ee) {
|
module.exports = function (c, ee, errorState) {
|
||||||
eventEmitter = ee;
|
eventEmitter = ee;
|
||||||
cfg = c;
|
cfg = c;
|
||||||
arduino = new Arduino();
|
arduino = new Arduino(errorState);
|
||||||
return arduino;
|
return arduino;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "mcopy-cli",
|
"name": "mcopy-cli",
|
||||||
"version": "1.6.5",
|
"version": "1.6.6",
|
||||||
"description": "CLI for controlling the mcopy optical printer platform",
|
"description": "CLI for controlling the mcopy optical printer platform",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"version": "1.6.5",
|
"version": "1.6.6",
|
||||||
"ext_port": 1111,
|
"ext_port": 1111,
|
||||||
"profiles": {
|
"profiles": {
|
||||||
"mcopy": {
|
"mcopy": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "mcopy",
|
"name": "mcopy",
|
||||||
"version": "1.6.5",
|
"version": "1.6.6",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "mcopy",
|
"name": "mcopy",
|
||||||
"version": "1.6.5",
|
"version": "1.6.6",
|
||||||
"description": "Small gauge film optical printer platform",
|
"description": "Small gauge film optical printer platform",
|
||||||
"main": "build.js",
|
"main": "build.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
|
|
|
@ -33,18 +33,20 @@ const KNOWN : string[] = [
|
||||||
class Arduino {
|
class Arduino {
|
||||||
|
|
||||||
private log : any;
|
private log : any;
|
||||||
private path : any = {}
|
private path : any = {};
|
||||||
private known : string[] = KNOWN
|
private known : string[] = KNOWN;
|
||||||
private alias : any = {}
|
private alias : any = {};
|
||||||
private serial : any = { connect : {}, projector : {}, camera : {}, light : {} }
|
private serial : any = { connect : {}, projector : {}, camera : {}, light : {} };
|
||||||
private baud : number = 57600
|
private baud : number = 57600;
|
||||||
private queue : any = {}
|
private queue : any = {};
|
||||||
private timer : number = 0
|
private timer : number = 0;
|
||||||
private lock : boolean = false
|
private lock : boolean = false;
|
||||||
private locks : any = {}
|
private locks : any = {};
|
||||||
private confirmExec : any
|
private confirmExec : any;
|
||||||
|
private errorState : Function;
|
||||||
|
|
||||||
constructor () {
|
constructor (errorState : Function) {
|
||||||
|
this.errorState = errorState;
|
||||||
this.init()
|
this.init()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,14 +171,18 @@ class Arduino {
|
||||||
}
|
}
|
||||||
|
|
||||||
end (serial : string, data : string) {
|
end (serial : string, data : string) {
|
||||||
const end = new Date().getTime();
|
const end : number = new Date().getTime();
|
||||||
const ms = end - this.timer;
|
const ms : number = end - this.timer;
|
||||||
let complete;
|
let complete : any;
|
||||||
if (this.queue[data] !== undefined) {
|
if (this.queue[data] !== undefined) {
|
||||||
this.locks[serial] = false;
|
this.locks[serial] = false;
|
||||||
complete = this.queue[data](ms); //execute callback
|
complete = this.queue[data](ms); //execute callback
|
||||||
eventEmitter.emit('arduino_end', data);
|
eventEmitter.emit('arduino_end', data);
|
||||||
delete this.queue[data];
|
delete this.queue[data];
|
||||||
|
} else if (data === 'E') {
|
||||||
|
//error state
|
||||||
|
//stop sequence
|
||||||
|
//throw error in ui
|
||||||
} else {
|
} else {
|
||||||
//console.log('Received stray "' + data + '"'); //silent to user
|
//console.log('Received stray "' + data + '"'); //silent to user
|
||||||
}
|
}
|
||||||
|
@ -397,10 +403,10 @@ class Arduino {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof module !== 'undefined' && module.parent) {
|
if (typeof module !== 'undefined' && module.parent) {
|
||||||
module.exports = function (c : any, ee : any) {
|
module.exports = function (c : any, ee : any, errorState : Function) {
|
||||||
eventEmitter = ee
|
eventEmitter = ee
|
||||||
cfg = c
|
cfg = c
|
||||||
arduino = new Arduino()
|
arduino = new Arduino(errorState)
|
||||||
return arduino
|
return arduino
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue