Create and install main process lib to control the cmd.js module

This commit is contained in:
mmcwilliams 2019-03-21 19:33:01 -04:00
parent 7a87ac924a
commit 600a0abc72
12 changed files with 1126 additions and 45 deletions

258
app/lib/cmd/index.js Normal file
View File

@ -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

1
app/lib/cmd/index.js.map Normal file
View File

@ -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,G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II;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"}

11
app/lib/cmd/package.json Normal file
View File

@ -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"
}

93
app/package-lock.json generated
View File

@ -321,7 +321,7 @@
}, },
"string_decoder": { "string_decoder": {
"version": "1.1.1", "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==", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
"requires": { "requires": {
"safe-buffer": "~5.1.0" "safe-buffer": "~5.1.0"
@ -616,7 +616,7 @@
}, },
"bl": { "bl": {
"version": "1.2.2", "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==", "integrity": "sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==",
"requires": { "requires": {
"readable-stream": "^2.3.5", "readable-stream": "^2.3.5",
@ -826,7 +826,7 @@
}, },
"camelcase-keys": { "camelcase-keys": {
"version": "2.1.0", "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=", "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -1008,7 +1008,7 @@
}, },
"string_decoder": { "string_decoder": {
"version": "1.1.1", "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==", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
"dev": true, "dev": true,
"requires": { "requires": {
@ -1017,6 +1017,9 @@
} }
} }
}, },
"cmd": {
"version": "file:lib/cmd"
},
"code-point-at": { "code-point-at": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
@ -1207,7 +1210,7 @@
}, },
"string_decoder": { "string_decoder": {
"version": "1.1.1", "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==", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
"dev": true, "dev": true,
"requires": { "requires": {
@ -2078,7 +2081,7 @@
}, },
"enabled": { "enabled": {
"version": "1.0.2", "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=", "integrity": "sha1-ll9lE9LC0cX0ZStkouM5ZGf8L5M=",
"requires": { "requires": {
"env-variable": "0.0.x" "env-variable": "0.0.x"
@ -2431,7 +2434,7 @@
}, },
"fecha": { "fecha": {
"version": "2.3.3", "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==" "integrity": "sha512-lUGBnIamTAwk4znq5BcqsDaxSmZ9nDVJaij6NvRt/Tg4R69gERA+otPKbS86ROw9nxVMw2/mp1fnaiWqbs6Sdg=="
}, },
"ffmpeg": { "ffmpeg": {
@ -2903,7 +2906,7 @@
}, },
"load-json-file": { "load-json-file": {
"version": "2.0.0", "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=", "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -3078,7 +3081,7 @@
}, },
"readable-stream": { "readable-stream": {
"version": "1.0.34", "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=", "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -3090,7 +3093,7 @@
}, },
"through2": { "through2": {
"version": "0.6.5", "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=", "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -3102,7 +3105,7 @@
}, },
"glob-watcher": { "glob-watcher": {
"version": "0.0.6", "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=", "integrity": "sha1-uVtKjfdLOcgymLDAXJeLTZo7cQs=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -3166,7 +3169,7 @@
}, },
"graceful-fs": { "graceful-fs": {
"version": "1.2.3", "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=", "integrity": "sha1-FaSAaldUfLLS2/J/QuiajDRRs2Q=",
"dev": true "dev": true
}, },
@ -3178,7 +3181,7 @@
}, },
"lodash": { "lodash": {
"version": "1.0.2", "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=", "integrity": "sha1-j1dWDIO1n8JwvT1WG2kAQ0MOJVE=",
"dev": true "dev": true
}, },
@ -3221,7 +3224,7 @@
}, },
"gulp": { "gulp": {
"version": "3.9.1", "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=", "integrity": "sha1-VxzkWSjdQK9lFPxAEYZgFsE4RbQ=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -3273,7 +3276,7 @@
}, },
"semver": { "semver": {
"version": "4.3.6", "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=", "integrity": "sha1-MAvG4OhjdPe6YQaLWx7NV/xlMto=",
"dev": true "dev": true
}, },
@ -3328,7 +3331,7 @@
}, },
"string_decoder": { "string_decoder": {
"version": "1.1.1", "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==", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
"dev": true, "dev": true,
"requires": { "requires": {
@ -3385,7 +3388,7 @@
}, },
"string_decoder": { "string_decoder": {
"version": "1.1.1", "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==", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
"dev": true, "dev": true,
"requires": { "requires": {
@ -3508,7 +3511,7 @@
}, },
"string_decoder": { "string_decoder": {
"version": "1.1.1", "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==", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
"dev": true, "dev": true,
"requires": { "requires": {
@ -3835,7 +3838,7 @@
}, },
"is-builtin-module": { "is-builtin-module": {
"version": "1.0.0", "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=", "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -4163,7 +4166,7 @@
}, },
"jsonfile": { "jsonfile": {
"version": "2.4.0", "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=", "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=",
"requires": { "requires": {
"graceful-fs": "^4.1.6" "graceful-fs": "^4.1.6"
@ -4286,7 +4289,7 @@
}, },
"load-json-file": { "load-json-file": {
"version": "1.1.0", "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=", "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -4652,7 +4655,7 @@
}, },
"meow": { "meow": {
"version": "3.7.0", "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=", "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -4793,7 +4796,7 @@
}, },
"mkdirp": { "mkdirp": {
"version": "0.5.1", "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=", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
@ -4822,7 +4825,7 @@
"dependencies": { "dependencies": {
"fs-extra": { "fs-extra": {
"version": "0.26.7", "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=", "integrity": "sha1-muH92UiXeY7at20JGM9C0MMYT6k=",
"requires": { "requires": {
"graceful-fs": "^4.1.2", "graceful-fs": "^4.1.2",
@ -4973,7 +4976,7 @@
"dependencies": { "dependencies": {
"semver": { "semver": {
"version": "5.3.0", "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=", "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=",
"dev": true "dev": true
}, },
@ -5337,7 +5340,7 @@
}, },
"os-homedir": { "os-homedir": {
"version": "1.0.2", "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=" "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M="
}, },
"os-locale": { "os-locale": {
@ -5353,7 +5356,7 @@
}, },
"os-tmpdir": { "os-tmpdir": {
"version": "1.0.2", "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=" "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ="
}, },
"osenv": { "osenv": {
@ -5484,7 +5487,7 @@
}, },
"path-is-absolute": { "path-is-absolute": {
"version": "1.0.1", "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=" "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
}, },
"path-key": { "path-key": {
@ -5635,7 +5638,7 @@
}, },
"kind-of": { "kind-of": {
"version": "1.1.0", "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=", "integrity": "sha1-FAo9LUGjbS78+pN3tiwk+ElaXEQ=",
"dev": true "dev": true
} }
@ -5679,7 +5682,7 @@
}, },
"pretty-bytes": { "pretty-bytes": {
"version": "1.0.4", "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=", "integrity": "sha1-CiLoIQYJrTVUL4yNXSFZr/B1HIQ=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -5689,7 +5692,7 @@
}, },
"pretty-hrtime": { "pretty-hrtime": {
"version": "1.0.3", "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=", "integrity": "sha1-t+PqQkNaTJsnWdmeDyAesZWALuE=",
"dev": true "dev": true
}, },
@ -5912,7 +5915,7 @@
"dependencies": { "dependencies": {
"array-back": { "array-back": {
"version": "1.0.4", "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=", "integrity": "sha1-ZEun8JX3/898Q7Xw3DnTwfA8Bjs=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -5954,7 +5957,7 @@
"dependencies": { "dependencies": {
"array-back": { "array-back": {
"version": "1.0.4", "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=", "integrity": "sha1-ZEun8JX3/898Q7Xw3DnTwfA8Bjs=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -6150,7 +6153,7 @@
}, },
"safe-regex": { "safe-regex": {
"version": "1.1.0", "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=", "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -6543,7 +6546,7 @@
"dependencies": { "dependencies": {
"array-back": { "array-back": {
"version": "1.0.4", "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=", "integrity": "sha1-ZEun8JX3/898Q7Xw3DnTwfA8Bjs=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -6694,7 +6697,7 @@
"dependencies": { "dependencies": {
"nan": { "nan": {
"version": "2.10.0", "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==" "integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA=="
} }
} }
@ -6759,7 +6762,7 @@
"dependencies": { "dependencies": {
"array-back": { "array-back": {
"version": "1.0.4", "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=", "integrity": "sha1-ZEun8JX3/898Q7Xw3DnTwfA8Bjs=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -6791,7 +6794,7 @@
}, },
"string_decoder": { "string_decoder": {
"version": "0.10.31", "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=" "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ="
}, },
"strip-ansi": { "strip-ansi": {
@ -6813,7 +6816,7 @@
}, },
"strip-eof": { "strip-eof": {
"version": "1.0.0", "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=" "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8="
}, },
"strip-indent": { "strip-indent": {
@ -6971,7 +6974,7 @@
}, },
"string_decoder": { "string_decoder": {
"version": "1.1.1", "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==", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
"requires": { "requires": {
"safe-buffer": "~5.1.0" "safe-buffer": "~5.1.0"
@ -7026,7 +7029,7 @@
}, },
"through2": { "through2": {
"version": "0.2.3", "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=", "integrity": "sha1-6zKE2k6jEbbMis42U3SKUqvyWj8=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -7513,7 +7516,7 @@
}, },
"graceful-fs": { "graceful-fs": {
"version": "3.0.11", "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=", "integrity": "sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -7522,7 +7525,7 @@
}, },
"readable-stream": { "readable-stream": {
"version": "1.0.34", "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=", "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -7544,7 +7547,7 @@
}, },
"through2": { "through2": {
"version": "0.6.5", "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=", "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -7771,7 +7774,7 @@
}, },
"wrap-ansi": { "wrap-ansi": {
"version": "2.1.0", "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=", "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=",
"requires": { "requires": {
"string-width": "^1.0.1", "string-width": "^1.0.1",

View File

@ -42,6 +42,7 @@
"arduino": "file:lib/arduino", "arduino": "file:lib/arduino",
"cam": "file:lib/cam", "cam": "file:lib/cam",
"capture": "file:lib/capture", "capture": "file:lib/capture",
"cmd": "file:lib/cmd",
"delay": "file:lib/delay", "delay": "file:lib/delay",
"devices": "file:lib/devices", "devices": "file:lib/devices",
"digital": "file:lib/digital", "digital": "file:lib/digital",

258
cli/lib/cmd/index.js Normal file
View File

@ -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

1
cli/lib/cmd/index.js.map Normal file
View File

@ -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,C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G,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;gBAC1C,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;aAC1B;YACD,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YAC1C,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,sBAAsB;YACjD,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,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"}

11
cli/lib/cmd/package.json Normal file
View File

@ -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"
}

258
lib/cmd/index.js Normal file
View File

@ -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

1
lib/cmd/index.js.map Normal file
View File

@ -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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;;;;;;;;;;;;;;;;;;;;;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"}

11
lib/cmd/package.json Normal file
View File

@ -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"
}

267
src/cmd/index.ts Normal file
View File

@ -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);
}