All work on grid + sequencer rewrite.
This commit is contained in:
parent
cfbeeb3ce9
commit
42691c1577
|
@ -45,8 +45,9 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="actions">
|
<div id="actions">
|
||||||
<button id="seq_run" onclick="seq.init();">START</button>
|
<button id="seq_run" onclick="seq.start();">START</button>
|
||||||
<button id="seq_stop" onclick="seq.stop(true);">STOP</button>
|
<button id="seq_pause" onclick="seq.pause();">STOP</button>
|
||||||
|
<button id="seq_stop" onclick="seq.stop();">STOP</button>
|
||||||
<button id="seq_clear" onclick="grid.clear();">CLEAR</button>
|
<button id="seq_clear" onclick="grid.clear();">CLEAR</button>
|
||||||
<button id="seq_plus24" onclick="grid.plus_24();">+ 24</button>
|
<button id="seq_plus24" onclick="grid.plus_24();">+ 24</button>
|
||||||
<button id="seq_mscript" onclick="mse.mscript.fromSequence();">TO SCRIPT</button>
|
<button id="seq_mscript" onclick="mse.mscript.fromSequence();">TO SCRIPT</button>
|
||||||
|
|
|
@ -2519,10 +2519,8 @@ mcopy.state = {
|
||||||
direction : true
|
direction : true
|
||||||
},
|
},
|
||||||
sequence : {
|
sequence : {
|
||||||
size : 24,
|
|
||||||
arr : ['CF', 'PF'],
|
|
||||||
light : ['255,255,255', ''],
|
|
||||||
pads: {
|
pads: {
|
||||||
|
//gaaaaaaaaah
|
||||||
cam_forward: 'CF',
|
cam_forward: 'CF',
|
||||||
proj_forward : 'PF',
|
proj_forward : 'PF',
|
||||||
black_forward : 'BF',
|
black_forward : 'BF',
|
||||||
|
@ -2531,8 +2529,7 @@ mcopy.state = {
|
||||||
proj_backward : 'PB',
|
proj_backward : 'PB',
|
||||||
black_backward : 'BB',
|
black_backward : 'BB',
|
||||||
|
|
||||||
light_set : 'L'//,
|
light_set : 'L',
|
||||||
/*
|
|
||||||
|
|
||||||
cam2_forward : 'C2F',
|
cam2_forward : 'C2F',
|
||||||
cam2_backward : 'C2B',
|
cam2_backward : 'C2B',
|
||||||
|
@ -2552,7 +2549,6 @@ mcopy.state = {
|
||||||
proj_forward_proj2_backward : 'PFPB',
|
proj_forward_proj2_backward : 'PFPB',
|
||||||
proj_backward_proj2_forward : 'PBPF'
|
proj_backward_proj2_forward : 'PBPF'
|
||||||
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,6 +4,8 @@ const Log = require("log");
|
||||||
let seq;
|
let seq;
|
||||||
class Sequencer {
|
class Sequencer {
|
||||||
constructor(cfg, cmd) {
|
constructor(cfg, cmd) {
|
||||||
|
this.running = false;
|
||||||
|
this.paused = false;
|
||||||
this.arr = [];
|
this.arr = [];
|
||||||
this.loops = 1;
|
this.loops = 1;
|
||||||
this.CMDS = {};
|
this.CMDS = {};
|
||||||
|
@ -31,9 +33,21 @@ class Sequencer {
|
||||||
}
|
}
|
||||||
async listener(event, arg) {
|
async listener(event, arg) {
|
||||||
console.dir(arg);
|
console.dir(arg);
|
||||||
if (arg && arg.set) {
|
if (arg && arg.start) {
|
||||||
|
this.start(arg);
|
||||||
|
}
|
||||||
|
else if (arg && arg.stop) {
|
||||||
|
this.stop();
|
||||||
|
}
|
||||||
|
else if (arg && arg.pause) {
|
||||||
|
this.pause();
|
||||||
|
}
|
||||||
|
else if (arg && arg.set) {
|
||||||
this.setSteps(arg.set);
|
this.setSteps(arg.set);
|
||||||
}
|
}
|
||||||
|
else if (arg && arg.unset) {
|
||||||
|
this.unsetSteps(arg.unset);
|
||||||
|
}
|
||||||
else if (arg && arg.loops) {
|
else if (arg && arg.loops) {
|
||||||
this.loops = arg.loops;
|
this.loops = arg.loops;
|
||||||
}
|
}
|
||||||
|
@ -42,24 +56,36 @@ class Sequencer {
|
||||||
setSteps(steps) {
|
setSteps(steps) {
|
||||||
console.dir(steps);
|
console.dir(steps);
|
||||||
}
|
}
|
||||||
//new
|
unsetSteps(steps) {
|
||||||
|
}
|
||||||
|
//new, replaces exec and init
|
||||||
async start(arg) {
|
async start(arg) {
|
||||||
if (arg && arg.arr) {
|
if (arg && arg.arr) {
|
||||||
this.arr = arg.arr;
|
this.arr = arg.arr; //overwrite sequence
|
||||||
}
|
}
|
||||||
if (arg && arg.loops) {
|
if (arg && arg.loops) {
|
||||||
this.loops = arg.loops;
|
this.loops = arg.loops; //overwrite loops
|
||||||
}
|
}
|
||||||
|
this.running = true;
|
||||||
|
this.paused = false;
|
||||||
for (let x = 0; x < this.loops; x++) {
|
for (let x = 0; x < this.loops; x++) {
|
||||||
|
//start loop
|
||||||
for (let y = 0; y < this.arr.length; y++) {
|
for (let y = 0; y < this.arr.length; y++) {
|
||||||
|
//start step
|
||||||
if (this.running) {
|
if (this.running) {
|
||||||
|
while (this.paused) {
|
||||||
|
await delay(42);
|
||||||
|
}
|
||||||
await this.step(y);
|
await this.step(y);
|
||||||
}
|
}
|
||||||
|
//end step
|
||||||
}
|
}
|
||||||
|
//end loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//new
|
//new
|
||||||
pause() {
|
pause() {
|
||||||
|
this.paused = true;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Stop the sequence
|
* Stop the sequence
|
||||||
|
|
|
@ -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;IAcd,YAAa,GAAS,EAAE,GAAS;QAVzB,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;IA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AAC,KAAK,EAAE,CAAC,EAAE,EAAE;YACpC,YAAY;YACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBACzC,YAAY;gBACZ,IAAI,IAAI,CAAC,OAAO,EAAE;oBACjB,OAAO,IAAI,CAAC,MAAM,EAAE;wBACnB,MAAM,KAAK,CAAC,EAAE,CAAC,CAAC;qBAChB;oBACD,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;iBACnB;gBACD,UAAU;aACV;YACD,UAAU;SACV;IACF,CAAC;IACD,KAAK;IACE,KAAK;QACX,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACpB,CAAC;IACD;;QAEI;IACG,IAAI;QACV,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,QAAQ;IAET,CAAC;IAEO,KAAK,CAAC,IAAI,CAAE,KAAc;QACjC,IAAI;YACH,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;SACxB;QAAC,OAAO,GAAG,EAAE;YACb,MAAM,GAAG,CAAC;SACV;IAEF,CAAC;IAEO,KAAK,CAAC,MAAM,CAAE,KAAc;QACnC,MAAM,WAAW,GAAY,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC;QACjD,MAAM,GAAG,GAAY,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC5C,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;CACD;AAED,MAAM,CAAC,OAAO,GAAG,UAAU,GAAS,EAAE,GAAS;IAC9C,OAAO,IAAI,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAChC,CAAC,CAAA"}
|
|
@ -218,9 +218,11 @@ devices.digitalCb = function (evt, args) {
|
||||||
$('#projector_type_digital').prop('checked', 'checked');
|
$('#projector_type_digital').prop('checked', 'checked');
|
||||||
gui.notify('DEVICES', `Using video ${state.fileName}`);
|
gui.notify('DEVICES', `Using video ${state.fileName}`);
|
||||||
|
|
||||||
mcopy.state.sequence.arr = ['PF', 'CF'];
|
seq.set(0, 'PF');
|
||||||
grid.setLight(1, color);
|
|
||||||
grid.state(0);
|
grid.state(0);
|
||||||
|
|
||||||
|
seq.set(1, 'CF');
|
||||||
|
seq.setLight(1, color);
|
||||||
grid.state(1);
|
grid.state(1);
|
||||||
|
|
||||||
if (light.disabled) {
|
if (light.disabled) {
|
||||||
|
|
|
@ -14,19 +14,20 @@ grid.init = function () {
|
||||||
* Set a specific grid pad to the state stored in the sequence
|
* Set a specific grid pad to the state stored in the sequence
|
||||||
* array at that step
|
* array at that step
|
||||||
*
|
*
|
||||||
* @param {integer} i Step in sequence
|
* @param {integer} x Step in sequence
|
||||||
**/
|
**/
|
||||||
grid.state = function (i) {
|
grid.state = function (x) {
|
||||||
'use strict';
|
'use strict';
|
||||||
const elem = $(`input[x=${i}]`);
|
const elem = $(`input[x=${x}]`);
|
||||||
const lightElem = $(`.L[x=${i}]`);
|
const lightElem = $(`.L[x=${x}]`);
|
||||||
if (typeof mcopy.state.sequence.arr[i] !== 'undefined') {
|
const step = seq.arr[x];
|
||||||
|
if (typeof step !== 'undefined') {
|
||||||
elem.prop('checked', false);
|
elem.prop('checked', false);
|
||||||
$(`.${mcopy.state.sequence.arr[i]}[x=${i}]`).prop('checked', true);
|
$(`.${step.cmd}[x=${x}]`).prop('checked', true);
|
||||||
if (mcopy.state.sequence.arr[i] === 'CF' || mcopy.state.sequence.arr[i] === 'CB') {
|
if (step.cmd === 'CF' || step.cmd === 'CB') {
|
||||||
lightElem.css('background', `rgb(${mcopy.state.sequence.light[i]})`)
|
lightElem.css('background', `rgb(${step.light})`)
|
||||||
.addClass('a')
|
.addClass('a')
|
||||||
.prop('title', `rgb(${mcopy.state.sequence.light[i]})`);
|
.prop('title', `rgb(${seq.light})`);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
lightElem.css('background', 'transparent')
|
lightElem.css('background', 'transparent')
|
||||||
|
@ -46,7 +47,14 @@ grid.state = function (i) {
|
||||||
**/
|
**/
|
||||||
grid.refresh = function () {
|
grid.refresh = function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
const cmds = ['cam_forward', 'proj_forward', 'cam_backward', 'proj_backward', 'light_set', 'numbers'];
|
const cmds = [
|
||||||
|
'cam_forward',
|
||||||
|
'proj_forward',
|
||||||
|
'cam_backward',
|
||||||
|
'proj_backward',
|
||||||
|
'light_set',
|
||||||
|
'numbers'
|
||||||
|
];
|
||||||
const check = '<input type="checkbox" x="xxxx" />';
|
const check = '<input type="checkbox" x="xxxx" />';
|
||||||
const div = '<div x="xxxx"></div>';
|
const div = '<div x="xxxx"></div>';
|
||||||
const width = 970 - 34 + ((940 / 24) * Math.abs(24 - seq.size));
|
const width = 970 - 34 + ((940 / 24) * Math.abs(24 - seq.size));
|
||||||
|
@ -77,22 +85,17 @@ grid.refresh = function () {
|
||||||
**/
|
**/
|
||||||
grid.click = function (t) {
|
grid.click = function (t) {
|
||||||
'use strict';
|
'use strict';
|
||||||
const i = parseInt($(t).attr('x'));
|
const x = parseInt($(t).attr('x'));
|
||||||
let c;
|
let c;
|
||||||
//TODO: ADD OTHER STATES
|
|
||||||
if ($(t).prop('checked')) {
|
if ($(t).prop('checked')) {
|
||||||
|
|
||||||
c = $(t).attr('class').replace('.', '');
|
c = $(t).attr('class').replace('.', '');
|
||||||
mcopy.state.sequence.arr[i] = c;
|
seq.set(x, c);
|
||||||
if (c === 'CF' || c === 'CB') {
|
|
||||||
mcopy.state.sequence.light[i] = light.color.join(',');
|
|
||||||
} else {
|
|
||||||
mcopy.state.sequence.light[i] = '';
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
mcopy.state.sequence.arr[i] = undefined;
|
//seq.arr[i] = undefined;
|
||||||
delete mcopy.state.sequence.arr[i];
|
//delete seq.arr[i];
|
||||||
}
|
}
|
||||||
grid.state(i);
|
grid.state(x);
|
||||||
seq.stats();
|
seq.stats();
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
|
@ -106,7 +109,7 @@ grid.clear = function () {
|
||||||
seq.clear();
|
seq.clear();
|
||||||
grid.refresh();
|
grid.refresh();
|
||||||
seq.stats();
|
seq.stats();
|
||||||
console.log('Sequencer cleared');
|
log.info('Sequencer cleared');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
|
@ -116,19 +119,7 @@ grid.plus_24 = function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
seq.size += 24;
|
seq.size += 24;
|
||||||
grid.refresh();
|
grid.refresh();
|
||||||
console.log(`Sequencer expanded to ${seq.size} steps`);
|
log.info(`Sequencer expanded to ${seq.size} steps`);
|
||||||
};
|
|
||||||
/**
|
|
||||||
* Set the light value at a specific step and then update
|
|
||||||
* GUI grid via .state()
|
|
||||||
*
|
|
||||||
* @param {integer} x Step in sequence
|
|
||||||
* @param {array} rgb Light value in RGB
|
|
||||||
**/
|
|
||||||
grid.setLight = function (x, rgb) {
|
|
||||||
'use strict';
|
|
||||||
mcopy.state.sequence.light[x] = rgb.join(',');
|
|
||||||
grid.state(x);
|
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Set light value to black (0,0,0) when double clicked
|
* Set light value to black (0,0,0) when double clicked
|
||||||
|
@ -137,14 +128,14 @@ grid.setLight = function (x, rgb) {
|
||||||
**/
|
**/
|
||||||
grid.blackout = function (t) {
|
grid.blackout = function (t) {
|
||||||
const elem = $(t);
|
const elem = $(t);
|
||||||
const i = elem.attr('x');
|
const x = elem.attr('x');
|
||||||
if (typeof mcopy.state.sequence.light[i] === 'undefined') {
|
if (typeof seq.arr[x].light === 'undefined') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (mcopy.state.sequence.light[i] === '0,0,0') {
|
if (seq.arr[x].light === '0,0,0') {
|
||||||
grid.setLight(i, light.color);
|
seq.setLight(i, light.color);
|
||||||
} else {
|
} else {
|
||||||
grid.setLight(i, [0, 0, 0]);
|
seq.setLight(i, [0, 0, 0]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -156,7 +147,9 @@ grid.blackout = function (t) {
|
||||||
*/
|
*/
|
||||||
grid.changeAll = function (rgb) {
|
grid.changeAll = function (rgb) {
|
||||||
'use strict';
|
'use strict';
|
||||||
for (let [i, c] of mcopy.state.sequence.arr.entries()) {
|
let c;
|
||||||
|
for (let step of seq.arr) {
|
||||||
|
c = step.cmd;
|
||||||
if (c === 'CF' || c === 'CB') {
|
if (c === 'CF' || c === 'CB') {
|
||||||
grid.setLight(i, rgb);
|
grid.setLight(i, rgb);
|
||||||
}
|
}
|
||||||
|
@ -170,7 +163,7 @@ grid.changeAll = function (rgb) {
|
||||||
**/
|
**/
|
||||||
grid.swatches = function (x) {
|
grid.swatches = function (x) {
|
||||||
'use strict';
|
'use strict';
|
||||||
const current = mcopy.state.sequence.light[x];
|
const current = seq.arr[x].light;
|
||||||
grid.swatchesElem = w2popup.open({
|
grid.swatchesElem = w2popup.open({
|
||||||
title : 'Select Color',
|
title : 'Select Color',
|
||||||
body : $('#light-swatches').html(),
|
body : $('#light-swatches').html(),
|
||||||
|
@ -229,7 +222,7 @@ grid.events = function () {
|
||||||
});
|
});
|
||||||
//$(document.body).on('click', '.L', function () {
|
//$(document.body).on('click', '.L', function () {
|
||||||
//alert('click');
|
//alert('click');
|
||||||
//console.log('please dont happen');
|
//log.warn('please dont happen');
|
||||||
//});
|
//});
|
||||||
$(document.body).on('dblclick', '.L', function () {
|
$(document.body).on('dblclick', '.L', function () {
|
||||||
grid.blackout(this);
|
grid.blackout(this);
|
||||||
|
|
|
@ -35,9 +35,11 @@ mse.mscript.fromSequence = function () {
|
||||||
let str;
|
let str;
|
||||||
let tmp = [];
|
let tmp = [];
|
||||||
let cont;
|
let cont;
|
||||||
//str = mcopy.state.sequence.arr.join('\n'); //quick hack
|
let cmd;
|
||||||
console.dir(mcopy.state.sequence);
|
//str = seq.arr.map(step => { return step.cmd }).join('\n'); //quick hack
|
||||||
for (let cmd of mcopy.state.sequence.arr) {
|
console.dir(seq.arr);
|
||||||
|
for (let step of seq.arr) {
|
||||||
|
cmd = step.cmd;
|
||||||
if (tmp.length > 0 && tmp[tmp.length - 1].cmd === cmd) {
|
if (tmp.length > 0 && tmp[tmp.length - 1].cmd === cmd) {
|
||||||
tmp[tmp.length - 1].num++;
|
tmp[tmp.length - 1].num++;
|
||||||
continue;
|
continue;
|
||||||
|
@ -69,18 +71,19 @@ mse.mscript.fromSequence = function () {
|
||||||
mse.mscript.toGUI = function () {
|
mse.mscript.toGUI = function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
let c;
|
let c;
|
||||||
for (let i = 0; i < mse.mscript.data.arr.length; i++) {
|
let step;
|
||||||
c = mse.mscript.data.arr[i];
|
for (let x = 0; x < mse.mscript.data.arr.length; x++) {
|
||||||
mcopy.state.sequence.arr[i] = c;
|
c = mse.mscript.data.arr[x];
|
||||||
|
seq.set(x, c);
|
||||||
console.dir(mse.mscript.data);
|
console.dir(mse.mscript.data);
|
||||||
if (c === 'CF' || c === 'CB') {
|
if (c === 'CF' || c === 'CB') {
|
||||||
if (typeof mse.mscript.data.light[i] !== 'undefined' && mse.mscript.data.light[i] !== '') {
|
if (typeof mse.mscript.data.light[x] !== 'undefined' && mse.mscript.data.light[x] !== '') {
|
||||||
mcopy.state.sequence.light[i] = mse.mscript.data.light[i];
|
seq.setLight(x, mse.mscript.data.light[x]);
|
||||||
} else {
|
} else {
|
||||||
mcopy.state.sequence.light[i] = light.color.join(',');
|
seq.setLight(x, light.color.join(','));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mcopy.state.sequence.light[i] = '';
|
//unset light?
|
||||||
}
|
}
|
||||||
grid.state(i);
|
grid.state(i);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,117 +3,27 @@ seq.id = 'sequence';
|
||||||
seq.arr = [];
|
seq.arr = [];
|
||||||
seq.loops = 1;
|
seq.loops = 1;
|
||||||
seq.size = 24;
|
seq.size = 24;
|
||||||
|
seq.time = 0;
|
||||||
|
seq.running = false;
|
||||||
|
|
||||||
/******
|
/******
|
||||||
Sequence Object
|
Sequence Object
|
||||||
*******/
|
*******/
|
||||||
|
|
||||||
/*seq.run = function () {
|
seq.stop = function (s) {
|
||||||
'use strict';
|
'use strict';
|
||||||
var c = mcopy.state.sequence.arr[seq.i],
|
ipcRenderer.send(seq.id, { stop : true });
|
||||||
timeEnd = 0,
|
$('#loop_current').text('');
|
||||||
rgb,
|
|
||||||
action = function () {
|
|
||||||
setTimeout(function () {
|
|
||||||
seq.i++;
|
|
||||||
seq.run();
|
|
||||||
}, cfg.arduino.sequenceDelay);
|
|
||||||
}
|
|
||||||
if (seq.i == 0) {
|
|
||||||
$('#loop_current').text(gui.fmtZero(mcopy.loopCount + 1, 6));
|
|
||||||
ipcRenderer.send('seq', { action : 'loop' });
|
|
||||||
}
|
|
||||||
if (seq.stop()) {
|
|
||||||
$('.row input').removeClass('h');
|
|
||||||
$('#numbers div').removeClass('h');
|
|
||||||
//console.log('Sequence stepped');
|
|
||||||
log.info('Sequence stopped', 'SERIAL', true);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (seq.i <= mcopy.state.sequence.arr.length && c !== undefined) {
|
|
||||||
log.info('Step ' + seq.i + ' command ' + c, 'SEQUENCE', true);
|
|
||||||
//gui action
|
|
||||||
$('.row input').removeClass('h');
|
|
||||||
$('#numbers div').removeClass('h');
|
|
||||||
$('.row input[x=' + seq.i + ']').addClass('h');
|
|
||||||
$('#numbers div[x=' + seq.i + ']').addClass('h');
|
|
||||||
if (c === cfg.cmd.camera_forward){
|
|
||||||
rgb = mcopy.state.sequence.light[seq.i].split(',');
|
|
||||||
cmd.camera_forward(rgb, action);
|
|
||||||
} else if (c === cfg.cmd.camera_backward) {
|
|
||||||
rgb = mcopy.state.sequence.light[seq.i].split(',');
|
|
||||||
cmd.camera_backward(rgb, action);
|
|
||||||
} else if (c === cfg.cmd.projector_forward) {
|
|
||||||
cmd.projector_forward(action);
|
|
||||||
} else if (c === cfg.cmd.projector_backward) {
|
|
||||||
cmd.projector_backward(action);
|
|
||||||
} else if (c === cfg.cmd.black_forward) {
|
|
||||||
cmd.black_forward(action);
|
|
||||||
} else if (c === cfg.cmd.black_backward) {
|
|
||||||
cmd.black_backward(action);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mcopy.loopCount++;
|
|
||||||
$('#loop_current').text(gui.fmtZero(mcopy.loopCount + 1, 6));
|
|
||||||
if (mcopy.loopCount < mcopy.loop) {
|
|
||||||
log.info('Loop ' + mcopy.loopCount + ' completed', 'SEQUENCE', true);
|
|
||||||
$('.row input').removeClass('h');
|
|
||||||
$('#numbers div').removeClass('h');
|
|
||||||
seq.i = 0;
|
|
||||||
seq.run();
|
|
||||||
} else {
|
|
||||||
timeEnd = +new Date();
|
|
||||||
timeEnd = timeEnd - seq.time;
|
|
||||||
if (timeEnd < 2000) {
|
|
||||||
log.info('Sequence completed in ' + timeEnd + 'ms', 'SEQUENCE', true);
|
|
||||||
} else {
|
|
||||||
log.info('Sequence completed in ' + humanizeDuration(timeEnd), 'SEQUENCE', true);
|
|
||||||
}
|
|
||||||
ipcRenderer.send('seq', { action : 'stop' });
|
|
||||||
gui.notify('Sequence done!', (mcopy.state.sequence.arr.length * mcopy.loop) + ' actions completed in ' + humanizeDuration(timeEnd));
|
|
||||||
//clear gui
|
|
||||||
$('.row input').removeClass('h');
|
|
||||||
$('#numbers div').removeClass('h');
|
|
||||||
$('#loop_current').text('');
|
|
||||||
seq.stats();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};*/
|
|
||||||
seq.stop = function (state) {
|
|
||||||
'use strict';
|
|
||||||
ipcRenderer.send('seq', { action : 'stop' });
|
|
||||||
/*
|
|
||||||
if (typeof state === 'undefined') {
|
|
||||||
if (seq.stopState === true) {
|
|
||||||
ipcRenderer.send('seq', { action : 'stop' });
|
|
||||||
}
|
|
||||||
return seq.stopState;
|
|
||||||
} else {
|
|
||||||
seq.stopState = state;
|
|
||||||
}
|
|
||||||
if (state === false) {
|
|
||||||
mcopy.loopCount = 0
|
|
||||||
$('#loop_current').text('');
|
|
||||||
} else {
|
|
||||||
ipcRenderer.send('seq', { action : 'stop' });
|
|
||||||
}*/
|
|
||||||
return state
|
|
||||||
};
|
};
|
||||||
seq.init = function (start) {
|
seq.start = function (start) {
|
||||||
'use strict';
|
'use strict';
|
||||||
/*if (typeof start === 'undefined') {
|
seq.time = +new Date();
|
||||||
start = 0;
|
|
||||||
mcopy.loopCount = 0;
|
|
||||||
seq.time = +new Date();
|
|
||||||
}*/
|
|
||||||
//seq.stop(false);
|
|
||||||
//seq.i = start;
|
|
||||||
|
|
||||||
ipcRenderer.send('seq', { action : 'start' });
|
ipcRenderer.send(seq.id, { start : true });
|
||||||
//seq.run();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
seq.set = function (x, cmd) {
|
seq.set = function (x, cmd) {
|
||||||
|
'use strict';
|
||||||
let increase = 0;
|
let increase = 0;
|
||||||
if (x >= seq.arr.length + 1) {
|
if (x >= seq.arr.length + 1) {
|
||||||
increase = x - seq.arr.length;
|
increase = x - seq.arr.length;
|
||||||
|
@ -136,6 +46,26 @@ seq.set = function (x, cmd) {
|
||||||
//update grid?
|
//update grid?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
seq.unset = function (x) {
|
||||||
|
'use strict';
|
||||||
|
seq.arr[x] = undefined
|
||||||
|
ipcRenderer.send(seq.id, { unset : [ x ]});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the light value at a specific step and then update
|
||||||
|
* GUI grid via .state()
|
||||||
|
*
|
||||||
|
* @param {integer} x Step in sequence
|
||||||
|
* @param {array} rgb Light value in RGB
|
||||||
|
**/
|
||||||
|
seq.setLight = function (x, rgb) {
|
||||||
|
'use strict';
|
||||||
|
let color = rgb.join(',');
|
||||||
|
seq.arr[x].light = color;
|
||||||
|
ipcRenderer.send(seq.id, { x, cmd : seq.arr[x].cmd, light : color });
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function bound to the change event on the loop counter
|
* Function bound to the change event on the loop counter
|
||||||
* input element
|
* input element
|
||||||
|
@ -155,7 +85,7 @@ seq.stats = function () {
|
||||||
let c = '';
|
let c = '';
|
||||||
let cam_total = 0;
|
let cam_total = 0;
|
||||||
let proj_total = 0;
|
let proj_total = 0;
|
||||||
let real_total = mcopy.state.sequence.arr.filter(function (elem) {
|
let real_total = seq.arr.filter(function (elem) {
|
||||||
if (elem === undefined) {
|
if (elem === undefined) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -163,7 +93,8 @@ seq.stats = function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
//timing
|
//timing
|
||||||
for (let c of mcopy.state.sequence.arr) {
|
for (let step of seq.arr) {
|
||||||
|
c = seq.cmd;
|
||||||
if (c === cfg.cmd.camera_forward || c === cfg.cmd.camera_backward){
|
if (c === cfg.cmd.camera_forward || c === cfg.cmd.camera_backward){
|
||||||
ms += cfg.arduino.cam.time;
|
ms += cfg.arduino.cam.time;
|
||||||
ms += cfg.arduino.cam.delay;
|
ms += cfg.arduino.cam.delay;
|
||||||
|
@ -216,92 +147,18 @@ seq.stats = function () {
|
||||||
$('#seq_stats .seq_count span').text(real_total.length * seq.loops);
|
$('#seq_stats .seq_count span').text(real_total.length * seq.loops);
|
||||||
return ms;
|
return ms;
|
||||||
};
|
};
|
||||||
|
|
||||||
seq.clear = function () {
|
seq.clear = function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
seq.size = 24;
|
seq.size = 24;
|
||||||
seq.arr = [];
|
seq.arr = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Queue for exec function
|
|
||||||
*/
|
|
||||||
seq.queue = [];
|
|
||||||
seq.running = false;
|
|
||||||
seq.state = {};
|
|
||||||
/**
|
|
||||||
* Execute an array of commands, locking up the UI during execution.
|
|
||||||
*/
|
|
||||||
seq.exec = function (arr) {
|
|
||||||
'use strict';
|
|
||||||
seq.running = true;
|
|
||||||
seq.state.len = arr.length;
|
|
||||||
//setup queue
|
|
||||||
seq.queue = arr;
|
|
||||||
//console.dir(arr);
|
|
||||||
gui.overlay(true);
|
|
||||||
gui.spinner(true, `Running sequence of ${arr.length} frame${(arr.length === 1 ? '' : 's')}`, 0, true);
|
|
||||||
log.info(`Sequence started`, 'SEQUENCE', true);
|
|
||||||
ipcRenderer.send('seq', { action : 'start' });
|
|
||||||
//seq.step();
|
|
||||||
};
|
|
||||||
|
|
||||||
seq.cancel = function () {
|
seq.cancel = function () {
|
||||||
gui.spinner(true, `Cancelling sequence...`);
|
gui.spinner(true, `Cancelling sequence...`);
|
||||||
seq.running = false;
|
seq.running = false;
|
||||||
|
seq.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
seq.execStop = function (msg) {
|
|
||||||
'use strict';
|
|
||||||
gui.overlay(false);
|
|
||||||
gui.spinner(false);
|
|
||||||
log.info(`Sequence ${msg}`, 'SEQUENCE', true);
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
seq.step = function () {
|
|
||||||
'use strict';
|
|
||||||
let elem;
|
|
||||||
let c;
|
|
||||||
let rgb;
|
|
||||||
let current;
|
|
||||||
let max;
|
|
||||||
|
|
||||||
if (!seq.running) {
|
|
||||||
return seq.execStop('stopped');
|
|
||||||
}
|
|
||||||
|
|
||||||
return setTimeout(() => {
|
|
||||||
elem = seq.queue.shift();
|
|
||||||
if (typeof elem !== 'undefined') {
|
|
||||||
c = elem.cmd;
|
|
||||||
if (typeof elem.light !== 'undefined') {
|
|
||||||
rgb = elem.light.split(',');
|
|
||||||
} else {
|
|
||||||
rgb = light.color;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return seq.execStop('completed');
|
|
||||||
}
|
|
||||||
if (typeof elem !== 'undefined') {
|
|
||||||
current = seq.state.len - seq.queue.length;
|
|
||||||
max = seq.state.len;
|
|
||||||
gui.spinner(true, `Sequence: step ${c} ${current}/${max}`, (current / max) * 100, true);
|
|
||||||
log.info(`Sequence: step ${c} ${current}/${max}`, 'SEQUENCE', true);
|
|
||||||
if (c === cfg.cmd.camera_forward){
|
|
||||||
cmd.camera_forward(rgb, seq.step);
|
|
||||||
} else if (c === cfg.cmd.camera_backward) {
|
|
||||||
cmd.camera_backward(rgb, seq.step);
|
|
||||||
} else if (c === cfg.cmd.projector_forward) {
|
|
||||||
cmd.projector_forward(seq.step);
|
|
||||||
} else if (c === cfg.cmd.projector_backward) {
|
|
||||||
cmd.projector_backward(seq.step);
|
|
||||||
} else if (c === cfg.cmd.black_forward) {
|
|
||||||
cmd.black_forward(seq.step);
|
|
||||||
} else if (c === cfg.cmd.black_backward) {
|
|
||||||
cmd.black_backward(seq.step);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, cfg.arduino.sequenceDelay);
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = seq;
|
module.exports = seq;
|
|
@ -117,22 +117,19 @@ var init = async function () {
|
||||||
log.error('Error enumerating connected devices', err)
|
log.error('Error enumerating connected devices', err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
light = require('light')(arduino, cfg, mainWindow.webContents)
|
light = require('light')(arduino, cfg, mainWindow.webContents)
|
||||||
dig = require('digital')(display, ffmpeg, ffprobe, mainWindow.webContents, light)
|
dig = require('digital')(display, ffmpeg, ffprobe, mainWindow.webContents, light)
|
||||||
cam = require('cam')(arduino, cfg, mainWindow.webContents, dig)
|
cam = require('cam')(arduino, cfg, mainWindow.webContents, dig)
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
app.on('ready', init)
|
app.on('ready', init)
|
||||||
|
|
||||||
app.on('window-all-closed', () => {
|
app.on('window-all-closed', () => {
|
||||||
//if (process.platform !== 'darwin') {
|
app.quit();
|
||||||
app.quit();
|
|
||||||
//}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.on('activate', () => {
|
app.on('activate', () => {
|
||||||
|
|
|
@ -45,10 +45,8 @@ mcopy.state = {
|
||||||
direction : true
|
direction : true
|
||||||
},
|
},
|
||||||
sequence : {
|
sequence : {
|
||||||
size : 24,
|
|
||||||
arr : ['CF', 'PF'],
|
|
||||||
light : ['255,255,255', ''],
|
|
||||||
pads: {
|
pads: {
|
||||||
|
//gaaaaaaaaah
|
||||||
cam_forward: 'CF',
|
cam_forward: 'CF',
|
||||||
proj_forward : 'PF',
|
proj_forward : 'PF',
|
||||||
black_forward : 'BF',
|
black_forward : 'BF',
|
||||||
|
@ -57,8 +55,7 @@ mcopy.state = {
|
||||||
proj_backward : 'PB',
|
proj_backward : 'PB',
|
||||||
black_backward : 'BB',
|
black_backward : 'BB',
|
||||||
|
|
||||||
light_set : 'L'//,
|
light_set : 'L',
|
||||||
/*
|
|
||||||
|
|
||||||
cam2_forward : 'C2F',
|
cam2_forward : 'C2F',
|
||||||
cam2_backward : 'C2B',
|
cam2_backward : 'C2B',
|
||||||
|
@ -78,7 +75,6 @@ mcopy.state = {
|
||||||
proj_forward_proj2_backward : 'PFPB',
|
proj_forward_proj2_backward : 'PFPB',
|
||||||
proj_backward_proj2_forward : 'PBPF'
|
proj_backward_proj2_forward : 'PBPF'
|
||||||
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,6 +4,8 @@ const Log = require("log");
|
||||||
let seq;
|
let seq;
|
||||||
class Sequencer {
|
class Sequencer {
|
||||||
constructor(cfg, cmd) {
|
constructor(cfg, cmd) {
|
||||||
|
this.running = false;
|
||||||
|
this.paused = false;
|
||||||
this.arr = [];
|
this.arr = [];
|
||||||
this.loops = 1;
|
this.loops = 1;
|
||||||
this.CMDS = {};
|
this.CMDS = {};
|
||||||
|
@ -31,9 +33,21 @@ class Sequencer {
|
||||||
}
|
}
|
||||||
async listener(event, arg) {
|
async listener(event, arg) {
|
||||||
console.dir(arg);
|
console.dir(arg);
|
||||||
if (arg && arg.set) {
|
if (arg && arg.start) {
|
||||||
|
this.start(arg);
|
||||||
|
}
|
||||||
|
else if (arg && arg.stop) {
|
||||||
|
this.stop();
|
||||||
|
}
|
||||||
|
else if (arg && arg.pause) {
|
||||||
|
this.pause();
|
||||||
|
}
|
||||||
|
else if (arg && arg.set) {
|
||||||
this.setSteps(arg.set);
|
this.setSteps(arg.set);
|
||||||
}
|
}
|
||||||
|
else if (arg && arg.unset) {
|
||||||
|
this.unsetSteps(arg.unset);
|
||||||
|
}
|
||||||
else if (arg && arg.loops) {
|
else if (arg && arg.loops) {
|
||||||
this.loops = arg.loops;
|
this.loops = arg.loops;
|
||||||
}
|
}
|
||||||
|
@ -42,24 +56,36 @@ class Sequencer {
|
||||||
setSteps(steps) {
|
setSteps(steps) {
|
||||||
console.dir(steps);
|
console.dir(steps);
|
||||||
}
|
}
|
||||||
//new
|
unsetSteps(steps) {
|
||||||
|
}
|
||||||
|
//new, replaces exec and init
|
||||||
async start(arg) {
|
async start(arg) {
|
||||||
if (arg && arg.arr) {
|
if (arg && arg.arr) {
|
||||||
this.arr = arg.arr;
|
this.arr = arg.arr; //overwrite sequence
|
||||||
}
|
}
|
||||||
if (arg && arg.loops) {
|
if (arg && arg.loops) {
|
||||||
this.loops = arg.loops;
|
this.loops = arg.loops; //overwrite loops
|
||||||
}
|
}
|
||||||
|
this.running = true;
|
||||||
|
this.paused = false;
|
||||||
for (let x = 0; x < this.loops; x++) {
|
for (let x = 0; x < this.loops; x++) {
|
||||||
|
//start loop
|
||||||
for (let y = 0; y < this.arr.length; y++) {
|
for (let y = 0; y < this.arr.length; y++) {
|
||||||
|
//start step
|
||||||
if (this.running) {
|
if (this.running) {
|
||||||
|
while (this.paused) {
|
||||||
|
await delay(42);
|
||||||
|
}
|
||||||
await this.step(y);
|
await this.step(y);
|
||||||
}
|
}
|
||||||
|
//end step
|
||||||
}
|
}
|
||||||
|
//end loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//new
|
//new
|
||||||
pause() {
|
pause() {
|
||||||
|
this.paused = true;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Stop the sequence
|
* Stop the sequence
|
||||||
|
|
|
@ -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;IAcd,YAAa,GAAS,EAAE,GAAS;QAVzB,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,EAA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ACD,UAAU;aACV;YACD,UAAU;SACV;IACF,CAAC;IACD,KAAK;IACE,KAAK;QACX,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACpB,CAAC;IACD;;QAEI;IACG,IAAI;QACV,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,QAAQ;IAET,CAAC;IAEO,KAAK,CAAC,IAAI,CAAE,KAAc;QACjC,IAAI;YACH,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;SACxB;QAAC,OAAO,GAAG,EAAE;YACb,MAAM,GAAG,CAAC;SACV;IAEF,CAAC;IAEO,KAAK,CAAC,MAAM,CAAE,KAAc;QACnC,MAAM,WAAW,GAAY,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC;QACjD,MAAM,GAAG,GAAY,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC5C,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;CACD;AAED,MAAM,CAAC,OAAO,GAAG,UAAU,GAAS,EAAE,GAAS;IAC9C,OAAO,IAAI,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAChC,CAAC,CAAA"}
|
|
@ -4,6 +4,8 @@ const Log = require("log");
|
||||||
let seq;
|
let seq;
|
||||||
class Sequencer {
|
class Sequencer {
|
||||||
constructor(cfg, cmd) {
|
constructor(cfg, cmd) {
|
||||||
|
this.running = false;
|
||||||
|
this.paused = false;
|
||||||
this.arr = [];
|
this.arr = [];
|
||||||
this.loops = 1;
|
this.loops = 1;
|
||||||
this.CMDS = {};
|
this.CMDS = {};
|
||||||
|
@ -31,9 +33,21 @@ class Sequencer {
|
||||||
}
|
}
|
||||||
async listener(event, arg) {
|
async listener(event, arg) {
|
||||||
console.dir(arg);
|
console.dir(arg);
|
||||||
if (arg && arg.set) {
|
if (arg && arg.start) {
|
||||||
|
this.start(arg);
|
||||||
|
}
|
||||||
|
else if (arg && arg.stop) {
|
||||||
|
this.stop();
|
||||||
|
}
|
||||||
|
else if (arg && arg.pause) {
|
||||||
|
this.pause();
|
||||||
|
}
|
||||||
|
else if (arg && arg.set) {
|
||||||
this.setSteps(arg.set);
|
this.setSteps(arg.set);
|
||||||
}
|
}
|
||||||
|
else if (arg && arg.unset) {
|
||||||
|
this.unsetSteps(arg.unset);
|
||||||
|
}
|
||||||
else if (arg && arg.loops) {
|
else if (arg && arg.loops) {
|
||||||
this.loops = arg.loops;
|
this.loops = arg.loops;
|
||||||
}
|
}
|
||||||
|
@ -42,24 +56,36 @@ class Sequencer {
|
||||||
setSteps(steps) {
|
setSteps(steps) {
|
||||||
console.dir(steps);
|
console.dir(steps);
|
||||||
}
|
}
|
||||||
//new
|
unsetSteps(steps) {
|
||||||
|
}
|
||||||
|
//new, replaces exec and init
|
||||||
async start(arg) {
|
async start(arg) {
|
||||||
if (arg && arg.arr) {
|
if (arg && arg.arr) {
|
||||||
this.arr = arg.arr;
|
this.arr = arg.arr; //overwrite sequence
|
||||||
}
|
}
|
||||||
if (arg && arg.loops) {
|
if (arg && arg.loops) {
|
||||||
this.loops = arg.loops;
|
this.loops = arg.loops; //overwrite loops
|
||||||
}
|
}
|
||||||
|
this.running = true;
|
||||||
|
this.paused = false;
|
||||||
for (let x = 0; x < this.loops; x++) {
|
for (let x = 0; x < this.loops; x++) {
|
||||||
|
//start loop
|
||||||
for (let y = 0; y < this.arr.length; y++) {
|
for (let y = 0; y < this.arr.length; y++) {
|
||||||
|
//start step
|
||||||
if (this.running) {
|
if (this.running) {
|
||||||
|
while (this.paused) {
|
||||||
|
await delay(42);
|
||||||
|
}
|
||||||
await this.step(y);
|
await this.step(y);
|
||||||
}
|
}
|
||||||
|
//end step
|
||||||
}
|
}
|
||||||
|
//end loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//new
|
//new
|
||||||
pause() {
|
pause() {
|
||||||
|
this.paused = true;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Stop the sequence
|
* Stop the sequence
|
||||||
|
|
|
@ -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;IAcd,YAAa,GAAS,EAAE,GAAS;QAVzB,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,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAChD,CAAC;IAEO,KAAK,CAAC,QAAQ,CAAE,KAAW,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,EAAE;YACb,MAAM,GAAG,CAAC;SACV;IAEF,CAAC;IAEO,KAAK,CAAC,MAAM,CAAE,KAAc;QACnC,MAAM,WAAW,GAAY,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC;QACjD,MAAM,GAAG,GAAY,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC5C,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;CACD;AAED,MAAM,CAAC,OAAO,GAAG,UAAU,GAAS,EAAE,GAAS;IAC9C,OAAO,IAAI,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAChC,CAAC,CAAA"}
|
|
@ -6,7 +6,8 @@ let seq : Sequencer;
|
||||||
|
|
||||||
class Sequencer {
|
class Sequencer {
|
||||||
private time : number;
|
private time : number;
|
||||||
private running : boolean;
|
private running : boolean = false;
|
||||||
|
private paused : boolean = false;
|
||||||
|
|
||||||
private arr : any[] = [];
|
private arr : any[] = [];
|
||||||
private loops : number = 1;
|
private loops : number = 1;
|
||||||
|
@ -46,8 +47,16 @@ class Sequencer {
|
||||||
|
|
||||||
private async listener (event : any, arg : any) {
|
private async listener (event : any, arg : any) {
|
||||||
console.dir(arg)
|
console.dir(arg)
|
||||||
if (arg && arg.set) {
|
if (arg && arg.start) {
|
||||||
|
this.start(arg);
|
||||||
|
} else if (arg && arg.stop) {
|
||||||
|
this.stop();
|
||||||
|
} else if (arg && arg.pause) {
|
||||||
|
this.pause();
|
||||||
|
} else if (arg && arg.set) {
|
||||||
this.setSteps(arg.set);
|
this.setSteps(arg.set);
|
||||||
|
} else if (arg && arg.unset) {
|
||||||
|
this.unsetSteps(arg.unset);
|
||||||
} else if (arg && arg.loops) {
|
} else if (arg && arg.loops) {
|
||||||
this.loops = arg.loops;
|
this.loops = arg.loops;
|
||||||
}
|
}
|
||||||
|
@ -57,26 +66,39 @@ class Sequencer {
|
||||||
public setSteps (steps : any) {
|
public setSteps (steps : any) {
|
||||||
console.dir(steps)
|
console.dir(steps)
|
||||||
}
|
}
|
||||||
//new
|
public unsetSteps (steps : number[]) {
|
||||||
|
|
||||||
|
}
|
||||||
|
//new, replaces exec and init
|
||||||
public async start (arg : any) {
|
public async start (arg : any) {
|
||||||
if (arg && arg.arr) {
|
if (arg && arg.arr) {
|
||||||
this.arr = arg.arr;
|
this.arr = arg.arr; //overwrite sequence
|
||||||
}
|
}
|
||||||
if (arg && arg.loops) {
|
if (arg && arg.loops) {
|
||||||
this.loops = arg.loops;
|
this.loops = arg.loops; //overwrite loops
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.running = true;
|
||||||
|
this.paused = false;
|
||||||
|
|
||||||
for (let x = 0; x < this.loops; x++) {
|
for (let x = 0; x < this.loops; x++) {
|
||||||
|
//start loop
|
||||||
for (let y = 0; y < this.arr.length; y++) {
|
for (let y = 0; y < this.arr.length; y++) {
|
||||||
|
//start step
|
||||||
if (this.running) {
|
if (this.running) {
|
||||||
|
while (this.paused) {
|
||||||
|
await delay(42);
|
||||||
|
}
|
||||||
await this.step(y);
|
await this.step(y);
|
||||||
}
|
}
|
||||||
|
//end step
|
||||||
}
|
}
|
||||||
|
//end loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//new
|
//new
|
||||||
public pause () {
|
public pause () {
|
||||||
|
this.paused = true;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Stop the sequence
|
* Stop the sequence
|
||||||
|
|
Loading…
Reference in New Issue