diff --git a/app/index.html b/app/index.html index 081e111..a4fca49 100644 --- a/app/index.html +++ b/app/index.html @@ -60,7 +60,7 @@

LOOPS

- +
diff --git a/app/js/app.js b/app/js/app.js index f12e8b5..d6e3ab3 100644 --- a/app/js/app.js +++ b/app/js/app.js @@ -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',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>1)+"px"})}for(var i,k=0,l=(f.lines-1)*(1-f.direction)/2;k - -## 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 - - -### sequence.stop() -Stop the sequence - -**Kind**: instance method of [Sequence](#Sequence) diff --git a/app/lib/sequence/index.js.map b/app/lib/sequence/index.js.map deleted file mode 100644 index b9d169d..0000000 --- a/app/lib/sequence/index.js.map +++ /dev/null @@ -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,EAAG,UAAU,EAAE,CAAC,CAAA;QACtC,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,UAAU,C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C,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"} \ No newline at end of file diff --git a/app/lib/sequencer/Readme.md b/app/lib/sequencer/Readme.md new file mode 100644 index 0000000..e69de29 diff --git a/cli/lib/sequence/index.js b/app/lib/sequencer/index.js similarity index 82% rename from cli/lib/sequence/index.js rename to app/lib/sequencer/index.js index b487c16..cd8c483 100644 --- a/cli/lib/sequence/index.js +++ b/app/lib/sequencer/index.js @@ -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 \ No newline at end of file diff --git a/app/lib/sequencer/index.js.map b/app/lib/sequencer/index.js.map new file mode 100644 index 0000000..e8fcdce --- /dev/null +++ b/app/lib/sequencer/index.js.map @@ -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,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AAI,IAAI,CAAC,OAAO,EAAE;oBACjB,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;iBACnB;aACD;SACD;IACF,CAAC;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,OAAO,IAAI,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAChC,CAAC,CAAA"} \ No newline at end of file diff --git a/cli/lib/sequence/package.json b/app/lib/sequencer/package.json similarity index 88% rename from cli/lib/sequence/package.json rename to app/lib/sequencer/package.json index 6687419..6fb32b0 100644 --- a/cli/lib/sequence/package.json +++ b/app/lib/sequencer/package.json @@ -1,5 +1,5 @@ { - "name": "sequence", + "name": "sequencer", "version": "1.0.0", "description": "", "main": "index.js", diff --git a/app/lib/ui/cam.js b/app/lib/ui/cam.js index 5184229..e9c4ced 100644 --- a/app/lib/ui/cam.js +++ b/app/lib/ui/cam.js @@ -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 { diff --git a/app/lib/ui/cmd.js b/app/lib/ui/cmd.js index 3d1469d..c215bb7 100644 --- a/app/lib/ui/cmd.js +++ b/app/lib/ui/cmd.js @@ -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); } }; diff --git a/app/lib/ui/devices.js b/app/lib/ui/devices.js index b5da7cc..414694c 100644 --- a/app/lib/ui/devices.js +++ b/app/lib/ui/devices.js @@ -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 = $('