From 600a0abc723b79d6e4b13e4c5f3a03a90fd61aff Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Thu, 21 Mar 2019 19:33:01 -0400 Subject: [PATCH] Create and install main process lib to control the cmd.js module --- app/lib/cmd/index.js | 258 +++++++++++++++++++++++++++++++++++++ app/lib/cmd/index.js.map | 1 + app/lib/cmd/package.json | 11 ++ app/package-lock.json | 93 +++++++------- app/package.json | 1 + cli/lib/cmd/index.js | 258 +++++++++++++++++++++++++++++++++++++ cli/lib/cmd/index.js.map | 1 + cli/lib/cmd/package.json | 11 ++ lib/cmd/index.js | 258 +++++++++++++++++++++++++++++++++++++ lib/cmd/index.js.map | 1 + lib/cmd/package.json | 11 ++ src/cmd/index.ts | 267 +++++++++++++++++++++++++++++++++++++++ 12 files changed, 1126 insertions(+), 45 deletions(-) create mode 100644 app/lib/cmd/index.js create mode 100644 app/lib/cmd/index.js.map create mode 100644 app/lib/cmd/package.json create mode 100644 cli/lib/cmd/index.js create mode 100644 cli/lib/cmd/index.js.map create mode 100644 cli/lib/cmd/package.json create mode 100644 lib/cmd/index.js create mode 100644 lib/cmd/index.js.map create mode 100644 lib/cmd/package.json create mode 100644 src/cmd/index.ts diff --git a/app/lib/cmd/index.js b/app/lib/cmd/index.js new file mode 100644 index 0000000..9aea590 --- /dev/null +++ b/app/lib/cmd/index.js @@ -0,0 +1,258 @@ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +const delay = require("delay"); +class Commands { + constructor(cfg, proj, cam, light) { + this.cfg = cfg; + this.proj = proj; + this.cam = cam; + this.light = light; + this.ipc = require('electron').ipcMain; + } + /** + * Move the projector one frame forward + **/ + async proj_forward() { + let ms; + try { + if (!this.proj.state.dir) { + await delay(this.cfg.arduino.serialDelay); + await this.proj.set(true); + } + await delay(this.cfg.arduino.serialDelay); + ms = await this.proj.move(); + } + catch (err) { + throw err; + } + return ms; + } + /** + * Move the projector one frame backward + **/ + async proj_backward() { + let ms; + try { + if (this.proj.state.dir) { + await delay(this.cfg.arduino.serialDelay); + await this.proj.set(false); + } + await delay(this.cfg.arduino.serialDelay); + ms = await this.proj.move(); + } + catch (err) { + throw err; + } + return ms; + } + /** + * Move the camera one frame forward + * + * @param {array} rgb Color to set light for frame + **/ + async cam_forward(rgb = [255, 255, 255]) { + const off = [0, 0, 0]; + let ms; + try { + if (!this.cam.state.dir) { + await delay(this.cfg.arduino.serialDelay); + await this.cam.set(true); + } + await delay(this.cfg.arduino.serialDelay); + await this.light.set(rgb); + await delay(this.cfg.arduino.serialDelay); + ms = await this.cam.move(); + await delay(this.cfg.arduino.serialDelay); + await this.light.set(off); + } + catch (err) { + throw err; + } + return ms; + } + /** + * Move the camera one frame forwardwith light off + **/ + async black_forward() { + const off = [0, 0, 0]; + let ms; + try { + if (!this.cam.state.dir) { + await delay(this.cfg.arduino.serialDelay); + await this.cam.set(true); + } + await delay(this.cfg.arduino.serialDelay); + await this.light.set(off); //make sure set to off + await delay(this.cfg.arduino.serialDelay); + ms = await this.cam.move(); + await delay(this.cfg.arduino.serialDelay); + await this.light.set(off); + } + catch (err) { + throw err; + } + return ms; + } + /** + * Move the camera one frame backward + * + * @param {array} rgb Color to set light for frame + **/ + async cam_backward(rgb = [255, 255, 255]) { + const off = [0, 0, 0]; + let ms; + try { + if (this.cam.state.dir) { + await delay(this.cfg.arduino.serialDelay); + await this.cam.set(false); + } + await delay(this.cfg.arduino.serialDelay); + await this.light.set(rgb); + await delay(this.cfg.arduino.serialDelay); + ms = await this.cam.move(); + await delay(this.cfg.arduino.serialDelay); + await this.light.set(off); + } + catch (err) { + throw err; + } + return ms; + } + /** + * Move the camera one frame forward, light set to black or off + * + **/ + async black_backward() { + const off = [0, 0, 0]; + let ms; + try { + if (this.cam.state.dir) { + await delay(this.cfg.arduino.serialDelay); + await this.cam.set(false); + } + await delay(this.cfg.arduino.serialDelay); + await this.light.set(off); //make sure set to off + await delay(this.cfg.arduino.serialDelay); + ms = await this.cam.move(); + await delay(this.cfg.arduino.serialDelay); + await this.light.set(off); + } + catch (err) { + throw err; + } + return ms; + } + /* + cam2_forward : 'C2F', + cam2_backward : 'C2B', + + cams_forward : 'CCF', + cams_forward : 'CCB', + + cam_forward_cam2_backward : 'CFCB', + cam_backward_cam2_forward : 'CBCF', + */ + /** + * Move the secondary projector forward one frame + * + * @param {function} callback Function to call after action + **/ + /*cmd.proj2_forward = function (callback) { + 'use strict'; + var res = function (ms) { + $('#cmd_proj2_forward').removeClass('active'); + gui.updateState(); + if (callback) { callback(ms); } + }; + $('#cmd_proj2_forward').addClass('active'); + if (!mcopy.state.projector2.direction) { + proj.set2(true, function (ms) { + setTimeout(function () { + proj.move2(res); + }, mcopy.cfg.arduino.serialDelay); + }); + } else { + setTimeout(function () { + proj.move2(res); + }, mcopy.cfg.arduino.serialDelay); + } + }; + cmd.proj2_backward = function (callback) {}; + + cmd.projs_forward = function (callback) {}; + cmd.projs_backward = function (callback) {}; + + cmd.proj_forward_proj2_backward = function (callback) {}; + cmd.proj_backward_proj2_forward = function (callback) {}; + */ + /** + * Move the camera to a specific frame. Accepts the input with the "move_cam_to" + * value. Moves as black frames to prevent multiple exposure. + * + **/ + async cam_to() { + /*const raw = $('#move_cam_to').val(); + const val = parseInt(raw); + let proceed = false; + let total; + let steps = []; + let c; + let cont; + if (val !== mcopy.state.camera.pos) { + if (val < mcopy.state.camera.pos) { + total = -(mcopy.state.camera.pos - val) + } else if (val > mcopy.state.camera.pos) { + total = val - mcopy.state.camera.pos + } + if (total > 0) { + c = 'BF'; + } else if (total < 0) { + c = 'BB'; + } + for (let i = 0; i < Math.abs(total); i++) { + steps.push({ cmd : c }) + } + cont = confirm(`Do you want to ${(total > 0 ? 'advance' : 'rewind')} the camera ${total} frame${(total === 1 ? '' : 's')} to frame ${val}?`) + if (cont) { + seq.exec(steps); + } + }*/ + } + /** + * Move the projector to a specific frame. Accepts the input with the "move_proj_to" + * value. + * + **/ + async proj_to() { + /*const raw = $('#move_proj_to').val(); + const val = parseInt(raw); + let proceed = false; + let total; + let steps = []; + let c; + let cont + if (val !== mcopy.state.projector.pos) { + if (val < mcopy.state.projector.pos) { + total = -(mcopy.state.projector.pos - val) + } else if (val > mcopy.state.projector.pos) { + total = val - mcopy.state.projector.pos + } + if (total > 0) { + c = 'PF'; + } else if (total < 0) { + c = 'PB'; + } + for (let i = 0; i < Math.abs(total); i++) { + steps.push({ cmd : c }) + } + cont = confirm(`Do you want to ${(total > 0 ? 'advance' : 'rewind')} the projector ${total} frame${(total === 1 ? '' : 's')} to frame ${val}?`) + if (cont) { + seq.exec(steps); + } + }*/ + } +} +module.exports = function (cfg, proj, cam, light) { + return new Commands(cfg, proj, cam, light); +}; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/app/lib/cmd/index.js.map b/app/lib/cmd/index.js.map new file mode 100644 index 0000000..54e6d13 --- /dev/null +++ b/app/lib/cmd/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cmd/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,+BAAgC;AAEhC,MAAM,QAAQ;IAQb,YAAa,GAAS,EAAE,IAAU,EAAE,GAAS,EAAE,KAAW;QACzD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QAEnB,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;IACxC,CAAC;IAED;;QAEI;IACG,KAAK,CAAC,YAAY;QACxB,IAAI,EAAW,CAAC;QAChB,IAAI;YACH,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE;gBACzB,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;gBAC1C,MAAM,IAAI,CAAC,IAAI,CAAC,GA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5C,CAAC,CAAA"} \ No newline at end of file diff --git a/app/lib/cmd/package.json b/app/lib/cmd/package.json new file mode 100644 index 0000000..c8b0f10 --- /dev/null +++ b/app/lib/cmd/package.json @@ -0,0 +1,11 @@ +{ + "name": "cmd", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC" +} diff --git a/app/package-lock.json b/app/package-lock.json index 1d8e7b1..e7e0de3 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -321,7 +321,7 @@ }, "string_decoder": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "requires": { "safe-buffer": "~5.1.0" @@ -616,7 +616,7 @@ }, "bl": { "version": "1.2.2", - "resolved": "http://registry.npmjs.org/bl/-/bl-1.2.2.tgz", + "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.2.tgz", "integrity": "sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==", "requires": { "readable-stream": "^2.3.5", @@ -826,7 +826,7 @@ }, "camelcase-keys": { "version": "2.1.0", - "resolved": "http://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", + "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=", "dev": true, "requires": { @@ -1008,7 +1008,7 @@ }, "string_decoder": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { @@ -1017,6 +1017,9 @@ } } }, + "cmd": { + "version": "file:lib/cmd" + }, "code-point-at": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", @@ -1207,7 +1210,7 @@ }, "string_decoder": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { @@ -2078,7 +2081,7 @@ }, "enabled": { "version": "1.0.2", - "resolved": "http://registry.npmjs.org/enabled/-/enabled-1.0.2.tgz", + "resolved": "https://registry.npmjs.org/enabled/-/enabled-1.0.2.tgz", "integrity": "sha1-ll9lE9LC0cX0ZStkouM5ZGf8L5M=", "requires": { "env-variable": "0.0.x" @@ -2431,7 +2434,7 @@ }, "fecha": { "version": "2.3.3", - "resolved": "http://registry.npmjs.org/fecha/-/fecha-2.3.3.tgz", + "resolved": "https://registry.npmjs.org/fecha/-/fecha-2.3.3.tgz", "integrity": "sha512-lUGBnIamTAwk4znq5BcqsDaxSmZ9nDVJaij6NvRt/Tg4R69gERA+otPKbS86ROw9nxVMw2/mp1fnaiWqbs6Sdg==" }, "ffmpeg": { @@ -2903,7 +2906,7 @@ }, "load-json-file": { "version": "2.0.0", - "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", "dev": true, "requires": { @@ -3078,7 +3081,7 @@ }, "readable-stream": { "version": "1.0.34", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "dev": true, "requires": { @@ -3090,7 +3093,7 @@ }, "through2": { "version": "0.6.5", - "resolved": "http://registry.npmjs.org/through2/-/through2-0.6.5.tgz", + "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", "dev": true, "requires": { @@ -3102,7 +3105,7 @@ }, "glob-watcher": { "version": "0.0.6", - "resolved": "http://registry.npmjs.org/glob-watcher/-/glob-watcher-0.0.6.tgz", + "resolved": "https://registry.npmjs.org/glob-watcher/-/glob-watcher-0.0.6.tgz", "integrity": "sha1-uVtKjfdLOcgymLDAXJeLTZo7cQs=", "dev": true, "requires": { @@ -3166,7 +3169,7 @@ }, "graceful-fs": { "version": "1.2.3", - "resolved": "http://registry.npmjs.org/graceful-fs/-/graceful-fs-1.2.3.tgz", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-1.2.3.tgz", "integrity": "sha1-FaSAaldUfLLS2/J/QuiajDRRs2Q=", "dev": true }, @@ -3178,7 +3181,7 @@ }, "lodash": { "version": "1.0.2", - "resolved": "http://registry.npmjs.org/lodash/-/lodash-1.0.2.tgz", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-1.0.2.tgz", "integrity": "sha1-j1dWDIO1n8JwvT1WG2kAQ0MOJVE=", "dev": true }, @@ -3221,7 +3224,7 @@ }, "gulp": { "version": "3.9.1", - "resolved": "http://registry.npmjs.org/gulp/-/gulp-3.9.1.tgz", + "resolved": "https://registry.npmjs.org/gulp/-/gulp-3.9.1.tgz", "integrity": "sha1-VxzkWSjdQK9lFPxAEYZgFsE4RbQ=", "dev": true, "requires": { @@ -3273,7 +3276,7 @@ }, "semver": { "version": "4.3.6", - "resolved": "http://registry.npmjs.org/semver/-/semver-4.3.6.tgz", + "resolved": "https://registry.npmjs.org/semver/-/semver-4.3.6.tgz", "integrity": "sha1-MAvG4OhjdPe6YQaLWx7NV/xlMto=", "dev": true }, @@ -3328,7 +3331,7 @@ }, "string_decoder": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { @@ -3385,7 +3388,7 @@ }, "string_decoder": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { @@ -3508,7 +3511,7 @@ }, "string_decoder": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { @@ -3835,7 +3838,7 @@ }, "is-builtin-module": { "version": "1.0.0", - "resolved": "http://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", "dev": true, "requires": { @@ -4163,7 +4166,7 @@ }, "jsonfile": { "version": "2.4.0", - "resolved": "http://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", "requires": { "graceful-fs": "^4.1.6" @@ -4286,7 +4289,7 @@ }, "load-json-file": { "version": "1.1.0", - "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", "dev": true, "requires": { @@ -4652,7 +4655,7 @@ }, "meow": { "version": "3.7.0", - "resolved": "http://registry.npmjs.org/meow/-/meow-3.7.0.tgz", + "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz", "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", "dev": true, "requires": { @@ -4793,7 +4796,7 @@ }, "mkdirp": { "version": "0.5.1", - "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "requires": { "minimist": "0.0.8" @@ -4822,7 +4825,7 @@ "dependencies": { "fs-extra": { "version": "0.26.7", - "resolved": "http://registry.npmjs.org/fs-extra/-/fs-extra-0.26.7.tgz", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.26.7.tgz", "integrity": "sha1-muH92UiXeY7at20JGM9C0MMYT6k=", "requires": { "graceful-fs": "^4.1.2", @@ -4973,7 +4976,7 @@ "dependencies": { "semver": { "version": "5.3.0", - "resolved": "http://registry.npmjs.org/semver/-/semver-5.3.0.tgz", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=", "dev": true }, @@ -5337,7 +5340,7 @@ }, "os-homedir": { "version": "1.0.2", - "resolved": "http://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=" }, "os-locale": { @@ -5353,7 +5356,7 @@ }, "os-tmpdir": { "version": "1.0.2", - "resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" }, "osenv": { @@ -5484,7 +5487,7 @@ }, "path-is-absolute": { "version": "1.0.1", - "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, "path-key": { @@ -5635,7 +5638,7 @@ }, "kind-of": { "version": "1.1.0", - "resolved": "http://registry.npmjs.org/kind-of/-/kind-of-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-1.1.0.tgz", "integrity": "sha1-FAo9LUGjbS78+pN3tiwk+ElaXEQ=", "dev": true } @@ -5679,7 +5682,7 @@ }, "pretty-bytes": { "version": "1.0.4", - "resolved": "http://registry.npmjs.org/pretty-bytes/-/pretty-bytes-1.0.4.tgz", + "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-1.0.4.tgz", "integrity": "sha1-CiLoIQYJrTVUL4yNXSFZr/B1HIQ=", "dev": true, "requires": { @@ -5689,7 +5692,7 @@ }, "pretty-hrtime": { "version": "1.0.3", - "resolved": "http://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz", + "resolved": "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz", "integrity": "sha1-t+PqQkNaTJsnWdmeDyAesZWALuE=", "dev": true }, @@ -5912,7 +5915,7 @@ "dependencies": { "array-back": { "version": "1.0.4", - "resolved": "http://registry.npmjs.org/array-back/-/array-back-1.0.4.tgz", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-1.0.4.tgz", "integrity": "sha1-ZEun8JX3/898Q7Xw3DnTwfA8Bjs=", "dev": true, "requires": { @@ -5954,7 +5957,7 @@ "dependencies": { "array-back": { "version": "1.0.4", - "resolved": "http://registry.npmjs.org/array-back/-/array-back-1.0.4.tgz", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-1.0.4.tgz", "integrity": "sha1-ZEun8JX3/898Q7Xw3DnTwfA8Bjs=", "dev": true, "requires": { @@ -6150,7 +6153,7 @@ }, "safe-regex": { "version": "1.1.0", - "resolved": "http://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", "dev": true, "requires": { @@ -6543,7 +6546,7 @@ "dependencies": { "array-back": { "version": "1.0.4", - "resolved": "http://registry.npmjs.org/array-back/-/array-back-1.0.4.tgz", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-1.0.4.tgz", "integrity": "sha1-ZEun8JX3/898Q7Xw3DnTwfA8Bjs=", "dev": true, "requires": { @@ -6694,7 +6697,7 @@ "dependencies": { "nan": { "version": "2.10.0", - "resolved": "http://registry.npmjs.org/nan/-/nan-2.10.0.tgz", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz", "integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==" } } @@ -6759,7 +6762,7 @@ "dependencies": { "array-back": { "version": "1.0.4", - "resolved": "http://registry.npmjs.org/array-back/-/array-back-1.0.4.tgz", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-1.0.4.tgz", "integrity": "sha1-ZEun8JX3/898Q7Xw3DnTwfA8Bjs=", "dev": true, "requires": { @@ -6791,7 +6794,7 @@ }, "string_decoder": { "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" }, "strip-ansi": { @@ -6813,7 +6816,7 @@ }, "strip-eof": { "version": "1.0.0", - "resolved": "http://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=" }, "strip-indent": { @@ -6971,7 +6974,7 @@ }, "string_decoder": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "requires": { "safe-buffer": "~5.1.0" @@ -7026,7 +7029,7 @@ }, "through2": { "version": "0.2.3", - "resolved": "http://registry.npmjs.org/through2/-/through2-0.2.3.tgz", + "resolved": "https://registry.npmjs.org/through2/-/through2-0.2.3.tgz", "integrity": "sha1-6zKE2k6jEbbMis42U3SKUqvyWj8=", "dev": true, "requires": { @@ -7513,7 +7516,7 @@ }, "graceful-fs": { "version": "3.0.11", - "resolved": "http://registry.npmjs.org/graceful-fs/-/graceful-fs-3.0.11.tgz", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-3.0.11.tgz", "integrity": "sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg=", "dev": true, "requires": { @@ -7522,7 +7525,7 @@ }, "readable-stream": { "version": "1.0.34", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "dev": true, "requires": { @@ -7544,7 +7547,7 @@ }, "through2": { "version": "0.6.5", - "resolved": "http://registry.npmjs.org/through2/-/through2-0.6.5.tgz", + "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", "dev": true, "requires": { @@ -7771,7 +7774,7 @@ }, "wrap-ansi": { "version": "2.1.0", - "resolved": "http://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", "requires": { "string-width": "^1.0.1", diff --git a/app/package.json b/app/package.json index f361dda..0fa005b 100644 --- a/app/package.json +++ b/app/package.json @@ -42,6 +42,7 @@ "arduino": "file:lib/arduino", "cam": "file:lib/cam", "capture": "file:lib/capture", + "cmd": "file:lib/cmd", "delay": "file:lib/delay", "devices": "file:lib/devices", "digital": "file:lib/digital", diff --git a/cli/lib/cmd/index.js b/cli/lib/cmd/index.js new file mode 100644 index 0000000..9aea590 --- /dev/null +++ b/cli/lib/cmd/index.js @@ -0,0 +1,258 @@ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +const delay = require("delay"); +class Commands { + constructor(cfg, proj, cam, light) { + this.cfg = cfg; + this.proj = proj; + this.cam = cam; + this.light = light; + this.ipc = require('electron').ipcMain; + } + /** + * Move the projector one frame forward + **/ + async proj_forward() { + let ms; + try { + if (!this.proj.state.dir) { + await delay(this.cfg.arduino.serialDelay); + await this.proj.set(true); + } + await delay(this.cfg.arduino.serialDelay); + ms = await this.proj.move(); + } + catch (err) { + throw err; + } + return ms; + } + /** + * Move the projector one frame backward + **/ + async proj_backward() { + let ms; + try { + if (this.proj.state.dir) { + await delay(this.cfg.arduino.serialDelay); + await this.proj.set(false); + } + await delay(this.cfg.arduino.serialDelay); + ms = await this.proj.move(); + } + catch (err) { + throw err; + } + return ms; + } + /** + * Move the camera one frame forward + * + * @param {array} rgb Color to set light for frame + **/ + async cam_forward(rgb = [255, 255, 255]) { + const off = [0, 0, 0]; + let ms; + try { + if (!this.cam.state.dir) { + await delay(this.cfg.arduino.serialDelay); + await this.cam.set(true); + } + await delay(this.cfg.arduino.serialDelay); + await this.light.set(rgb); + await delay(this.cfg.arduino.serialDelay); + ms = await this.cam.move(); + await delay(this.cfg.arduino.serialDelay); + await this.light.set(off); + } + catch (err) { + throw err; + } + return ms; + } + /** + * Move the camera one frame forwardwith light off + **/ + async black_forward() { + const off = [0, 0, 0]; + let ms; + try { + if (!this.cam.state.dir) { + await delay(this.cfg.arduino.serialDelay); + await this.cam.set(true); + } + await delay(this.cfg.arduino.serialDelay); + await this.light.set(off); //make sure set to off + await delay(this.cfg.arduino.serialDelay); + ms = await this.cam.move(); + await delay(this.cfg.arduino.serialDelay); + await this.light.set(off); + } + catch (err) { + throw err; + } + return ms; + } + /** + * Move the camera one frame backward + * + * @param {array} rgb Color to set light for frame + **/ + async cam_backward(rgb = [255, 255, 255]) { + const off = [0, 0, 0]; + let ms; + try { + if (this.cam.state.dir) { + await delay(this.cfg.arduino.serialDelay); + await this.cam.set(false); + } + await delay(this.cfg.arduino.serialDelay); + await this.light.set(rgb); + await delay(this.cfg.arduino.serialDelay); + ms = await this.cam.move(); + await delay(this.cfg.arduino.serialDelay); + await this.light.set(off); + } + catch (err) { + throw err; + } + return ms; + } + /** + * Move the camera one frame forward, light set to black or off + * + **/ + async black_backward() { + const off = [0, 0, 0]; + let ms; + try { + if (this.cam.state.dir) { + await delay(this.cfg.arduino.serialDelay); + await this.cam.set(false); + } + await delay(this.cfg.arduino.serialDelay); + await this.light.set(off); //make sure set to off + await delay(this.cfg.arduino.serialDelay); + ms = await this.cam.move(); + await delay(this.cfg.arduino.serialDelay); + await this.light.set(off); + } + catch (err) { + throw err; + } + return ms; + } + /* + cam2_forward : 'C2F', + cam2_backward : 'C2B', + + cams_forward : 'CCF', + cams_forward : 'CCB', + + cam_forward_cam2_backward : 'CFCB', + cam_backward_cam2_forward : 'CBCF', + */ + /** + * Move the secondary projector forward one frame + * + * @param {function} callback Function to call after action + **/ + /*cmd.proj2_forward = function (callback) { + 'use strict'; + var res = function (ms) { + $('#cmd_proj2_forward').removeClass('active'); + gui.updateState(); + if (callback) { callback(ms); } + }; + $('#cmd_proj2_forward').addClass('active'); + if (!mcopy.state.projector2.direction) { + proj.set2(true, function (ms) { + setTimeout(function () { + proj.move2(res); + }, mcopy.cfg.arduino.serialDelay); + }); + } else { + setTimeout(function () { + proj.move2(res); + }, mcopy.cfg.arduino.serialDelay); + } + }; + cmd.proj2_backward = function (callback) {}; + + cmd.projs_forward = function (callback) {}; + cmd.projs_backward = function (callback) {}; + + cmd.proj_forward_proj2_backward = function (callback) {}; + cmd.proj_backward_proj2_forward = function (callback) {}; + */ + /** + * Move the camera to a specific frame. Accepts the input with the "move_cam_to" + * value. Moves as black frames to prevent multiple exposure. + * + **/ + async cam_to() { + /*const raw = $('#move_cam_to').val(); + const val = parseInt(raw); + let proceed = false; + let total; + let steps = []; + let c; + let cont; + if (val !== mcopy.state.camera.pos) { + if (val < mcopy.state.camera.pos) { + total = -(mcopy.state.camera.pos - val) + } else if (val > mcopy.state.camera.pos) { + total = val - mcopy.state.camera.pos + } + if (total > 0) { + c = 'BF'; + } else if (total < 0) { + c = 'BB'; + } + for (let i = 0; i < Math.abs(total); i++) { + steps.push({ cmd : c }) + } + cont = confirm(`Do you want to ${(total > 0 ? 'advance' : 'rewind')} the camera ${total} frame${(total === 1 ? '' : 's')} to frame ${val}?`) + if (cont) { + seq.exec(steps); + } + }*/ + } + /** + * Move the projector to a specific frame. Accepts the input with the "move_proj_to" + * value. + * + **/ + async proj_to() { + /*const raw = $('#move_proj_to').val(); + const val = parseInt(raw); + let proceed = false; + let total; + let steps = []; + let c; + let cont + if (val !== mcopy.state.projector.pos) { + if (val < mcopy.state.projector.pos) { + total = -(mcopy.state.projector.pos - val) + } else if (val > mcopy.state.projector.pos) { + total = val - mcopy.state.projector.pos + } + if (total > 0) { + c = 'PF'; + } else if (total < 0) { + c = 'PB'; + } + for (let i = 0; i < Math.abs(total); i++) { + steps.push({ cmd : c }) + } + cont = confirm(`Do you want to ${(total > 0 ? 'advance' : 'rewind')} the projector ${total} frame${(total === 1 ? '' : 's')} to frame ${val}?`) + if (cont) { + seq.exec(steps); + } + }*/ + } +} +module.exports = function (cfg, proj, cam, light) { + return new Commands(cfg, proj, cam, light); +}; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/cli/lib/cmd/index.js.map b/cli/lib/cmd/index.js.map new file mode 100644 index 0000000..54e6d13 --- /dev/null +++ b/cli/lib/cmd/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cmd/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,+BAAgC;AAEhC,MAAM,QAAQ;IAQb,YAAa,GAAS,EAAE,IAAU,EAAE,GAAS,EAAE,KAAW;QACzD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QAEnB,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;IACxC,CAAC;IAED;;QAEI;IACG,KAAK,CAAC,YAAY;QACxB,IAAI,EAAW,CAAC;QAChB,IAAI;YACH,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE;gBACzB,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;gBAC1C,MAAM,IAA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,KAAK,CAAC,CAAC;AAC5C,CAAC,CAAA"} \ No newline at end of file diff --git a/cli/lib/cmd/package.json b/cli/lib/cmd/package.json new file mode 100644 index 0000000..c8b0f10 --- /dev/null +++ b/cli/lib/cmd/package.json @@ -0,0 +1,11 @@ +{ + "name": "cmd", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC" +} diff --git a/lib/cmd/index.js b/lib/cmd/index.js new file mode 100644 index 0000000..9aea590 --- /dev/null +++ b/lib/cmd/index.js @@ -0,0 +1,258 @@ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +const delay = require("delay"); +class Commands { + constructor(cfg, proj, cam, light) { + this.cfg = cfg; + this.proj = proj; + this.cam = cam; + this.light = light; + this.ipc = require('electron').ipcMain; + } + /** + * Move the projector one frame forward + **/ + async proj_forward() { + let ms; + try { + if (!this.proj.state.dir) { + await delay(this.cfg.arduino.serialDelay); + await this.proj.set(true); + } + await delay(this.cfg.arduino.serialDelay); + ms = await this.proj.move(); + } + catch (err) { + throw err; + } + return ms; + } + /** + * Move the projector one frame backward + **/ + async proj_backward() { + let ms; + try { + if (this.proj.state.dir) { + await delay(this.cfg.arduino.serialDelay); + await this.proj.set(false); + } + await delay(this.cfg.arduino.serialDelay); + ms = await this.proj.move(); + } + catch (err) { + throw err; + } + return ms; + } + /** + * Move the camera one frame forward + * + * @param {array} rgb Color to set light for frame + **/ + async cam_forward(rgb = [255, 255, 255]) { + const off = [0, 0, 0]; + let ms; + try { + if (!this.cam.state.dir) { + await delay(this.cfg.arduino.serialDelay); + await this.cam.set(true); + } + await delay(this.cfg.arduino.serialDelay); + await this.light.set(rgb); + await delay(this.cfg.arduino.serialDelay); + ms = await this.cam.move(); + await delay(this.cfg.arduino.serialDelay); + await this.light.set(off); + } + catch (err) { + throw err; + } + return ms; + } + /** + * Move the camera one frame forwardwith light off + **/ + async black_forward() { + const off = [0, 0, 0]; + let ms; + try { + if (!this.cam.state.dir) { + await delay(this.cfg.arduino.serialDelay); + await this.cam.set(true); + } + await delay(this.cfg.arduino.serialDelay); + await this.light.set(off); //make sure set to off + await delay(this.cfg.arduino.serialDelay); + ms = await this.cam.move(); + await delay(this.cfg.arduino.serialDelay); + await this.light.set(off); + } + catch (err) { + throw err; + } + return ms; + } + /** + * Move the camera one frame backward + * + * @param {array} rgb Color to set light for frame + **/ + async cam_backward(rgb = [255, 255, 255]) { + const off = [0, 0, 0]; + let ms; + try { + if (this.cam.state.dir) { + await delay(this.cfg.arduino.serialDelay); + await this.cam.set(false); + } + await delay(this.cfg.arduino.serialDelay); + await this.light.set(rgb); + await delay(this.cfg.arduino.serialDelay); + ms = await this.cam.move(); + await delay(this.cfg.arduino.serialDelay); + await this.light.set(off); + } + catch (err) { + throw err; + } + return ms; + } + /** + * Move the camera one frame forward, light set to black or off + * + **/ + async black_backward() { + const off = [0, 0, 0]; + let ms; + try { + if (this.cam.state.dir) { + await delay(this.cfg.arduino.serialDelay); + await this.cam.set(false); + } + await delay(this.cfg.arduino.serialDelay); + await this.light.set(off); //make sure set to off + await delay(this.cfg.arduino.serialDelay); + ms = await this.cam.move(); + await delay(this.cfg.arduino.serialDelay); + await this.light.set(off); + } + catch (err) { + throw err; + } + return ms; + } + /* + cam2_forward : 'C2F', + cam2_backward : 'C2B', + + cams_forward : 'CCF', + cams_forward : 'CCB', + + cam_forward_cam2_backward : 'CFCB', + cam_backward_cam2_forward : 'CBCF', + */ + /** + * Move the secondary projector forward one frame + * + * @param {function} callback Function to call after action + **/ + /*cmd.proj2_forward = function (callback) { + 'use strict'; + var res = function (ms) { + $('#cmd_proj2_forward').removeClass('active'); + gui.updateState(); + if (callback) { callback(ms); } + }; + $('#cmd_proj2_forward').addClass('active'); + if (!mcopy.state.projector2.direction) { + proj.set2(true, function (ms) { + setTimeout(function () { + proj.move2(res); + }, mcopy.cfg.arduino.serialDelay); + }); + } else { + setTimeout(function () { + proj.move2(res); + }, mcopy.cfg.arduino.serialDelay); + } + }; + cmd.proj2_backward = function (callback) {}; + + cmd.projs_forward = function (callback) {}; + cmd.projs_backward = function (callback) {}; + + cmd.proj_forward_proj2_backward = function (callback) {}; + cmd.proj_backward_proj2_forward = function (callback) {}; + */ + /** + * Move the camera to a specific frame. Accepts the input with the "move_cam_to" + * value. Moves as black frames to prevent multiple exposure. + * + **/ + async cam_to() { + /*const raw = $('#move_cam_to').val(); + const val = parseInt(raw); + let proceed = false; + let total; + let steps = []; + let c; + let cont; + if (val !== mcopy.state.camera.pos) { + if (val < mcopy.state.camera.pos) { + total = -(mcopy.state.camera.pos - val) + } else if (val > mcopy.state.camera.pos) { + total = val - mcopy.state.camera.pos + } + if (total > 0) { + c = 'BF'; + } else if (total < 0) { + c = 'BB'; + } + for (let i = 0; i < Math.abs(total); i++) { + steps.push({ cmd : c }) + } + cont = confirm(`Do you want to ${(total > 0 ? 'advance' : 'rewind')} the camera ${total} frame${(total === 1 ? '' : 's')} to frame ${val}?`) + if (cont) { + seq.exec(steps); + } + }*/ + } + /** + * Move the projector to a specific frame. Accepts the input with the "move_proj_to" + * value. + * + **/ + async proj_to() { + /*const raw = $('#move_proj_to').val(); + const val = parseInt(raw); + let proceed = false; + let total; + let steps = []; + let c; + let cont + if (val !== mcopy.state.projector.pos) { + if (val < mcopy.state.projector.pos) { + total = -(mcopy.state.projector.pos - val) + } else if (val > mcopy.state.projector.pos) { + total = val - mcopy.state.projector.pos + } + if (total > 0) { + c = 'PF'; + } else if (total < 0) { + c = 'PB'; + } + for (let i = 0; i < Math.abs(total); i++) { + steps.push({ cmd : c }) + } + cont = confirm(`Do you want to ${(total > 0 ? 'advance' : 'rewind')} the projector ${total} frame${(total === 1 ? '' : 's')} to frame ${val}?`) + if (cont) { + seq.exec(steps); + } + }*/ + } +} +module.exports = function (cfg, proj, cam, light) { + return new Commands(cfg, proj, cam, light); +}; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/lib/cmd/index.js.map b/lib/cmd/index.js.map new file mode 100644 index 0000000..54e6d13 --- /dev/null +++ b/lib/cmd/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cmd/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,+BAAgC;AAEhC,MAAM,QAAQ;IAQb,YAAa,GAAS,EAAE,IAAU,EAAE,GAAS,EAAE,KAAW;QACzD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QAEnB,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;IACxC,CAAC;IAED;;QAEI;IACG,KAAK,CAAC,YAAY;QACxB,IAAI,EAAW,CAAC;QAChB,IAAI;YACH,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE;gBACzB,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;gBAC1C,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;aAC1B;YACD,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YAC1C,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;SAC5B;QAAC,OAAO,GAAG,EAAE;YACb,MAAM,GAAG,CAAC;SACV;QACD,OAAO,EAAE,CAAC;IACX,CAAC;IACD;;QAEI;IACG,KAAK,CAAC,aAAa;QACzB,IAAI,EAAW,CAAC;QAChB,IAAI;YACH,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE;gBACxB,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,CAA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AAW,CAAC,CAAC;YAC1C,EAAE,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;YAC3B,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YAC1C,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;SAC1B;QAAC,OAAO,GAAG,EAAE;YACb,MAAM,GAAG,CAAC;SACV;QACD,OAAO,EAAE,CAAC;IACX,CAAC;IAED;;;;;;;;;MASE;IACF;;;;QAII;IACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;MA2BE;IAGF;;;;QAII;IACG,KAAK,CAAC,MAAM;QAClB;;;;;;;;;;;;;;;;;;;;;;;;;WAyBG;IACJ,CAAC;IAED;;;;QAII;IACG,KAAK,CAAC,OAAO;QACnB;;;;;;;;;;;;;;;;;;;;;;;;;WAyBG;IACJ,CAAC;CAED;AAED,MAAM,CAAC,OAAO,GAAG,UAAU,GAAS,EAAE,IAAU,EAAE,GAAS,EAAE,KAAW;IACvE,OAAO,IAAI,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAC5C,CAAC,CAAA"} \ No newline at end of file diff --git a/lib/cmd/package.json b/lib/cmd/package.json new file mode 100644 index 0000000..c8b0f10 --- /dev/null +++ b/lib/cmd/package.json @@ -0,0 +1,11 @@ +{ + "name": "cmd", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC" +} diff --git a/src/cmd/index.ts b/src/cmd/index.ts new file mode 100644 index 0000000..1781062 --- /dev/null +++ b/src/cmd/index.ts @@ -0,0 +1,267 @@ +'use strict'; + +import delay = require('delay'); + +class Commands { + private proj : any; + private cam : any; + private light : any; + + private cfg : any; + private ipc : any; + + constructor (cfg : any, proj : any, cam : any, light : any) { + this.cfg = cfg; + this.proj = proj; + this.cam = cam; + this.light = light; + + this.ipc = require('electron').ipcMain; + } + + /** + * Move the projector one frame forward + **/ + public async proj_forward () { + let ms : number; + try { + if (!this.proj.state.dir) { + await delay(this.cfg.arduino.serialDelay); + await this.proj.set(true); + } + await delay(this.cfg.arduino.serialDelay); + ms = await this.proj.move(); + } catch (err) { + throw err; + } + return ms; + } + /** + * Move the projector one frame backward + **/ + public async proj_backward () { + let ms : number; + try { + if (this.proj.state.dir) { + await delay(this.cfg.arduino.serialDelay); + await this.proj.set(false); + } + await delay(this.cfg.arduino.serialDelay); + ms = await this.proj.move(); + } catch (err) { + throw err; + } + return ms; + } + /** + * Move the camera one frame forward + * + * @param {array} rgb Color to set light for frame + **/ + public async cam_forward (rgb : number[] = [255, 255, 255]) { + const off : number[] = [0, 0, 0]; + let ms : number; + try { + if (!this.cam.state.dir) { + await delay(this.cfg.arduino.serialDelay); + await this.cam.set(true); + } + await delay(this.cfg.arduino.serialDelay); + await this.light.set(rgb); + await delay(this.cfg.arduino.serialDelay); + ms = await this.cam.move(); + await delay(this.cfg.arduino.serialDelay); + await this.light.set(off); + } catch (err) { + throw err; + } + return ms; + } + /** + * Move the camera one frame forwardwith light off + **/ + public async black_forward () { + const off : number[] = [0, 0, 0]; + let ms : number; + try { + if (!this.cam.state.dir) { + await delay(this.cfg.arduino.serialDelay); + await this.cam.set(true); + } + await delay(this.cfg.arduino.serialDelay); + await this.light.set(off); //make sure set to off + await delay(this.cfg.arduino.serialDelay); + ms = await this.cam.move(); + await delay(this.cfg.arduino.serialDelay); + await this.light.set(off); + } catch (err) { + throw err; + } + return ms; + } + /** + * Move the camera one frame backward + * + * @param {array} rgb Color to set light for frame + **/ + public async cam_backward (rgb : number[] = [255, 255, 255]) { + const off : number[] = [0, 0, 0]; + let ms : number; + try { + if (this.cam.state.dir) { + await delay(this.cfg.arduino.serialDelay); + await this.cam.set(false); + } + await delay(this.cfg.arduino.serialDelay); + await this.light.set(rgb); + await delay(this.cfg.arduino.serialDelay); + ms = await this.cam.move(); + await delay(this.cfg.arduino.serialDelay); + await this.light.set(off); + } catch (err) { + throw err; + } + return ms; + } + /** + * Move the camera one frame forward, light set to black or off + * + **/ + public async black_backward () { + const off : number[] = [0, 0, 0]; + let ms : number; + try { + if (this.cam.state.dir) { + await delay(this.cfg.arduino.serialDelay); + await this.cam.set(false); + } + await delay(this.cfg.arduino.serialDelay); + await this.light.set(off); //make sure set to off + await delay(this.cfg.arduino.serialDelay); + ms = await this.cam.move(); + await delay(this.cfg.arduino.serialDelay); + await this.light.set(off); + } catch (err) { + throw err; + } + return ms; + } + + /* + cam2_forward : 'C2F', + cam2_backward : 'C2B', + + cams_forward : 'CCF', + cams_forward : 'CCB', + + cam_forward_cam2_backward : 'CFCB', + cam_backward_cam2_forward : 'CBCF', + */ + /** + * Move the secondary projector forward one frame + * + * @param {function} callback Function to call after action + **/ + /*cmd.proj2_forward = function (callback) { + 'use strict'; + var res = function (ms) { + $('#cmd_proj2_forward').removeClass('active'); + gui.updateState(); + if (callback) { callback(ms); } + }; + $('#cmd_proj2_forward').addClass('active'); + if (!mcopy.state.projector2.direction) { + proj.set2(true, function (ms) { + setTimeout(function () { + proj.move2(res); + }, mcopy.cfg.arduino.serialDelay); + }); + } else { + setTimeout(function () { + proj.move2(res); + }, mcopy.cfg.arduino.serialDelay); + } + }; + cmd.proj2_backward = function (callback) {}; + + cmd.projs_forward = function (callback) {}; + cmd.projs_backward = function (callback) {}; + + cmd.proj_forward_proj2_backward = function (callback) {}; + cmd.proj_backward_proj2_forward = function (callback) {}; + */ + + + /** + * Move the camera to a specific frame. Accepts the input with the "move_cam_to" + * value. Moves as black frames to prevent multiple exposure. + * + **/ + public async cam_to () { + /*const raw = $('#move_cam_to').val(); + const val = parseInt(raw); + let proceed = false; + let total; + let steps = []; + let c; + let cont; + if (val !== mcopy.state.camera.pos) { + if (val < mcopy.state.camera.pos) { + total = -(mcopy.state.camera.pos - val) + } else if (val > mcopy.state.camera.pos) { + total = val - mcopy.state.camera.pos + } + if (total > 0) { + c = 'BF'; + } else if (total < 0) { + c = 'BB'; + } + for (let i = 0; i < Math.abs(total); i++) { + steps.push({ cmd : c }) + } + cont = confirm(`Do you want to ${(total > 0 ? 'advance' : 'rewind')} the camera ${total} frame${(total === 1 ? '' : 's')} to frame ${val}?`) + if (cont) { + seq.exec(steps); + } + }*/ + } + + /** + * Move the projector to a specific frame. Accepts the input with the "move_proj_to" + * value. + * + **/ + public async proj_to () { + /*const raw = $('#move_proj_to').val(); + const val = parseInt(raw); + let proceed = false; + let total; + let steps = []; + let c; + let cont + if (val !== mcopy.state.projector.pos) { + if (val < mcopy.state.projector.pos) { + total = -(mcopy.state.projector.pos - val) + } else if (val > mcopy.state.projector.pos) { + total = val - mcopy.state.projector.pos + } + if (total > 0) { + c = 'PF'; + } else if (total < 0) { + c = 'PB'; + } + for (let i = 0; i < Math.abs(total); i++) { + steps.push({ cmd : c }) + } + cont = confirm(`Do you want to ${(total > 0 ? 'advance' : 'rewind')} the projector ${total} frame${(total === 1 ? '' : 's')} to frame ${val}?`) + if (cont) { + seq.exec(steps); + } + }*/ + } + +} + +module.exports = function (cfg : any, proj : any, cam : any, light : any) { + return new Commands(cfg, proj, cam, light); +} \ No newline at end of file