Sequence now runs entirely in the main process. Renderer no longer stores the sequence, it is a for loop inside the main process.

This commit is contained in:
mmcwilliams 2019-03-23 21:58:22 -04:00
parent 11e9176cb8
commit 43ee0d0672
28 changed files with 239 additions and 86 deletions

View File

@ -1,5 +1,5 @@
{ {
"version": "1.3.3", "version": "1.4.0",
"ext_port": 1111, "ext_port": 1111,
"profiles": { "profiles": {
"mcopy": { "mcopy": {

View File

@ -2568,4 +2568,5 @@ async function init () {
light.init(); light.init();
proj.init(); proj.init();
cam.init(); cam.init();
seq.init();
}; };

View File

@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const Log = require("log"); const Log = require("log");
let seq; let seq;
class Sequencer { class Sequencer {
constructor(cfg, cmd) { constructor(cfg, cmd, ui) {
this.running = false; this.running = false;
this.paused = false; this.paused = false;
this.arr = []; this.arr = [];
@ -12,19 +12,19 @@ class Sequencer {
this.id = 'sequence'; this.id = 'sequence';
this.cfg = cfg; this.cfg = cfg;
this.cmd = cmd; this.cmd = cmd;
this.ui = ui;
this.cmds(cfg.cmd); this.cmds(cfg.cmd);
this.init(); this.init();
} }
cmds(obj) { cmds(obj) {
let keys = Object.keys(obj); let keys = Object.keys(obj);
let key; for (let key of keys) {
for (key in keys) { this.CMDS[obj[key]] = key;
this.CMDS[keys[key]] = key;
} }
} }
//currently called by ui //currently called by ui
async init() { async init() {
this.log = Log({ label: this.id }); this.log = await Log({ label: this.id });
this.ipc = require('electron').ipcMain; this.ipc = require('electron').ipcMain;
this.listen(); this.listen();
} }
@ -32,7 +32,6 @@ class Sequencer {
this.ipc.on(this.id, this.listener.bind(this)); this.ipc.on(this.id, this.listener.bind(this));
} }
async listener(event, arg) { async listener(event, arg) {
console.dir(arg);
if (arg && arg.start) { if (arg && arg.start) {
this.start(arg); this.start(arg);
} }
@ -49,14 +48,23 @@ class Sequencer {
this.unsetSteps(arg.unset); this.unsetSteps(arg.unset);
} }
else if (arg && arg.loops) { else if (arg && arg.loops) {
this.loops = arg.loops; this.setLoops(arg.loops);
} }
event.returnValue = true; event.returnValue = true;
} }
setLoops(count) {
this.loops = count;
this.log.info(`Set loop count to ${count}`);
}
setSteps(steps) { setSteps(steps) {
console.dir(steps); for (let step of steps) {
this.arr[step.x] = step;
}
} }
unsetSteps(steps) { unsetSteps(steps) {
for (let x of steps) {
this.arr[x] = undefined;
}
} }
//new, replaces exec and init //new, replaces exec and init
async start(arg) { async start(arg) {
@ -68,20 +76,35 @@ class Sequencer {
} }
this.running = true; this.running = true;
this.paused = false; this.paused = false;
//start sequence
this.log.info(`Starting sequence...`);
for (let x = 0; x < this.loops; x++) { for (let x = 0; x < this.loops; x++) {
//start loop //start loop
this.log.info(`Starting loop ${x + 1}`);
this.ui.send(this.id, { loop: x, start: true });
for (let y = 0; y < this.arr.length; y++) { for (let y = 0; y < this.arr.length; y++) {
//start step //start step
this.log.info(`Starting step ${y + 1} of loop ${x + 1}`);
this.ui.send(this.id, { step: y, start: true });
if (this.running) { if (this.running) {
while (this.paused) { while (this.paused) {
await delay(42); await delay(42);
} }
await this.step(y); await this.step(y);
} }
else {
break;
}
//end step //end step
this.log.info(`Ended step ${y + 1} of loop ${x + 1}`);
this.ui.send(this.id, { step: y, stop: true });
} }
//end loop //end loop
this.log.info(`Ended loop ${x + 1}`);
this.ui.send(this.id, { loop: x, stop: true });
} }
//end sequence
this.log.info(`Ended sequence`);
} }
//new //new
pause() { pause() {
@ -94,21 +117,23 @@ class Sequencer {
this.running = false; this.running = false;
//clear? //clear?
} }
async step(index) { async step(x) {
try { try {
await this.cmdMap(index); await this.cmdMap(x);
} }
catch (err) { catch (err) {
throw err; throw err;
} }
} }
async cmdMap(index) { async cmdMap(x) {
const cmdOriginal = this.arr[index].cmd; const cmdOriginal = this.arr[x].cmd;
const cmd = this.CMDS[cmdOriginal]; const cmd = this.CMDS[cmdOriginal];
return await this.cmd[cmd]; this.log.info(`CMD: '${cmdOriginal}' -> ${cmd}`);
//I wrote this when I was very tired and delirious
return await this.cmd[cmd]();
} }
} }
module.exports = function (cfg, cmd) { module.exports = function (cfg, cmd, ui) {
return new Sequencer(cfg, cmd); return new Sequencer(cfg, cmd, ui);
}; };
//# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sequencer/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,2BAA4B;AAE5B,IAAI,GAAe,CAAC;AAEpB,MAAM,SAAS;IAed,YAAa,GAAS,EAAE,GAAS;QAbzB,YAAO,GAAa,KAAK,CAAC;QAC1B,WAAM,GAAa,KAAK,CAAC;QAEzB,QAAG,GAAW,EAAE,CAAC;QACjB,UAAK,GAAY,CAAC,CAAC;QAInB,SAAI,GAAS,EAAE,CAAC;QAGhB,OAAE,GAAY,UAAU,CAAC;QAGhC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACnB,IAAI,CAAC,IAAI,EAAE,CAAC;IACb,CAAC;IAEO,IAAI,CAAE,GAAS;QACtB,IAAI,IAAI,GAAc,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACvC,IAAI,GAAY,CAAC;QACjB,KAAK,GAAG,IAAI,IAAI,EAAE;YACjB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC;SAC3B;IACF,CAAC;IAED,wBAAwB;IAChB,KAAK,CAAC,IAAI;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,EAAE,KAAK,EAAG,IAAI,CAAC,EAAE,EAAE,CAAC,CAAA;QACnC,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;QACvC,IAAI,CAAC,MAAM,EAAE,CAAC;IACf,CAAC;IAEO,MAAM;QACb,IAAI,CAAC,GA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C,CAAC,GAAG,CAAC;QAC7C,MAAM,GAAG,GAAY,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC5C,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,WAAW,QAAQ,GAAG,EAAE,CAAC,CAAC;QACjD,kDAAkD;QAClD,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;IAC9B,CAAC;CACD;AAED,MAAM,CAAC,OAAO,GAAG,UAAU,GAAS,EAAE,GAAS,EAAE,EAAQ;IACxD,OAAO,IAAI,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;AACpC,CAAC,CAAA"}

View File

@ -81,7 +81,7 @@ class Settings {
if (exists) { if (exists) {
str = await fs.readFile(this.file, 'utf8'); str = await fs.readFile(this.file, 'utf8');
this.state = JSON.parse(str); this.state = JSON.parse(str);
console.dir(this.state); //console.dir(this.state)
} }
else { else {
this.save(); this.save();

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;IAab;;QAEI;IACJ;QAfQ,SAAI,GAAW,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,uBAAuB,CAAC,CAAC;QACjE,UAAK,GAAS;YACpB,MAAM,EAAG;gBACR,IAAI,EAAG,IAAI;gBACX,OAAO,EAAG,IAAI;aACd;YACD,OAAO,EAAG,EAAE;YACZ,OAAO,EAAG,OAAO;YACjB,MAAM,EAAG,EAAE;YACX,SAAS,EAAG,EAAE;YACd,KAAK,EAAG,EAAE;SACV,CAAA;IAMD,CAAC;IACD;;QAEI;IACI,KAAK,CAAC,QAAQ;QACrB,MAAM,GAAG,GAAY,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,C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CAAC;QAER,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChB,MAAM,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEpC,IAAI,MAAM,EAAE;YACX,GAAG,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAC3C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC7B,yBAAyB;SACzB;aAAM;YACN,IAAI,CAAC,IAAI,EAAE,CAAC;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,OAAO,EAAE,CAAC;IAChB,CAAC;IAAA,CAAC;CACF;AAED,MAAM,CAAC,OAAO,GAAG,IAAI,QAAQ,EAAE,CAAA"}

View File

@ -91,6 +91,12 @@ devices.ready = function (event, arg) {
} }
//devices.profile(arg.profile) //devices.profile(arg.profile)
} }
seq.set(0, cfg.cmd.camera_forward);
seq.set(1, cfg.cmd.projector_forward);
grid.state(0);
grid.state(1);
if (arg.projector_second) { if (arg.projector_second) {
//add second row of projector pads to grid //add second row of projector pads to grid
} }

View File

@ -10,6 +10,45 @@ seq.running = false;
Sequence Object Sequence Object
*******/ *******/
seq.init = function () {
seq.listen();
}
seq.listen = function () {
ipcRenderer.on(seq.id, seq.listener);
}
seq.listener = function (event, arg) {
console.log(JSON.stringify(arg))
if (typeof arg.loop !== 'undefined' && arg.start) {
$('#loop_current').text(gui.fmtZero(arg.loop + 1, 6));
} else if (typeof arg.loop !== 'undefined' && arg.stop) {
$('#loop_current').text('');
} else if (typeof arg.step !== 'undefined' && arg.start) {
seq.activeStep(arg.step);
log.info(`Step ${arg.step} active`, 'SERIAL', true);
} else if (arg.step && arg.stop) {
seq.inactiveAll();
} else if (arg.stop) {
log.info('Sequence stopped', 'SERIAL', true);
} else if (arg.start) {
//
}
return event.returnValue = true;
}
seq.activeStep = function (x) {
seq.inactiveAll();
console.log(`.row input[x=${x + ''}]`)
$(`.row input[x=${x + ''}]`).addClass('h');
$(`#numbers div[x=${x + ''}]`).addClass('h');
}
seq.inactiveAll = function () {
$('.row input').removeClass('h');
$('#numbers div').removeClass('h');
}
seq.stop = function (s) { seq.stop = function (s) {
'use strict'; 'use strict';
ipcRenderer.send(seq.id, { stop : true }); ipcRenderer.send(seq.id, { stop : true });
@ -18,7 +57,6 @@ seq.stop = function (s) {
seq.start = function (start) { seq.start = function (start) {
'use strict'; 'use strict';
seq.time = +new Date(); seq.time = +new Date();
ipcRenderer.send(seq.id, { start : true }); ipcRenderer.send(seq.id, { start : true });
}; };
@ -76,7 +114,7 @@ seq.setLoops = function (count) {
'use strict'; 'use strict';
seq.loops = count; seq.loops = count;
seq.stats(); seq.stats();
ipcRenderer.send(seq.id, { loops : seq.count }) ipcRenderer.send(seq.id, { loops : seq.loops })
}; };
seq.stats = function () { seq.stats = function () {

View File

@ -123,7 +123,7 @@ var init = async function () {
proj = require('proj')(arduino, cfg, mainWindow.webContents, dig) proj = require('proj')(arduino, cfg, mainWindow.webContents, dig)
cmd = require('cmd')(cfg, proj, cam, light) cmd = require('cmd')(cfg, proj, cam, light)
seq = require('sequencer')(cfg, cmd) seq = require('sequencer')(cfg, cmd, mainWindow.webContents)
} }
app.on('ready', init) app.on('ready', init)

2
app/package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "mcopy-app", "name": "mcopy-app",
"version": "1.3.2", "version": "1.3.5",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

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

@ -94,4 +94,5 @@ async function init () {
light.init(); light.init();
proj.init(); proj.init();
cam.init(); cam.init();
seq.init();
}; };

View File

@ -1,5 +1,5 @@
{ {
"version": "1.3.3", "version": "1.4.0",
"ext_port": 1111, "ext_port": 1111,
"profiles": { "profiles": {
"mcopy": { "mcopy": {

View File

@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const Log = require("log"); const Log = require("log");
let seq; let seq;
class Sequencer { class Sequencer {
constructor(cfg, cmd) { constructor(cfg, cmd, ui) {
this.running = false; this.running = false;
this.paused = false; this.paused = false;
this.arr = []; this.arr = [];
@ -12,19 +12,19 @@ class Sequencer {
this.id = 'sequence'; this.id = 'sequence';
this.cfg = cfg; this.cfg = cfg;
this.cmd = cmd; this.cmd = cmd;
this.ui = ui;
this.cmds(cfg.cmd); this.cmds(cfg.cmd);
this.init(); this.init();
} }
cmds(obj) { cmds(obj) {
let keys = Object.keys(obj); let keys = Object.keys(obj);
let key; for (let key of keys) {
for (key in keys) { this.CMDS[obj[key]] = key;
this.CMDS[keys[key]] = key;
} }
} }
//currently called by ui //currently called by ui
async init() { async init() {
this.log = Log({ label: this.id }); this.log = await Log({ label: this.id });
this.ipc = require('electron').ipcMain; this.ipc = require('electron').ipcMain;
this.listen(); this.listen();
} }
@ -32,7 +32,6 @@ class Sequencer {
this.ipc.on(this.id, this.listener.bind(this)); this.ipc.on(this.id, this.listener.bind(this));
} }
async listener(event, arg) { async listener(event, arg) {
console.dir(arg);
if (arg && arg.start) { if (arg && arg.start) {
this.start(arg); this.start(arg);
} }
@ -49,14 +48,23 @@ class Sequencer {
this.unsetSteps(arg.unset); this.unsetSteps(arg.unset);
} }
else if (arg && arg.loops) { else if (arg && arg.loops) {
this.loops = arg.loops; this.setLoops(arg.loops);
} }
event.returnValue = true; event.returnValue = true;
} }
setLoops(count) {
this.loops = count;
this.log.info(`Set loop count to ${count}`);
}
setSteps(steps) { setSteps(steps) {
console.dir(steps); for (let step of steps) {
this.arr[step.x] = step;
}
} }
unsetSteps(steps) { unsetSteps(steps) {
for (let x of steps) {
this.arr[x] = undefined;
}
} }
//new, replaces exec and init //new, replaces exec and init
async start(arg) { async start(arg) {
@ -68,20 +76,35 @@ class Sequencer {
} }
this.running = true; this.running = true;
this.paused = false; this.paused = false;
//start sequence
this.log.info(`Starting sequence...`);
for (let x = 0; x < this.loops; x++) { for (let x = 0; x < this.loops; x++) {
//start loop //start loop
this.log.info(`Starting loop ${x + 1}`);
this.ui.send(this.id, { loop: x, start: true });
for (let y = 0; y < this.arr.length; y++) { for (let y = 0; y < this.arr.length; y++) {
//start step //start step
this.log.info(`Starting step ${y + 1} of loop ${x + 1}`);
this.ui.send(this.id, { step: y, start: true });
if (this.running) { if (this.running) {
while (this.paused) { while (this.paused) {
await delay(42); await delay(42);
} }
await this.step(y); await this.step(y);
} }
else {
break;
}
//end step //end step
this.log.info(`Ended step ${y + 1} of loop ${x + 1}`);
this.ui.send(this.id, { step: y, stop: true });
} }
//end loop //end loop
this.log.info(`Ended loop ${x + 1}`);
this.ui.send(this.id, { loop: x, stop: true });
} }
//end sequence
this.log.info(`Ended sequence`);
} }
//new //new
pause() { pause() {
@ -94,21 +117,23 @@ class Sequencer {
this.running = false; this.running = false;
//clear? //clear?
} }
async step(index) { async step(x) {
try { try {
await this.cmdMap(index); await this.cmdMap(x);
} }
catch (err) { catch (err) {
throw err; throw err;
} }
} }
async cmdMap(index) { async cmdMap(x) {
const cmdOriginal = this.arr[index].cmd; const cmdOriginal = this.arr[x].cmd;
const cmd = this.CMDS[cmdOriginal]; const cmd = this.CMDS[cmdOriginal];
return await this.cmd[cmd]; this.log.info(`CMD: '${cmdOriginal}' -> ${cmd}`);
//I wrote this when I was very tired and delirious
return await this.cmd[cmd]();
} }
} }
module.exports = function (cfg, cmd) { module.exports = function (cfg, cmd, ui) {
return new Sequencer(cfg, cmd); return new Sequencer(cfg, cmd, ui);
}; };
//# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sequencer/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,2BAA4B;AAE5B,IAAI,GAAe,CAAC;AAEpB,MAAM,SAAS;IAed,YAAa,GAAS,EAAE,GAAS;QAbzB,YAAO,GAAa,KAAK,CAAC;QAC1B,WAAM,GAAa,KAAK,CAAC;QAEzB,QAAG,GAAW,EAAE,CAAC;QACjB,UAAK,GAAY,CAAC,CAAC;QAInB,SAAI,GAAS,EAAE,CAAC;QAGhB,OAAE,GAAY,UAAU,CAAC;QAGhC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACnB,IAAI,CAAC,IAAI,EAAE,CAAC;IACb,CAAC;IAEO,IAAI,CAAE,GAAS;QACtB,IAAI,IAAI,GAAc,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACvC,IAAI,GAAY,CAAC;QACjB,KAAK,GAAG,IAAI,IAAI,EAAE;YACjB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC;SAC3B;IACF,CAAC;IAED,wBAAwB;IAChB,KAAK,CAAC,IAAI;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,EAAE,KAAK,EAAG,IAAI,CAAC,EAAE,EAAE,CAAC,CAAA;QACnC,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC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C,MAAM,CAAE,CAAU;QAC/B,MAAM,WAAW,GAAY,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QAC7C,MAAM,GAAG,GAAY,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC5C,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,WAAW,QAAQ,GAAG,EAAE,CAAC,CAAC;QACjD,kDAAkD;QAClD,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;IAC9B,CAAC;CACD;AAED,MAAM,CAAC,OAAO,GAAG,UAAU,GAAS,EAAE,GAAS,EAAE,EAAQ;IACxD,OAAO,IAAI,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;AACpC,CAAC,CAAA"}

View File

@ -81,7 +81,7 @@ class Settings {
if (exists) { if (exists) {
str = await fs.readFile(this.file, 'utf8'); str = await fs.readFile(this.file, 'utf8');
this.state = JSON.parse(str); this.state = JSON.parse(str);
console.dir(this.state); //console.dir(this.state)
} }
else { else {
this.save(); this.save();

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;IAab;;QAEI;IACJ;QAfQ,SAAI,GAAW,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,uBAAuB,CAAC,CAAC;QACjE,UAAK,GAAS;YACpB,MAAM,EAAG;gBACR,IAAI,EAAG,IAAI;gBACX,OAAO,EAAG,IAAI;aACd;YACD,OAAO,EAAG,EAAE;YACZ,OAAO,EAAG,OAAO;YACjB,MAAM,EAAG,EAAE;YACX,SAAS,EAAG,EAAE;YACd,KAAK,EAAG,EAAE;SACV,CAAA;IAMD,CAAC;IACD;;QAEI;IACI,KAAK,CAAC,QAAQ;QACrB,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AC;IACD;;QAEI;IACG,KAAK,CAAC,OAAO;QACnB,IAAI,MAAM,CAAC;QACX,IAAI,GAAG,CAAC;QAER,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChB,MAAM,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEpC,IAAI,MAAM,EAAE;YACX,GAAG,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAC3C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC7B,yBAAyB;SACzB;aAAM;YACN,IAAI,CAAC,IAAI,EAAE,CAAC;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,OAAO,EAAE,CAAC;IAChB,CAAC;IAAA,CAAC;CACF;AAED,MAAM,CAAC,OAAO,GAAG,IAAI,QAAQ,EAAE,CAAA"}

2
cli/package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "mcopy-cli", "name": "mcopy-cli",
"version": "1.3.2", "version": "1.3.5",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "mcopy-cli", "name": "mcopy-cli",
"version": "1.3.4", "version": "1.4.0",
"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": {

View File

@ -1,5 +1,5 @@
{ {
"version": "1.3.4", "version": "1.4.0",
"ext_port": 1111, "ext_port": 1111,
"profiles": { "profiles": {
"mcopy": { "mcopy": {

View File

@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const Log = require("log"); const Log = require("log");
let seq; let seq;
class Sequencer { class Sequencer {
constructor(cfg, cmd) { constructor(cfg, cmd, ui) {
this.running = false; this.running = false;
this.paused = false; this.paused = false;
this.arr = []; this.arr = [];
@ -12,19 +12,19 @@ class Sequencer {
this.id = 'sequence'; this.id = 'sequence';
this.cfg = cfg; this.cfg = cfg;
this.cmd = cmd; this.cmd = cmd;
this.ui = ui;
this.cmds(cfg.cmd); this.cmds(cfg.cmd);
this.init(); this.init();
} }
cmds(obj) { cmds(obj) {
let keys = Object.keys(obj); let keys = Object.keys(obj);
let key; for (let key of keys) {
for (key in keys) { this.CMDS[obj[key]] = key;
this.CMDS[keys[key]] = key;
} }
} }
//currently called by ui //currently called by ui
async init() { async init() {
this.log = Log({ label: this.id }); this.log = await Log({ label: this.id });
this.ipc = require('electron').ipcMain; this.ipc = require('electron').ipcMain;
this.listen(); this.listen();
} }
@ -32,7 +32,6 @@ class Sequencer {
this.ipc.on(this.id, this.listener.bind(this)); this.ipc.on(this.id, this.listener.bind(this));
} }
async listener(event, arg) { async listener(event, arg) {
console.dir(arg);
if (arg && arg.start) { if (arg && arg.start) {
this.start(arg); this.start(arg);
} }
@ -49,14 +48,23 @@ class Sequencer {
this.unsetSteps(arg.unset); this.unsetSteps(arg.unset);
} }
else if (arg && arg.loops) { else if (arg && arg.loops) {
this.loops = arg.loops; this.setLoops(arg.loops);
} }
event.returnValue = true; event.returnValue = true;
} }
setLoops(count) {
this.loops = count;
this.log.info(`Set loop count to ${count}`);
}
setSteps(steps) { setSteps(steps) {
console.dir(steps); for (let step of steps) {
this.arr[step.x] = step;
}
} }
unsetSteps(steps) { unsetSteps(steps) {
for (let x of steps) {
this.arr[x] = undefined;
}
} }
//new, replaces exec and init //new, replaces exec and init
async start(arg) { async start(arg) {
@ -68,20 +76,35 @@ class Sequencer {
} }
this.running = true; this.running = true;
this.paused = false; this.paused = false;
//start sequence
this.log.info(`Starting sequence...`);
for (let x = 0; x < this.loops; x++) { for (let x = 0; x < this.loops; x++) {
//start loop //start loop
this.log.info(`Starting loop ${x + 1}`);
this.ui.send(this.id, { loop: x, start: true });
for (let y = 0; y < this.arr.length; y++) { for (let y = 0; y < this.arr.length; y++) {
//start step //start step
this.log.info(`Starting step ${y + 1} of loop ${x + 1}`);
this.ui.send(this.id, { step: y, start: true });
if (this.running) { if (this.running) {
while (this.paused) { while (this.paused) {
await delay(42); await delay(42);
} }
await this.step(y); await this.step(y);
} }
else {
break;
}
//end step //end step
this.log.info(`Ended step ${y + 1} of loop ${x + 1}`);
this.ui.send(this.id, { step: y, stop: true });
} }
//end loop //end loop
this.log.info(`Ended loop ${x + 1}`);
this.ui.send(this.id, { loop: x, stop: true });
} }
//end sequence
this.log.info(`Ended sequence`);
} }
//new //new
pause() { pause() {
@ -94,21 +117,23 @@ class Sequencer {
this.running = false; this.running = false;
//clear? //clear?
} }
async step(index) { async step(x) {
try { try {
await this.cmdMap(index); await this.cmdMap(x);
} }
catch (err) { catch (err) {
throw err; throw err;
} }
} }
async cmdMap(index) { async cmdMap(x) {
const cmdOriginal = this.arr[index].cmd; const cmdOriginal = this.arr[x].cmd;
const cmd = this.CMDS[cmdOriginal]; const cmd = this.CMDS[cmdOriginal];
return await this.cmd[cmd]; this.log.info(`CMD: '${cmdOriginal}' -> ${cmd}`);
//I wrote this when I was very tired and delirious
return await this.cmd[cmd]();
} }
} }
module.exports = function (cfg, cmd) { module.exports = function (cfg, cmd, ui) {
return new Sequencer(cfg, cmd); return new Sequencer(cfg, cmd, ui);
}; };
//# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sequencer/index.ts"],"names":[],"mappings":"AA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AG,CAAC,GAAG,CAAC,EAAE,CAAC;IAC9B,CAAC;CACD;AAED,MAAM,CAAC,OAAO,GAAG,UAAU,GAAS,EAAE,GAAS,EAAE,EAAQ;IACxD,OAAO,IAAI,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;AACpC,CAAC,CAAA"}

View File

@ -81,7 +81,7 @@ class Settings {
if (exists) { if (exists) {
str = await fs.readFile(this.file, 'utf8'); str = await fs.readFile(this.file, 'utf8');
this.state = JSON.parse(str); this.state = JSON.parse(str);
console.dir(this.state); //console.dir(this.state)
} }
else { else {
this.save(); this.save();

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;IAab;;QAEI;IACJ;QAfQ,SAAI,GAAW,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,uBAAuB,CAAC,CAAC;QACjE,UAAK,GAAS;YACpB,MAAM,EAAG;gBACR,IAAI,EAAG,IAAI;gBACX,OAAO,EAAG,IAAI;aACd;YACD,OAAO,EAAG,EAAE;YACZ,OAAO,EAAG,OAAO;YACjB,MAAM,EAAG,EAAE;YACX,SAAS,EAAG,EAAE;YACd,KAAK,EAAG,EAAE;SACV,CAAA;IAMD,CAAC;IACD;;QAEI;IACI,KAAK,CAAC,QAAQ;QACrB,MAAM,GAAG,GAAY,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC;QACxD,MAAM,MAAM,GAAa,MAAM,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QAC7C,IAAI,CAAC,MAAM,EAAE;YACZ,IAAI;gBACH,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;aACpB;YAAC,OAAO,GAAG,EAAE;gBACb,IAAI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M,CAAC,CAAC;YAC3C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC7B,yBAAyB;SACzB;aAAM;YACN,IAAI,CAAC,IAAI,EAAE,CAAC;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,OAAO,EAAE,CAAC;IAChB,CAAC;IAAA,CAAC;CACF;AAED,MAAM,CAAC,OAAO,GAAG,IAAI,QAAQ,EAAE,CAAA"}

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "mcopy", "name": "mcopy",
"version": "1.3.5", "version": "1.4.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "mcopy", "name": "mcopy",
"version": "1.3.5", "version": "1.4.0",
"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,6 @@
'use strict'; 'use strict';
import uuid from 'uuid/v4';
import Log = require('log'); import Log = require('log');
let seq : Sequencer; let seq : Sequencer;
@ -16,27 +17,28 @@ class Sequencer {
private cmd : any; private cmd : any;
private CMDS : any = {}; private CMDS : any = {};
private ipc : any; private ipc : any;
private ui : any;
private log : any; private log : any;
private id : string = 'sequence'; private id : string = 'sequence';
constructor (cfg : any, cmd : any) { constructor (cfg : any, cmd : any, ui : any) {
this.cfg = cfg; this.cfg = cfg;
this.cmd = cmd; this.cmd = cmd;
this.ui = ui;
this.cmds(cfg.cmd); this.cmds(cfg.cmd);
this.init(); this.init();
} }
private cmds (obj : any) { private cmds (obj : any) {
let keys : string[] = Object.keys(obj); let keys : string[] = Object.keys(obj);
let key : string; for (let key of keys) {
for (key in keys) { this.CMDS[obj[key]] = key;
this.CMDS[keys[key]] = key;
} }
} }
//currently called by ui //currently called by ui
private async init () { private async init () {
this.log = Log({ label : this.id }) this.log = await Log({ label : this.id })
this.ipc = require('electron').ipcMain; this.ipc = require('electron').ipcMain;
this.listen(); this.listen();
} }
@ -46,7 +48,6 @@ class Sequencer {
} }
private async listener (event : any, arg : any) { private async listener (event : any, arg : any) {
console.dir(arg)
if (arg && arg.start) { if (arg && arg.start) {
this.start(arg); this.start(arg);
} else if (arg && arg.stop) { } else if (arg && arg.stop) {
@ -58,17 +59,28 @@ class Sequencer {
} else if (arg && arg.unset) { } else if (arg && arg.unset) {
this.unsetSteps(arg.unset); this.unsetSteps(arg.unset);
} else if (arg && arg.loops) { } else if (arg && arg.loops) {
this.loops = arg.loops; this.setLoops(arg.loops);
} }
event.returnValue = true; event.returnValue = true;
} }
public setSteps (steps : any) { public setLoops (count : number) {
console.dir(steps) this.loops = count;
this.log.info(`Set loop count to ${count}`);
} }
public unsetSteps (steps : number[]) {
public setSteps (steps : any[]) {
for (let step of steps) {
this.arr[step.x] = step;
} }
}
public unsetSteps (steps : number[]) {
for (let x of steps) {
this.arr[x] = undefined;
}
}
//new, replaces exec and init //new, replaces exec and init
public async start (arg : any) { public async start (arg : any) {
if (arg && arg.arr) { if (arg && arg.arr) {
@ -81,25 +93,44 @@ class Sequencer {
this.running = true; this.running = true;
this.paused = false; this.paused = false;
//start sequence
this.log.info(`Starting sequence...`)
for (let x = 0; x < this.loops; x++) { for (let x = 0; x < this.loops; x++) {
//start loop //start loop
this.log.info(`Starting loop ${x + 1}`)
this.ui.send(this.id, { loop : x, start : true });
for (let y = 0; y < this.arr.length; y++) { for (let y = 0; y < this.arr.length; y++) {
//start step //start step
this.log.info(`Starting step ${y + 1} of loop ${x + 1}`)
this.ui.send(this.id, { step : y, start : true });
if (this.running) { if (this.running) {
while (this.paused) { while (this.paused) {
await delay(42); await delay(42);
} }
await this.step(y); await this.step(y);
} else {
break
} }
//end step //end step
this.log.info(`Ended step ${y + 1} of loop ${x + 1}`)
this.ui.send(this.id, { step : y, stop : true });
} }
//end loop //end loop
this.log.info(`Ended loop ${x + 1}`)
this.ui.send(this.id, { loop : x, stop : true });
} }
//end sequence
this.log.info(`Ended sequence`)
} }
//new //new
public pause () { public pause () {
this.paused = true; this.paused = true;
} }
/** /**
* Stop the sequence * Stop the sequence
**/ **/
@ -109,22 +140,23 @@ class Sequencer {
} }
private async step (index : number) { private async step (x: number) {
try { try {
await this.cmdMap(index) await this.cmdMap(x)
} catch (err) { } catch (err) {
throw err; throw err;
} }
} }
private async cmdMap (index : number) { private async cmdMap (x : number) {
const cmdOriginal : string = this.arr[index].cmd; const cmdOriginal : string = this.arr[x].cmd;
const cmd : string = this.CMDS[cmdOriginal]; const cmd : string = this.CMDS[cmdOriginal];
return await this.cmd[cmd]; this.log.info(`CMD: '${cmdOriginal}' -> ${cmd}`);
//I wrote this when I was very tired and delirious
return await this.cmd[cmd]();
} }
} }
module.exports = function (cfg : any, cmd : any) { module.exports = function (cfg : any, cmd : any, ui : any) {
return new Sequencer(cfg, cmd); return new Sequencer(cfg, cmd, ui);
} }

View File

@ -82,7 +82,7 @@ class Settings {
if (exists) { if (exists) {
str = await fs.readFile(this.file, 'utf8'); str = await fs.readFile(this.file, 'utf8');
this.state = JSON.parse(str); this.state = JSON.parse(str);
console.dir(this.state) //console.dir(this.state)
} else { } else {
this.save(); this.save();
} }