Secondary projector and secondary camera behaviors have been added to the main process. This is not represented in the UI... yet. All renderer code is still in flux.

This commit is contained in:
mmcwilliams 2019-04-04 18:49:07 -04:00
parent 18c515402e
commit 7a52bc7c6e
57 changed files with 2216 additions and 357 deletions

View File

@ -404,46 +404,94 @@ button:focus {
padding-bottom: 21px;
padding-left: 70px;
}
#sequence #cam_forward,
#sequence #proj_forward,
#sequence #camera_forward,
#sequence #camera_second_forward,
#sequence #projector_forward,
#sequence #projector_second_forward,
#sequence #black_forward {
clear: both;
}
#sequence #cam_forward input[type=checkbox],
#sequence #proj_forward input[type=checkbox],
#sequence #camera_forward input[type=checkbox],
#sequence #camera_second_forward input[type=checkbox],
#sequence #projector_forward input[type=checkbox],
#sequence #projector_second_forward input[type=checkbox],
#sequence #black_forward input[type=checkbox] {
border: 2px solid #00C4A0;
}
#sequence #cam_forward input[type=checkbox]:checked,
#sequence #proj_forward input[type=checkbox]:checked,
#sequence #camera_forward input[type=checkbox]:checked,
#sequence #camera_second_forward input[type=checkbox]:checked,
#sequence #projector_forward input[type=checkbox]:checked,
#sequence #projector_second_forward input[type=checkbox]:checked,
#sequence #black_forward input[type=checkbox]:checked {
background: #00C4A0;
}
#sequence #cam_forward > div,
#sequence #proj_forward > div,
#sequence #camera_forward > div,
#sequence #camera_second_forward > div,
#sequence #projector_forward > div,
#sequence #projector_second_forward > div,
#sequence #black_forward > div {
color: #00C4A0;
}
#sequence #cam_backward,
#sequence #proj_backward,
#sequence #camera_backward,
#sequence #camera_second_backward,
#sequence #projector_backward,
#sequence #projector_second_backward,
#sequence #black_backward {
clear: both;
}
#sequence #cam_backward input[type=checkbox],
#sequence #proj_backward input[type=checkbox],
#sequence #camera_backward input[type=checkbox],
#sequence #camera_second_backward input[type=checkbox],
#sequence #projector_backward input[type=checkbox],
#sequence #projector_second_backward input[type=checkbox],
#sequence #black_backward input[type=checkbox] {
border: 2px solid #AB1A25;
}
#sequence #cam_backward input[type=checkbox]:checked,
#sequence #proj_backward input[type=checkbox]:checked,
#sequence #camera_backward input[type=checkbox]:checked,
#sequence #camera_second_backward input[type=checkbox]:checked,
#sequence #projector_backward input[type=checkbox]:checked,
#sequence #projector_second_backward input[type=checkbox]:checked,
#sequence #black_backward input[type=checkbox]:checked {
background: #AB1A25;
}
#sequence #cam_backward > div,
#sequence #proj_backward > div,
#sequence #camera_backward > div,
#sequence #camera_second_backward > div,
#sequence #projector_backward > div,
#sequence #projector_second_backward > div,
#sequence #black_backward > div {
color: #AB1A25;
}
#sequence #camera_second_forward,
#sequence #projector_second_forward {
display: none;
}
#sequence #camera_second_forward input[type=checkbox],
#sequence #projector_second_forward input[type=checkbox] {
border: 2px solid #14d8b4;
}
#sequence #camera_second_forward input[type=checkbox]:checked,
#sequence #projector_second_forward input[type=checkbox]:checked {
background: #14d8b4;
}
#sequence #camera_second_forward > div,
#sequence #projector_second_forward > div {
color: #14d8b4;
}
#sequence #camera_second_backward,
#sequence #projector_second_backward {
display: none;
}
#sequence #camera_second_backward input[type=checkbox],
#sequence #projector_second_backward input[type=checkbox] {
border: 2px solid #bf2e39;
}
#sequence #camera_second_backward input[type=checkbox]:checked,
#sequence #projector_second_backward input[type=checkbox]:checked {
background: #bf2e39;
}
#sequence #camera_second_backward > div,
#sequence #projector_second_backward > div {
color: #bf2e39;
}
#sequence input[type=checkbox] {
-webkit-appearance: none;
-moz-appearance: none;

View File

@ -146,7 +146,10 @@
"camera_second_forward": "1",
"camera_second_backward": "2",
"camera_second": "3",
"cameras": "4"
"cameras": "4",
"camera_projectors_identifier" : "5",
"cameras_projector_identifier" : "6",
"cameras_projectors_identifier" : "7"
}
}
}

View File

@ -27,10 +27,16 @@
</div>
<div id="seq_scroll">
<div id="sequence">
<div id="cam_forward" class="row" y="0"></div>
<div id="proj_forward" class="row" y="1"></div>
<div id="cam_backward" class="row spacer" y="0"></div>
<div id="proj_backward" class="row" y="1"></div>
<div id="camera_forward" class="row" y="0"></div>
<div id="camera_second_forward" class="row" y="2"></div>
<div id="projector_forward" class="row" y="1"></div>
<div id="projector_second_forward" class="row" y="3"></div>
<div id="camera_backward" class="row spacer" y="0"></div>
<div id="camera_second_backward" class="row" y="2"></div>
<div id="projector_backward" class="row" y="1"></div>
<div id="projector_second_backward" class="row" y="3"></div>
<div id="light_set" class="row spacer"></div>
<div id="numbers" class="row"></div>
</div>

View File

