2019-03-21 23:33:01 +00:00
|
|
|
'use strict';
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
2020-07-27 01:52:53 +00:00
|
|
|
const uuid_1 = require("uuid");
|
2019-06-09 01:43:14 +00:00
|
|
|
const delay_1 = require("delay");
|
2019-03-21 23:33:01 +00:00
|
|
|
class Commands {
|
2019-07-26 22:30:10 +00:00
|
|
|
/**
|
|
|
|
* @constructor
|
|
|
|
* Assign all connected devices and mock devices as private classes.
|
|
|
|
*
|
|
|
|
* @param {object} cfg Configuration object
|
|
|
|
* @param {object} proj Projector 1
|
|
|
|
* @param {object} cam Camera 1
|
|
|
|
* @param {object} light Light source
|
2023-02-19 05:29:07 +00:00
|
|
|
* @param {object} alert Alert object
|
2019-07-26 22:30:10 +00:00
|
|
|
* @param {object} cam2 (optional) Camera 2
|
2022-08-03 13:02:47 +00:00
|
|
|
* @param {object} proj2 (optional) Projector 2
|
2023-02-19 05:29:07 +00:00
|
|
|
* @param {object} capper Capper object
|
|
|
|
*
|
2019-07-26 22:30:10 +00:00
|
|
|
**/
|
2022-08-03 13:02:47 +00:00
|
|
|
constructor(cfg, proj, cam, light, alert, cam2 = null, proj2 = null, capper = null) {
|
2019-03-21 23:33:01 +00:00
|
|
|
this.cfg = cfg;
|
|
|
|
this.proj = proj;
|
|
|
|
this.cam = cam;
|
|
|
|
this.light = light;
|
2022-08-03 13:02:47 +00:00
|
|
|
this.alertObj = alert;
|
2022-07-15 22:11:26 +00:00
|
|
|
if (cam2 !== null)
|
2019-04-04 22:49:07 +00:00
|
|
|
this.cam2 = cam2;
|
2022-07-15 22:11:26 +00:00
|
|
|
if (proj2 !== null)
|
2019-04-04 22:49:07 +00:00
|
|
|
this.proj2 = proj2;
|
2022-07-15 22:11:26 +00:00
|
|
|
if (capper !== null)
|
|
|
|
this.capper = capper;
|
2019-03-21 23:33:01 +00:00
|
|
|
this.ipc = require('electron').ipcMain;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Move the projector one frame forward
|
2019-07-26 22:30:10 +00:00
|
|
|
*
|
|
|
|
* @returns {integer} Length of action in ms
|
2019-03-21 23:33:01 +00:00
|
|
|
**/
|
2019-03-22 01:02:28 +00:00
|
|
|
async projector_forward() {
|
2019-03-21 23:33:01 +00:00
|
|
|
let ms;
|
|
|
|
try {
|
|
|
|
if (!this.proj.state.dir) {
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-03-21 23:33:01 +00:00
|
|
|
await this.proj.set(true);
|
|
|
|
}
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-03-21 23:33:01 +00:00
|
|
|
ms = await this.proj.move();
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
return ms;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Move the projector one frame backward
|
2019-07-26 22:30:10 +00:00
|
|
|
*
|
|
|
|
* @returns {integer} Length of action in ms
|
2019-03-21 23:33:01 +00:00
|
|
|
**/
|
2019-03-22 01:02:28 +00:00
|
|
|
async projector_backward() {
|
2019-03-21 23:33:01 +00:00
|
|
|
let ms;
|
|
|
|
try {
|
|
|
|
if (this.proj.state.dir) {
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-03-21 23:33:01 +00:00
|
|
|
await this.proj.set(false);
|
|
|
|
}
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-03-21 23:33:01 +00:00
|
|
|
ms = await this.proj.move();
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
return ms;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Move the camera one frame forward
|
|
|
|
*
|
2022-08-03 13:02:47 +00:00
|
|
|
* @param {object} cmd Full cmd object
|
2019-07-26 22:30:10 +00:00
|
|
|
*
|
|
|
|
* @returns {integer} Length of action in ms
|
2019-03-21 23:33:01 +00:00
|
|
|
**/
|
2022-08-03 13:02:47 +00:00
|
|
|
async camera_forward() {
|
2020-07-27 01:52:53 +00:00
|
|
|
const id = uuid_1.v4();
|
2019-03-21 23:33:01 +00:00
|
|
|
const off = [0, 0, 0];
|
2022-08-03 13:02:47 +00:00
|
|
|
let rgb = [255, 255, 255];
|
2019-03-21 23:33:01 +00:00
|
|
|
let ms;
|
|
|
|
try {
|
|
|
|
if (!this.cam.state.dir) {
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-03-21 23:33:01 +00:00
|
|
|
await this.cam.set(true);
|
|
|
|
}
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2020-07-27 01:52:53 +00:00
|
|
|
await this.light.set(rgb, id);
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-03-21 23:33:01 +00:00
|
|
|
ms = await this.cam.move();
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2020-07-27 01:52:53 +00:00
|
|
|
await this.light.set(off, id);
|
2019-03-21 23:33:01 +00:00
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
return ms;
|
|
|
|
}
|
|
|
|
/**
|
2019-07-26 22:30:10 +00:00
|
|
|
* Move the camera one frame forward with light off
|
|
|
|
*
|
|
|
|
* @returns {integer} Length of action in ms
|
2019-03-21 23:33:01 +00:00
|
|
|
**/
|
|
|
|
async black_forward() {
|
2020-07-27 01:52:53 +00:00
|
|
|
const id = uuid_1.v4();
|
2019-03-21 23:33:01 +00:00
|
|
|
const off = [0, 0, 0];
|
2022-07-15 22:11:26 +00:00
|
|
|
let ms = 0;
|
2019-03-21 23:33:01 +00:00
|
|
|
try {
|
|
|
|
if (!this.cam.state.dir) {
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-03-21 23:33:01 +00:00
|
|
|
await this.cam.set(true);
|
|
|
|
}
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2022-07-15 22:11:26 +00:00
|
|
|
if (this.capper) {
|
|
|
|
ms += await this.capper.capper(true, id);
|
|
|
|
}
|
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2020-07-27 01:52:53 +00:00
|
|
|
await this.light.set(off, id); //make sure set to off
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2022-07-15 22:11:26 +00:00
|
|
|
ms += await this.cam.move();
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2020-07-27 01:52:53 +00:00
|
|
|
await this.light.set(off, id);
|
2022-07-15 22:11:26 +00:00
|
|
|
if (this.capper) {
|
|
|
|
ms += await this.capper.capper(false, id);
|
|
|
|
}
|
2019-03-21 23:33:01 +00:00
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
return ms;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Move the camera one frame backward
|
|
|
|
*
|
2022-08-03 13:02:47 +00:00
|
|
|
* @param {object} cmd Full cmd object
|
2019-07-26 22:30:10 +00:00
|
|
|
*
|
|
|
|
* @returns {integer} Length of action in ms
|
2019-03-21 23:33:01 +00:00
|
|
|
**/
|
2022-08-03 13:02:47 +00:00
|
|
|
async camera_backward() {
|
2020-07-27 01:52:53 +00:00
|
|
|
const id = uuid_1.v4();
|
2019-03-21 23:33:01 +00:00
|
|
|
const off = [0, 0, 0];
|
2022-08-03 13:02:47 +00:00
|
|
|
let rgb = [255, 255, 255];
|
2019-03-21 23:33:01 +00:00
|
|
|
let ms;
|
|
|
|
try {
|
|
|
|
if (this.cam.state.dir) {
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-03-21 23:33:01 +00:00
|
|
|
await this.cam.set(false);
|
|
|
|
}
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2020-07-27 01:52:53 +00:00
|
|
|
await this.light.set(rgb, id);
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-03-21 23:33:01 +00:00
|
|
|
ms = await this.cam.move();
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2020-07-27 01:52:53 +00:00
|
|
|
await this.light.set(off, id);
|
2019-03-21 23:33:01 +00:00
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
return ms;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Move the camera one frame forward, light set to black or off
|
|
|
|
*
|
2019-07-26 22:30:10 +00:00
|
|
|
* @returns {integer} Length of action in ms
|
2019-03-21 23:33:01 +00:00
|
|
|
**/
|
|
|
|
async black_backward() {
|
2020-07-27 01:52:53 +00:00
|
|
|
const id = uuid_1.v4();
|
2019-03-21 23:33:01 +00:00
|
|
|
const off = [0, 0, 0];
|
2022-07-15 22:11:26 +00:00
|
|
|
let ms = 0;
|
2019-03-21 23:33:01 +00:00
|
|
|
try {
|
|
|
|
if (this.cam.state.dir) {
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-03-21 23:33:01 +00:00
|
|
|
await this.cam.set(false);
|
|
|
|
}
|
2022-07-15 22:11:26 +00:00
|
|
|
if (this.capper) {
|
|
|
|
ms += await this.capper.capper(true, id);
|
|
|
|
}
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2020-07-27 01:52:53 +00:00
|
|
|
await this.light.set(off, id); //make sure set to off
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2022-07-15 22:11:26 +00:00
|
|
|
ms += await this.cam.move();
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2020-07-27 01:52:53 +00:00
|
|
|
await this.light.set(off, id);
|
2022-07-15 22:11:26 +00:00
|
|
|
if (this.capper) {
|
|
|
|
ms += await this.capper.capper(false, id);
|
|
|
|
}
|
2019-03-21 23:33:01 +00:00
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
return ms;
|
|
|
|
}
|
2019-04-04 22:49:07 +00:00
|
|
|
/**
|
|
|
|
* Move the second camera one frame forward
|
|
|
|
*
|
2022-08-03 13:02:47 +00:00
|
|
|
* @param {object} cmd Full cmd object
|
2019-07-26 22:30:10 +00:00
|
|
|
*
|
|
|
|
* @returns {integer} Length of action in ms
|
2019-04-04 22:49:07 +00:00
|
|
|
**/
|
2022-08-03 13:02:47 +00:00
|
|
|
async camera_second_forward() {
|
2020-07-27 01:52:53 +00:00
|
|
|
const id = uuid_1.v4();
|
2019-04-04 22:49:07 +00:00
|
|
|
const off = [0, 0, 0];
|
2022-08-03 13:02:47 +00:00
|
|
|
let rgb = [255, 255, 255];
|
2019-04-04 22:49:07 +00:00
|
|
|
let ms;
|
|
|
|
try {
|
|
|
|
if (!this.cam2.state.dir) {
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
await this.cam2.set(true);
|
|
|
|
}
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2020-07-27 01:52:53 +00:00
|
|
|
await this.light.set(rgb, id);
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
ms = await this.cam2.move();
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2020-07-27 01:52:53 +00:00
|
|
|
await this.light.set(off, id);
|
2019-04-04 22:49:07 +00:00
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
return ms;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Move the second camera one frame backward
|
|
|
|
*
|
2022-08-03 13:02:47 +00:00
|
|
|
* @param {object} cmd Full cmd object
|
2019-07-26 22:30:10 +00:00
|
|
|
*
|
|
|
|
* @returns {integer} Length of action in ms
|
2019-04-04 22:49:07 +00:00
|
|
|
**/
|
2022-08-03 13:02:47 +00:00
|
|
|
async camera_second_backward() {
|
2020-07-27 01:52:53 +00:00
|
|
|
const id = uuid_1.v4();
|
2019-04-04 22:49:07 +00:00
|
|
|
const off = [0, 0, 0];
|
2022-08-03 13:02:47 +00:00
|
|
|
let rgb = [255, 255, 255];
|
2019-04-04 22:49:07 +00:00
|
|
|
let ms;
|
|
|
|
try {
|
|
|
|
if (this.cam2.state.dir) {
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
await this.cam2.set(false);
|
|
|
|
}
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2020-07-27 01:52:53 +00:00
|
|
|
await this.light.set(rgb, id);
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
ms = await this.cam2.move();
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2020-07-27 01:52:53 +00:00
|
|
|
await this.light.set(off, id);
|
2019-04-04 22:49:07 +00:00
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
return ms;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Move the both cameras one frame forward
|
|
|
|
*
|
2022-08-03 13:02:47 +00:00
|
|
|
* @param {object} cmd Full cmd object
|
2019-07-26 22:30:10 +00:00
|
|
|
*
|
|
|
|
* @returns {integer} Length of action in ms
|
2019-04-04 22:49:07 +00:00
|
|
|
**/
|
2022-08-03 13:02:47 +00:00
|
|
|
async cameras_forward() {
|
2020-07-27 01:52:53 +00:00
|
|
|
const id = uuid_1.v4();
|
2019-04-04 22:49:07 +00:00
|
|
|
const off = [0, 0, 0];
|
2022-08-03 13:02:47 +00:00
|
|
|
let rgb = [255, 255, 255];
|
2019-04-04 22:49:07 +00:00
|
|
|
let both;
|
|
|
|
let ms;
|
|
|
|
try {
|
|
|
|
if (!this.cam.state.dir) {
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
await this.cam.set(true);
|
|
|
|
}
|
|
|
|
if (!this.cam2.state.dir) {
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
await this.cam2.set(true);
|
|
|
|
}
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2020-07-27 01:52:53 +00:00
|
|
|
await this.light.set(rgb, id);
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) {
|
|
|
|
ms = await this.cam.both();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.cam.move();
|
2019-04-16 14:01:42 +00:00
|
|
|
this.cam2.move();
|
|
|
|
both = [await this.cam.move, await this.cam2.move];
|
2019-04-04 22:49:07 +00:00
|
|
|
ms = Math.max(...both);
|
|
|
|
}
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2020-07-27 01:52:53 +00:00
|
|
|
await this.light.set(off, id);
|
2019-04-04 22:49:07 +00:00
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
return ms;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Move the both cameras one frame backward
|
|
|
|
*
|
2022-08-03 13:02:47 +00:00
|
|
|
* @param {object} cmd Full cmd object
|
2019-07-26 22:30:10 +00:00
|
|
|
*
|
|
|
|
* @returns {integer} Length of action in ms
|
2019-04-04 22:49:07 +00:00
|
|
|
**/
|
2022-08-03 13:02:47 +00:00
|
|
|
async cameras_backward() {
|
2020-07-27 01:52:53 +00:00
|
|
|
const id = uuid_1.v4();
|
2019-04-04 22:49:07 +00:00
|
|
|
const off = [0, 0, 0];
|
2022-08-03 13:02:47 +00:00
|
|
|
let rgb = [255, 255, 255];
|
2019-04-04 22:49:07 +00:00
|
|
|
let both;
|
|
|
|
let ms;
|
|
|
|
try {
|
|
|
|
if (this.cam.state.dir) {
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
await this.cam.set(false);
|
|
|
|
}
|
|
|
|
if (this.cam2.state.dir) {
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
await this.cam2.set(false);
|
|
|
|
}
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2020-07-27 01:52:53 +00:00
|
|
|
await this.light.set(rgb, id);
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) {
|
|
|
|
ms = await this.cam.both();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.cam.move();
|
2019-04-16 14:01:42 +00:00
|
|
|
this.cam2.move();
|
|
|
|
both = [await this.cam.move, await this.cam2.move];
|
2019-04-04 22:49:07 +00:00
|
|
|
ms = Math.max(...both);
|
|
|
|
}
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2020-07-27 01:52:53 +00:00
|
|
|
await this.light.set(off, id);
|
2019-04-04 22:49:07 +00:00
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
return ms;
|
|
|
|
}
|
2019-07-26 22:30:10 +00:00
|
|
|
/**
|
|
|
|
* Move first camera one frame forward and rewind secondary camera one frame backward
|
|
|
|
*
|
2022-08-03 13:02:47 +00:00
|
|
|
* @param {object} cmd Full cmd object
|
2019-07-26 22:30:10 +00:00
|
|
|
*
|
|
|
|
* @returns {integer} Length of action in ms
|
|
|
|
**/
|
2022-08-03 13:02:47 +00:00
|
|
|
async camera_forward_camera_second_backward() {
|
2020-07-27 01:52:53 +00:00
|
|
|
const id = uuid_1.v4();
|
2019-04-04 22:49:07 +00:00
|
|
|
const off = [0, 0, 0];
|
2022-08-03 13:02:47 +00:00
|
|
|
let rgb = [255, 255, 255];
|
2019-04-04 22:49:07 +00:00
|
|
|
let both;
|
|
|
|
let ms;
|
|
|
|
try {
|
|
|
|
if (!this.cam.state.dir) {
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
await this.cam.set(true);
|
|
|
|
}
|
|
|
|
if (this.cam2.state.dir) {
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
await this.cam2.set(false);
|
|
|
|
}
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2020-07-27 01:52:53 +00:00
|
|
|
await this.light.set(rgb, id);
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) {
|
|
|
|
ms = await this.cam.both();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.cam.move();
|
2019-04-16 14:01:42 +00:00
|
|
|
this.cam2.move();
|
|
|
|
both = [await this.cam.move, await this.cam2.move];
|
2019-04-04 22:49:07 +00:00
|
|
|
ms = Math.max(...both);
|
|
|
|
}
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2020-07-27 01:52:53 +00:00
|
|
|
await this.light.set(off, id);
|
2019-04-04 22:49:07 +00:00
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
return ms;
|
|
|
|
}
|
2019-07-26 22:30:10 +00:00
|
|
|
/**
|
|
|
|
* Rewind first camera one frame backward and move secondary camera one frame forward
|
|
|
|
*
|
2022-08-03 13:02:47 +00:00
|
|
|
* @param {object} cmd Full cmd object
|
2019-07-26 22:30:10 +00:00
|
|
|
*
|
|
|
|
* @returns {integer} Length of action in ms
|
|
|
|
**/
|
2022-08-03 13:02:47 +00:00
|
|
|
async camera_backward_camera_second_forward() {
|
2020-07-27 01:52:53 +00:00
|
|
|
const id = uuid_1.v4();
|
2019-04-04 22:49:07 +00:00
|
|
|
const off = [0, 0, 0];
|
2022-08-03 13:02:47 +00:00
|
|
|
let rgb = [255, 255, 255];
|
2019-04-04 22:49:07 +00:00
|
|
|
let both;
|
|
|
|
let ms;
|
|
|
|
try {
|
|
|
|
if (this.cam.state.dir) {
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
await this.cam.set(false);
|
|
|
|
}
|
|
|
|
if (!this.cam2.state.dir) {
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
await this.cam2.set(true);
|
|
|
|
}
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2020-07-27 01:52:53 +00:00
|
|
|
await this.light.set(rgb, id);
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) {
|
|
|
|
ms = await this.cam.both();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.cam.move();
|
|
|
|
this.cam.move();
|
|
|
|
both = [await this.cam.move, await this.proj2.move];
|
|
|
|
ms = Math.max(...both);
|
|
|
|
}
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2020-07-27 01:52:53 +00:00
|
|
|
await this.light.set(off, id);
|
2019-04-04 22:49:07 +00:00
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
return ms;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Move the secondary projector forward one frame
|
|
|
|
*
|
2019-07-26 22:30:10 +00:00
|
|
|
* @returns {integer} Length of action in ms
|
2019-04-04 22:49:07 +00:00
|
|
|
**/
|
|
|
|
async projector_second_forward() {
|
|
|
|
let ms;
|
|
|
|
try {
|
|
|
|
if (!this.proj2.state.dir) {
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
await this.proj2.set(true);
|
|
|
|
}
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
ms = await this.proj2.move();
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
return ms;
|
|
|
|
}
|
2019-07-26 22:30:10 +00:00
|
|
|
/**
|
|
|
|
* Rewind the secondary projector backward one frame
|
|
|
|
*
|
|
|
|
* @returns {integer} Length of action in ms
|
|
|
|
**/
|
2019-04-04 22:49:07 +00:00
|
|
|
async projector_second_backward() {
|
|
|
|
let ms;
|
|
|
|
try {
|
|
|
|
if (this.proj2.state.dir) {
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
await this.proj2.set(false);
|
|
|
|
}
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
ms = await this.proj2.move();
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
return ms;
|
|
|
|
}
|
2019-07-26 22:30:10 +00:00
|
|
|
/**
|
|
|
|
* Move the both projectors forward one frame
|
|
|
|
*
|
|
|
|
* @returns {integer} Length of action in ms
|
|
|
|
**/
|
2019-04-04 22:49:07 +00:00
|
|
|
async projectors_forward() {
|
|
|
|
let both;
|
|
|
|
let ms;
|
|
|
|
try {
|
|
|
|
if (!this.proj.state.dir) {
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
await this.proj.set(true);
|
|
|
|
}
|
|
|
|
if (!this.proj2.state.dir) {
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
await this.proj2.set(true);
|
|
|
|
}
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
if (this.proj && this.proj2 && this.proj.arduino.alias.projector === this.proj.arduino.alias.projector_second) {
|
|
|
|
ms = await this.proj.both();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.proj.move();
|
|
|
|
this.proj2.move();
|
|
|
|
both = [await this.proj.move, await this.proj2.move];
|
|
|
|
ms = Math.max(...both);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
return ms;
|
|
|
|
}
|
2019-07-26 22:30:10 +00:00
|
|
|
/**
|
|
|
|
* Rewind both projectors backwards one frame
|
|
|
|
*
|
|
|
|
* @returns {integer} Length of action in ms
|
|
|
|
**/
|
2019-04-04 22:49:07 +00:00
|
|
|
async projectors_backward() {
|
|
|
|
let both;
|
|
|
|
let ms;
|
|
|
|
try {
|
|
|
|
if (this.proj.state.dir) {
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
await this.proj.set(false);
|
|
|
|
}
|
|
|
|
if (this.proj2.state.dir) {
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
await this.proj2.set(false);
|
|
|
|
}
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
//run one projector without await?
|
|
|
|
if (this.proj && this.proj2 && this.proj.arduino.alias.projector === this.proj.arduino.alias.projector_second) {
|
|
|
|
ms = await this.proj.both();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.proj.move();
|
|
|
|
this.proj2.move();
|
|
|
|
both = [await this.proj.move, await this.proj2.move];
|
|
|
|
ms = Math.max(...both);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
return ms;
|
|
|
|
}
|
2019-07-26 22:30:10 +00:00
|
|
|
/**
|
|
|
|
* Move the primary projector forward one frame and rewind the secondary projector
|
|
|
|
* one frame backwards.
|
|
|
|
*
|
|
|
|
* @returns {integer} Length of action in ms
|
|
|
|
**/
|
2019-04-04 22:49:07 +00:00
|
|
|
async projector_forward_projector_second_backward() {
|
|
|
|
let both;
|
|
|
|
let ms;
|
|
|
|
try {
|
|
|
|
if (!this.proj.state.dir) {
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
await this.proj.set(true);
|
|
|
|
}
|
|
|
|
if (this.proj2.state.dir) {
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
await this.proj2.set(false);
|
|
|
|
}
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
//run one projector without await?
|
|
|
|
if (this.proj && this.proj2 && this.proj.arduino.alias.projector === this.proj.arduino.alias.projector_second) {
|
|
|
|
ms = await this.proj.both();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.proj.move();
|
|
|
|
this.proj2.move();
|
|
|
|
both = [await this.proj.move, await this.proj2.move];
|
|
|
|
ms = Math.max(...both);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
return ms;
|
|
|
|
}
|
2019-07-26 22:30:10 +00:00
|
|
|
/**
|
|
|
|
* Rewind the primary projector backwards one frame and move the secondary
|
|
|
|
* projector forward one frame.
|
|
|
|
*
|
|
|
|
* @returns {integer} Length of action in ms
|
|
|
|
**/
|
2019-04-04 22:49:07 +00:00
|
|
|
async projector_backward_projector_second_forward() {
|
|
|
|
let both;
|
|
|
|
let ms;
|
|
|
|
try {
|
|
|
|
if (this.proj.state.dir) {
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
await this.proj.set(false);
|
|
|
|
}
|
|
|
|
if (!this.proj2.state.dir) {
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
await this.proj2.set(true);
|
|
|
|
}
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(this.cfg.arduino.serialDelay);
|
2019-04-04 22:49:07 +00:00
|
|
|
//run one projector without await?
|
|
|
|
if (this.proj && this.proj2 && this.proj.arduino.alias.projector === this.proj.arduino.alias.projector_second) {
|
|
|
|
ms = await this.proj.both();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.proj.move();
|
|
|
|
this.proj2.move();
|
|
|
|
both = [await this.proj.move, await this.proj2.move];
|
|
|
|
ms = Math.max(...both);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
return ms;
|
|
|
|
}
|
2022-08-03 13:02:47 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
return ms;
|
|
|
|
}
|
2023-02-28 17:49:11 +00:00
|
|
|
/**
|
|
|
|
* Pauses a sequence for a length of time
|
|
|
|
*
|
|
|
|
* @returns {integer} Length of action in ms
|
|
|
|
**/
|
|
|
|
async pause(cmd) {
|
|
|
|
let ms;
|
|
|
|
try {
|
|
|
|
ms = await delay_1.delay(cmd.light * 1000); //delay is in seconds
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
return ms;
|
|
|
|
}
|
2023-07-05 19:17:45 +00:00
|
|
|
async camera_exposure(cmd) {
|
|
|
|
let ms;
|
|
|
|
try {
|
|
|
|
ms = await this.cam.exposure(cmd.light);
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
return ms;
|
|
|
|
}
|
2019-03-21 23:33:01 +00:00
|
|
|
}
|
2022-08-03 13:02:47 +00:00
|
|
|
module.exports = function (cfg, proj, cam, light, alert, cam2, proj2, capper) {
|
|
|
|
return new Commands(cfg, proj, cam, light, alert, cam2, proj2, capper);
|
2019-03-21 23:33:01 +00:00
|
|
|
};
|
|
|
|
//# sourceMappingURL=index.js.map
|