Merge in 9 months of work on capper branch #71

Merged
mattmcw merged 95 commits from capper into main 2023-02-19 05:28:46 +00:00
20 changed files with 390 additions and 59 deletions
Showing only changes of commit ee0ab663d7 - Show all commits

View File

@ -2499,6 +2499,7 @@ const mse = require('./lib/ui/mscript.js');
const capper = require('./lib/ui/capper.js');
const Mscript = require('./lib/mscript');
const { delay } = require('./lib/delay');
const alertObj = require('./lib/ui/alert.js');
let log;
@ -2527,4 +2528,5 @@ async function init () {
cam.init();
seq.init();
capper.init();
alertObj.init();
};

58
app/lib/alert/index.js Normal file
View File

@ -0,0 +1,58 @@
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
/* class representing alert functionality */
class Alert {
constructor(ui) {
this.id = 'alert';
this.cb = null;
this.ui = ui;
this.init();
}
/**
*
**/
async init() {
const Log = require('log');
this.log = await Log({ label: this.id });
this.ipc = require('electron').ipcMain;
this.listen();
}
/**
*
**/
listen() {
this.ipc.on(this.id, this.listener.bind(this));
}
/**
*
**/
async listener(event, arg) {
if (this.cb !== null) {
try {
await this.cb(arg.state, arg.id);
}
catch (err) {
this.log.error(err);
}
}
event.returnValue = true;
}
/**
*
**/
async start(cmd) {
const start = +new Date();
const msg = (cmd + '').replace('ALERT', '').replace('Alert', '').replace('alert', '').trim();
this.ui.send(this.id, { msg });
return new Promise(function (resolve, reject) {
this.cb = function () {
const ms = (+new Date()) - start;
return resolve(ms);
};
}.bind(this));
}
}
module.exports = function (ui) {
return new Alert(ui);
};
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/alert/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAIb,4CAA4C;AAE5C,MAAM,KAAK;IAOV,YAAc,EAAQ;QAJd,OAAE,GAAY,OAAO,CAAA;QACrB,OAAE,GAAc,IAAI,CAAA;QAI3B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;QACZ,IAAI,CAAC,IAAI,EAAE,CAAA;IACZ,CAAC;IAED;;QAEI;IACI,KAAK,CAAC,IAAI;QACjB,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAA;QAC1B,IAAI,CAAC,GAAG,GAAG,MAAM,GAAG,CAAC,EAAE,KAAK,EAAG,IAAI,CAAC,EAAE,EAAE,CAAC,CAAA;QACzC,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,CAAA;QACtC,IAAI,CAAC,MAAM,EAAE,CAAA;IACd,CAAC;IAED;;QAEI;IACI,MAAM;QACb,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IAC/C,CAAC;IAED;;QAEI;IACI,KAAK,CAAC,QAAQ,CAAE,KAAW,EAAE,GAAS;QAC7C,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,EAAE;YACrB,IAAI;gBACH,MAAM,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC,CAAA;aAChC;YAAC,OAAO,GAAG,EAAE;gBACb,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;aACnB;SACD;QACD,KAAK,CAAC,WAAW,GAAG,IAAI,CAAA;IACzB,CAAC;IAED;;QAEI;IACG,KAAK,CAAC,KAAK,CAAE,GAAY;QAC/B,MAAM,KAAK,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;QAC1B,MAAM,GAAG,GAAY,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;QACrG,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,CAAA;QAC9B,OAAO,IAAI,OAAO,CAAC,UAAU,OAAkB,EAAE,MAAiB;YACjE,IAAI,CAAC,EAAE,GAAG;gBACT,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC;gBACjC,OAAO,OAAO,CAAC,EAAE,CAAC,CAAC;YACpB,CAAC,CAAA;QACF,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACf,CAAC;CACD;AAED,MAAM,CAAC,OAAO,GAAG,UAAU,EAAQ;IAClC,OAAO,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC;AACtB,CAAC,CAAA"}

View File

