Resolves #4 (4 years ago!). Adds delay (stops scripts for X seconds), alert (displays an alert that stops script execution) and pause (displays a pre-populated alert).
This commit is contained in:
parent
d9290f7262
commit
3c19cd35cf
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "1.7.20",
|
||||
"version": "1.7.21",
|
||||
"ext_port": 1111,
|
||||
"profiles": {
|
||||
"mcopy": {
|
||||
|
|
|
@ -612,6 +612,21 @@ class Commands {
|
|||
}
|
||||
return ms;
|
||||
}
|
||||
/**
|
||||
* Pauses a sequence for a length of time
|
||||
*
|
||||
* @returns {integer} Length of action in ms
|
||||
**/
|
||||
async pause(cmd) {
|
||||
let ms;
|
||||
try {
|
||||
ms = await delay_1.delay(cmd.light * 1000); //delay is in seconds
|
||||
}
|
||||
catch (err) {
|
||||
throw err;
|
||||
}
|
||||
return ms;
|
||||
}
|
||||
}
|
||||
module.exports = function (cfg, proj, cam, light, alert, cam2, proj2, capper) {
|
||||
return new Commands(cfg, proj, cam, light, alert, cam2, proj2, capper);
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -212,17 +212,23 @@ export default class Mscript {
|
|||
*/
|
||||
light_state(str: string): void;
|
||||
/**
|
||||
* Interpret a pause command
|
||||
* Interpret a delay command
|
||||
*
|
||||
* @param {string} line String containing pause command
|
||||
* @param {string} line String containing delay command
|
||||
**/
|
||||
pause(line: string): void;
|
||||
delay(line: string): void;
|
||||
/**
|
||||
* Interpret an alert command
|
||||
*
|
||||
* @param {string} line String containing pause command
|
||||
* @param {string} line String containing alert message
|
||||
**/
|
||||
alert(line: string): void;
|
||||
/**
|
||||
* Interpret an pause command
|
||||
*
|
||||
* @param {string} line String containing alert message
|
||||
**/
|
||||
pause(line: string): void;
|
||||
/**
|
||||
* Throw an error with specific message
|
||||
*
|
||||
|
|
|
@ -60,6 +60,7 @@ const ALTS = {
|
|||
'PFPB': [],
|
||||
'PBPF': []
|
||||
};
|
||||
const DELAY = 'DELAY';
|
||||
const PAUSE = 'PAUSE';
|
||||
const ALERT = 'ALERT';
|
||||
/** helper functions */
|
||||
|
@ -149,8 +150,11 @@ class Mscript {
|
|||
else if (CMD.indexOf(this.two) !== -1) {
|
||||
this.basic_cmd(line, this.two);
|
||||
}
|
||||
else if (startsWith(line, DELAY)) {
|
||||
this.delay(line);
|
||||
}
|
||||
else if (startsWith(line, PAUSE)) {
|
||||
//this.pause(line);
|
||||
this.pause(line);
|
||||
}
|
||||
else if (startsWith(line, ALERT)) {
|
||||
this.alert(line);
|
||||
|
@ -897,11 +901,11 @@ class Mscript {
|
|||
this.color = color;
|
||||
}
|
||||
/**
|
||||
* Interpret a pause command
|
||||
* Interpret a delay command
|
||||
*
|
||||
* @param {string} line String containing pause command
|
||||
* @param {string} line String containing delay command
|
||||
**/
|
||||
pause(line) {
|
||||
delay(line) {
|
||||
let lenStr = line.split(' ')[1] || '';
|
||||
let len;
|
||||
lenStr = lenStr.trim();
|
||||
|
@ -918,19 +922,19 @@ class Mscript {
|
|||
if (this.rec !== -1) {
|
||||
//hold generated arr in state loop array
|
||||
this.loops[this.rec].arr
|
||||
.push('PA');
|
||||
.push('DE');
|
||||
this.loops[this.rec].meta
|
||||
.push(lenStr);
|
||||
}
|
||||
else {
|
||||
this.arr.push('PA');
|
||||
this.arr.push('DE');
|
||||
this.meta.push(lenStr);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Interpret an alert command
|
||||
*
|
||||
* @param {string} line String containing pause command
|
||||
* @param {string} line String containing alert message
|
||||
**/
|
||||
alert(line) {
|
||||
let msg = line.split(' ')[1] || '';
|
||||
|
@ -947,6 +951,25 @@ class Mscript {
|
|||
this.meta.push(line);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Interpret an pause command
|
||||
*
|
||||
* @param {string} line String containing alert message
|
||||
**/
|
||||
pause(line) {
|
||||
const msg = "Paused script. Click OK to continue.";
|
||||
if (this.rec !== -1) {
|
||||
//hold generated arr in state loop array
|
||||
this.loops[this.rec].arr
|
||||
.push('AL');
|
||||
this.loops[this.rec].meta
|
||||
.push(msg);
|
||||
}
|
||||
else {
|
||||
this.arr.push('AL');
|
||||
this.meta.push(msg);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Throw an error with specific message
|
||||
*
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "mcopy-app",
|
||||
"version": "1.7.20",
|
||||
"version": "1.7.21",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "mcopy-app",
|
||||
"version": "1.7.20",
|
||||
"version": "1.7.21",
|
||||
"description": "GUI for the mcopy small gauge film optical printer platform",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "1.7.20",
|
||||
"version": "1.7.21",
|
||||
"ext_port": 1111,
|
||||
"profiles": {
|
||||
"mcopy": {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "mcopy",
|
||||
"version": "1.7.20",
|
||||
"version": "1.7.21",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "mcopy",
|
||||
"version": "1.7.20",
|
||||
"version": "1.7.21",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"arduino": "file:app/lib/arduino",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "mcopy",
|
||||
"version": "1.7.20",
|
||||
"version": "1.7.21",
|
||||
"description": "Small gauge film optical printer platform",
|
||||
"main": "build.js",
|
||||
"directories": {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "1.7.20",
|
||||
"version": "1.7.21",
|
||||
"ext_port": 1111,
|
||||
"profiles": {
|
||||
"mcopy": {
|
||||
|
|
|
@ -619,6 +619,23 @@ class Commands {
|
|||
}
|
||||
return ms;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pauses a sequence for a length of time
|
||||
*
|
||||
* @returns {integer} Length of action in ms
|
||||
**/
|
||||
|
||||
public async pause (cmd : any) {
|
||||
let ms : number;
|
||||
try {
|
||||
ms = await delay(cmd.light * 1000); //delay is in seconds
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
return ms;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function (cfg : any, proj : any, cam : any, light : any, alert : any, cam2 : any, proj2 : any, capper : any) {
|
||||
|
|
|
@ -72,6 +72,7 @@ const ALTS : any = {
|
|||
'PBPF' : [ ]
|
||||
};
|
||||
|
||||
const DELAY : string = 'DELAY';
|
||||
const PAUSE : string = 'PAUSE';
|
||||
const ALERT : string = 'ALERT';
|
||||
|
||||
|
@ -190,8 +191,10 @@ export default class Mscript {
|
|||
this.basic_cmd(line, this.three);
|
||||
} else if (CMD.indexOf(this.two) !== -1) {
|
||||
this.basic_cmd(line, this.two);
|
||||
} else if (startsWith(line, DELAY)) {
|
||||
this.delay(line);
|
||||
} else if (startsWith(line, PAUSE)) {
|
||||
//this.pause(line);
|
||||
this.pause(line);
|
||||
} else if (startsWith(line, ALERT)) {
|
||||
this.alert(line);
|
||||
} else if (startsWith(line, '@') || line.indexOf('@') !== -1) {
|
||||
|
@ -886,11 +889,11 @@ export default class Mscript {
|
|||
}
|
||||
|
||||
/**
|
||||
* Interpret a pause command
|
||||
* Interpret a delay command
|
||||
*
|
||||
* @param {string} line String containing pause command
|
||||
* @param {string} line String containing delay command
|
||||
**/
|
||||
pause (line : string) {
|
||||
delay (line : string) {
|
||||
let lenStr : string = line.split(' ')[1] || ''
|
||||
let len : number;
|
||||
lenStr = lenStr.trim();
|
||||
|
@ -910,11 +913,11 @@ export default class Mscript {
|
|||
if (this.rec !== -1) {
|
||||
//hold generated arr in state loop array
|
||||
this.loops[this.rec].arr
|
||||
.push('PA');
|
||||
.push('DE');
|
||||
this.loops[this.rec].meta
|
||||
.push(lenStr);
|
||||
} else {
|
||||
this.arr.push('PA');
|
||||
this.arr.push('DE');
|
||||
this.meta.push(lenStr);
|
||||
}
|
||||
}
|
||||
|
@ -922,7 +925,7 @@ export default class Mscript {
|
|||
/**
|
||||
* Interpret an alert command
|
||||
*
|
||||
* @param {string} line String containing pause command
|
||||
* @param {string} line String containing alert message
|
||||
**/
|
||||
alert (line : string) {
|
||||
let msg : string = line.split(' ')[1] || ''
|
||||
|
@ -939,6 +942,25 @@ export default class Mscript {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Interpret an pause command
|
||||
*
|
||||
* @param {string} line String containing alert message
|
||||
**/
|
||||
pause (line : string) {
|
||||
const msg : string = "Paused script. Click OK to continue."
|
||||
if (this.rec !== -1) {
|
||||
//hold generated arr in state loop array
|
||||
this.loops[this.rec].arr
|
||||
.push('AL');
|
||||
this.loops[this.rec].meta
|
||||
.push(msg);
|
||||
} else {
|
||||
this.arr.push('AL');
|
||||
this.meta.push(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw an error with specific message
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue