Made progress on sequencer module, renamed from sequence.

This commit is contained in:
mmcwilliams 2019-03-22 04:33:53 -04:00
parent 425dd9fd6a
commit 553d2bbb0d
32 changed files with 188 additions and 755 deletions

View File

@ -60,7 +60,7 @@
</div>
<div id="seq_loop_wrap">
<h3>LOOPS</h3>
<input type="number" min="1" id="seq_loop" value="00001" onchange="this.value = gui.fmtZero(this.value, 6); grid.loopChange(this);"/>
<input type="number" min="1" id="seq_loop" value="00001" onchange="this.value = gui.fmtZero(this.value, 6); seq.setLoops(parseInt(this.value));"/>
<div id="loop_current"></div>
</div>
</div>

View File

@ -2473,7 +2473,6 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//fgnass.github.com/spin.js#v2.0.1
!function(a,b){"object"==typeof exports?module.exports=b():"function"==typeof define&&define.amd?define(b):a.Spinner=b()}(this,function(){"use strict";function a(a,b){var c,d=document.createElement(a||"div");for(c in b)d[c]=b[c];return d}function b(a){for(var b=1,c=arguments.length;c>b;b++)a.appendChild(arguments[b]);return a}function c(a,b,c,d){var e=["opacity",b,~~(100*a),c,d].join("-"),f=.01+c/d*100,g=Math.max(1-(1-a)/b*(100-f),a),h=j.substring(0,j.indexOf("Animation")).toLowerCase(),i=h&&"-"+h+"-"||"";return l[e]||(m.insertRule("@"+i+"keyframes "+e+"{0%{opacity:"+g+"}"+f+"%{opacity:"+a+"}"+(f+.01)+"%{opacity:1}"+(f+b)%100+"%{opacity:"+a+"}100%{opacity:"+g+"}}",m.cssRules.length),l[e]=1),e}function d(a,b){var c,d,e=a.style;for(b=b.charAt(0).toUpperCase()+b.slice(1),d=0;d<k.length;d++)if(c=k[d]+b,void 0!==e[c])return c;return void 0!==e[b]?b:void 0}function e(a,b){for(var c in b)a.style[d(a,c)||c]=b[c];return a}function f(a){for(var b=1;b<arguments.length;b++){var c=arguments[b];for(var d in c)void 0===a[d]&&(a[d]=c[d])}return a}function g(a,b){return"string"==typeof a?a:a[b%a.length]}function h(a){this.opts=f(a||{},h.defaults,n)}function i(){function c(b,c){return a("<"+b+' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">',c)}m.addRule(".spin-vml","behavior:url(#default#VML)"),h.prototype.lines=function(a,d){function f(){return e(c("group",{coordsize:k+" "+k,coordorigin:-j+" "+-j}),{width:k,height:k})}function h(a,h,i){b(m,b(e(f(),{rotation:360/d.lines*a+"deg",left:~~h}),b(e(c("roundrect",{arcsize:d.corners}),{width:j,height:d.width,left:d.radius,top:-d.width>>1,filter:i}),c("fill",{color:g(d.color,a),opacity:d.opacity}),c("stroke",{opacity:0}))))}var i,j=d.length+d.width,k=2*j,l=2*-(d.width+d.length)+"px",m=e(f(),{position:"absolute",top:l,left:l});if(d.shadow)for(i=1;i<=d.lines;i++)h(i,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(i=1;i<=d.lines;i++)h(i);return b(a,m)},h.prototype.opacity=function(a,b,c,d){var e=a.firstChild;d=d.shadow&&d.lines||0,e&&b+d<e.childNodes.length&&(e=e.childNodes[b+d],e=e&&e.firstChild,e=e&&e.firstChild,e&&(e.opacity=c))}}var j,k=["webkit","Moz","ms","O"],l={},m=function(){var c=a("style",{type:"text/css"});return b(document.getElementsByTagName("head")[0],c),c.sheet||c.styleSheet}(),n={lines:12,length:7,width:5,radius:10,rotate:0,corners:1,color:"#000",direction:1,speed:1,trail:100,opacity:.25,fps:20,zIndex:2e9,className:"spinner",top:"50%",left:"50%",position:"absolute"};h.defaults={},f(h.prototype,{spin:function(b){this.stop();{var c=this,d=c.opts,f=c.el=e(a(0,{className:d.className}),{position:d.position,width:0,zIndex:d.zIndex});d.radius+d.length+d.width}if(e(f,{left:d.left,top:d.top}),b&&b.insertBefore(f,b.firstChild||null),f.setAttribute("role","progressbar"),c.lines(f,c.opts),!j){var g,h=0,i=(d.lines-1)*(1-d.direction)/2,k=d.fps,l=k/d.speed,m=(1-d.opacity)/(l*d.trail/100),n=l/d.lines;!function o(){h++;for(var a=0;a<d.lines;a++)g=Math.max(1-(h+(d.lines-a)*n)%l*m,d.opacity),c.opacity(f,a*d.direction+i,g,d);c.timeout=c.el&&setTimeout(o,~~(1e3/k))}()}return c},stop:function(){var a=this.el;return a&&(clearTimeout(this.timeout),a.parentNode&&a.parentNode.removeChild(a),this.el=void 0),this},lines:function(d,f){function h(b,c){return e(a(),{position:"absolute",width:f.length+f.width+"px",height:f.width+"px",background:b,boxShadow:c,transformOrigin:"left",transform:"rotate("+~~(360/f.lines*k+f.rotate)+"deg) translate("+f.radius+"px,0)",borderRadius:(f.corners*f.width>>1)+"px"})}for(var i,k=0,l=(f.lines-1)*(1-f.direction)/2;k<f.lines;k++)i=e(a(),{position:"absolute",top:1+~(f.width/2)+"px",transform:f.hwaccel?"translate3d(0,0,0)":"",opacity:f.opacity,animation:j&&c(f.opacity,f.trail,l+k*f.direction,f.lines)+" "+1/f.speed+"s linear infinite"}),f.shadow&&b(i,e(h("#000","0 0 4px #000"),{top:"2px"})),b(d,b(i,h(g(f.color,k),"0 0 1px rgba(0,0,0,.1)")));return d},opacity:function(a,b,c){b<a.childNodes.length&&(a.childNodes[b].style.opacity=c)}});var o=e(a("group"),{behavior:"url(#default#VML)"});return!d(o,"transform")&&o.adj?i():j=d(o,"animation"),h});
const mcopy = {};
mcopy.cfg = require('./data/cfg.json');
const { remote, ipcRenderer } = require('electron');
const dialog = require('electron').remote.dialog;

View File

@ -169,12 +169,12 @@ class Commands {
proj.set2(true, function (ms) {
setTimeout(function () {
proj.move2(res);
}, mcopy.cfg.arduino.serialDelay);
}, this.cfg.arduino.serialDelay);
});
} else {
setTimeout(function () {
proj.move2(res);
}, mcopy.cfg.arduino.serialDelay);
}, this.cfg.arduino.serialDelay);
}
};
cmd.projector_second_backward = function (callback) {};