@ -12,13 +12,14 @@ class Commands {
* @param {object} cam Camera 1
* @param {object} light Light source
* @param {object} cam2 (optional) Camera 2
* @param {object} proj2 {optional} Projector 2
* @param {object} proj2 (optional) Projector 2
**/
constructor(cfg, proj, cam, light, cam2 = null, proj2 = null, capper = null) {
constructor(cfg, proj, cam, light, alert, cam2 = null, proj2 = null, capper = null) {
this.cfg = cfg;
this.proj = proj;
this.cam = cam;
this.light = light;
this.alertObj = alert;
if (cam2 !== null)
this.cam2 = cam2;
if (proj2 !== null)
@ -70,13 +71,14 @@ class Commands {
/**
* Move the camera one frame forward
*
* @param {array} rgb Color to set light for frame
* @param {object} cmd Full cmd object
*
* @returns {integer} Length of action in ms
**/
async camera_forward(rgb = [255, 255, 255]) {
async camera_forward() {
const id = uuid_1.v4();
const off = [0, 0, 0];
let rgb = [255, 255, 255];
let ms;
try {
if (!this.cam.state.dir) {
@ -131,13 +133,14 @@ class Commands {
/**
* Move the camera one frame backward
*
* @param {array} rgb Color to set light for frame
* @param {object} cmd Full cmd object
*
* @returns {integer} Length of action in ms
**/
async camera_backward(rgb = [255, 255, 255]) {
async camera_backward() {
const id = uuid_1.v4();
const off = [0, 0, 0];
let rgb = [255, 255, 255];
let ms;
try {
if (this.cam.state.dir) {
@ -191,13 +194,14 @@ class Commands {
/**
* Move the second camera one frame forward
*
* @param {array} rgb Color to set light for frame
* @param {object} cmd Full cmd object
*
* @returns {integer} Length of action in ms
**/
async camera_second_forward(rgb = [255, 255, 255]) {
async camera_second_forward() {
const id = uuid_1.v4();
const off = [0, 0, 0];
let rgb = [255, 255, 255];
let ms;
try {
if (!this.cam2.state.dir) {
@ -219,13 +223,14 @@ class Commands {
/**
* Move the second camera one frame backward
*
* @param {array} rgb Color to set light for frame
* @param {object} cmd Full cmd object
*
* @returns {integer} Length of action in ms
**/
async camera_second_backward(rgb = [255, 255, 255]) {
async camera_second_backward() {
const id = uuid_1.v4();
const off = [0, 0, 0];
let rgb = [255, 255, 255];
let ms;
try {
if (this.cam2.state.dir) {
@ -247,13 +252,14 @@ class Commands {
/**
* Move the both cameras one frame forward
*
* @param {array} rgb Color to set light for frame
* @param {object} cmd Full cmd object
*
* @returns {integer} Length of action in ms
**/
async cameras_forward(rgb = [255, 255, 255]) {
async cameras_forward() {
const id = uuid_1.v4();
const off = [0, 0, 0];
let rgb = [255, 255, 255];
let both;
let ms;
try {
@ -288,13 +294,14 @@ class Commands {
/**
* Move the both cameras one frame backward
*
* @param {array} rgb Color to set light for frame
* @param {object} cmd Full cmd object
*
* @returns {integer} Length of action in ms
**/
async cameras_backward(rgb = [255, 255, 255]) {
async cameras_backward() {
const id = uuid_1.v4();
const off = [0, 0, 0];
let rgb = [255, 255, 255];
let both;
let ms;
try {
@ -329,13 +336,14 @@ class Commands {
/**
* Move first camera one frame forward and rewind secondary camera one frame backward
*
* @param {array} rgb Color to set light for frames
* @param {object} cmd Full cmd object
*
* @returns {integer} Length of action in ms
**/
async camera_forward_camera_second_backward(rgb = [255, 255, 255]) {
async camera_forward_camera_second_backward() {
const id = uuid_1.v4();
const off = [0, 0, 0];
let rgb = [255, 255, 255];
let both;
let ms;
try {
@ -370,13 +378,14 @@ class Commands {
/**
* Rewind first camera one frame backward and move secondary camera one frame forward
*
* @param {array} rgb Color to set light for frame
* @param {object} cmd Full cmd object
*
* @returns {integer} Length of action in ms
**/
async camera_backward_camera_second_forward(rgb = [255, 255, 255]) {
async camera_backward_camera_second_forward() {
const id = uuid_1.v4();
const off = [0, 0, 0];
let rgb = [255, 255, 255];
let both;
let ms;
try {
@ -585,8 +594,23 @@ class Commands {
}
return ms;
}
/**
* Throws an alert to pause a sequence
*
* @returns {integer} Length of action in ms
**/
async alert(cmd) {
let ms;
try {
ms = await this.alertObj.start(cmd.light); //change this meta
}
module.exports = function (cfg, proj, cam, light, cam2, proj2, capper) {
return new Commands(cfg, proj, cam, light, cam2, proj2, capper);
catch (err) {
throw err;
}
return ms;
}
}
module.exports = function (cfg, proj, cam, light, alert, cam2, proj2, capper) {
return new Commands(cfg, proj, cam, light, alert, cam2, proj2, capper);
};
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@ -7,8 +7,22 @@ const CMD = [
'BF',
'CB',
'PB',
'BB'
'BB',
'C2F',
'C2B',
'CCF',
'CCB',
'P2F',
'P2B',
'PPF',
'PPB'
];
/*
'CFCB',
'CBCF',
'PFPB',
'PBPF'
*/
const ALTS = {
'CF': ['CAMERA FORWARD', 'CAM FORWARD'],
'PF': ['PROJECTOR FORWARD', 'PROJ FORWARD'],
@ -17,8 +31,22 @@ const ALTS = {
'PB': ['PROJECTOR FORWARD', 'PROJ FORWARD', 'PROJECTOR BACK', 'PROJ BACK'],
'BB': ['BLACK BACKWARD', 'BLACK BACK', 'BLANK BACK'],
'L ': ['LIGHT', 'COLOR', 'LAMP'],
'F ': ['FADE']
'F ': ['FADE'],
'C2F': ['CAMERA2 FORWARD', 'CAM2 FORWARD'],
'C2B': ['CAMERA2 BACKWARD', 'CAM2 BACKWARD', 'CAMERA2 BACK', 'CAM2 BACK'],
'CCF': ['CAMERAS FORWARD', 'CAMS FORWARD'],
'CCB': ['CAMERAS BACKWARD', 'CAMS BACKWARD', 'CAMERAS BACK', 'CAMS BACK'],
'P2F': ['PROJECTOR2 FORWARD', 'PROJ2 FORWARD'],
'P2B': ['PROJECTOR2 BACKWARD', 'PROJ2 BACKWARD', 'PROJECTOR2 BACK', 'PROJ2 BACK'],
'PPF': ['PROJECTORS FORWARD', 'PROJS FORWARD'],
'PPB': ['PROJECTORS BACKWARD', 'PROJS BACKWARD', 'PROJECTORS BACK', 'PROJS BACK'],
};
/*
'CFCB' : [ ],
'CBCF' : [ ],
'PFPB' : [ ],
'PBPF' : [ ]
*/
const PAUSE = 'PAUSE';
const ALERT = 'ALERT';
/** helper functions */
@ -56,7 +84,9 @@ class Mscript {
clear() {
this.lines = [];
this.cam = 0;
this.cam2 = 0;
this.proj = 0;
this.proj2 = 0;
this.color = '';
this.loops = [];
this.rec = -1;
@ -654,7 +684,7 @@ class Mscript {
.push(lenStr);
}
else {
this.arr.push('AL');
this.arr.push('PA');
this.meta.push(lenStr);
}
}
@ -671,11 +701,11 @@ class Mscript {
this.loops[this.rec].arr
.push('AL');
this.loops[this.rec].meta
.push(msg);
.push(line);
}
else {
this.arr.push('AL');
this.meta.push(msg);
this.meta.push(line);
}
}
/**

File diff suppressed because one or more lines are too long

View File

@ -230,8 +230,7 @@ class Sequencer {
const cmdOriginal = this.arr[x].cmd;
const cmd = this.CMDS[cmdOriginal];
this.log.info(`CMD: '${cmdOriginal}' -> ${cmd}`);
//I wrote this when I was very tired and delirious
return await this.cmd[cmd]();
return await this.cmd[cmd](this.arr[x]);
}
}
module.exports = function (cfg, cmd, ui) {

File diff suppressed because one or more lines are too long

27
app/lib/ui/alert.js Normal file
View File

@ -0,0 +1,27 @@
'use strict';
let alertObj;
class Alert {
constructor() {
this.id = 'alert';
}
init() {
this.listen();
}
start(msg) {
alert(msg);
this.end();
}
end() {
const obj = {};
ipcRenderer.sendSync(this.id, obj);
}
listen() {
ipcRenderer.on(this.id, (function (event, arg) {
this.start(arg.msg);
}).bind(this));
}
;
}
alertObj = new Alert();
module.exports = alertObj;
//# sourceMappingURL=alert.js.map

1
app/lib/ui/alert.js.map Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"alert.js","sourceRoot":"","sources":["../../src/lib/ui/alert.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAOb,IAAI,QAAgB,CAAC;AAErB,MAAM,KAAK;IAGV;QAFA,OAAE,GAAY,OAAO,CAAC;IAGtB,CAAC;IAEM,IAAI;QACV,IAAI,CAAC,MAAM,EAAE,CAAC;IACf,CAAC;IAEM,KAAK,CAAE,GAAY;QACzB,KAAK,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,GAAG,EAAE,CAAC;IACZ,CAAC;IAEO,GAAG;QACV,MAAM,GAAG,GAAS,EAAE,CAAC;QAErB,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IACpC,CAAC;IAEO,MAAM;QACb,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,UAAU,KAAa,EAAE,GAAS;YAC1D,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAChB,CAAC;IAAA,CAAC;CAEF;AAED,QAAQ,GAAG,IAAI,KAAK,EAAE,CAAC;AACvB,MAAM,CAAC,OAAO,GAAG,QAAQ,CAAC"}

View File

@ -38,6 +38,7 @@ let dev;
let cmd;
let seq;
let capper;
let alert;
const cfg = require('./data/cfg.json')
@ -119,6 +120,7 @@ var init = async function () {
filmout = require('filmout')(display, ffmpeg, ffprobe, mainWindow.webContents, light)
cam = require('cam')(arduino, cfg, mainWindow.webContents, filmout)
proj = require('proj')(arduino, cfg, mainWindow.webContents, filmout)
alert = require('alert')(mainWindow.webContents)
if (dev && dev.connected && dev.connected.camera_second) {
cam2 = require('cam')(arduino, cfg, mainWindow.webContents, filmout, true)
@ -131,8 +133,9 @@ var init = async function () {
capper = require('capper')(arduino, cfg, mainWindow.webContents, filmout, true)
}
cmd = require('cmd')(cfg, proj, cam, light, cam2, proj2, capper)
cmd = require('cmd')(cfg, proj, cam, light, alert, cam2, proj2, capper)
seq = require('sequencer')(cfg, cmd, mainWindow.webContents)
}
app.on('ready', init)

9
app/package-lock.json generated
View File

@ -11,6 +11,7 @@
"license": "MIT",
"dependencies": {
"@electron/remote": "^2.0.8",
"alert": "file:lib/alert",
"animated-gif-detector": "^1.2.0",
"arduino": "file:lib/arduino",
"cam": "file:lib/cam",
@ -68,6 +69,7 @@
"electron-installer-debian": "^3.1.0"
}
},
"lib/alert": {},
"lib/arduino": {
"version": "1.0.0",
"license": "ISC"
@ -1189,6 +1191,10 @@
"uri-js": "^4.2.2"
}
},
"node_modules/alert": {
"resolved": "lib/alert",
"link": true
},
"node_modules/animated-gif-detector": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/animated-gif-detector/-/animated-gif-detector-1.2.0.tgz",
@ -12256,6 +12262,9 @@
"uri-js": "^4.2.2"
}
},
"alert": {
"version": "file:lib/alert"
},
"animated-gif-detector": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/animated-gif-detector/-/animated-gif-detector-1.2.0.tgz",

View File

@ -51,6 +51,7 @@
},
"dependencies": {
"@electron/remote": "^2.0.8",
"alert" : "file:lib/alert",
"animated-gif-detector": "^1.2.0",
"arduino": "file:lib/arduino",
"cam": "file:lib/cam",

View File

@ -25,6 +25,7 @@ const mse = require('./lib/ui/mscript.js');
const capper = require('./lib/ui/capper.js');
const Mscript = require('./lib/mscript');
const { delay } = require('./lib/delay');
const alertObj = require('./lib/ui/alert.js');
let log;
@ -53,4 +54,5 @@ async function init () {
cam.init();
seq.init();
capper.init();
alertObj.init();
};

40
app/src/lib/ui/alert.ts Normal file
View File

@ -0,0 +1,40 @@
'use strict';
/// <reference path ="jquery.d.ts"/>
declare var uuid : any;
declare var ipcRenderer : any;
let alertObj : Alert;
class Alert {
id : string = 'alert';
constructor () {
}
public init () {
this.listen();
}
public start (msg : string) {
alert(msg);
this.end();
}
private end () {
const obj : any = {};
ipcRenderer.sendSync(this.id, obj);
}
private listen () {
ipcRenderer.on(this.id, (function (event : Event, arg : any) {
this.start(arg.msg);
}).bind(this));
};
}
alertObj = new Alert();
module.exports = alertObj;

68
src/alert/index.ts Normal file
View File

@ -0,0 +1,68 @@
'use strict';
import { delay } from 'delay'
/* class representing alert functionality */
class Alert {
private ipc : any
private log : any
private id : string = 'alert'
private cb : Function = null
private ui : any
constructor ( ui : any) {
this.ui = ui
this.init()
}
/**
*
**/
private async init () {
const Log = require('log')
this.log = await Log({ label : this.id })
this.ipc = require('electron').ipcMain
this.listen()
}
/**
*
**/
private listen () {
this.ipc.on(this.id, this.listener.bind(this))
}
/**
*
**/
private async listener (event : any, arg : any) {
if (this.cb !== null) {
try {
await this.cb(arg.state, arg.id)
} catch (err) {
this.log.error(err)
}
}
event.returnValue = true
}
/**
*
**/
public async start (cmd : string) {
const start = +new Date();
const msg : string = (cmd + '').replace('ALERT', '').replace('Alert', '').replace('alert', '').trim()
this.ui.send(this.id, { msg })
return new Promise(function (resolve : Function, reject : Function) {
this.cb = function () {
const ms = (+new Date()) - start;
return resolve(ms);
}
}.bind(this));
}
}
module.exports = function (ui : any) {
return new Alert(ui);
}

View File

@ -13,6 +13,8 @@ class Commands {
private capper : any;
private alertObj : any;
private cfg : any;
private ipc : any;
@ -25,14 +27,15 @@ class Commands {
* @param {object} cam Camera 1
* @param {object} light Light source
* @param {object} cam2 (optional) Camera 2
* @param {object} proj2 {optional} Projector 2
* @param {object} proj2 (optional) Projector 2
**/
constructor (cfg : any, proj : any, cam : any, light : any, cam2 : any = null, proj2 : any = null, capper : any = null) {
constructor (cfg : any, proj : any, cam : any, light : any, alert : any, cam2 : any = null, proj2 : any = null, capper : any = null) {
this.cfg = cfg;
this.proj = proj;
this.cam = cam;
this.light = light;
this.alertObj = alert;
if (cam2 !== null) this.cam2 = cam2;
if (proj2 !== null) this.proj2 = proj2;
@ -82,13 +85,14 @@ class Commands {
/**
* Move the camera one frame forward
*
* @param {array} rgb Color to set light for frame
* @param {object} cmd Full cmd object
*
* @returns {integer} Length of action in ms
**/
public async camera_forward (rgb : number[] = [255, 255, 255]) {
public async camera_forward () {
const id : string = uuid();
const off : number[] = [0, 0, 0];
let rgb : number[] = [255, 255, 255];
let ms : number;
try {
if (!this.cam.state.dir) {
@ -141,13 +145,14 @@ class Commands {
/**
* Move the camera one frame backward
*
* @param {array} rgb Color to set light for frame
* @param {object} cmd Full cmd object
*
* @returns {integer} Length of action in ms
**/
public async camera_backward (rgb : number[] = [255, 255, 255]) {
public async camera_backward () {
const id : string = uuid();
const off : number[] = [0, 0, 0];
let rgb : number[] = [255, 255, 255];
let ms : number;
try {
if (this.cam.state.dir) {
@ -200,13 +205,14 @@ class Commands {
/**
* Move the second camera one frame forward
*
* @param {array} rgb Color to set light for frame
* @param {object} cmd Full cmd object
*
* @returns {integer} Length of action in ms
**/
public async camera_second_forward (rgb : number[] = [255, 255, 255]) {
public async camera_second_forward () {
const id : string = uuid();
const off : number[] = [0, 0, 0];
let rgb : number[] = [255, 255, 255];
let ms : number;
try {
if (!this.cam2.state.dir) {
@ -228,13 +234,14 @@ class Commands {
/**
* Move the second camera one frame backward
*
* @param {array} rgb Color to set light for frame
* @param {object} cmd Full cmd object
*
* @returns {integer} Length of action in ms
**/
public async camera_second_backward (rgb : number[] = [255, 255, 255]) {
public async camera_second_backward () {
const id : string = uuid();
const off : number[] = [0, 0, 0];
let rgb : number[] = [255, 255, 255];
let ms : number;
try {
if (this.cam2.state.dir) {
@ -257,13 +264,14 @@ class Commands {
/**
* Move the both cameras one frame forward
*
* @param {array} rgb Color to set light for frame
* @param {object} cmd Full cmd object
*
* @returns {integer} Length of action in ms
**/
public async cameras_forward (rgb : number[] = [255, 255, 255]) {
public async cameras_forward () {
const id : string = uuid();
const off : number[] = [0, 0, 0];
let rgb : number[] = [255, 255, 255];
let both : number[];
let ms : number;
try {
@ -298,13 +306,14 @@ class Commands {
/**
* Move the both cameras one frame backward
*
* @param {array} rgb Color to set light for frame
* @param {object} cmd Full cmd object
*
* @returns {integer} Length of action in ms
**/
public async cameras_backward (rgb : number[] = [255, 255, 255]) {
public async cameras_backward () {
const id : string = uuid();
const off : number[] = [0, 0, 0];
let rgb : number[] = [255, 255, 255];
let both : number[];
let ms : number;
try {
@ -340,13 +349,14 @@ class Commands {
/**
* Move first camera one frame forward and rewind secondary camera one frame backward
*
* @param {array} rgb Color to set light for frames
* @param {object} cmd Full cmd object
*
* @returns {integer} Length of action in ms
**/
public async camera_forward_camera_second_backward (rgb : number[] = [255, 255, 255]) {
public async camera_forward_camera_second_backward () {
const id : string = uuid();
const off : number[] = [0, 0, 0];
let rgb : number[] = [255, 255, 255];
let both : number[];
let ms : number;
try {
@ -381,13 +391,14 @@ class Commands {
/**
* Rewind first camera one frame backward and move secondary camera one frame forward
*
* @param {array} rgb Color to set light for frame
* @param {object} cmd Full cmd object
*
* @returns {integer} Length of action in ms
**/
public async camera_backward_camera_second_forward (rgb : number[] = [255, 255, 255]) {
public async camera_backward_camera_second_forward () {
const id : string = uuid();
const off : number[] = [0, 0, 0];
let rgb : number[] = [255, 255, 255];
let both : number[];
let ms : number;
try {
@ -589,8 +600,24 @@ class Commands {
}
return ms;
}
/**
* Throws an alert to pause a sequence
*
* @returns {integer} Length of action in ms
**/
public async alert (cmd : any) {
let ms : number;
try {
ms = await this.alertObj.start(cmd.light); //change this meta
} catch (err) {
throw err;
}
return ms;
}
}
module.exports = function (cfg : any, proj : any, cam : any, light : any, cam2 : any, proj2 : any, capper : any) {
return new Commands(cfg, proj, cam, light, cam2, proj2, capper);
module.exports = function (cfg : any, proj : any, cam : any, light : any, alert : any, cam2 : any, proj2 : any, capper : any) {
return new Commands(cfg, proj, cam, light, alert, cam2, proj2, capper);
}

View File

@ -15,8 +15,23 @@ const CMD = [
'BF',
'CB',
'PB',
'BB'
'BB',
'C2F',
'C2B',
'CCF',
'CCB',
'P2F',
'P2B',
'PPF',
'PPB'
];
/*
'CFCB',
'CBCF',
'PFPB',
'PBPF'
*/
const ALTS = {
'CF' : ['CAMERA FORWARD', 'CAM FORWARD'],
'PF' : ['PROJECTOR FORWARD', 'PROJ FORWARD'],
@ -25,9 +40,22 @@ const ALTS = {
'PB' : ['PROJECTOR FORWARD', 'PROJ FORWARD', 'PROJECTOR BACK', 'PROJ BACK'],
'BB' : ['BLACK BACKWARD', 'BLACK BACK', 'BLANK BACK'],
'L ' : ['LIGHT', 'COLOR', 'LAMP'],
'F ' : ['FADE']
'F ' : ['FADE'],
'C2F' : ['CAMERA2 FORWARD', 'CAM2 FORWARD'],
'C2B' : ['CAMERA2 BACKWARD', 'CAM2 BACKWARD', 'CAMERA2 BACK', 'CAM2 BACK'],
'CCF' : ['CAMERAS FORWARD', 'CAMS FORWARD'],
'CCB' : ['CAMERAS BACKWARD', 'CAMS BACKWARD', 'CAMERAS BACK', 'CAMS BACK'],
'P2F' : ['PROJECTOR2 FORWARD', 'PROJ2 FORWARD'],
'P2B' : ['PROJECTOR2 BACKWARD', 'PROJ2 BACKWARD', 'PROJECTOR2 BACK', 'PROJ2 BACK'],
'PPF' : ['PROJECTORS FORWARD', 'PROJS FORWARD'],
'PPB' : ['PROJECTORS BACKWARD', 'PROJS BACKWARD', 'PROJECTORS BACK', 'PROJS BACK'],
};
/*
'CFCB' : [ ],
'CBCF' : [ ],
'PFPB' : [ ],
'PBPF' : [ ]
*/
const PAUSE = 'PAUSE';
const ALERT = 'ALERT';
@ -57,7 +85,9 @@ class Mscript {
output : any;
lines : any[];
cam : number;
cam2 : number;
proj : number;
proj2 : number;
color : string;
loops : any[];
rec : number;
@ -83,7 +113,9 @@ class Mscript {
this.lines = [];
this.cam = 0;
this.cam2 = 0;
this.proj = 0;
this.proj2 = 0;
this.color = '';
this.loops = [];
this.rec = -1;
@ -667,7 +699,7 @@ class Mscript {
this.loops[this.rec].meta
.push(lenStr);
} else {
this.arr.push('AL');
this.arr.push('PA');
this.meta.push(lenStr);
}
}
@ -685,10 +717,10 @@ class Mscript {
this.loops[this.rec].arr
.push('AL');
this.loops[this.rec].meta
.push(msg);
.push(line);
} else {
this.arr.push('AL');
this.meta.push(msg);
this.meta.push(line);
}
}
@ -727,6 +759,14 @@ BF - Black forwards
CB - Camera backwards
PB - Projector backwards
BB - Black backwards
C2F - Camera 2 forwards
C2B - Camera 2 backwards
CCF - Both cameras forwards
CCB - Both cameras backwards
P2F - Projector 2 forwards
P2B - Projector 2 backwards
PPF - Both projectors forwards
PPB - Both projectors backwards
ALERT {MESSAGE} - Stop the sequence and requiure user interaction to complete
PAUSE # - Pause the sequence for a # of seconds

View File

@ -266,8 +266,7 @@ class Sequencer {
const cmdOriginal : string = this.arr[x].cmd;
const cmd : string = this.CMDS[cmdOriginal];
this.log.info(`CMD: '${cmdOriginal}' -> ${cmd}`);
//I wrote this when I was very tired and delirious
return await this.cmd[cmd]();
return await this.cmd[cmd](this.arr[x]);
}
}