Merge branch 'main' into canon_ble

This commit is contained in:
Matt McWilliams 2023-02-28 15:59:11 -05:00
commit d23eb290d9
35 changed files with 406 additions and 107 deletions

View File

@ -1,5 +1,5 @@
{ {
"version": "1.7.20", "version": "1.7.21",
"ext_port": 1111, "ext_port": 1111,
"profiles": { "profiles": {
"mcopy": { "mcopy": {

View File

@ -2497,6 +2497,7 @@ const devices = require('./lib/ui/devices.js');
const filmout = require('./lib/ui/filmout.js'); const filmout = require('./lib/ui/filmout.js');
const mse = require('./lib/ui/mscript.js'); const mse = require('./lib/ui/mscript.js');
const capper = require('./lib/ui/capper.js'); const capper = require('./lib/ui/capper.js');
const timing = require('./lib/ui/timing.js');
const Mscript = require('./lib/mscript'); const Mscript = require('./lib/mscript');
const { delay } = require('./lib/delay'); const { delay } = require('./lib/delay');
const alertObj = require('./lib/ui/alert.js'); const alertObj = require('./lib/ui/alert.js');

View File

@ -612,6 +612,21 @@ class Commands {
} }
return ms; 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) { module.exports = function (cfg, proj, cam, light, alert, cam2, proj2, capper) {
return new Commands(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

View File

@ -1,8 +0,0 @@
/**
* Delay in an async/await function
*
* @param {integer} ms Milliseconds to delay for
*
* @returns {Promise} Promise to resolve after timeout
**/
declare function delay(ms: number): Promise<unknown>;

View File

@ -41,9 +41,16 @@ class Devices {
* local settings object. * local settings object.
**/ **/
listener(event, arg) { listener(event, arg) {
this.log.info(`Saving profile ${arg.profile}`, 'SETTINGS', false, false); if (typeof arg.profile !== 'undefined') {
this.settings.update('profile', arg.profile); this.log.info(`Saving profile ${arg.profile}`, 'SETTINGS', false, false);
this.settings.save(); this.settings.update('profile', arg.profile);
this.settings.save();
}
if (typeof arg.timing !== 'undefined') {
this.log.info(`Saving timing info`, 'SETTINGS', false, false);
this.settings.update('timing', arg.timing);
this.settings.save();
}
} }
/** /**
* *
@ -510,6 +517,9 @@ class Devices {
light, light,
profile: this.settings.state.profile profile: this.settings.state.profile
}; };
if (this.settings.state.timing) {
args.timing = this.settings.state.timing;
}
if (projector_second && projector_second.arduino) { if (projector_second && projector_second.arduino) {
args.projector_second = projector_second; args.projector_second = projector_second;
this.settings.update('projector_second', projector_second); this.settings.update('projector_second', projector_second);

File diff suppressed because one or more lines are too long

View File

@ -212,17 +212,23 @@ export default class Mscript {
*/ */
light_state(str: string): void; 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 * Interpret an alert command
* *
* @param {string} line String containing pause command * @param {string} line String containing alert message
**/ **/
alert(line: string): void; 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 * Throw an error with specific message
* *

View File

@ -60,6 +60,7 @@ const ALTS = {
'PFPB': [], 'PFPB': [],
'PBPF': [] 'PBPF': []
}; };
const DELAY = 'DELAY';
const PAUSE = 'PAUSE'; const PAUSE = 'PAUSE';
const ALERT = 'ALERT'; const ALERT = 'ALERT';
/** helper functions */ /** helper functions */
@ -149,8 +150,11 @@ class Mscript {
else if (CMD.indexOf(this.two) !== -1) { else if (CMD.indexOf(this.two) !== -1) {
this.basic_cmd(line, this.two); this.basic_cmd(line, this.two);
} }
else if (startsWith(line, DELAY)) {
this.delay(line);
}
else if (startsWith(line, PAUSE)) { else if (startsWith(line, PAUSE)) {
//this.pause(line); this.pause(line);
} }
else if (startsWith(line, ALERT)) { else if (startsWith(line, ALERT)) {
this.alert(line); this.alert(line);
@ -897,11 +901,11 @@ class Mscript {
this.color = color; 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 lenStr = line.split(' ')[1] || '';
let len; let len;
lenStr = lenStr.trim(); lenStr = lenStr.trim();
@ -918,19 +922,19 @@ class Mscript {
if (this.rec !== -1) { if (this.rec !== -1) {
//hold generated arr in state loop array //hold generated arr in state loop array
this.loops[this.rec].arr this.loops[this.rec].arr
.push('PA'); .push('DE');
this.loops[this.rec].meta this.loops[this.rec].meta
.push(lenStr); .push(lenStr);
} }
else { else {
this.arr.push('PA'); this.arr.push('DE');
this.meta.push(lenStr); this.meta.push(lenStr);
} }
} }
/** /**
* Interpret an alert command * Interpret an alert command
* *
* @param {string} line String containing pause command * @param {string} line String containing alert message
**/ **/
alert(line) { alert(line) {
let msg = line.split(' ')[1] || ''; let msg = line.split(' ')[1] || '';
@ -947,6 +951,25 @@ class Mscript {
this.meta.push(line); 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 * Throw an error with specific message
* *

File diff suppressed because one or more lines are too long

View File

@ -19,7 +19,8 @@ class Settings {
camera: {}, camera: {},
projector: {}, projector: {},
light: {}, light: {},
capper: {} capper: {},
timing: {}
}; };
this.state = this.freshState(); this.state = this.freshState();
} }

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/settings/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,yBAA0B;AAC1B,6BAA8B;AAC9B,+BAAgC;AAEhC,MAAM,QAAQ;IAeb;;QAEI;IACJ;QAjBQ,SAAI,GAAW,IAAI,CAAC,IAAI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;SACZ;IACF,CAAC;IACD;;QAEI;IACG,KAAK,CAAC,KAAK;QACjB,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,MAAM,EAAE;YACX,IAAI;gBACH,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAC3B;YAAC,OAAO,GAAG,EAAE;gBACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;aACnB;SACD;QACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAC/B,IAAI,CAAC,OAAO,EAAE,CAAC;IAChB,CAAC;IAAA,CAAC;CACF;AAED,MAAM,CAAC,OAAO,GAAG,IAAI,QAAQ,EAAE,CAAA"}

View File

@ -80,6 +80,7 @@ cam.end = function (c, id, ms) {
} }
gui.counterUpdate('cam2', cam.second.pos); gui.counterUpdate('cam2', cam.second.pos);
} }
timing.update(c, ms);
gui.counterUpdate('cam', cam.pos) gui.counterUpdate('cam', cam.pos)
if (typeof cam.queue[id] !== 'undefined') { if (typeof cam.queue[id] !== 'undefined') {
if (typeof cam.queue[id].callback !== 'undefined') { if (typeof cam.queue[id].callback !== 'undefined') {
@ -182,6 +183,7 @@ cam.second.end = function (c, id, ms) {
cam.second.pos -= 1; cam.second.pos -= 1;
} }
} }
timing.update(c, ms);
gui.counterUpdate('cam2', cam.second.pos) gui.counterUpdate('cam2', cam.second.pos)
if (typeof cam.second.queue[id] !== 'undefined') { if (typeof cam.second.queue[id] !== 'undefined') {
if (typeof cam.queue[id].callback !== 'undefined') { if (typeof cam.queue[id].callback !== 'undefined') {

View File

@ -83,8 +83,12 @@ class Devices {
else { else {
light.enable(); light.enable();
} }
timing.reset(p);
//devices.profile(arg.profile) //devices.profile(arg.profile)
} }
if (arg && arg.timing) {
timing.restore(arg.timing);
}
if (arg.projector_second) { if (arg.projector_second) {
//add second row of projector pads to grid //add second row of projector pads to grid
proj.second.enable(); proj.second.enable();
@ -128,6 +132,7 @@ class Devices {
for (let key of keys) { for (let key of keys) {
cfg[key] = keys[key]; cfg[key] = keys[key];
} }
timing.reset(p);
if (typeof p.light !== 'undefined' && p.light === false) { if (typeof p.light !== 'undefined' && p.light === false) {
light.disable(); light.disable();
} }
@ -135,6 +140,7 @@ class Devices {
light.enable(); light.enable();
} }
ipcRenderer.send('profile', { profile }); ipcRenderer.send('profile', { profile });
timing.store();
} }
intval() { intval() {
const url = $('#intval').val(); const url = $('#intval').val();

File diff suppressed because one or more lines are too long

View File

@ -173,6 +173,7 @@ proj.second.end = function (c, id, ms) {
proj.second.pos -= 1; proj.second.pos -= 1;
} }
} }
timing.update(c, ms);
gui.counterUpdate('proj2', proj.second.pos); gui.counterUpdate('proj2', proj.second.pos);
if (typeof proj.second.queue[id] !== 'undefined') { if (typeof proj.second.queue[id] !== 'undefined') {
if (typeof proj.second.queue[id].callback !== 'undefined') { if (typeof proj.second.queue[id].callback !== 'undefined') {

View File

@ -51,6 +51,8 @@ class Sequence {
$('#cmd_capper_off').addClass('active'); $('#cmd_capper_off').addClass('active');
$('#cmd_capper_on').removeClass('active'); $('#cmd_capper_on').removeClass('active');
} }
this.stats();
timing.store();
} }
} }
return event.returnValue = true; return event.returnValue = true;
@ -178,23 +180,8 @@ class Sequence {
if (!step) if (!step)
continue; continue;
c = step.cmd; c = step.cmd;
if (c === cfg.cmd.camera_forward || c === cfg.cmd.camera_backward) { ms += timing.get(c);
ms += cfg.arduino.cam.time; ms += cfg.arduino.serialDelay;
ms += cfg.arduino.cam.delay;
ms += cfg.arduino.serialDelay;
}
if (c === cfg.cmd.projector_forward || c === cfg.cmd.projector_backward) {
ms += cfg.arduino.proj.time;
ms += cfg.arduino.proj.delay;
ms += cfg.arduino.serialDelay;
}
if (c === cfg.cmd.black_forward || c === cfg.cmd.black_backward) {
ms += cfg.arduino.black.before;
ms += cfg.arduino.black.after;
ms += cfg.arduino.cam.time;
ms += cfg.arduino.cam.delay;
ms += cfg.arduino.serialDelay;
}
ms += cfg.arduino.sequenceDelay; ms += cfg.arduino.sequenceDelay;
if (c === cfg.cmd.camera_forward || c === cfg.cmd.black_forward) { if (c === cfg.cmd.camera_forward || c === cfg.cmd.black_forward) {
cam_total++; cam_total++;

File diff suppressed because one or more lines are too long

96
app/lib/ui/timing.js Normal file
View File

@ -0,0 +1,96 @@
'use strict';
let timing;
class Timing {
constructor() {
this.data = {};
this.fromArduino = {
'c': 'cam',
'3': 'cam2',
'4': 'cams',
'b': 'black',
'p': 'proj',
'w': 'proj2',
'x': 'projs'
};
this.fromCmd = {
'CF': 'cam',
'CB': 'cam',
'BF': 'black',
'BB': 'black',
'C2F': 'cam2',
'C2B': 'cam2',
'CCF': 'cams',
'CCB': 'cams',
'CFCB': 'cams',
'CBCF': 'cams',
'PF': 'proj',
'PB': 'proj',
'P2F': 'proj2',
'P2B': 'proj2',
'PPF': 'projs',
'PPB': 'projs',
'PFPB': 'projs',
'PBPF': 'projs'
};
}
reset(profile) {
const keys = Object.keys(profile);
const cmds = Object.keys(cfg.cmd);
let cam;
let proj;
let pad;
for (let key of keys) {
console.log(key);
if (key === 'label') {
continue;
}
else if (key === 'cam') {
cam = 0;
cam += profile[key].time;
cam += profile[key].delay;
cam += profile[key].momentary;
pad = 0;
if (typeof profile['black'] !== 'undefined' && typeof profile['black'].before !== 'undefined' && typeof profile['black'].after !== 'undefined') {
pad = (profile['black'].before + profile['black'].after);
}
this.data['cam'] = cam;
this.data['cam2'] = cam;
this.data['cams'] = cam;
this.data['black'] = cam + pad;
}
else if (key === 'proj') {
proj = 0;
proj += profile[key].time;
proj += profile[key].delay;
proj += profile[key].momentary;
this.data['proj'] = proj;
this.data['proj2'] = proj;
this.data['projs'] = proj;
}
}
}
restore(timing) {
this.data = timing;
}
//update with rolling average
update(c, ms) {
let cmd = this.fromArduino[c];
if (typeof cmd !== 'undefined' && typeof this.data[cmd] !== 'undefined') {
this.data[cmd] = Math.round((this.data[cmd] + ms) / 2);
}
}
//get current value
get(c) {
const cmd = this.fromCmd[c];
if (typeof cmd !== 'undefined' && typeof this.data[cmd] !== 'undefined') {
return this.data[cmd];
}
return 0;
}
store() {
ipcRenderer.send('profile', { timing: this.data });
}
}
timing = new Timing();
module.exports = timing;
//# sourceMappingURL=timing.js.map

1
app/lib/ui/timing.js.map Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"timing.js","sourceRoot":"","sources":["../../src/lib/ui/timing.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,IAAI,MAAe,CAAC;AAMpB,MAAM,MAAM;IAoCX;QAnCO,SAAI,GAAgB,EAE1B,CAAA;QAEO,gBAAW,GAAS;YAC3B,GAAG,EAAG,KAAK;YACR,GAAG,EAAG,MAAM;YACZ,GAAG,EAAG,MAAM;YACZ,GAAG,EAAG,OAAO;YAChB,GAAG,EAAG,MAAM;YACT,GAAG,EAAG,OAAO;YAChB,GAAG,EAAG,OAAO;SACb,CAAA;QAEO,YAAO,GAAU;YACxB,IAAI,EAAG,KAAK;YACZ,IAAI,EAAG,KAAK;YACZ,IAAI,EAAG,OAAO;YACX,IAAI,EAAG,OAAO;YACd,KAAK,EAAE,MAAM;YACb,KAAK,EAAE,MAAM;YACb,KAAK,EAAG,MAAM;YACd,KAAK,EAAG,MAAM;YACd,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,MAAM;YACjB,IAAI,EAAG,MAAM;YACb,IAAI,EAAG,MAAM;YACb,KAAK,EAAG,OAAO;YACf,KAAK,EAAG,OAAO;YACf,KAAK,EAAG,OAAO;YACf,KAAK,EAAG,OAAO;YACf,MAAM,EAAG,OAAO;YAChB,MAAM,EAAG,OAAO;SAChB,CAAA;IAID,CAAC;IAEM,KAAK,CAAE,OAAa;QAC1B,MAAM,IAAI,GAAc,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7C,MAAM,IAAI,GAAc,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAA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AM,EAAE,CAAC;AAEtB,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC"}

View File

@ -20,26 +20,26 @@ const { delay } = require('delay')
//Objects //Objects
const mcopy = {} const mcopy = {}
let SYSTEM; let SYSTEM
let log; let log
let mainWindow; let mainWindow
let arduino; let arduino
let menu; let menu
let display; let display
let ffmpeg; let ffmpeg
let ffprobe; let ffprobe
let cam; let cam
let cam2; let cam2
let proj; let proj
let proj2; let proj2
let light; let light
let filmout; let filmout
let dev; let dev
let cmd; let cmd
let seq; let seq
let capper; let capper
let alert; let alert
let server; let server
const cfg = require('./data/cfg.json') const cfg = require('./data/cfg.json')
@ -142,12 +142,12 @@ var init = async function () {
app.on('ready', init) app.on('ready', init)
app.on('window-all-closed', () => { app.on('window-all-closed', () => {
app.quit(); app.quit()
}); });
app.on('activate', () => { app.on('activate', () => {
if (mainWindow === null) { if (mainWindow === null) {
createWindow(); createWindow()
} }
}); });

2
app/package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "mcopy-app", "name": "mcopy-app",
"version": "1.7.20", "version": "1.7.21",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {

View File

@ -1,6 +1,6 @@
{ {
"name": "mcopy-app", "name": "mcopy-app",
"version": "1.7.20", "version": "1.7.21",
"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": {

View File

@ -23,6 +23,7 @@ const devices = require('./lib/ui/devices.js');
const filmout = require('./lib/ui/filmout.js'); const filmout = require('./lib/ui/filmout.js');
const mse = require('./lib/ui/mscript.js'); const mse = require('./lib/ui/mscript.js');
const capper = require('./lib/ui/capper.js'); const capper = require('./lib/ui/capper.js');
const timing = require('./lib/ui/timing.js');
const Mscript = require('./lib/mscript'); const Mscript = require('./lib/mscript');
const { delay } = require('./lib/delay'); const { delay } = require('./lib/delay');
const alertObj = require('./lib/ui/alert.js'); const alertObj = require('./lib/ui/alert.js');

View File

@ -79,8 +79,12 @@ class Devices {
} else { } else {
light.enable(); light.enable();
} }
timing.reset(p);
//devices.profile(arg.profile) //devices.profile(arg.profile)
} }
if (arg && arg.timing) {
timing.restore(arg.timing);
}
if (arg.projector_second) { if (arg.projector_second) {
//add second row of projector pads to grid //add second row of projector pads to grid
@ -126,14 +130,17 @@ class Devices {
const p : any = cfg.profiles[profile]; const p : any = cfg.profiles[profile];
const keys : any[] = Object.keys(p); const keys : any[] = Object.keys(p);
for (let key of keys) { for (let key of keys) {
cfg[key] = keys[key] cfg[key] = keys[key];
} }
timing.reset(p);
if (typeof p.light !== 'undefined' && p.light === false) { if (typeof p.light !== 'undefined' && p.light === false) {
light.disable(); light.disable();
} else { } else {
light.enable(); light.enable();
} }
ipcRenderer.send('profile', { profile }) ipcRenderer.send('profile', { profile })
timing.store();
} }
intval () { intval () {

View File

@ -75,6 +75,8 @@ class Sequence {
$('#cmd_capper_off').addClass('active'); $('#cmd_capper_off').addClass('active');
$('#cmd_capper_on').removeClass('active'); $('#cmd_capper_on').removeClass('active');
} }
this.stats();
timing.store();
} }
} }
return event.returnValue = true; return event.returnValue = true;
@ -207,28 +209,13 @@ class Sequence {
} }
return true; return true;
}); });
//timing //timing
for (let step of this.grid) { for (let step of this.grid) {
if (!step) continue if (!step) continue
c = step.cmd; c = step.cmd;
if (c === cfg.cmd.camera_forward || c === cfg.cmd.camera_backward){ ms += timing.get(c);
ms += cfg.arduino.cam.time; ms += cfg.arduino.serialDelay;
ms += cfg.arduino.cam.delay;
ms += cfg.arduino.serialDelay;
}
if (c === cfg.cmd.projector_forward || c === cfg.cmd.projector_backward){
ms += cfg.arduino.proj.time;
ms += cfg.arduino.proj.delay;
ms += cfg.arduino.serialDelay;
}
if (c === cfg.cmd.black_forward || c === cfg.cmd.black_backward){
ms += cfg.arduino.black.before;
ms += cfg.arduino.black.after;
ms += cfg.arduino.cam.time;
ms += cfg.arduino.cam.delay;
ms += cfg.arduino.serialDelay;
}
ms += cfg.arduino.sequenceDelay; ms += cfg.arduino.sequenceDelay;
if (c === cfg.cmd.camera_forward || c === cfg.cmd.black_forward) { if (c === cfg.cmd.camera_forward || c === cfg.cmd.black_forward) {

113
app/src/lib/ui/timing.ts Normal file
View File

@ -0,0 +1,113 @@
'use strict';
let timing : Timing;
interface TimingData {
[key: string]: number;
}
class Timing {
public data : TimingData = {
}
private fromArduino : any = {
'c' : 'cam',
'3' : 'cam2',
'4' : 'cams',
'b' : 'black',
'p' : 'proj',
'w' : 'proj2',
'x' : 'projs'
}
private fromCmd : any = {
'CF' : 'cam',
'CB' : 'cam',
'BF' : 'black',
'BB' : 'black',
'C2F': 'cam2',
'C2B': 'cam2',
'CCF' : 'cams',
'CCB' : 'cams',
'CFCB': 'cams',
'CBCF': 'cams',
'PF' : 'proj',
'PB' : 'proj',
'P2F' : 'proj2',
'P2B' : 'proj2',
'PPF' : 'projs',
'PPB' : 'projs',
'PFPB' : 'projs',
'PBPF' : 'projs'
}
constructor () {
}
public reset (profile : any) {
const keys : string[] = Object.keys(profile);
const cmds : string[] = Object.keys(cfg.cmd);
let cam : number;
let proj : number;
let pad : number;
for (let key of keys) {
if (key === 'label') {
continue
} else if (key === 'cam') {
cam = 0;
cam += profile[key].time;
cam += profile[key].delay;
cam += profile[key].momentary;
pad = 0;
if (typeof profile['black'] !== 'undefined' && typeof profile['black'].before !== 'undefined' && typeof profile['black'].after !== 'undefined') {
pad = (profile['black'].before + profile['black'].after);
}
this.data['cam'] = cam
this.data['cam2'] = cam
this.data['cams'] = cam
this.data['black'] = cam + pad
} else if (key === 'proj') {
proj = 0;
proj += profile[key].time;
proj += profile[key].delay;
proj += profile[key].momentary;
this.data['proj'] = proj;
this.data['proj2'] = proj;
this.data['projs'] = proj;
}
}
}
public restore (timing : TimingData) {
this.data = timing;
}
//update with rolling average
public update (c : string, ms : number) {
let cmd : string = this.fromArduino[c];
if (typeof cmd !== 'undefined' && typeof this.data[cmd] !== 'undefined') {
this.data[cmd] = Math.round((this.data[cmd] + ms) / 2);
}
}
//get current value
public get (c : string) : number {
const cmd : string = this.fromCmd[c];
if (typeof cmd !== 'undefined' && typeof this.data[cmd] !== 'undefined') {
return this.data[cmd];
}
return 0;
}
public store () {
ipcRenderer.send('profile', { timing : this.data })
}
}
timing = new Timing();
module.exports = timing;

View File

@ -1,5 +1,5 @@
{ {
"version": "1.7.20", "version": "1.7.21",
"ext_port": 1111, "ext_port": 1111,
"profiles": { "profiles": {
"mcopy": { "mcopy": {

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "mcopy", "name": "mcopy",
"version": "1.7.20", "version": "1.7.21",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "mcopy", "name": "mcopy",
"version": "1.7.20", "version": "1.7.21",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"arduino": "file:app/lib/arduino", "arduino": "file:app/lib/arduino",

View File

@ -1,6 +1,6 @@
{ {
"name": "mcopy", "name": "mcopy",
"version": "1.7.20", "version": "1.7.21",
"description": "Small gauge film optical printer platform", "description": "Small gauge film optical printer platform",
"main": "build.js", "main": "build.js",
"directories": { "directories": {

View File

@ -1,5 +1,5 @@
{ {
"version": "1.7.20", "version": "1.7.21",
"ext_port": 1111, "ext_port": 1111,
"profiles": { "profiles": {
"mcopy": { "mcopy": {

View File

@ -619,6 +619,23 @@ class Commands {
} }
return ms; 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) { module.exports = function (cfg : any, proj : any, cam : any, light : any, alert : any, cam2 : any, proj2 : any, capper : any) {

View File

@ -53,9 +53,16 @@ class Devices {
* local settings object. * local settings object.
**/ **/
private listener (event : any, arg : any){ private listener (event : any, arg : any){
this.log.info(`Saving profile ${arg.profile}`, 'SETTINGS', false, false); if (typeof arg.profile !== 'undefined') {
this.settings.update('profile', arg.profile); this.log.info(`Saving profile ${arg.profile}`, 'SETTINGS', false, false);
this.settings.save(); this.settings.update('profile', arg.profile);
this.settings.save();
}
if (typeof arg.timing !== 'undefined') {
this.log.info(`Saving timing info`, 'SETTINGS', false, false);
this.settings.update('timing', arg.timing);
this.settings.save();
}
} }
/** /**
* *
@ -501,7 +508,10 @@ class Devices {
camera, camera,
projector, projector,
light, light,
profile: this.settings.state.profile profile: this.settings.state.profile
}
if (this.settings.state.timing) {
args.timing = this.settings.state.timing
} }
if (projector_second && projector_second.arduino) { if (projector_second && projector_second.arduino) {

View File

@ -72,6 +72,7 @@ const ALTS : any = {
'PBPF' : [ ] 'PBPF' : [ ]
}; };
const DELAY : string = 'DELAY';
const PAUSE : string = 'PAUSE'; const PAUSE : string = 'PAUSE';
const ALERT : string = 'ALERT'; const ALERT : string = 'ALERT';
@ -190,8 +191,10 @@ export default class Mscript {
this.basic_cmd(line, this.three); this.basic_cmd(line, this.three);
} else if (CMD.indexOf(this.two) !== -1) { } else if (CMD.indexOf(this.two) !== -1) {
this.basic_cmd(line, this.two); this.basic_cmd(line, this.two);
} else if (startsWith(line, DELAY)) {
this.delay(line);
} else if (startsWith(line, PAUSE)) { } else if (startsWith(line, PAUSE)) {
//this.pause(line); this.pause(line);
} else if (startsWith(line, ALERT)) { } else if (startsWith(line, ALERT)) {
this.alert(line); this.alert(line);
} else if (startsWith(line, '@') || line.indexOf('@') !== -1) { } 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 lenStr : string = line.split(' ')[1] || ''
let len : number; let len : number;
lenStr = lenStr.trim(); lenStr = lenStr.trim();
@ -910,11 +913,11 @@ export default class Mscript {
if (this.rec !== -1) { if (this.rec !== -1) {
//hold generated arr in state loop array //hold generated arr in state loop array
this.loops[this.rec].arr this.loops[this.rec].arr
.push('PA'); .push('DE');
this.loops[this.rec].meta this.loops[this.rec].meta
.push(lenStr); .push(lenStr);
} else { } else {
this.arr.push('PA'); this.arr.push('DE');
this.meta.push(lenStr); this.meta.push(lenStr);
} }
} }
@ -922,7 +925,7 @@ export default class Mscript {
/** /**
* Interpret an alert command * Interpret an alert command
* *
* @param {string} line String containing pause command * @param {string} line String containing alert message
**/ **/
alert (line : string) { alert (line : string) {
let msg : string = line.split(' ')[1] || '' 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 * Throw an error with specific message
* *

View File

@ -16,7 +16,8 @@ class Settings {
camera : {}, camera : {},
projector : {}, projector : {},
light : {}, light : {},
capper : {} capper : {},
timing : {}
} }
public state : any; public state : any;
/** /**