View File

@ -1,567 +0,0 @@
<a name="Sequence"></a>
## Sequence
Run the sequence
seq.run = function () {
'use strict';
var c = mcopy.state.sequence.arr[seq.i],
timeEnd = 0,
rgb,
action = function () {
setTimeout(function () {
seq.i++;
seq.run();
}, mcopy.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');
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 === 'CF'){
rgb = mcopy.state.sequence.light[seq.i].split(',');
cmd.camera_forward(rgb, action);
} else if (c === 'CB') {
rgb = mcopy.state.sequence.light[seq.i].split(',');
cmd.camera_backward(rgb, action);
} else if (c === 'PF') {
cmd.projector_forward(action);
} else if (c === 'PB') {
cmd.projector_backward(action);
} else if (c === 'BF') {
cmd.black_forward(action);
} else if (c === 'BB') {
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';
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) {
'use strict';
if (typeof start === 'undefined') {
start = 0;
mcopy.loopCount = 0;
seq.time = +new Date();
}
seq.stop(false);
seq.i = start;
ipcRenderer.send('seq', { action : 'start' });
seq.run();
};
//!!! redo
seq.stats = function () {
'use strict';
var ms = 0,
c = '',
cam_total = 0,
proj_total = 0,
real_total = mcopy.state.sequence.arr.filter(function (elem) {
if (elem === undefined) {
return false;
}
return true;
});
//timing
for (var i = 0; i < mcopy.state.sequence.arr.length; i++) {
c = mcopy.state.sequence.arr[i];
if (c === 'CF' || c === 'CB'){
ms += mcopy.cfg.arduino.cam.time;
ms += mcopy.cfg.arduino.cam.delay;
ms += mcopy.cfg.arduino.serialDelay;
}
if (c === 'PF' || c === 'PB'){
ms += mcopy.cfg.arduino.proj.time;
ms += mcopy.cfg.arduino.proj.delay;
ms += mcopy.cfg.arduino.serialDelay;
}
if (c === 'BF' || c === 'BB'){
ms += mcopy.cfg.arduino.black.before;
ms += mcopy.cfg.arduino.black.after;
ms += mcopy.cfg.arduino.cam.time;
ms += mcopy.cfg.arduino.cam.delay;
ms += mcopy.cfg.arduino.serialDelay;
}
ms += mcopy.cfg.arduino.sequenceDelay;
if (c === 'CF' || c === 'BF') {
cam_total++;
}
if (c === 'CB' || c === 'BB') {
cam_total--;
}
if (c === 'PF') {
proj_total++;
}
if (c === 'PB') {
proj_total--;
}
}
//timing
ms = ms * mcopy.loop;
if (ms < 2000) {
$('#seq_stats .timing span').text(ms + 'ms');
} else {
$('#seq_stats .timing span').text(humanizeDuration(ms));
}
//ending frames
cam_total = cam_total * mcopy.loop;
proj_total = proj_total * mcopy.loop;
$('#seq_stats .cam_end span').text(gui.fmtZero(mcopy.state.camera.pos + cam_total, 6));
$('#seq_stats .proj_end span').text(gui.fmtZero(mcopy.state.projector.pos + proj_total, 6));
//count
$('#seq_stats .seq_count span').text(real_total.length * mcopy.loop);
return ms;
};
seq.clear = function () {
'use strict';
mcopy.state.sequence.size = 24;
mcopy.state.sequence.arr = [];
};
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);
log.info(`Sequence started`, 'SEQUENCE', true);
seq.step();
};
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);
log.info(`Sequence: step ${c} ${current}/${max}`, 'SEQUENCE', true);
if (c === 'CF'){
cmd.camera_forward(rgb, seq.step);
} else if (c === 'CB') {
cmd.camera_backward(rgb, seq.step);
} else if (c === 'PF') {
cmd.projector_forward(seq.step);
} else if (c === 'PB') {
cmd.projector_backward(seq.step);
} else if (c === 'BF') {
cmd.black_forward(seq.step);
} else if (c === 'BB') {
cmd.black_backward(seq.step);
}
}
}, mcopy.cfg.arduino.sequenceDelay);
};
// FROM SERVER SIDE
proj.state = {
dir : true, //default dir
digital : false
}
proj.init = function () {
proj.listen()
}
proj.set = async function (dir, id) {
let cmd
let ms
if (dir) {
cmd = mcopy.cfg.arduino.cmd.projector_forward
} else {
cmd = mcopy.cfg.arduino.cmd.projector_backward
}
proj.state.dir = dir
if (proj.state.digital) {
dig.set(dir)
} else {
try {
ms = await arduino.send('projector', cmd)
} catch (err) {
console.error(err)
}
}
return await proj.end(cmd, id, ms)
}
proj.move = async function (frame, id) {
const cmd = mcopy.cfg.arduino.cmd.projector
let ms
if (proj.digital) {
try {
ms = await dig.move()
} catch (err) {
console.error(err)
}
} else {
try {
ms = await arduino.send('projector', cmd)
} catch (err) {
console.error(err)
}
}
return await proj.end(mcopy.cfg.arduino.cmd.projector, id, ms)
}
proj.listen = function () {
ipcMain.on('proj', async (event, arg) => {
if (typeof arg.dir !== 'undefined') {
try {
await proj.set(arg.dir, arg.id)
} catch (err) {
console.error(err)
}
} else if (typeof arg.frame !== 'undefined') {
try {
await proj.move(arg.frame, arg.id)
} catch (err) {
console.error(err)
}
} else if (typeof arg.val !== 'undefined') {
dig.state.frame = arg.val
}
event.returnValue = true
})
ipcMain.on('digital', proj.connectDigital)
}
proj.end = async function (cmd, id, ms) {
let message = ''
if (cmd === mcopy.cfg.arduino.cmd.projector_forward) {
message = 'Projector set to FORWARD'
} else if (cmd === mcopy.cfg.arduino.cmd.projector_backward) {
message = 'Projector set to BACKWARD'
} else if (cmd === mcopy.cfg.arduino.cmd.projector) {
message = 'Projector '
if (proj.state.dir) {
message += 'ADVANCED'
} else {
message += 'REWOUND'
}
message += ' 1 frame'
}
log.info(message, 'PROJECTOR', true, true)
return await mainWindow.webContents.send('proj', {cmd: cmd, id : id, ms: ms})
}
proj.connectDigital = async function (evt, arg) {
let info;
let frames = 0;
try {
info = await ffprobe.info(arg.path);
} catch (err) {
log.error(err, 'DIGITAL', true, true);
proj.digital = false;
await mainWindow.webContents.send('digital', { valid : false });
return false;
}
try {
frames = await ffprobe.frames(arg.path);
} catch (err) {
log.error(err, 'DIGITAL', true, true);
proj.digital = false;
await mainWindow.webContents.send('digital', { valid : false });
return false;
}
dig.state.frame = 0;
dig.state.path = arg.path;
dig.state.fileName = arg.fileName;
dig.state.frames = frames;
dig.state.info = info;
//console.dir(dig.state);
log.info(`Opened ${dig.state.fileName}`, 'DIGITAL', true, true);
log.info(`Frames : ${frames}`, 'DIGITAL', true, true);
proj.digital = true;
return await mainWindow.webContents.send('digital', { valid : true, state : JSON.stringify(dig.state) });
}
const dig = {};
dig.state = {
frame : 0,
frames : 0,
path : null,
fileName : null,
info : {},
dir : true
};
dig.set = function (dir) {
dig.state.dir = dir;
}
dig.move = async function () {
let start = +new Date()
let last = dig.state.dir + 0;
if (dig.state.dir) {
dig.state.frame++
} else {
dig.state.frame--
}
if (dig.state.frame < 1) {
dig.state.frame = 1
}
return (+new Date()) - start
}
dig.start = async function () {
try {
await ffmpeg.clearAll()
} catch (err) {
console.error(err)
}
try {
await ffmpeg.frame(dig.state, light.state)
} catch (err) {
console.error(err)
}
display.start(dig.state.frame)
await delay(20)
}
dig.end = async function () {
await delay(20)
display.end()
}
cam.intval = null
cam.state = {
dir : true //default dir
}
cam.init = function () {
cam.listen()
}
cam.set = async function (dir, id) {
let cmd
let ms
if (dir) {
cmd = mcopy.cfg.arduino.cmd.camera_forward
} else {
cmd = mcopy.cfg.arduino.cmd.camera_backward
}
cam.state.dir = dir
if (cam.intval) {
try {
ms = await cam.intval.setDir(dir)
} catch (err) {
console.error(err)
}
} else {
try {
ms = await arduino.send('camera', cmd)
} catch (err) {
console.error(err)
}
}
return await cam.end(cmd, id, ms)
}
cam.move = async function (frame, id) {
const cmd = mcopy.cfg.arduino.cmd.camera
let ms
if (proj.digital) {
await dig.start()
}
if (cam.intval) {
try {
ms = await cam.intval.move()
} catch (err) {
console.error(err)
}
} else {
try {
ms = await arduino.send('camera', cmd)
} catch (err) {
console.error(err)
}
}
if (proj.digital) {
await dig.end()
}
log.info('Camera move time', { ms })
return cam.end(cmd, id, ms)
}
cam.exposure = function (exposure, id) {
let cmd = 'E'
cam.intval.setExposure('camera', exposure, ms => {
cam.end(cmd, id, ms)
})
}
cam.connectIntval = async function (event, arg) {
return new Promise((resolve, reject) => {
if (arg.connect) {
cam.intval = new Intval(arg.url)
cam.intval.connect((err, ms, state) => {
if (err) {
mainWindow.webContents.send('intval', { connected : false })
log.info(`Cannot connect to ${arg.url}`, 'INTVAL', true, true)
cam.intval = null
delete cam.intval
} else {
mainWindow.webContents.send('intval', { connected : true, url : arg.url, state : state })
log.info(`Connected to INTVAL3 @ ${arg.url}`, 'INTVAL', true, true)
settings.update('camera', { intval : arg.url })
settings.save()
dev.remember('intval', arg.url, 'camera')
}
return resolve(true)
})
} else if (arg.disconnect) {
cam.intval = null
return resolve(false)
}
})
}
cam.listen = function () {
ipcMain.on('cam', async (event, arg) => {
if (typeof arg.dir !== 'undefined') {
try {
await cam.set(arg.dir, arg.id)
} catch (err) {
console.error(err)
}
} else if (typeof arg.frame !== 'undefined') {
try {
await cam.move(arg.frame, arg.id)
} catch (err) {
console.error(err)
}
}
event.returnValue = true
})
ipcMain.on('intval', cam.connectIntval)
}
cam.end = async function (cmd, id, ms) {
var message = ''
if (cmd === mcopy.cfg.arduino.cmd.camera_forward) {
message = 'Camera set to FORWARD'
} else if (cmd === mcopy.cfg.arduino.cmd.camera_backward) {
message = 'Camera set to BACKWARD'
} else if (cmd === mcopy.cfg.arduino.cmd.camera) {
message = 'Camera '
if (cam.state.dir) {
message += 'ADVANCED'
} else {
message += 'REWOUND'
}
message += ' 1 frame'
}
log.info(message, 'CAMERA', true, true)
mainWindow.webContents.send('cam', {cmd: cmd, id : id, ms: ms})
};
const seq = {};
seq.init = function () {
seq.listen();
}
seq.listen = function () {
ipcMain.on('seq', async (evt, arg) => {
if (arg.action === 'stop' && proj.digital) {
display.end()
}
})
}
**Kind**: global class
<a name="Sequence+stop"></a>
### sequence.stop()
Stop the sequence
**Kind**: instance method of [<code>Sequence</code>](#Sequence)

View File

@ -1 +0,0 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sequence/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,2BAA4B;AAE5B,IAAI,GAAc,CAAC;AAEnB,MAAM,QAAQ;IA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G,UAAU,GAAS,EAAE,GAAS;IAC9C,GAAG,GAAG,IAAI,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAC9B,CAAC,CAAA"}

View File

View File

@ -2,11 +2,12 @@
Object.defineProperty(exports, "__esModule", { value: true });
const Log = require("log");
let seq;
class Sequence {
class Sequencer {
constructor(cfg, cmd) {
this.arr = [];
this.loops = 1;
this.CMDS = {};
this.id = 'sequence';
this.cfg = cfg;
this.cmd = cmd;
this.cmds(cfg.cmd);
@ -21,23 +22,25 @@ class Sequence {
}
//currently called by ui
async init() {
this.log = Log({ label: 'sequence' });
this.log = Log({ label: this.id });
this.ipc = require('electron').ipcMain;
this.listen();
}
listen() {
this.ipc.on('sequence', this.listener.bind(this));
this.ipc.on(this.id, this.listener.bind(this));
}
async listener(event, arg) {
if (arg && arg.diff) {
this.diff(arg.diff);
console.dir(arg);
if (arg && arg.set) {
this.setSteps(arg.set);
}
else if (arg && arg.loops) {
this.loops = arg.loops;
}
event.returnValue = true;
}
diff(steps) {
setSteps(steps) {
console.dir(steps);
}
//new
async start(arg) {
@ -80,6 +83,6 @@ class Sequence {
}
}
module.exports = function (cfg, cmd) {
seq = new Sequence(cfg, cmd);
return new Sequencer(cfg, cmd);
};
//# sourceMappingURL=index.js.map

View File

@ -0,0 +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,G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+1,5 @@
{
"name": "sequence",
"name": "sequencer",
"version": "1.0.0",
"description": "",
"main": "index.js",

View File

@ -55,11 +55,11 @@ cam.move = function (callback) {
};
cam.end = function (c, id, ms) {
'use strict';
if (c === mcopy.cfg.arduino.cmd.camera_forward) {
if (c === cfg.arduino.cmd.camera_forward) {
mcopy.state.camera.direction = true;
} else if (c === mcopy.cfg.arduino.cmd.camera_backward) {
} else if (c === cfg.arduino.cmd.camera_backward) {
mcopy.state.camera.direction = false;
} else if (c === mcopy.cfg.arduino.cmd.camera) {
} else if (c === cfg.arduino.cmd.camera) {
if (mcopy.state.camera.direction) {
mcopy.state.camera.pos += 1;
} else {

View File

@ -17,12 +17,12 @@ cmd.projector_forward = function (callback) {
proj.set(true, function (ms) {
setTimeout(function () {
proj.move(res);
}, mcopy.cfg.arduino.serialDelay);
}, cfg.arduino.serialDelay);
});
} else {
setTimeout(function () {
proj.move(res);
}, mcopy.cfg.arduino.serialDelay);
}, cfg.arduino.serialDelay);
}
};
/**
@ -42,12 +42,12 @@ cmd.projector_backward = function (callback) {
proj.set(false, function (ms) {
setTimeout(function () {
proj.move(res);
}, mcopy.cfg.arduino.serialDelay);
}, cfg.arduino.serialDelay);
});
} else {
setTimeout(function () {
proj.move(res);
}, mcopy.cfg.arduino.serialDelay);
}, cfg.arduino.serialDelay);
}
};
/**
@ -67,7 +67,7 @@ cmd.camera_forward = function (rgb, callback) {
$('#cmd_cam_forward').removeClass('active');
if (callback) { callback(ms); }
});
}, mcopy.cfg.arduino.serialDelay);
}, cfg.arduino.serialDelay);
};
$('#cmd_cam_forward').addClass('active');
if (!mcopy.state.camera.direction) {
@ -77,16 +77,16 @@ cmd.camera_forward = function (rgb, callback) {
light.set(rgb, function () {
setTimeout( function () {
cam.move(res);
}, mcopy.cfg.arduino.serialDelay);
}, cfg.arduino.serialDelay);
});
}, mcopy.cfg.arduino.serialDelay);
}, cfg.arduino.serialDelay);
});
} else {
light.display(rgb);
light.set(rgb, function () {
setTimeout(function () {
cam.move(res);
}, mcopy.cfg.arduino.serialDelay);
}, cfg.arduino.serialDelay);
});
}
};
@ -111,16 +111,16 @@ cmd.black_forward = function (callback) {
light.set(off, function () {
setTimeout( function () {
cam.move(res);
}, mcopy.cfg.arduino.serialDelay);
}, cfg.arduino.serialDelay);
});
}, mcopy.cfg.arduino.serialDelay);
}, cfg.arduino.serialDelay);
});
} else {
light.display(off);
light.set(off, function () {
setTimeout(function () {
cam.move(res);
}, mcopy.cfg.arduino.serialDelay);
}, cfg.arduino.serialDelay);
});
}
};
@ -149,7 +149,7 @@ cmd.camera_backward = function (rgb, callback) {
light.set(rgb, function () {
cam.move(res);
});
}, mcopy.cfg.arduino.serialDelay);
}, cfg.arduino.serialDelay);
});
} else {
setTimeout(function () {
@ -157,7 +157,7 @@ cmd.camera_backward = function (rgb, callback) {
light.set(rgb, function () {
cam.move(res);
});
}, mcopy.cfg.arduino.serialDelay);
}, cfg.arduino.serialDelay);
}
};
/**
@ -181,7 +181,7 @@ cmd.black_backward = function (callback) {
light.set(off, function () {
cam.move(res);
});
}, mcopy.cfg.arduino.serialDelay);
}, cfg.arduino.serialDelay);
});
} else {
setTimeout(function () {
@ -189,7 +189,7 @@ cmd.black_backward = function (callback) {
light.set(off, function () {
cam.move(res);
});
}, mcopy.cfg.arduino.serialDelay);
}, cfg.arduino.serialDelay);
}
};

View File

@ -9,14 +9,14 @@ devices.init = function () {
};
devices.profiles = function () {
'use strict';
const keys = Object.keys(mcopy.cfg.profiles);
const keys = Object.keys(cfg.profiles);
const elem = $('#profile')
let opt;
elem.empty();
for (let key of keys) {
opt = $('<option>');
opt.val(key);
opt.text(mcopy.cfg.profiles[key].label);
opt.text(cfg.profiles[key].label);
elem.append(opt);
}
elem.on('change', (t) => {
@ -26,10 +26,10 @@ devices.profiles = function () {
devices.profile = function (profile) {
'use strict';
log.info(`Changed configuration profile to "${profile}"`, 'DEVICES', true, true);
const p = mcopy.cfg.profiles[profile];
const p = cfg.profiles[profile];
const keys = Object.keys(p);
for (let key of keys) {
mcopy.cfg[key] = keys[key]
cfg[key] = keys[key]
}
if (typeof p.light !== 'undefined' && p.light === false) {
light.disable();
@ -83,7 +83,7 @@ devices.ready = function (event, arg) {
if (arg && arg.profile) {
$('#profile').val(arg.profile)
log.info(`Using configuration profile "${arg.profile}"`, 'DEVICES', true, true);
p = mcopy.cfg.profiles[arg.profile];
p = cfg.profiles[arg.profile];
if (typeof p.light !== 'undefined' && p.light === false) {
light.disable();
} else {

View File

@ -49,13 +49,13 @@ grid.refresh = function () {
const cmds = ['cam_forward', 'proj_forward', 'cam_backward', 'proj_backward', 'light_set', 'numbers'];
const check = '<input type="checkbox" x="xxxx" />';
const div = '<div x="xxxx"></div>';
const width = 970 - 34 + ((940 / 24) * Math.abs(24 - mcopy.state.sequence.size));
const width = 970 - 34 + ((940 / 24) * Math.abs(24 - seq.size));
let elem;
$('#sequence').width(`${width}px`);
for (let i = 0; i < cmds.length; i++) {
$('#' + cmds[i]).empty();
for (let x = 0; x < mcopy.state.sequence.size; x++) {
for (let x = 0; x < seq.size; x++) {
if (i === cmds.length - 1) {
elem = div.replace('xxxx', x);
$('#' + cmds[i]).append($(elem).text(x));
@ -109,26 +109,14 @@ grid.clear = function () {
console.log('Sequencer cleared');
}
};
/**
* Function bound to the change event on the loop counter
* input element
*
* @param {object} t This, passed from changed element
*/
grid.loopChange = function (t) {
'use strict';
const count = parseInt(t.value);
mcopy.loop = count;
seq.stats();
};
/**
* Add 24 frames to the sequence in the GUI
**/
grid.plus_24 = function () {
'use strict';
mcopy.state.sequence.size += 24;
seq.size += 24;
grid.refresh();
console.log(`Sequencer expanded to ${mcopy.state.sequence.size} steps`);
console.log(`Sequencer expanded to ${seq.size} steps`);
};
/**
* Set the light value at a specific step and then update

View File

@ -48,12 +48,12 @@ mse.mscript.fromSequence = function () {
return `${line.cmd} ${line.num}`
})
if (mcopy.loop > 1) {
if (seq.loop > 1) {
tmp.map(line => {
return ` ${line}`;
})
tmp.reverse();
tmp.push(`LOOP ${mcopy.loop}`);
tmp.push(`LOOP ${seq.loop}`);
tmp.reverse();
tmp.push('END');
}

View File

@ -47,11 +47,11 @@ proj.move = function (callback) {
};
proj.end = function (c, id, ms) {
'use strict';
if (c === mcopy.cfg.arduino.cmd.projector_forward) {
if (c === cfg.arduino.cmd.projector_forward) {
mcopy.state.projector.direction = true;
} else if (c === mcopy.cfg.arduino.cmd.projector_backward) {
} else if (c === cfg.arduino.cmd.projector_backward) {
mcopy.state.projector.direction = false;
} else if (c === mcopy.cfg.arduino.cmd.projector) {
} else if (c === cfg.arduino.cmd.projector) {
if (mcopy.state.projector.direction) {
mcopy.state.projector.pos += 1;
} else {

View File

@ -1,44 +1,12 @@
const seq = {};
seq.id = 'sequence';
seq.arr = [];
seq.loops = 1;
seq.size = 24;
/******
Sequence Object
*******/
seq.i = 0;
seq.time = 0;
seq.stopState = false;
mcopy.loop = 1;
mcopy.loopCount = 0;
seq.cmd = {
camera_forward : 'CF',
camera_backward : 'CB',
projector_forward : 'PF',
projector_backward : 'PB',
black_forward : 'BF',
black_backward : 'BB',
//dual commands
camera_second_forward : 'C2F',
camera_second_backward : 'C2B',
cameras_forward : 'CCF',
cameras_forward : 'CCB',
camera_forward_camera_second_backward : 'CFCB',
camera_backward_camera_second_forward : 'CBCF',
projector_second_forward : 'P2F',
projector_second_backward : 'P2B',
projectors_forward : 'PPF',
projectors_backward : 'PPB',
projector_forward_projector_second_backward : 'PFPB',
projector_backward_projector_second_forward : 'PBPF'
}
/*seq.run = function () {
'use strict';
@ -49,7 +17,7 @@ seq.cmd = {
setTimeout(function () {
seq.i++;
seq.run();
}, mcopy.cfg.arduino.sequenceDelay);
}, cfg.arduino.sequenceDelay);
}
if (seq.i == 0) {
$('#loop_current').text(gui.fmtZero(mcopy.loopCount + 1, 6));
@ -69,19 +37,19 @@ seq.cmd = {
$('#numbers div').removeClass('h');
$('.row input[x=' + seq.i + ']').addClass('h');
$('#numbers div[x=' + seq.i + ']').addClass('h');
if (c === seq.cmd.camera_forward){
if (c === cfg.cmd.camera_forward){
rgb = mcopy.state.sequence.light[seq.i].split(',');
cmd.camera_forward(rgb, action);
} else if (c === seq.cmd.camera_backward) {
} else if (c === cfg.cmd.camera_backward) {
rgb = mcopy.state.sequence.light[seq.i].split(',');
cmd.camera_backward(rgb, action);
} else if (c === seq.cmd.projector_forward) {
} else if (c === cfg.cmd.projector_forward) {
cmd.projector_forward(action);
} else if (c === seq.cmd.projector_backward) {
} else if (c === cfg.cmd.projector_backward) {
cmd.projector_backward(action);
} else if (c === seq.cmd.black_forward) {
} else if (c === cfg.cmd.black_forward) {
cmd.black_forward(action);
} else if (c === seq.cmd.black_backward) {
} else if (c === cfg.cmd.black_backward) {
cmd.black_backward(action);
}
} else {
@ -144,57 +112,93 @@ seq.init = function (start) {
ipcRenderer.send('seq', { action : 'start' });
//seq.run();
};
seq.set = function (x, cmd) {
let increase = 0;
if (x >= seq.arr.length + 1) {
increase = x - seq.arr.length;
for (let i = 0; i < increase; i++) {
seq.arr.push({});
}
}
if (!seq.arr[x]) seq.arr[x] = {};
seq.arr[x].x = x;
seq.arr[x].cmd = cmd;
if (cmd.indexOf('C') !== -1) {
seq.arr[x].light = light.color;
} else {
if (seq.arr[x].light) {
delete seq.arr[x].light;
}
}
//set
ipcRenderer.send(seq.id, { set : [ seq.arr[x] ] });
//update grid?
}
/**
* Function bound to the change event on the loop counter
* input element
*
* @param {integer} count Integer to set loops to
*/
seq.setLoops = function (count) {
'use strict';
seq.loops = count;
seq.stats();
ipcRenderer.send(seq.id, { loops : seq.count })
};
seq.stats = function () {
'use strict';
var ms = 0,
c = '',
cam_total = 0,
proj_total = 0,
real_total = mcopy.state.sequence.arr.filter(function (elem) {
if (elem === undefined) {
return false;
}
return true;
});
let ms = 0;
let c = '';
let cam_total = 0;
let proj_total = 0;
let real_total = mcopy.state.sequence.arr.filter(function (elem) {
if (elem === undefined) {
return false;
}
return true;
});
//timing
for (var i = 0; i < mcopy.state.sequence.arr.length; i++) {
c = mcopy.state.sequence.arr[i];
if (c === seq.cmd.camera_forward || c === seq.cmd.camera_backward){
ms += mcopy.cfg.arduino.cam.time;
ms += mcopy.cfg.arduino.cam.delay;
ms += mcopy.cfg.arduino.serialDelay;
for (let c of mcopy.state.sequence.arr) {
if (c === cfg.cmd.camera_forward || c === cfg.cmd.camera_backward){
ms += cfg.arduino.cam.time;
ms += cfg.arduino.cam.delay;
ms += cfg.arduino.serialDelay;
}
if (c === seq.cmd.projector_forward || c === seq.cmd.projector_backward){
ms += mcopy.cfg.arduino.proj.time;
ms += mcopy.cfg.arduino.proj.delay;
ms += mcopy.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 === seq.cmd.black_forward || c === seq.cmd.black_backward){
ms += mcopy.cfg.arduino.black.before;
ms += mcopy.cfg.arduino.black.after;
ms += mcopy.cfg.arduino.cam.time;
ms += mcopy.cfg.arduino.cam.delay;
ms += mcopy.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 += mcopy.cfg.arduino.sequenceDelay;
ms += cfg.arduino.sequenceDelay;
if (c === seq.cmd.camera_forward || c === seq.cmd.black_forward) {
if (c === cfg.cmd.camera_forward || c === cfg.cmd.black_forward) {
cam_total++;
}
if (c === seq.cmd.camera_backward || c === seq.cmd.black_backward) {
if (c === cfg.cmd.camera_backward || c === cfg.cmd.black_backward) {
cam_total--;
}
if (c === seq.cmd.projector_forward) {
if (c === cfg.cmd.projector_forward) {
proj_total++;
}
if (c === seq.cmd.projector_backward) {
if (c === cfg.cmd.projector_backward) {
proj_total--;
}
}
//timing
ms = ms * mcopy.loop;
ms = ms * seq.loops;
if (ms < 2000) {
$('#seq_stats .timing span').text(ms + 'ms');
} else {
@ -202,20 +206,20 @@ seq.stats = function () {
}
//ending frames
cam_total = cam_total * mcopy.loop;
proj_total = proj_total * mcopy.loop;
cam_total = cam_total * seq.loops;
proj_total = proj_total * seq.loops;
$('#seq_stats .cam_end span').text(gui.fmtZero(mcopy.state.camera.pos + cam_total, 6));
$('#seq_stats .proj_end span').text(gui.fmtZero(mcopy.state.projector.pos + proj_total, 6));
//count
$('#seq_stats .seq_count span').text(real_total.length * mcopy.loop);
$('#seq_stats .seq_count span').text(real_total.length * seq.loops);
return ms;
};
seq.clear = function () {
'use strict';
mcopy.state.sequence.size = 24;
mcopy.state.sequence.arr = [];
seq.size = 24;
seq.arr = [];
};
/**
@ -283,21 +287,21 @@ seq.step = function () {
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 === seq.cmd.camera_forward){
if (c === cfg.cmd.camera_forward){
cmd.camera_forward(rgb, seq.step);
} else if (c === seq.cmd.camera_backward) {
} else if (c === cfg.cmd.camera_backward) {
cmd.camera_backward(rgb, seq.step);
} else if (c === seq.cmd.projector_forward) {
} else if (c === cfg.cmd.projector_forward) {
cmd.projector_forward(seq.step);
} else if (c === seq.cmd.projector_backward) {
} else if (c === cfg.cmd.projector_backward) {
cmd.projector_backward(seq.step);
} else if (c === seq.cmd.black_forward) {
} else if (c === cfg.cmd.black_forward) {
cmd.black_forward(seq.step);
} else if (c === seq.cmd.black_backward) {
} else if (c === cfg.cmd.black_backward) {
cmd.black_backward(seq.step);
}
}
}, mcopy.cfg.arduino.sequenceDelay);
}, cfg.arduino.sequenceDelay);
};
module.exports = seq;

View File

@ -42,6 +42,7 @@ let light;
let dig;
let dev;
let cmd;
let seq;
const cfg = require('./data/cfg.json')
@ -68,7 +69,7 @@ var createWindow = function () {
})
}
const seq = {};
/*const seq = {};
seq.init = function () {
seq.listen();
}
@ -81,7 +82,7 @@ seq.listen = function () {
display.open()
}
})
}
}*/
var init = async function () {
@ -98,9 +99,6 @@ var init = async function () {
await settings.restore()
//dev.init()
seq.init()
display = require('display')(SYSTEM)
ffmpeg = require('ffmpeg')(SYSTEM)
ffprobe = require('ffprobe')(SYSTEM)
@ -109,6 +107,7 @@ var init = async function () {
dev = require('devices')(arduino, settings, mainWindow, cam)
//why is delay happening still?
await delay(2000)
try {
@ -125,11 +124,7 @@ var init = async function () {
proj = require('proj')(arduino, cfg, mainWindow.webContents, dig)
cmd = require('cmd')(cfg, proj, cam, light);
//console.dir(dev.state)
//cmd
//seq
seq = require('sequencer')(cfg, cmd);
}
app.on('ready', init)

3
app/package-lock.json generated
View File

@ -6256,6 +6256,9 @@
"resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz",
"integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg=="
},
"sequencer": {
"version": "file:lib/sequencer"
},
"sequencify": {
"version": "0.0.7",
"resolved": "https://registry.npmjs.org/sequencify/-/sequencify-0.0.7.tgz",

View File

@ -61,6 +61,7 @@
"mscript": "file:lib/mscript",
"node-notifier": "^5.3.0",
"proj": "file:lib/proj",
"sequencer": "file:lib/sequencer",
"serialport": "^7.0.2",
"server": "file:lib/server",
"settings": "file:lib/settings",

View File

@ -1,5 +1,4 @@
const mcopy = {};
mcopy.cfg = require('./data/cfg.json');
const { remote, ipcRenderer } = require('electron');
const dialog = require('electron').remote.dialog;

View File

@ -169,12 +169,12 @@ class Commands {
proj.set2(true, function (ms) {
setTimeout(function () {
proj.move2(res);
}, mcopy.cfg.arduino.serialDelay);
}, this.cfg.arduino.serialDelay);
});
} else {
setTimeout(function () {
proj.move2(res);
}, mcopy.cfg.arduino.serialDelay);
}, this.cfg.arduino.serialDelay);
}
};
cmd.projector_second_backward = function (callback) {};

View File

@ -1 +0,0 @@
{"version":3,"file":"index.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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,GAAG,GAAG,IAAI,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAC9B,CAAC,CAAA"}

View File

@ -2,11 +2,12 @@
Object.defineProperty(exports, "__esModule", { value: true });
const Log = require("log");
let seq;
class Sequence {
class Sequencer {
constructor(cfg, cmd) {
this.arr = [];
this.loops = 1;
this.CMDS = {};
this.id = 'sequence';
this.cfg = cfg;
this.cmd = cmd;
this.cmds(cfg.cmd);
@ -21,23 +22,25 @@ class Sequence {
}
//currently called by ui
async init() {
this.log = Log({ label: 'sequence' });
this.log = Log({ label: this.id });
this.ipc = require('electron').ipcMain;
this.listen();
}
listen() {
this.ipc.on('sequence', this.listener.bind(this));
this.ipc.on(this.id, this.listener.bind(this));
}
async listener(event, arg) {
if (arg && arg.diff) {
this.diff(arg.diff);
console.dir(arg);
if (arg && arg.set) {
this.setSteps(arg.set);
}
else if (arg && arg.loops) {
this.loops = arg.loops;
}
event.returnValue = true;
}
diff(steps) {
setSteps(steps) {
console.dir(steps);
}
//new
async start(arg) {
@ -80,6 +83,6 @@ class Sequence {
}
}
module.exports = function (cfg, cmd) {
seq = new Sequence(cfg, cmd);
return new Sequencer(cfg, cmd);
};
//# sourceMappingURL=index.js.map

View File

@ -0,0 +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;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O,GAAG,UAAU,GAAS,EAAE,GAAS;IAC9C,OAAO,IAAI,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAChC,CAAC,CAAA"}

View File

@ -1,5 +1,5 @@
{
"name": "sequence",
"name": "sequencer",
"version": "1.0.0",
"description": "",
"main": "index.js",

View File

@ -169,12 +169,12 @@ class Commands {
proj.set2(true, function (ms) {
setTimeout(function () {
proj.move2(res);
}, mcopy.cfg.arduino.serialDelay);
}, this.cfg.arduino.serialDelay);
});
} else {
setTimeout(function () {
proj.move2(res);
}, mcopy.cfg.arduino.serialDelay);
}, this.cfg.arduino.serialDelay);
}
};
cmd.projector_second_backward = function (callback) {};

View File

@ -1 +0,0 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sequence/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,2BAA4B;AAE5B,IAAI,GAAc,CAAC;AAEnB,MAAM,QAAQ;IAab,YAAa,GAAS,EAAE,GAAS;QATzB,QAAG,GAAW,EAAE,CAAC;QACjB,UAAK,GAAY,CAAC,CAAC;QAInB,SAAI,GAAS,EAAE,CAAC;QAKvB,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,EAA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AC;IACD,KAAK;IACE,KAAK;IAEZ,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,GAAG,GAAG,IAAI,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAC9B,CAAC,CAAA"}

View File

@ -2,11 +2,12 @@
Object.defineProperty(exports, "__esModule", { value: true });
const Log = require("log");
let seq;
class Sequence {
class Sequencer {
constructor(cfg, cmd) {
this.arr = [];
this.loops = 1;
this.CMDS = {};
this.id = 'sequence';
this.cfg = cfg;
this.cmd = cmd;
this.cmds(cfg.cmd);
@ -21,23 +22,25 @@ class Sequence {
}
//currently called by ui
async init() {
this.log = Log({ label: 'sequence' });
this.log = Log({ label: this.id });
this.ipc = require('electron').ipcMain;
this.listen();
}
listen() {
this.ipc.on('sequence', this.listener.bind(this));
this.ipc.on(this.id, this.listener.bind(this));
}
async listener(event, arg) {
if (arg && arg.diff) {
this.diff(arg.diff);
console.dir(arg);
if (arg && arg.set) {
this.setSteps(arg.set);
}
else if (arg && arg.loops) {
this.loops = arg.loops;
}
event.returnValue = true;
}
diff(steps) {
setSteps(steps) {
console.dir(steps);
}
//new
async start(arg) {
@ -80,6 +83,6 @@ class Sequence {
}
}
module.exports = function (cfg, cmd) {
seq = new Sequence(cfg, cmd);
return new Sequencer(cfg, cmd);
};
//# sourceMappingURL=index.js.map

View File

@ -0,0 +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,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C;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"}

View File

@ -1,5 +1,5 @@
{
"name": "sequence",
"name": "sequencer",
"version": "1.0.0",
"description": "",
"main": "index.js",

View File

@ -174,12 +174,12 @@ class Commands {
proj.set2(true, function (ms) {
setTimeout(function () {
proj.move2(res);
}, mcopy.cfg.arduino.serialDelay);
}, this.cfg.arduino.serialDelay);
});
} else {
setTimeout(function () {
proj.move2(res);
}, mcopy.cfg.arduino.serialDelay);
}, this.cfg.arduino.serialDelay);
}
};
cmd.projector_second_backward = function (callback) {};

View File

@ -2,9 +2,9 @@
import Log = require('log');
let seq : Sequence;
let seq : Sequencer;
class Sequence {
class Sequencer {
private time : number;
private running : boolean;
@ -16,6 +16,7 @@ class Sequence {
private CMDS : any = {};
private ipc : any;
private log : any;
private id : string = 'sequence';
constructor (cfg : any, cmd : any) {
this.cfg = cfg;
@ -34,26 +35,27 @@ class Sequence {
//currently called by ui
private async init () {
this.log = Log({ label : 'sequence' })
this.log = Log({ label : this.id })
this.ipc = require('electron').ipcMain;
this.listen();
}
private listen () {
this.ipc.on('sequence', this.listener.bind(this));
this.ipc.on(this.id, this.listener.bind(this));
}
private async listener (event : any, arg : any) {
if (arg && arg.diff) {
this.diff(arg.diff);
console.dir(arg)
if (arg && arg.set) {
this.setSteps(arg.set);
} else if (arg && arg.loops) {
this.loops = arg.loops;
}
event.returnValue = true;
}
private diff (steps : any[]) {
public setSteps (steps : any) {
console.dir(steps)
}
//new
public async start (arg : any) {
@ -102,5 +104,5 @@ class Sequence {
}
module.exports = function (cfg : any, cmd : any) {
seq = new Sequence(cfg, cmd);
return new Sequencer(cfg, cmd);
}