@ -68,36 +68,66 @@
width: 970px;
padding-bottom: 21px;
padding-left: 70px;
#cam_forward,
#proj_forward,
#camera_forward,
#camera_second_forward,
#projector_forward,
#projector_second_forward,
#black_forward{
clear: both;
input[type=checkbox]{
border: 2px solid @FORWARD;
&:checked{
background: @FORWARD;
//background: radial-gradient(circle at 25px 25px, #00C4A0, #343434);
}
}
>div{
color: @FORWARD;
}
}
#cam_backward,
#proj_backward,
#camera_backward,
#camera_second_backward,
#projector_backward,
#projector_second_backward,
#black_backward{
clear: both;
input[type=checkbox]{
border: 2px solid @BACKWARD;
&:checked{
background: @BACKWARD;
//background: radial-gradient(circle at 25px 25px, #AB1A25, #343434);
}
}
>div{
color: @BACKWARD;
}
}
#camera_second_forward,
#projector_second_forward {
display: none;
input[type=checkbox]{
border: 2px solid @FORWARD + @SECOND;
&:checked{
background: @FORWARD + @SECOND;
}
}
>div{
color: @FORWARD + @SECOND;
}
}
#camera_second_backward,
#projector_second_backward{
display: none;
input[type=checkbox]{
border: 2px solid @BACKWARD + @SECOND;
&:checked{
background: @BACKWARD + @SECOND;
}
}
>div{
color: @BACKWARD + @SECOND;
}
}
input[type=checkbox]{
-webkit-appearance: none;
-moz-appearance: none;

View File

@ -5,6 +5,7 @@
@FORWARD: #00C4A0;
@BACKWARD: #AB1A25;
@SELECTED: #DAE035;
@SECOND : rgb(20, 20, 20);
@SEQ: #3C3636;
@SCRIPT: rgb(39, 40, 34);

View File

@ -99,6 +99,7 @@ class Arduino {
if (this.locks[serial]) {
return false;
}
this.timer = new Date().getTime();
this.locks[serial] = true;
await delay(cfg.arduino.serialDelay);
try {
@ -108,8 +109,8 @@ class Arduino {
return console.error(e);
}
this.locks[serial] = false;
this.timer = new Date().getTime();
return await eventEmitter.emit('arduino_send', cmd);
await eventEmitter.emit('arduino_send', cmd);
return results;
}
async string(serial, str) {
const device = this.alias[serial];
@ -160,10 +161,10 @@ class Arduino {
else {
//console.log('Received stray "' + data + '"'); //silent to user
}
return complete;
return ms;
}
aliasSerial(serial, device) {
//console.log(`Making "${serial}" an alias of ${device}`)
//this.log.info(`Making "${serial}" an alias of ${device}`);
this.alias[serial] = device;
}
async connect(serial, device, confirm) {
@ -273,21 +274,27 @@ class Arduino {
else if (data === cfg.arduino.cmd.projector_camera_identifier) {
type = 'projector,camera';
}
else if (data === cfg.ardino.cmd.projector_second_identifier) {
else if (data === cfg.arduino.cmd.projector_second_identifier) {
type = 'projector_second';
}
else if (data === cfg.ardino.cmd.projectors_identifier) {
else if (data === cfg.arduino.cmd.projectors_identifier) {
type = 'projector,projector_second';
}
else if (data === cfg.ardino.cmd.camera_second_identifier) {
else if (data === cfg.arduino.cmd.camera_second_identifier) {
type = 'camera_second';
}
else if (data === cfg.ardino.cmd.cameras_identifier) {
else if (data === cfg.arduino.cmd.cameras_identifier) {
type = 'camera,camera_second';
}
//camera,projector,projector_second
//camera,camera_second,projector
//camera,camera_second,projector,projector_second
else if (data === cfg.arduino.cmd.camera_projectors_identifier) {
type = 'camera,projector,projector_second';
}
else if (data === cfg.arduino.cmd.cameras_projector_identifier) {
type = 'camera,camera_second,projector';
}
else if (data === cfg.arduino.cmd.cameras_projectors_identifier) {
type = 'camera,camera_second,projector,projector_second';
}
return resolve(type);
};
await delay(cfg.arduino.serialDelay);

File diff suppressed because one or more lines are too long

View File

@ -99,9 +99,22 @@ class Camera {
//await delay(100 * 1000);
await this.dig.end();
}
this.log.info('Camera move time', { ms });
//this.log.info('Camera move time', { ms });
return this.end(cmd, id, ms);
}
async both(frame, id) {
id = 'cameras';
const cmd = this.cfg.arduino.cmd[id];
let ms;
try {
ms = await this.arduino.send(this.id, cmd);
}
catch (err) {
this.log.error(`Error moving ${this.id}`, err);
}
//this.log.info('Cameras move time', { ms });
return await this.end(cmd, id, ms);
}
/**
*
**/
@ -199,11 +212,15 @@ class Camera {
}
message += ' 1 frame';
}
else if (cmd === this.cfg.arduino.cmd.camerass) {
message += 'Cameras both MOVED 1 frame each';
}
message += ` ${ms}ms`;
this.log.info(message);
this.ui.send(this.id, { cmd: cmd, id: id, ms: ms });
}
}
module.exports = function (arduino, cfg, ui, dig) {
return new Camera(arduino, cfg, ui, dig);
module.exports = function (arduino, cfg, ui, dig, second) {
return new Camera(arduino, cfg, ui, dig, second);
};
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@ -2,11 +2,15 @@
Object.defineProperty(exports, "__esModule", { value: true });
const delay = require("delay");
class Commands {
constructor(cfg, proj, cam, light) {
constructor(cfg, proj, cam, light, cam2 = null, proj2 = null) {
this.cfg = cfg;
this.proj = proj;
this.cam = cam;
this.light = light;
if (cam2)
this.cam2 = cam2;
if (proj2)
this.proj2 = proj2;
this.ipc = require('electron').ipcMain;
}
/**
@ -142,8 +146,349 @@ class Commands {
}
return ms;
}
/**
* Move the second camera one frame forward
*
* @param {array} rgb Color to set light for frame
**/
async camera_second_forward(rgb = [255, 255, 255]) {
const off = [0, 0, 0];
let ms;
try {
if (!this.cam2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam2.set(true);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await delay(this.cfg.arduino.serialDelay);
ms = await this.cam2.move();
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
}
catch (err) {
throw err;
}
return ms;
}
/**
* Move the second camera one frame backward
*
* @param {array} rgb Color to set light for frame
**/
async camera_second_backward(rgb = [255, 255, 255]) {
const off = [0, 0, 0];
let ms;
try {
if (this.cam2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam2.set(false);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await delay(this.cfg.arduino.serialDelay);
ms = await this.cam2.move();
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
}
catch (err) {
throw err;
}
return ms;
}
/**
* Move the both cameras one frame forward
*
* @param {array} rgb Color to set light for frame
**/
async cameras_forward(rgb = [255, 255, 255]) {
const off = [0, 0, 0];
let both;
let ms;
try {
if (!this.cam.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam.set(true);
}
if (!this.cam2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam2.set(true);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await delay(this.cfg.arduino.serialDelay);
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);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
}
catch (err) {
throw err;
}
return ms;
}
/**
* Move the both cameras one frame backward
*
* @param {array} rgb Color to set light for frame
**/
async cameras_backward(rgb = [255, 255, 255]) {
const off = [0, 0, 0];
let both;
let ms;
try {
if (this.cam.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam.set(false);
}
if (this.cam2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam2.set(false);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await delay(this.cfg.arduino.serialDelay);
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);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
}
catch (err) {
throw err;
}
return ms;
}
async camera_forward_camera_second_backward(rgb = [255, 255, 255]) {
const off = [0, 0, 0];
let both;
let ms;
try {
if (!this.cam.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam.set(true);
}
if (this.cam2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam2.set(false);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await delay(this.cfg.arduino.serialDelay);
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);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
}
catch (err) {
throw err;
}
return ms;
}
async camera_backward_camera_second_forward(rgb = [255, 255, 255]) {
const off = [0, 0, 0];
let both;
let ms;
try {
if (this.cam.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam.set(false);
}
if (!this.cam2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam2.set(true);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await delay(this.cfg.arduino.serialDelay);
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);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
}
catch (err) {
throw err;
}
return ms;
}
/**
* Move the secondary projector forward one frame
*
**/
async projector_second_forward() {
let ms;
try {
if (!this.proj2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj2.set(true);
}
await delay(this.cfg.arduino.serialDelay);
ms = await this.proj2.move();
}
catch (err) {
throw err;
}
return ms;
}
async projector_second_backward() {
let ms;
try {
if (this.proj2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj2.set(false);
}
await delay(this.cfg.arduino.serialDelay);
ms = await this.proj2.move();
}
catch (err) {
throw err;
}
return ms;
}
async projectors_forward() {
let both;
let ms;
try {
if (!this.proj.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj.set(true);
}
if (!this.proj2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj2.set(true);
}
await delay(this.cfg.arduino.serialDelay);
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;
}
async projectors_backward() {
let both;
let ms;
try {
if (this.proj.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj.set(false);
}
if (this.proj2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj2.set(false);
}
await delay(this.cfg.arduino.serialDelay);
//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;
}
async projector_forward_projector_second_backward() {
let both;
let ms;
try {
if (!this.proj.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj.set(true);
}
if (this.proj2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj2.set(false);
}
await delay(this.cfg.arduino.serialDelay);
//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;
}
async projector_backward_projector_second_forward() {
let both;
let ms;
try {
if (this.proj.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj.set(false);
}
if (!this.proj2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj2.set(true);
}
await delay(this.cfg.arduino.serialDelay);
//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;
}
}
module.exports = function (cfg, proj, cam, light) {
return new Commands(cfg, proj, cam, light);
module.exports = function (cfg, proj, cam, light, cam2, proj2) {
return new Commands(cfg, proj, cam, light, cam2, proj2);
};
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@ -256,7 +256,6 @@ class Devices {
}
else if (type === 'projector_second') {
this.connected.projector_second = device;
this.arduino.aliasSerial('projector_second', device);
try {
connectSuccess = await this.arduino.connect('projector_second', device, false);
}
@ -267,38 +266,83 @@ class Devices {
this.log.info(`Connected to ${device} as PROJECTOR_SECOND`, 'SERIAL', true, true);
}
else if (type === 'projector,projector_second') {
/*this.connected.projector_second = device
this.arduino.aliasSerial('projector_second', device)
this.connected.projector = device;
this.connected.projector_second = device;
this.arduino.aliasSerial('projector_second', device);
try {
connectSuccess = await this.arduino.connect('projector_second', device, false)
} catch (err) {
console.error(err)
return false
}*/
connectSuccess = await this.arduino.connect('projector', device, false);
}
catch (err) {
this.log.error('Error connecting to projector and secondary projector', err);
return false;
}
}
else if (type === 'camera_second') {
/*this.connected.projector_second = device
this.arduino.aliasSerial('projector_second', device)
this.connected.camera_second = device;
try {
connectSuccess = await this.arduino.connect('projector_second', device, false)
} catch (err) {
console.error(err)
return false
}*/
connectSuccess = await this.arduino.connect('camera_second', device, false);
}
catch (err) {
console.error(err);
return false;
}
}
else if (type === 'camera,camera_second') {
/*this.connected.projector_second = device
this.arduino.aliasSerial('projector_second', device)
this.connected.camera = device;
this.connected.camera_second = device;
this.arduino.aliasSerial('camera_second', device);
try {
connectSuccess = await this.arduino.connect('projector_second', device, false)
} catch (err) {
console.error(err)
return false
}*/
connectSuccess = await this.arduino.connect('camera', device, false);
}
catch (err) {
this.log.error('Error connecting to camera, camera_secondary and projector', err);
return false;
}
}
else if ('camera,projector,projector_second') {
this.connected.camera = device;
this.connected.projector = device;
this.connected.projector_second = device;
this.arduino.aliasSerial('projector', device);
this.arduino.aliasSerial('projector_second', device);
try {
connectSuccess = await this.arduino.connect('camera', device, false);
}
catch (err) {
this.log.error('Error connecting to camera, projector and projector_second', err);
return false;
}
}
else if ('camera,camera_second,projector') {
this.connected.camera = device;
this.connected.camera_second = device;
this.connected.projector = device;
this.arduino.aliasSerial('camera_second', device);
this.arduino.aliasSerial('projector', device);
try {
connectSuccess = await this.arduino.connect('camera', device, false);
}
catch (err) {
this.log.error('Error connecting to camera, camera_second and projector', err);
return false;
}
}
else if ('camera,camera_second,projector,projector_second') {
this.connected.camera = device;
this.connected.camera_second = device;
this.connected.projector = device;
this.connected.projector_second = device;
this.arduino.aliasSerial('camera_second', device);
this.arduino.aliasSerial('projector', device);
this.arduino.aliasSerial('projector_second', device);
try {
connectSuccess = await this.arduino.connect('camera', device, false);
}
catch (err) {
this.log.error('Error connecting to camera, camera_second, projector and projector_second', err);
return false;
}
}
//camera,projector,projector_second
//camera,camera_second,projector
//camera,camera_second,projector,projector_second
return connectSuccess;
}
/**
@ -311,7 +355,8 @@ class Devices {
let l = {};
let type;
let d;
let s = {};
let cs = {};
let ps = {};
let checklist = [];
this.connected = {
projector: false,
@ -353,10 +398,13 @@ class Devices {
await this.fakeLight();
}
l.arduino = this.connected.light;
if (this.connected.projector_second) {
s = this.connected.projector_second;
if (this.connected.camera_second) {
cs = { arduino: this.connected.camera_second };
}
return this.ready(p, c, l, s);
if (this.connected.projector_second) {
ps = { arduino: this.connected.projector_second };
}
return this.ready(p, c, l, cs, ps);
}
/**
*
@ -382,25 +430,33 @@ class Devices {
/**
*
**/
ready(projector, camera, light, projector_second) {
ready(projector, camera, light, camera_second, projector_second) {
let args = {
camera,
projector,
light,
profile: this.settings.state.profile
};
if (projector_second && projector_second.arduino) {
if (projector_second) {
args.projector_second = projector_second;
}
this.ui.send('ready', args);
this.settings.update('camera', camera);
this.settings.update('projector', projector);
this.settings.update('light', light);
if (projector_second && projector_second.arduino) {
this.settings.update('projector_second', projector_second);
this.mainWindow.setSize(800, 800);
}
if (camera_second) {
args.camera_second = camera_second;
this.settings.update('camera_second', camera_second);
if (projector_second) {
this.mainWindow.setSize(900, 800);
}
else {
this.mainWindow.setSize(800, 800);
}
}
this.settings.update('camera', camera);
this.settings.update('projector', projector);
this.settings.update('light', light);
this.settings.save();
this.ui.send('ready', args);
return true;
}
;

File diff suppressed because one or more lines are too long

View File

@ -84,7 +84,20 @@ class Projector {
this.log.error(`Error moving ${this.id}`, err);
}
}
this.log.info('Projector move time', { ms });
//this.log.info('Projector move time', { ms });
return await this.end(cmd, id, ms);
}
async both(frame, id) {
id = 'projectors';
const cmd = this.cfg.arduino.cmd[id];
let ms;
try {
ms = await this.arduino.send(this.id, cmd);
}
catch (err) {
this.log.error(`Error moving ${this.id}`, err);
}
//this.log.info('Projectors move time', { ms });
return await this.end(cmd, id, ms);
}
/**
@ -141,7 +154,7 @@ class Projector {
message += ' 1 frame';
}
else if (cmd === this.cfg.arduino.cmd.projector_second) {
message = 'Projector second';
message = 'Projector second ';
if (this.state.dir) {
message += 'ADVANCED';
}
@ -150,11 +163,15 @@ class Projector {
}
message += ' 1 frame';
}
else if (cmd === this.cfg.arduino.cmd.projectors) {
message += 'Projectors both MOVED 1 frame each';
}
message += ` ${ms}ms`;
this.log.info(message, 'PROJECTOR');
return await this.ui.send(this.id, { cmd: cmd, id: id, ms: ms });
}
}
module.exports = function (arduino, cfg, ui, dig) {
return new Projector(arduino, cfg, ui, dig);
module.exports = function (arduino, cfg, ui, dig, second) {
return new Projector(arduino, cfg, ui, dig, second);
};
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@ -99,6 +99,9 @@ class Sequencer {
while (this.paused) {
await delay(42);
}
if (typeof this.arr[y] === 'undefined') {
continue;
}
this.log.info(`Starting step ${y + 1} of loop ${x + 1}`);
this.ui.send(this.id, { step: y, loop: x, start: true });
await this.step(y);

File diff suppressed because one or more lines are too long

View File

@ -85,4 +85,11 @@ cam.listen = function () {
});
};
cam.second = {};
cam.second.queue = {};
cam.second.lock = false;
cam.second.id = 'camera_second';
cam.second.pos = 0;
cam.second.dir = true;
module.exports = cam;

View File

@ -48,31 +48,35 @@ grid.state = function (x) {
grid.refresh = function () {
'use strict';
const cmds = [
'cam_forward',
'proj_forward',
'cam_backward',
'proj_backward',
'camera_forward',
'camera_second_forward',
'projector_forward',
'projector_second_forward',
'camera_backward',
'camera_second_backward',
'projector_backward',
'projector_second_backward',
'light_set',
'numbers'
];
const check = '<input type="checkbox" x="xxxx" />';
const div = '<div x="xxxx"></div>';
const width = 970 - 34 + ((940 / 24) * Math.abs(24 - seq.size));
let elem;
let cmd;
$('#sequence').width(`${width}px`);
for (let i = 0; i < cmds.length; i++) {
$('#' + cmds[i]).empty();
cmd = `#${cmds[i]}`;
$(cmd).empty();
for (let x = 0; x < seq.size; x++) {
if (i === cmds.length - 1) {
elem = div.replace('xxxx', x);
$('#' + cmds[i]).append($(elem).text(x));
} else if (i === cmds.length - 2) {
elem = div.replace('xxxx', x);
$('#' + cmds[i]).append($(elem).addClass(cfg.cmd[cmds[i]]));
if (cmds[i] === 'numbers') {
elem = `<div x="${x}">${x}</div>`
$(cmd).append($(elem));
} else if (cmds[i] === 'light_set') {
elem = `<div x="${x}" class="L"></div>`
$(cmd).append($(elem));
} else {
elem = check.replace('xxxx', x);
$('#' + cmds[i]).append($(elem).addClass(cfg.cmd[cmds[i]]));
elem = `<input type="checkbox" x="${x}" />`;
$(cmd).append($(elem).addClass(cfg.cmd[cmds[i]]));
}
grid.state(x);
}
@ -87,13 +91,14 @@ grid.click = function (t) {
'use strict';
const x = parseInt($(t).attr('x'));
let c;
if ($(t).prop('checked')) {
if ($(t).prop('checked')) {
c = $(t).attr('class').replace('.', '');
seq.set(x, c);
} else {
//seq.grid[i] = undefined;
//delete seq.grid[i];
seq.grid[i] = undefined;
delete seq.grid[i];
seq.unset(x);
}
grid.state(x);
seq.stats();

View File

@ -2,7 +2,6 @@ const proj = {};
proj.queue = {};
proj.lock = false;
proj.lock2 = false;
proj.id = 'projector';
proj.dir = true;
proj.pos = 0;
@ -86,14 +85,11 @@ proj.setValue = function (val) {
ipcRenderer.sendSync(proj.id, obj);
};
proj.setValue2 = function (val) {
'use strict';
var obj = {
val: val,
second : true,
id : uuid.v4()
};
ipcRenderer.sendSync(proj.id, obj);
};
proj.second = {};
proj.second.queue = {};
proj.second.lock = false;
proj.second.id = 'projector_second';
proj.second.dir = true;
proj.second.pos = 0;
module.exports = proj;

View File

@ -25,24 +25,22 @@ seq.listener = function (event, arg) {
if (arg.start) {
if (typeof arg.loop !== 'undefined' && typeof arg.step !== 'undefined') {
seq.activeStep(arg.step);
log.info(`Step ${arg.step + 1} running of ${seq.arr.length}`, 'SERIAL', true);
log.info(`Loop ${arg.loop + 1} of ${seq.loops}`, 'SERIAL', true);
log.info(`Step ${arg.step + 1}/${seq.arr.length}, Loop ${arg.loop + 1}/${seq.loops}`, 'SERIAL', true);
} else if (typeof arg.loop !== 'undefined') {
$('#loop_current').text(gui.fmtZero(arg.loop + 1, 6));
} else {
//
seq.progress(0, 0);
}
} else if (arg.stop) {
if (typeof arg.loop !== 'undefined' && typeof arg.step !== 'undefined') {
//console.log(JSON.stringify(arg))
seq.progress(arg.step, arg.loop);
seq.progress(arg.step + 1, arg.loop);
seq.inactiveAll();
} else if (typeof arg.loop !== 'undefined') {
$('#loop_current').text('');
} else {
gui.overlay(false);
gui.spinner(false);
//seq.progress(0, 0);
log.info('Sequence stopped', 'SERIAL', true);
}
}
@ -54,13 +52,14 @@ seq.progress = function (step, loop) {
const len = seq.arr.length;
const total = len * seq.loops;
let pos = (loop * len) + step;
let progress;
let progress = 0;
if (pos === 0) {
progress = 0;
} else {
if (pos > 0 && total > 0) {
progress = (pos / total) * 100;
}
//console.log(`${progress}%`)
elem.attr('aria-valuenow', progress);
elem.css('width', `${progress}%`);
}
@ -124,6 +123,18 @@ seq.set = function (x, cmd) {
//update grid?
}
seq.unsetAll = function () {
const len = seq.grid.length;
const steps = [];
for (let i = 0; i < len; i++) {
if (typeof seq.grid[i] !== 'undefined') {
steps.push(i);
}
}
ipcRenderer.send(seq.id, { unset : steps });
seq.grid = [];
}
seq.unset = function (x) {
'use strict';
seq.grid[x] = undefined
@ -229,7 +240,8 @@ seq.stats = function () {
seq.clear = function () {
'use strict';
seq.size = 24;
seq.grid = [];
seq.unsetAll();
seq.progress(0, 0);
};
seq.cancel = function () {

View File

@ -122,8 +122,19 @@ var init = async function () {
cam = require('cam')(arduino, cfg, mainWindow.webContents, dig)
proj = require('proj')(arduino, cfg, mainWindow.webContents, dig)
cmd = require('cmd')(cfg, proj, cam, light)
if (dev && dev.connected && dev.connected.camera_second) {
cam2 = require('cam')(arduino, cfg, mainWindow.webContents, dig, true)
}
if (dev && dev.connected && dev.connected.projector_second) {
proj2 = require('proj')(arduino, cfg, mainWindow.webContents, dig, true)
}
cmd = require('cmd')(cfg, proj, cam, light, cam2, proj2)
seq = require('sequencer')(cfg, cmd, mainWindow.webContents)
await delay(5000)
await cmd.projectors_forward();
}
app.on('ready', init)

View File

@ -146,7 +146,10 @@
"camera_second_forward": "1",
"camera_second_backward": "2",
"camera_second": "3",
"cameras": "4"
"cameras": "4",
"camera_projectors_identifier" : "5",
"cameras_projector_identifier" : "6",
"cameras_projectors_identifier" : "7"
}
}
}

View File

@ -99,6 +99,7 @@ class Arduino {
if (this.locks[serial]) {
return false;
}
this.timer = new Date().getTime();
this.locks[serial] = true;
await delay(cfg.arduino.serialDelay);
try {
@ -108,8 +109,8 @@ class Arduino {
return console.error(e);
}
this.locks[serial] = false;
this.timer = new Date().getTime();
return await eventEmitter.emit('arduino_send', cmd);
await eventEmitter.emit('arduino_send', cmd);
return results;
}
async string(serial, str) {
const device = this.alias[serial];
@ -160,10 +161,10 @@ class Arduino {
else {
//console.log('Received stray "' + data + '"'); //silent to user
}
return complete;
return ms;
}
aliasSerial(serial, device) {
//console.log(`Making "${serial}" an alias of ${device}`)
//this.log.info(`Making "${serial}" an alias of ${device}`);
this.alias[serial] = device;
}
async connect(serial, device, confirm) {
@ -273,21 +274,27 @@ class Arduino {
else if (data === cfg.arduino.cmd.projector_camera_identifier) {
type = 'projector,camera';
}
else if (data === cfg.ardino.cmd.projector_second_identifier) {
else if (data === cfg.arduino.cmd.projector_second_identifier) {
type = 'projector_second';
}
else if (data === cfg.ardino.cmd.projectors_identifier) {
else if (data === cfg.arduino.cmd.projectors_identifier) {
type = 'projector,projector_second';
}
else if (data === cfg.ardino.cmd.camera_second_identifier) {
else if (data === cfg.arduino.cmd.camera_second_identifier) {
type = 'camera_second';
}
else if (data === cfg.ardino.cmd.cameras_identifier) {
else if (data === cfg.arduino.cmd.cameras_identifier) {
type = 'camera,camera_second';
}
//camera,projector,projector_second
//camera,camera_second,projector
//camera,camera_second,projector,projector_second
else if (data === cfg.arduino.cmd.camera_projectors_identifier) {
type = 'camera,projector,projector_second';
}
else if (data === cfg.arduino.cmd.cameras_projector_identifier) {
type = 'camera,camera_second,projector';
}
else if (data === cfg.arduino.cmd.cameras_projectors_identifier) {
type = 'camera,camera_second,projector,projector_second';
}
return resolve(type);
};
await delay(cfg.arduino.serialDelay);

File diff suppressed because one or more lines are too long

View File

@ -99,9 +99,22 @@ class Camera {
//await delay(100 * 1000);
await this.dig.end();
}
this.log.info('Camera move time', { ms });
//this.log.info('Camera move time', { ms });
return this.end(cmd, id, ms);
}
async both(frame, id) {
id = 'cameras';
const cmd = this.cfg.arduino.cmd[id];
let ms;
try {
ms = await this.arduino.send(this.id, cmd);
}
catch (err) {
this.log.error(`Error moving ${this.id}`, err);
}
//this.log.info('Cameras move time', { ms });
return await this.end(cmd, id, ms);
}
/**
*
**/
@ -199,11 +212,15 @@ class Camera {
}
message += ' 1 frame';
}
else if (cmd === this.cfg.arduino.cmd.camerass) {
message += 'Cameras both MOVED 1 frame each';
}
message += ` ${ms}ms`;
this.log.info(message);
this.ui.send(this.id, { cmd: cmd, id: id, ms: ms });
}
}
module.exports = function (arduino, cfg, ui, dig) {
return new Camera(arduino, cfg, ui, dig);
module.exports = function (arduino, cfg, ui, dig, second) {
return new Camera(arduino, cfg, ui, dig, second);
};
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@ -2,11 +2,15 @@
Object.defineProperty(exports, "__esModule", { value: true });
const delay = require("delay");
class Commands {
constructor(cfg, proj, cam, light) {
constructor(cfg, proj, cam, light, cam2 = null, proj2 = null) {
this.cfg = cfg;
this.proj = proj;
this.cam = cam;
this.light = light;
if (cam2)
this.cam2 = cam2;
if (proj2)
this.proj2 = proj2;
this.ipc = require('electron').ipcMain;
}
/**
@ -142,8 +146,349 @@ class Commands {
}
return ms;
}
/**
* Move the second camera one frame forward
*
* @param {array} rgb Color to set light for frame
**/
async camera_second_forward(rgb = [255, 255, 255]) {
const off = [0, 0, 0];
let ms;
try {
if (!this.cam2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam2.set(true);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await delay(this.cfg.arduino.serialDelay);
ms = await this.cam2.move();
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
}
catch (err) {
throw err;
}
return ms;
}
/**
* Move the second camera one frame backward
*
* @param {array} rgb Color to set light for frame
**/
async camera_second_backward(rgb = [255, 255, 255]) {
const off = [0, 0, 0];
let ms;
try {
if (this.cam2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam2.set(false);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await delay(this.cfg.arduino.serialDelay);
ms = await this.cam2.move();
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
}
catch (err) {
throw err;
}
return ms;
}
/**
* Move the both cameras one frame forward
*
* @param {array} rgb Color to set light for frame
**/
async cameras_forward(rgb = [255, 255, 255]) {
const off = [0, 0, 0];
let both;
let ms;
try {
if (!this.cam.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam.set(true);
}
if (!this.cam2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam2.set(true);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await delay(this.cfg.arduino.serialDelay);
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);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
}
catch (err) {
throw err;
}
return ms;
}
/**
* Move the both cameras one frame backward
*
* @param {array} rgb Color to set light for frame
**/
async cameras_backward(rgb = [255, 255, 255]) {
const off = [0, 0, 0];
let both;
let ms;
try {
if (this.cam.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam.set(false);
}
if (this.cam2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam2.set(false);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await delay(this.cfg.arduino.serialDelay);
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);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
}
catch (err) {
throw err;
}
return ms;
}
async camera_forward_camera_second_backward(rgb = [255, 255, 255]) {
const off = [0, 0, 0];
let both;
let ms;
try {
if (!this.cam.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam.set(true);
}
if (this.cam2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam2.set(false);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await delay(this.cfg.arduino.serialDelay);
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);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
}
catch (err) {
throw err;
}
return ms;
}
async camera_backward_camera_second_forward(rgb = [255, 255, 255]) {
const off = [0, 0, 0];
let both;
let ms;
try {
if (this.cam.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam.set(false);
}
if (!this.cam2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam2.set(true);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await delay(this.cfg.arduino.serialDelay);
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);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
}
catch (err) {
throw err;
}
return ms;
}
/**
* Move the secondary projector forward one frame
*
**/
async projector_second_forward() {
let ms;
try {
if (!this.proj2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj2.set(true);
}
await delay(this.cfg.arduino.serialDelay);
ms = await this.proj2.move();
}
catch (err) {
throw err;
}
return ms;
}
async projector_second_backward() {
let ms;
try {
if (this.proj2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj2.set(false);
}
await delay(this.cfg.arduino.serialDelay);
ms = await this.proj2.move();
}
catch (err) {
throw err;
}
return ms;
}
async projectors_forward() {
let both;
let ms;
try {
if (!this.proj.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj.set(true);
}
if (!this.proj2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj2.set(true);
}
await delay(this.cfg.arduino.serialDelay);
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;
}
async projectors_backward() {
let both;
let ms;
try {
if (this.proj.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj.set(false);
}
if (this.proj2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj2.set(false);
}
await delay(this.cfg.arduino.serialDelay);
//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;
}
async projector_forward_projector_second_backward() {
let both;
let ms;
try {
if (!this.proj.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj.set(true);
}
if (this.proj2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj2.set(false);
}
await delay(this.cfg.arduino.serialDelay);
//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;
}
async projector_backward_projector_second_forward() {
let both;
let ms;
try {
if (this.proj.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj.set(false);
}
if (!this.proj2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj2.set(true);
}
await delay(this.cfg.arduino.serialDelay);
//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;
}
}
module.exports = function (cfg, proj, cam, light) {
return new Commands(cfg, proj, cam, light);
module.exports = function (cfg, proj, cam, light, cam2, proj2) {
return new Commands(cfg, proj, cam, light, cam2, proj2);
};
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@ -256,7 +256,6 @@ class Devices {
}
else if (type === 'projector_second') {
this.connected.projector_second = device;
this.arduino.aliasSerial('projector_second', device);
try {
connectSuccess = await this.arduino.connect('projector_second', device, false);
}
@ -267,38 +266,83 @@ class Devices {
this.log.info(`Connected to ${device} as PROJECTOR_SECOND`, 'SERIAL', true, true);
}
else if (type === 'projector,projector_second') {
/*this.connected.projector_second = device
this.arduino.aliasSerial('projector_second', device)
this.connected.projector = device;
this.connected.projector_second = device;
this.arduino.aliasSerial('projector_second', device);
try {
connectSuccess = await this.arduino.connect('projector_second', device, false)
} catch (err) {
console.error(err)
return false
}*/
connectSuccess = await this.arduino.connect('projector', device, false);
}
catch (err) {
this.log.error('Error connecting to projector and secondary projector', err);
return false;
}
}
else if (type === 'camera_second') {
/*this.connected.projector_second = device
this.arduino.aliasSerial('projector_second', device)
this.connected.camera_second = device;
try {
connectSuccess = await this.arduino.connect('projector_second', device, false)
} catch (err) {
console.error(err)
return false
}*/
connectSuccess = await this.arduino.connect('camera_second', device, false);
}
catch (err) {
console.error(err);
return false;
}
}
else if (type === 'camera,camera_second') {
/*this.connected.projector_second = device
this.arduino.aliasSerial('projector_second', device)
this.connected.camera = device;
this.connected.camera_second = device;
this.arduino.aliasSerial('camera_second', device);
try {
connectSuccess = await this.arduino.connect('projector_second', device, false)
} catch (err) {
console.error(err)
return false
}*/
connectSuccess = await this.arduino.connect('camera', device, false);
}
catch (err) {
this.log.error('Error connecting to camera, camera_secondary and projector', err);
return false;
}
}
else if ('camera,projector,projector_second') {
this.connected.camera = device;
this.connected.projector = device;
this.connected.projector_second = device;
this.arduino.aliasSerial('projector', device);
this.arduino.aliasSerial('projector_second', device);
try {
connectSuccess = await this.arduino.connect('camera', device, false);
}
catch (err) {
this.log.error('Error connecting to camera, projector and projector_second', err);
return false;
}
}
else if ('camera,camera_second,projector') {
this.connected.camera = device;
this.connected.camera_second = device;
this.connected.projector = device;
this.arduino.aliasSerial('camera_second', device);
this.arduino.aliasSerial('projector', device);
try {
connectSuccess = await this.arduino.connect('camera', device, false);
}
catch (err) {
this.log.error('Error connecting to camera, camera_second and projector', err);
return false;
}
}
else if ('camera,camera_second,projector,projector_second') {
this.connected.camera = device;
this.connected.camera_second = device;
this.connected.projector = device;
this.connected.projector_second = device;
this.arduino.aliasSerial('camera_second', device);
this.arduino.aliasSerial('projector', device);
this.arduino.aliasSerial('projector_second', device);
try {
connectSuccess = await this.arduino.connect('camera', device, false);
}
catch (err) {
this.log.error('Error connecting to camera, camera_second, projector and projector_second', err);
return false;
}
}
//camera,projector,projector_second
//camera,camera_second,projector
//camera,camera_second,projector,projector_second
return connectSuccess;
}
/**
@ -311,7 +355,8 @@ class Devices {
let l = {};
let type;
let d;
let s = {};
let cs = {};
let ps = {};
let checklist = [];
this.connected = {
projector: false,
@ -353,10 +398,13 @@ class Devices {
await this.fakeLight();
}
l.arduino = this.connected.light;
if (this.connected.projector_second) {
s = this.connected.projector_second;
if (this.connected.camera_second) {
cs = { arduino: this.connected.camera_second };
}
return this.ready(p, c, l, s);
if (this.connected.projector_second) {
ps = { arduino: this.connected.projector_second };
}
return this.ready(p, c, l, cs, ps);
}
/**
*
@ -382,25 +430,33 @@ class Devices {
/**
*
**/
ready(projector, camera, light, projector_second) {
ready(projector, camera, light, camera_second, projector_second) {
let args = {
camera,
projector,
light,
profile: this.settings.state.profile
};
if (projector_second && projector_second.arduino) {
if (projector_second) {
args.projector_second = projector_second;
}
this.ui.send('ready', args);
this.settings.update('camera', camera);
this.settings.update('projector', projector);
this.settings.update('light', light);
if (projector_second && projector_second.arduino) {
this.settings.update('projector_second', projector_second);
this.mainWindow.setSize(800, 800);
}
if (camera_second) {
args.camera_second = camera_second;
this.settings.update('camera_second', camera_second);
if (projector_second) {
this.mainWindow.setSize(900, 800);
}
else {
this.mainWindow.setSize(800, 800);
}
}
this.settings.update('camera', camera);
this.settings.update('projector', projector);
this.settings.update('light', light);
this.settings.save();
this.ui.send('ready', args);
return true;
}
;

File diff suppressed because one or more lines are too long

View File

@ -84,7 +84,20 @@ class Projector {
this.log.error(`Error moving ${this.id}`, err);
}
}
this.log.info('Projector move time', { ms });
//this.log.info('Projector move time', { ms });
return await this.end(cmd, id, ms);
}
async both(frame, id) {
id = 'projectors';
const cmd = this.cfg.arduino.cmd[id];
let ms;
try {
ms = await this.arduino.send(this.id, cmd);
}
catch (err) {
this.log.error(`Error moving ${this.id}`, err);
}
//this.log.info('Projectors move time', { ms });
return await this.end(cmd, id, ms);
}
/**
@ -141,7 +154,7 @@ class Projector {
message += ' 1 frame';
}
else if (cmd === this.cfg.arduino.cmd.projector_second) {
message = 'Projector second';
message = 'Projector second ';
if (this.state.dir) {
message += 'ADVANCED';
}
@ -150,11 +163,15 @@ class Projector {
}
message += ' 1 frame';
}
else if (cmd === this.cfg.arduino.cmd.projectors) {
message += 'Projectors both MOVED 1 frame each';
}
message += ` ${ms}ms`;
this.log.info(message, 'PROJECTOR');
return await this.ui.send(this.id, { cmd: cmd, id: id, ms: ms });
}
}
module.exports = function (arduino, cfg, ui, dig) {
return new Projector(arduino, cfg, ui, dig);
module.exports = function (arduino, cfg, ui, dig, second) {
return new Projector(arduino, cfg, ui, dig, second);
};
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@ -99,6 +99,9 @@ class Sequencer {
while (this.paused) {
await delay(42);
}
if (typeof this.arr[y] === 'undefined') {
continue;
}
this.log.info(`Starting step ${y + 1} of loop ${x + 1}`);
this.ui.send(this.id, { step: y, loop: x, start: true });
await this.step(y);

File diff suppressed because one or more lines are too long

View File

@ -146,7 +146,10 @@
"camera_second_forward": "1",
"camera_second_backward": "2",
"camera_second": "3",
"cameras": "4"
"cameras": "4",
"camera_projectors_identifier" : "5",
"cameras_projector_identifier" : "6",
"cameras_projectors_identifier" : "7"
}
}
}

View File

@ -58,7 +58,7 @@ const char cmd_debug = 'd';
const char cmd_connect = 'i';
volatile char cmd_char = 'z';
const char cmd_mcopy_identifier = 'm';
const char cmd_proj_identifier = 'j'; //'d'; //dual projector identifier
const char cmd_proj_identifier = 'd'; //dual projector identifier
const int serialDelay = 5;

View File

@ -30,15 +30,15 @@ const int proj_delay = 42;
boolean proj_dir = true;
boolean proj_running = false;
const char cmd_projector = 'p';
const char cmd_proj_forward = 'g';
const char cmd_proj_backward = 'h';
const char cmd_projector = 'w'; //_second
const char cmd_proj_forward = 'u';
const char cmd_proj_backward = 'v';
const char cmd_debug = 'd';
const char cmd_connect = 'i';
volatile char cmd_char = 'z';
const char cmd_mcopy_identifier = 'm';
const char cmd_proj_identifier = 'j';
const char cmd_proj_identifier = 't'; //_second
const int serialDelay = 5;

View File

@ -99,6 +99,7 @@ class Arduino {
if (this.locks[serial]) {
return false;
}
this.timer = new Date().getTime();
this.locks[serial] = true;
await delay(cfg.arduino.serialDelay);
try {
@ -108,8 +109,8 @@ class Arduino {
return console.error(e);
}
this.locks[serial] = false;
this.timer = new Date().getTime();
return await eventEmitter.emit('arduino_send', cmd);
await eventEmitter.emit('arduino_send', cmd);
return results;
}
async string(serial, str) {
const device = this.alias[serial];
@ -160,10 +161,10 @@ class Arduino {
else {
//console.log('Received stray "' + data + '"'); //silent to user
}
return complete;
return ms;
}
aliasSerial(serial, device) {
//console.log(`Making "${serial}" an alias of ${device}`)
//this.log.info(`Making "${serial}" an alias of ${device}`);
this.alias[serial] = device;
}
async connect(serial, device, confirm) {
@ -273,21 +274,27 @@ class Arduino {
else if (data === cfg.arduino.cmd.projector_camera_identifier) {
type = 'projector,camera';
}
else if (data === cfg.ardino.cmd.projector_second_identifier) {
else if (data === cfg.arduino.cmd.projector_second_identifier) {
type = 'projector_second';
}
else if (data === cfg.ardino.cmd.projectors_identifier) {
else if (data === cfg.arduino.cmd.projectors_identifier) {
type = 'projector,projector_second';
}
else if (data === cfg.ardino.cmd.camera_second_identifier) {
else if (data === cfg.arduino.cmd.camera_second_identifier) {
type = 'camera_second';
}
else if (data === cfg.ardino.cmd.cameras_identifier) {
else if (data === cfg.arduino.cmd.cameras_identifier) {
type = 'camera,camera_second';
}
//camera,projector,projector_second
//camera,camera_second,projector
//camera,camera_second,projector,projector_second
else if (data === cfg.arduino.cmd.camera_projectors_identifier) {
type = 'camera,projector,projector_second';
}
else if (data === cfg.arduino.cmd.cameras_projector_identifier) {
type = 'camera,camera_second,projector';
}
else if (data === cfg.arduino.cmd.cameras_projectors_identifier) {
type = 'camera,camera_second,projector,projector_second';
}
return resolve(type);
};
await delay(cfg.arduino.serialDelay);

File diff suppressed because one or more lines are too long

View File

@ -99,9 +99,22 @@ class Camera {
//await delay(100 * 1000);
await this.dig.end();
}
this.log.info('Camera move time', { ms });
//this.log.info('Camera move time', { ms });
return this.end(cmd, id, ms);
}
async both(frame, id) {
id = 'cameras';
const cmd = this.cfg.arduino.cmd[id];
let ms;
try {
ms = await this.arduino.send(this.id, cmd);
}
catch (err) {
this.log.error(`Error moving ${this.id}`, err);
}
//this.log.info('Cameras move time', { ms });
return await this.end(cmd, id, ms);
}
/**
*
**/
@ -199,11 +212,15 @@ class Camera {
}
message += ' 1 frame';
}
else if (cmd === this.cfg.arduino.cmd.camerass) {
message += 'Cameras both MOVED 1 frame each';
}
message += ` ${ms}ms`;
this.log.info(message);
this.ui.send(this.id, { cmd: cmd, id: id, ms: ms });
}
}
module.exports = function (arduino, cfg, ui, dig) {
return new Camera(arduino, cfg, ui, dig);
module.exports = function (arduino, cfg, ui, dig, second) {
return new Camera(arduino, cfg, ui, dig, second);
};
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@ -2,11 +2,15 @@
Object.defineProperty(exports, "__esModule", { value: true });
const delay = require("delay");
class Commands {
constructor(cfg, proj, cam, light) {
constructor(cfg, proj, cam, light, cam2 = null, proj2 = null) {
this.cfg = cfg;
this.proj = proj;
this.cam = cam;
this.light = light;
if (cam2)
this.cam2 = cam2;
if (proj2)
this.proj2 = proj2;
this.ipc = require('electron').ipcMain;
}
/**
@ -142,8 +146,349 @@ class Commands {
}
return ms;
}
/**
* Move the second camera one frame forward
*
* @param {array} rgb Color to set light for frame
**/
async camera_second_forward(rgb = [255, 255, 255]) {
const off = [0, 0, 0];
let ms;
try {
if (!this.cam2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam2.set(true);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await delay(this.cfg.arduino.serialDelay);
ms = await this.cam2.move();
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
}
catch (err) {
throw err;
}
return ms;
}
/**
* Move the second camera one frame backward
*
* @param {array} rgb Color to set light for frame
**/
async camera_second_backward(rgb = [255, 255, 255]) {
const off = [0, 0, 0];
let ms;
try {
if (this.cam2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam2.set(false);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await delay(this.cfg.arduino.serialDelay);
ms = await this.cam2.move();
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
}
catch (err) {
throw err;
}
return ms;
}
/**
* Move the both cameras one frame forward
*
* @param {array} rgb Color to set light for frame
**/
async cameras_forward(rgb = [255, 255, 255]) {
const off = [0, 0, 0];
let both;
let ms;
try {
if (!this.cam.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam.set(true);
}
if (!this.cam2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam2.set(true);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await delay(this.cfg.arduino.serialDelay);
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);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
}
catch (err) {
throw err;
}
return ms;
}
/**
* Move the both cameras one frame backward
*
* @param {array} rgb Color to set light for frame
**/
async cameras_backward(rgb = [255, 255, 255]) {
const off = [0, 0, 0];
let both;
let ms;
try {
if (this.cam.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam.set(false);
}
if (this.cam2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam2.set(false);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await delay(this.cfg.arduino.serialDelay);
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);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
}
catch (err) {
throw err;
}
return ms;
}
async camera_forward_camera_second_backward(rgb = [255, 255, 255]) {
const off = [0, 0, 0];
let both;
let ms;
try {
if (!this.cam.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam.set(true);
}
if (this.cam2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam2.set(false);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await delay(this.cfg.arduino.serialDelay);
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);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
}
catch (err) {
throw err;
}
return ms;
}
async camera_backward_camera_second_forward(rgb = [255, 255, 255]) {
const off = [0, 0, 0];
let both;
let ms;
try {
if (this.cam.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam.set(false);
}
if (!this.cam2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam2.set(true);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await delay(this.cfg.arduino.serialDelay);
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);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
}
catch (err) {
throw err;
}
return ms;
}
/**
* Move the secondary projector forward one frame
*
**/
async projector_second_forward() {
let ms;
try {
if (!this.proj2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj2.set(true);
}
await delay(this.cfg.arduino.serialDelay);
ms = await this.proj2.move();
}
catch (err) {
throw err;
}
return ms;
}
async projector_second_backward() {
let ms;
try {
if (this.proj2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj2.set(false);
}
await delay(this.cfg.arduino.serialDelay);
ms = await this.proj2.move();
}
catch (err) {
throw err;
}
return ms;
}
async projectors_forward() {
let both;
let ms;
try {
if (!this.proj.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj.set(true);
}
if (!this.proj2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj2.set(true);
}
await delay(this.cfg.arduino.serialDelay);
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;
}
async projectors_backward() {
let both;
let ms;
try {
if (this.proj.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj.set(false);
}
if (this.proj2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj2.set(false);
}
await delay(this.cfg.arduino.serialDelay);
//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;
}
async projector_forward_projector_second_backward() {
let both;
let ms;
try {
if (!this.proj.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj.set(true);
}
if (this.proj2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj2.set(false);
}
await delay(this.cfg.arduino.serialDelay);
//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;
}
async projector_backward_projector_second_forward() {
let both;
let ms;
try {
if (this.proj.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj.set(false);
}
if (!this.proj2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj2.set(true);
}
await delay(this.cfg.arduino.serialDelay);
//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;
}
}
module.exports = function (cfg, proj, cam, light) {
return new Commands(cfg, proj, cam, light);
module.exports = function (cfg, proj, cam, light, cam2, proj2) {
return new Commands(cfg, proj, cam, light, cam2, proj2);
};
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@ -256,7 +256,6 @@ class Devices {
}
else if (type === 'projector_second') {
this.connected.projector_second = device;
this.arduino.aliasSerial('projector_second', device);
try {
connectSuccess = await this.arduino.connect('projector_second', device, false);
}
@ -267,38 +266,83 @@ class Devices {
this.log.info(`Connected to ${device} as PROJECTOR_SECOND`, 'SERIAL', true, true);
}
else if (type === 'projector,projector_second') {
/*this.connected.projector_second = device
this.arduino.aliasSerial('projector_second', device)
this.connected.projector = device;
this.connected.projector_second = device;
this.arduino.aliasSerial('projector_second', device);
try {
connectSuccess = await this.arduino.connect('projector_second', device, false)
} catch (err) {
console.error(err)
return false
}*/
connectSuccess = await this.arduino.connect('projector', device, false);
}
catch (err) {
this.log.error('Error connecting to projector and secondary projector', err);
return false;
}
}
else if (type === 'camera_second') {
/*this.connected.projector_second = device
this.arduino.aliasSerial('projector_second', device)
this.connected.camera_second = device;
try {
connectSuccess = await this.arduino.connect('projector_second', device, false)
} catch (err) {
console.error(err)
return false
}*/
connectSuccess = await this.arduino.connect('camera_second', device, false);
}
catch (err) {
console.error(err);
return false;
}
}
else if (type === 'camera,camera_second') {
/*this.connected.projector_second = device
this.arduino.aliasSerial('projector_second', device)
this.connected.camera = device;
this.connected.camera_second = device;
this.arduino.aliasSerial('camera_second', device);
try {
connectSuccess = await this.arduino.connect('projector_second', device, false)
} catch (err) {
console.error(err)
return false
}*/
connectSuccess = await this.arduino.connect('camera', device, false);
}
catch (err) {
this.log.error('Error connecting to camera, camera_secondary and projector', err);
return false;
}
}
else if ('camera,projector,projector_second') {
this.connected.camera = device;
this.connected.projector = device;
this.connected.projector_second = device;
this.arduino.aliasSerial('projector', device);
this.arduino.aliasSerial('projector_second', device);
try {
connectSuccess = await this.arduino.connect('camera', device, false);
}
catch (err) {
this.log.error('Error connecting to camera, projector and projector_second', err);
return false;
}
}
else if ('camera,camera_second,projector') {
this.connected.camera = device;
this.connected.camera_second = device;
this.connected.projector = device;
this.arduino.aliasSerial('camera_second', device);
this.arduino.aliasSerial('projector', device);
try {
connectSuccess = await this.arduino.connect('camera', device, false);
}
catch (err) {
this.log.error('Error connecting to camera, camera_second and projector', err);
return false;
}
}
else if ('camera,camera_second,projector,projector_second') {
this.connected.camera = device;
this.connected.camera_second = device;
this.connected.projector = device;
this.connected.projector_second = device;
this.arduino.aliasSerial('camera_second', device);
this.arduino.aliasSerial('projector', device);
this.arduino.aliasSerial('projector_second', device);
try {
connectSuccess = await this.arduino.connect('camera', device, false);
}
catch (err) {
this.log.error('Error connecting to camera, camera_second, projector and projector_second', err);
return false;
}
}
//camera,projector,projector_second
//camera,camera_second,projector
//camera,camera_second,projector,projector_second
return connectSuccess;
}
/**
@ -311,7 +355,8 @@ class Devices {
let l = {};
let type;
let d;
let s = {};
let cs = {};
let ps = {};
let checklist = [];
this.connected = {
projector: false,
@ -353,10 +398,13 @@ class Devices {
await this.fakeLight();
}
l.arduino = this.connected.light;
if (this.connected.projector_second) {
s = this.connected.projector_second;
if (this.connected.camera_second) {
cs = { arduino: this.connected.camera_second };
}
return this.ready(p, c, l, s);
if (this.connected.projector_second) {
ps = { arduino: this.connected.projector_second };
}
return this.ready(p, c, l, cs, ps);
}
/**
*
@ -382,25 +430,33 @@ class Devices {
/**
*
**/
ready(projector, camera, light, projector_second) {
ready(projector, camera, light, camera_second, projector_second) {
let args = {
camera,
projector,
light,
profile: this.settings.state.profile
};
if (projector_second && projector_second.arduino) {
if (projector_second) {
args.projector_second = projector_second;
}
this.ui.send('ready', args);
this.settings.update('camera', camera);
this.settings.update('projector', projector);
this.settings.update('light', light);
if (projector_second && projector_second.arduino) {
this.settings.update('projector_second', projector_second);
this.mainWindow.setSize(800, 800);
}
if (camera_second) {
args.camera_second = camera_second;
this.settings.update('camera_second', camera_second);
if (projector_second) {
this.mainWindow.setSize(900, 800);
}
else {
this.mainWindow.setSize(800, 800);
}
}
this.settings.update('camera', camera);
this.settings.update('projector', projector);
this.settings.update('light', light);
this.settings.save();
this.ui.send('ready', args);
return true;
}
;

File diff suppressed because one or more lines are too long

View File

@ -84,7 +84,20 @@ class Projector {
this.log.error(`Error moving ${this.id}`, err);
}
}
this.log.info('Projector move time', { ms });
//this.log.info('Projector move time', { ms });
return await this.end(cmd, id, ms);
}
async both(frame, id) {
id = 'projectors';
const cmd = this.cfg.arduino.cmd[id];
let ms;
try {
ms = await this.arduino.send(this.id, cmd);
}
catch (err) {
this.log.error(`Error moving ${this.id}`, err);
}
//this.log.info('Projectors move time', { ms });
return await this.end(cmd, id, ms);
}
/**
@ -141,7 +154,7 @@ class Projector {
message += ' 1 frame';
}
else if (cmd === this.cfg.arduino.cmd.projector_second) {
message = 'Projector second';
message = 'Projector second ';
if (this.state.dir) {
message += 'ADVANCED';
}
@ -150,11 +163,15 @@ class Projector {
}
message += ' 1 frame';
}
else if (cmd === this.cfg.arduino.cmd.projectors) {
message += 'Projectors both MOVED 1 frame each';
}
message += ` ${ms}ms`;
this.log.info(message, 'PROJECTOR');
return await this.ui.send(this.id, { cmd: cmd, id: id, ms: ms });
}
}
module.exports = function (arduino, cfg, ui, dig) {
return new Projector(arduino, cfg, ui, dig);
module.exports = function (arduino, cfg, ui, dig, second) {
return new Projector(arduino, cfg, ui, dig, second);
};
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@ -99,6 +99,9 @@ class Sequencer {
while (this.paused) {
await delay(42);
}
if (typeof this.arr[y] === 'undefined') {
continue;
}
this.log.info(`Starting step ${y + 1} of loop ${x + 1}`);
this.ui.send(this.id, { step: y, loop: x, start: true });
await this.step(y);

File diff suppressed because one or more lines are too long

View File

@ -146,7 +146,10 @@
"camera_second_forward": "1",
"camera_second_backward": "2",
"camera_second": "3",
"cameras": "4"
"cameras": "4",
"camera_projectors_identifier" : "5",
"cameras_projector_identifier" : "6",
"cameras_projectors_identifier" : "7"
}
}
}

View File

@ -107,6 +107,7 @@ class Arduino {
if (this.locks[serial]) {
return false
}
this.timer = new Date().getTime()
this.locks[serial] = true
await delay(cfg.arduino.serialDelay)
try {
@ -115,8 +116,9 @@ class Arduino {
return console.error(e)
}
this.locks[serial] = false
this.timer = new Date().getTime()
return await eventEmitter.emit('arduino_send', cmd)
await eventEmitter.emit('arduino_send', cmd)
return results
}
async string (serial : string, str : string) {
@ -156,23 +158,23 @@ class Arduino {
}
end (serial : string, data : string) {
const end = new Date().getTime()
const ms = end - this.timer
let complete
const end = new Date().getTime();
const ms = end - this.timer;
let complete;
if (this.queue[data] !== undefined) {
this.locks[serial] = false;
complete = this.queue[data](ms) //execute callback
eventEmitter.emit('arduino_end', data)
delete this.queue[data]
complete = this.queue[data](ms); //execute callback
eventEmitter.emit('arduino_end', data);
delete this.queue[data];
} else {
//console.log('Received stray "' + data + '"'); //silent to user
}
return complete
return ms;
}
aliasSerial (serial : string, device : string) {
//console.log(`Making "${serial}" an alias of ${device}`)
this.alias[serial] = device
//this.log.info(`Making "${serial}" an alias of ${device}`);
this.alias[serial] = device;
}
async connect (serial : string, device : string, confirm : any) {
@ -280,18 +282,21 @@ class Arduino {
type = 'projector,camera,light'
} else if (data === cfg.arduino.cmd.projector_camera_identifier) {
type = 'projector,camera'
} else if (data === cfg.ardino.cmd.projector_second_identifier) {
} else if (data === cfg.arduino.cmd.projector_second_identifier) {
type = 'projector_second'
} else if (data === cfg.ardino.cmd.projectors_identifier) {
} else if (data === cfg.arduino.cmd.projectors_identifier) {
type = 'projector,projector_second'
} else if (data === cfg.ardino.cmd.camera_second_identifier) {
} else if (data === cfg.arduino.cmd.camera_second_identifier) {
type = 'camera_second'
} else if (data === cfg.ardino.cmd.cameras_identifier) {
} else if (data === cfg.arduino.cmd.cameras_identifier) {
type = 'camera,camera_second'
} else if (data === cfg.arduino.cmd.camera_projectors_identifier) {
type = 'camera,projector,projector_second'
} else if (data === cfg.arduino.cmd.cameras_projector_identifier) {
type = 'camera,camera_second,projector'
} else if (data === cfg.arduino.cmd.cameras_projectors_identifier) {
type = 'camera,camera_second,projector,projector_second'
}
//camera,projector,projector_second
//camera,camera_second,projector
//camera,camera_second,projector,projector_second
return resolve(type)
}
await delay(cfg.arduino.serialDelay)

View File

@ -105,10 +105,23 @@ class Camera {
//await delay(100 * 1000);
await this.dig.end();
}
this.log.info('Camera move time', { ms });
//this.log.info('Camera move time', { ms });
return this.end(cmd, id, ms);
}
public async both (frame : any, id : string) {
id = 'cameras';
const cmd : string = this.cfg.arduino.cmd[id];
let ms : number;
try {
ms = await this.arduino.send(this.id, cmd)
} catch (err) {
this.log.error(`Error moving ${this.id}`, err)
}
//this.log.info('Cameras move time', { ms });
return await this.end(cmd, id, ms)
}
/**
*
**/
@ -195,12 +208,15 @@ class Camera {
message += 'REWOUND';
}
message += ' 1 frame';
} else if (cmd === this.cfg.arduino.cmd.camerass) {
message += 'Cameras both MOVED 1 frame each';
}
message += ` ${ms}ms`
this.log.info(message);
this.ui.send(this.id, {cmd: cmd, id : id, ms: ms});
}
}
module.exports = function (arduino : Arduino, cfg : any, ui : any, dig : any) {
return new Camera(arduino, cfg, ui, dig);
module.exports = function (arduino : Arduino, cfg : any, ui : any, dig : any, second : boolean) {
return new Camera(arduino, cfg, ui, dig, second);
}

View File

@ -7,15 +7,21 @@ class Commands {
private cam : any;
private light : any;
private cam2 : any;
private proj2 : any;
private cfg : any;
private ipc : any;
constructor (cfg : any, proj : any, cam : any, light : any) {
constructor (cfg : any, proj : any, cam : any, light : any, cam2 : any = null, proj2 : any = null) {
this.cfg = cfg;
this.proj = proj;
this.cam = cam;
this.light = light;
if (cam2) this.cam2 = cam2;
if (proj2) this.proj2 = proj2;
this.ipc = require('electron').ipcMain;
}
@ -147,52 +153,348 @@ class Commands {
return ms;
}
/*
camera_second_forward : 'C2F',
camera_second_backward : 'C2B',
/**
* Move the second camera one frame forward
*
* @param {array} rgb Color to set light for frame
**/
public async camera_second_forward (rgb : number[] = [255, 255, 255]) {
const off : number[] = [0, 0, 0];
let ms : number;
try {
if (!this.cam2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam2.set(true);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await delay(this.cfg.arduino.serialDelay);
ms = await this.cam2.move();
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
} catch (err) {
throw err;
}
return ms;
}
/**
* Move the second camera one frame backward
*
* @param {array} rgb Color to set light for frame
**/
public async camera_second_backward (rgb : number[] = [255, 255, 255]) {
const off : number[] = [0, 0, 0];
let ms : number;
try {
if (this.cam2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam2.set(false);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await delay(this.cfg.arduino.serialDelay);
ms = await this.cam2.move();
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
} catch (err) {
throw err;
}
return ms;
}
/**
* Move the both cameras one frame forward
*
* @param {array} rgb Color to set light for frame
**/
public async cameras_forward (rgb : number[] = [255, 255, 255]) {
const off : number[] = [0, 0, 0];
let both : number[];
let ms : number;
try {
if (!this.cam.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam.set(true);
}
if (!this.cam2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam2.set(true);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await delay(this.cfg.arduino.serialDelay);
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);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
} catch (err) {
throw err;
}
return ms;
}
/**
* Move the both cameras one frame backward
*
* @param {array} rgb Color to set light for frame
**/
public async cameras_backward (rgb : number[] = [255, 255, 255]) {
const off : number[] = [0, 0, 0];
let both : number[];
let ms : number;
try {
if (this.cam.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam.set(false);
}
if (this.cam2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam2.set(false);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await delay(this.cfg.arduino.serialDelay);
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);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
} catch (err) {
throw err;
}
return ms;
}
public async camera_forward_camera_second_backward (rgb : number[] = [255, 255, 255]) {
const off : number[] = [0, 0, 0];
let both : number[];
let ms : number;
try {
if (!this.cam.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam.set(true);
}
if (this.cam2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam2.set(false);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await delay(this.cfg.arduino.serialDelay);
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);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
} catch (err) {
throw err;
}
return ms;
}
public async camera_backward_camera_second_forward (rgb : number[] = [255, 255, 255]) {
const off : number[] = [0, 0, 0];
let both : number[];
let ms : number;
try {
if (this.cam.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam.set(false);
}
if (!this.cam2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.cam2.set(true);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(rgb);
await delay(this.cfg.arduino.serialDelay);
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);
}
await delay(this.cfg.arduino.serialDelay);
await this.light.set(off);
} catch (err) {
throw err;
}
return ms;
}
cameras_forward : 'CCF',
cameras_forward : 'CCB',
camera_forward_camera_second_backward : 'CFCB',
camera_backward_camera_second_forward : 'CBCF',
*/
/**
* Move the secondary projector forward one frame
*
* @param {function} callback Function to call after action
**/
/*cmd.projector_second_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);
}, this.cfg.arduino.serialDelay);
});
} else {
setTimeout(function () {
proj.move2(res);
}, this.cfg.arduino.serialDelay);
public async projector_second_forward () {
let ms : number;
try {
if (!this.proj2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj2.set(true);
}
await delay(this.cfg.arduino.serialDelay);
ms = await this.proj2.move();
} catch (err) {
throw err;
}
};
cmd.projector_second_backward = function (callback) {};
return ms;
}
public async projector_second_backward () {
let ms : number;
try {
if (this.proj2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj2.set(false);
}
await delay(this.cfg.arduino.serialDelay);
ms = await this.proj2.move();
} catch (err) {
throw err;
}
return ms;
}
cmd.projectors_forward = function (callback) {};
cmd.projectors_backward = function (callback) {};
public async projectors_forward () {
let both : number[];
let ms : number;
try {
if (!this.proj.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj.set(true);
}
if (!this.proj2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj2.set(true);
}
await delay(this.cfg.arduino.serialDelay);
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;
}
cmd.projector_forward_projector_second_backward = function (callback) {};
cmd.projector_backward_projector_second_forward = function (callback) {};
*/
public async projectors_backward () {
let both : number[];
let ms : number;
try {
if (this.proj.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj.set(false);
}
if (this.proj2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj2.set(false);
}
await delay(this.cfg.arduino.serialDelay);
//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;
}
public async projector_forward_projector_second_backward () {
let both : number[];
let ms : number;
try {
if (!this.proj.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj.set(true);
}
if (this.proj2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj2.set(false);
}
await delay(this.cfg.arduino.serialDelay);
//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;
}
public async projector_backward_projector_second_forward () {
let both : number[];
let ms : number;
try {
if (this.proj.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj.set(false);
}
if (!this.proj2.state.dir) {
await delay(this.cfg.arduino.serialDelay);
await this.proj2.set(true);
}
await delay(this.cfg.arduino.serialDelay);
//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;
}
}
module.exports = function (cfg : any, proj : any, cam : any, light : any) {
return new Commands(cfg, proj, cam, light);
module.exports = function (cfg : any, proj : any, cam : any, light : any, cam2 : any, proj2 : any) {
return new Commands(cfg, proj, cam, light, cam2, proj2);
}

View File

@ -257,7 +257,6 @@ class Devices {
this.log.info(`Connected to ${device} as PROJECTOR + CAMERA`, 'SERIAL', true, true)
} else if (type === 'projector_second') {
this.connected.projector_second = device
this.arduino.aliasSerial('projector_second', device)
try {
connectSuccess = await this.arduino.connect('projector_second', device, false)
} catch (err) {
@ -266,37 +265,74 @@ class Devices {
}
this.log.info(`Connected to ${device} as PROJECTOR_SECOND`, 'SERIAL', true, true)
} else if (type === 'projector,projector_second') {
/*this.connected.projector_second = device
this.connected.projector = device
this.connected.projector_second = device
this.arduino.aliasSerial('projector_second', device)
try {
connectSuccess = await this.arduino.connect('projector_second', device, false)
connectSuccess = await this.arduino.connect('projector', device, false)
} catch (err) {
console.error(err)
this.log.error('Error connecting to projector and secondary projector', err)
return false
}*/
}
} else if (type === 'camera_second') {
/*this.connected.projector_second = device
this.arduino.aliasSerial('projector_second', device)
this.connected.camera_second = device
try {
connectSuccess = await this.arduino.connect('projector_second', device, false)
connectSuccess = await this.arduino.connect('camera_second', device, false)
} catch (err) {
console.error(err)
return false
}*/
}
} else if (type === 'camera,camera_second') {
/*this.connected.projector_second = device
this.connected.camera = device
this.connected.camera_second = device
this.arduino.aliasSerial('camera_second', device)
try {
connectSuccess = await this.arduino.connect('camera', device, false)
} catch (err) {
this.log.error('Error connecting to camera, camera_secondary and projector', err)
return false
}
} else if ('camera,projector,projector_second') {
this.connected.camera = device
this.connected.projector = device
this.connected.projector_second = device
this.arduino.aliasSerial('projector', device)
this.arduino.aliasSerial('projector_second', device)
try {
connectSuccess = await this.arduino.connect('projector_second', device, false)
connectSuccess = await this.arduino.connect('camera', device, false)
} catch (err) {
console.error(err)
this.log.error('Error connecting to camera, projector and projector_second', err)
return false
}*/
}
} else if ('camera,camera_second,projector') {
this.connected.camera = device
this.connected.camera_second = device
this.connected.projector = device
this.arduino.aliasSerial('camera_second', device)
this.arduino.aliasSerial('projector', device)
try {
connectSuccess = await this.arduino.connect('camera', device, false)
} catch (err) {
this.log.error('Error connecting to camera, camera_second and projector', err)
return false
}
} else if ('camera,camera_second,projector,projector_second') {
this.connected.camera = device
this.connected.camera_second = device
this.connected.projector = device
this.connected.projector_second = device
this.arduino.aliasSerial('camera_second', device)
this.arduino.aliasSerial('projector', device)
this.arduino.aliasSerial('projector_second', device)
try {
connectSuccess = await this.arduino.connect('camera', device, false)
} catch (err) {
this.log.error('Error connecting to camera, camera_second, projector and projector_second', err)
return false
}
}
//camera,projector,projector_second
//camera,camera_second,projector
//camera,camera_second,projector,projector_second
return connectSuccess
}
/**
@ -309,7 +345,8 @@ class Devices {
let l : any = {}
let type : string;
let d : any
let s : any = {}
let cs : any = {}
let ps : any = {}
let checklist : any[] = []
this.connected = {
@ -358,11 +395,15 @@ class Devices {
l.arduino = this.connected.light
if (this.connected.projector_second) {
s = this.connected.projector_second
if (this.connected.camera_second) {
cs = { arduino : this.connected.camera_second }
}
return this.ready(p, c, l, s)
if (this.connected.projector_second) {
ps = { arduino : this.connected.projector_second }
}
return this.ready(p, c, l, cs, ps)
}
/**
*
@ -387,25 +428,37 @@ class Devices {
/**
*
**/
private ready (projector : any, camera : any, light : any, projector_second : any) {
private ready (projector : any, camera : any, light : any, camera_second : any, projector_second : any) {
let args : any = {
camera,
projector,
light,
profile: this.settings.state.profile
}
if (projector_second && projector_second.arduino) {
if (projector_second) {
args.projector_second = projector_second
}
this.ui.send('ready', args)
this.settings.update('camera', camera)
this.settings.update('projector', projector)
this.settings.update('light', light)
if (projector_second && projector_second.arduino) {
this.settings.update('projector_second', projector_second)
this.mainWindow.setSize(800, 800)
}
if (camera_second) {
args.camera_second = camera_second
this.settings.update('camera_second', camera_second)
if (projector_second) {
this.mainWindow.setSize(900, 800)
} else {
this.mainWindow.setSize(800, 800)
}
}
this.settings.update('camera', camera)
this.settings.update('projector', projector)
this.settings.update('light', light)
this.settings.save()
this.ui.send('ready', args)
return true
};

View File

@ -87,7 +87,20 @@ class Projector {
this.log.error(`Error moving ${this.id}`, err)
}
}
this.log.info('Projector move time', { ms });
//this.log.info('Projector move time', { ms });
return await this.end(cmd, id, ms)
}
public async both (frame : any, id : string) {
id = 'projectors';
const cmd : string = this.cfg.arduino.cmd[id];
let ms : number;
try {
ms = await this.arduino.send(this.id, cmd)
} catch (err) {
this.log.error(`Error moving ${this.id}`, err)
}
//this.log.info('Projectors move time', { ms });
return await this.end(cmd, id, ms)
}
@ -136,19 +149,22 @@ class Projector {
}
message += ' 1 frame'
} else if (cmd === this.cfg.arduino.cmd.projector_second) {
message = 'Projector second'
message = 'Projector second '
if (this.state.dir) {
message += 'ADVANCED'
} else {
message += 'REWOUND'
}
message += ' 1 frame'
} else if (cmd === this.cfg.arduino.cmd.projectors) {
message += 'Projectors both MOVED 1 frame each';
}
message += ` ${ms}ms`
this.log.info(message, 'PROJECTOR')
return await this.ui.send(this.id, {cmd: cmd, id : id, ms: ms})
}
}
module.exports = function (arduino : Arduino, cfg : any, ui : any, dig : any) {
return new Projector(arduino, cfg, ui, dig);
module.exports = function (arduino : Arduino, cfg : any, ui : any, dig : any, second : boolean) {
return new Projector(arduino, cfg, ui, dig, second);
}

View File

@ -120,6 +120,10 @@ class Sequencer {
await delay(42);
}
if (typeof this.arr[y] === 'undefined') {
continue
}
this.log.info(`Starting step ${y + 1} of loop ${x + 1}`)
this.ui.send(this.id, { step : y, loop : x, start : true });