In camera and projector modules, for both main and renderer, use a string id to bind ipc paths and set up the ability to then have multiple of the proj, cam or even light class. Need to do light.
This commit is contained in:
parent
600a0abc72
commit
fe046027da
|
@ -8,9 +8,14 @@ class Camera {
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
constructor(arduino, cfg, ui, dig) {
|
constructor(arduino, cfg, ui, dig) {
|
||||||
this.state = { dir: true, digital: false };
|
this.state = {
|
||||||
|
pos: 0,
|
||||||
|
dir: true,
|
||||||
|
digital: false
|
||||||
|
};
|
||||||
this.arduino = null;
|
this.arduino = null;
|
||||||
this.intval = null;
|
this.intval = null;
|
||||||
|
this.id = 'camera';
|
||||||
this.arduino = arduino;
|
this.arduino = arduino;
|
||||||
this.cfg = cfg;
|
this.cfg = cfg;
|
||||||
this.ui = ui;
|
this.ui = ui;
|
||||||
|
@ -21,7 +26,7 @@ class Camera {
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
async init() {
|
async init() {
|
||||||
this.log = await Log({ label: 'cam' });
|
this.log = await Log({ label: this.id });
|
||||||
this.ipc = require('electron').ipcMain;
|
this.ipc = require('electron').ipcMain;
|
||||||
this.listen();
|
this.listen();
|
||||||
}
|
}
|
||||||
|
@ -29,7 +34,7 @@ class Camera {
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
listen() {
|
listen() {
|
||||||
this.ipc.on('cam', this.listener.bind(this));
|
this.ipc.on(this.id, this.listener.bind(this));
|
||||||
this.ipc.on('intval', this.connectIntval.bind(this));
|
this.ipc.on('intval', this.connectIntval.bind(this));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -55,7 +60,7 @@ class Camera {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
ms = await this.arduino.send('camera', cmd);
|
ms = await this.arduino.send(this.id, cmd);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error(err);
|
this.log.error(err);
|
||||||
|
@ -82,7 +87,7 @@ class Camera {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
ms = await this.arduino.send('camera', cmd);
|
ms = await this.arduino.send(this.id, cmd);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error(err);
|
this.log.error(err);
|
||||||
|
@ -99,7 +104,7 @@ class Camera {
|
||||||
**/
|
**/
|
||||||
exposure(exposure, id) {
|
exposure(exposure, id) {
|
||||||
let cmd = 'E';
|
let cmd = 'E';
|
||||||
this.intval.setExposure('camera', exposure, (ms) => {
|
this.intval.setExposure(this.id, exposure, (ms) => {
|
||||||
this.end(cmd, id, ms);
|
this.end(cmd, id, ms);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -138,7 +143,6 @@ class Camera {
|
||||||
await this.set(arg.dir, arg.id);
|
await this.set(arg.dir, arg.id);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.trace();
|
|
||||||
this.log.error(err);
|
this.log.error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,10 +151,12 @@ class Camera {
|
||||||
await this.move(arg.frame, arg.id);
|
await this.move(arg.frame, arg.id);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.trace();
|
|
||||||
this.log.error(err);
|
this.log.error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (typeof arg.val !== 'undefined') {
|
||||||
|
this.state.pos = arg.val;
|
||||||
|
}
|
||||||
event.returnValue = true;
|
event.returnValue = true;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -175,7 +181,7 @@ class Camera {
|
||||||
message += ' 1 frame';
|
message += ' 1 frame';
|
||||||
}
|
}
|
||||||
this.log.info(message, 'CAMERA', true, true);
|
this.log.info(message, 'CAMERA', true, true);
|
||||||
this.ui.send('cam', { cmd: cmd, id: id, ms: ms });
|
this.ui.send(this.id, { cmd: cmd, id: id, ms: ms });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.exports = function (arduino, cfg, ui, dig) {
|
module.exports = function (arduino, cfg, ui, dig) {
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -7,8 +7,13 @@ class Projector {
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
constructor(arduino, cfg, ui, dig) {
|
constructor(arduino, cfg, ui, dig) {
|
||||||
this.state = { dir: true, digital: false };
|
this.state = {
|
||||||
|
pos: 0,
|
||||||
|
dir: true,
|
||||||
|
digital: false
|
||||||
|
};
|
||||||
this.arduino = null;
|
this.arduino = null;
|
||||||
|
this.id = 'projector';
|
||||||
this.arduino = arduino;
|
this.arduino = arduino;
|
||||||
this.cfg = cfg;
|
this.cfg = cfg;
|
||||||
this.ui = ui;
|
this.ui = ui;
|
||||||
|
@ -27,7 +32,7 @@ class Projector {
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
listen() {
|
listen() {
|
||||||
this.ipc.on('proj', this.listener.bind(this));
|
this.ipc.on(this.id, this.listener.bind(this));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -47,7 +52,7 @@ class Projector {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
ms = await this.arduino.send('projector', cmd);
|
ms = await this.arduino.send(this.id, cmd);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error('Error setting projector direction', err);
|
this.log.error('Error setting projector direction', err);
|
||||||
|
@ -71,7 +76,7 @@ class Projector {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
ms = await this.arduino.send('projector', cmd);
|
ms = await this.arduino.send(this.id, cmd);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error('Error moving projector', err);
|
this.log.error('Error moving projector', err);
|
||||||
|
@ -101,6 +106,7 @@ class Projector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (typeof arg.val !== 'undefined') {
|
else if (typeof arg.val !== 'undefined') {
|
||||||
|
this.state.pos = arg.val;
|
||||||
this.dig.state.frame = arg.val;
|
this.dig.state.frame = arg.val;
|
||||||
}
|
}
|
||||||
event.returnValue = true;
|
event.returnValue = true;
|
||||||
|
@ -127,7 +133,7 @@ class Projector {
|
||||||
message += ' 1 frame';
|
message += ' 1 frame';
|
||||||
}
|
}
|
||||||
this.log.info(message, 'PROJECTOR');
|
this.log.info(message, 'PROJECTOR');
|
||||||
return await this.ui.send('proj', { cmd: cmd, id: id, ms: ms });
|
return await this.ui.send(this.id, { cmd: cmd, id: id, ms: ms });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.exports = function (arduino, cfg, ui, dig) {
|
module.exports = function (arduino, cfg, ui, dig) {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/proj/index.ts"],"names":[],"mappings":";AAAA,iDAAiD;;AAEjD,2BAA4B;AAE5B,MAAM,SAAS;IAUd;;QAEI;IACJ,YAAa,OAAiB,EAAE,GAAS,EAAE,EAAQ,EAAE,GAAS;QAZtD,UAAK,GAAS,EAAE,GAAG,EAAG,IAAI,EAAE,OAAO,EAAG,KAAK,EAAE,CAAC;QAC9C,YAAO,GAAa,IAAI,CAAC;QAYhC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,EAAE,CAAC;IACb,CAAC;IAED;;QAEI;IACJ,KAAK,CAAC,IAAI;QACT,IAAI,CAAC,GAAG,GAAG,MAAM,GAAG,CAAC,EAAE,KAAK,EAAG,MAAM,EAAE,CAAC,CAAA;QACxC,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;QACvC,IAA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C,OAAO,GAAG,0BAA0B,CAAA;SACpC;aAAM,IAAI,GAAG,KAAK,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE;YACtD,OAAO,GAAG,2BAA2B,CAAA;SACrC;aAAM,IAAI,GAAG,KAAK,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE;YAClD,OAAO,GAAG,YAAY,CAAA;YACtB,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE;gBACnB,OAAO,IAAI,UAAU,CAAA;aACrB;iBAAM;gBACN,OAAO,IAAI,SAAS,CAAA;aACpB;YACD,OAAO,IAAI,UAAU,CAAA;SACrB;QACD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;QACnC,OAAO,MAAM,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,EAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAC,CAAC,CAAA;IAChE,CAAC;CACD;AAED,MAAM,CAAC,OAAO,GAAG,UAAU,OAAiB,EAAE,GAAS,EAAE,EAAQ,EAAE,GAAS;IAC3E,OAAO,IAAI,SAAS,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;AAC7C,CAAC,CAAA"}
|
|
@ -2,6 +2,7 @@ const cam = {};
|
||||||
|
|
||||||
cam.queue = {};
|
cam.queue = {};
|
||||||
cam.lock = false;
|
cam.lock = false;
|
||||||
|
cam.id = 'camera';
|
||||||
cam.init = function () {
|
cam.init = function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
cam.listen();
|
cam.listen();
|
||||||
|
@ -16,7 +17,7 @@ cam.set = function (dir, callback) {
|
||||||
dir : dir,
|
dir : dir,
|
||||||
id : uuid.v4()
|
id : uuid.v4()
|
||||||
};
|
};
|
||||||
ipcRenderer.sendSync('cam', obj);
|
ipcRenderer.sendSync(cam.id, obj);
|
||||||
|
|
||||||
if (typeof callback !== 'undefined') {
|
if (typeof callback !== 'undefined') {
|
||||||
obj.callback = callback;
|
obj.callback = callback;
|
||||||
|
@ -24,6 +25,15 @@ cam.set = function (dir, callback) {
|
||||||
cam.queue[obj.id] = obj;
|
cam.queue[obj.id] = obj;
|
||||||
cam.lock = true;
|
cam.lock = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
cam.setValue = function (val) {
|
||||||
|
'use strict';
|
||||||
|
var obj = {
|
||||||
|
val: val,
|
||||||
|
id : uuid.v4()
|
||||||
|
};
|
||||||
|
ipcRenderer.sendSync(cam.id, obj);
|
||||||
|
};
|
||||||
cam.move = function (callback) {
|
cam.move = function (callback) {
|
||||||
'use strict';
|
'use strict';
|
||||||
var obj;
|
var obj;
|
||||||
|
@ -34,7 +44,7 @@ cam.move = function (callback) {
|
||||||
frame : true,
|
frame : true,
|
||||||
id : uuid.v4()
|
id : uuid.v4()
|
||||||
};
|
};
|
||||||
ipcRenderer.sendSync('cam', obj);
|
ipcRenderer.sendSync(cam.id, obj);
|
||||||
|
|
||||||
if (typeof callback !== 'undefined') {
|
if (typeof callback !== 'undefined') {
|
||||||
obj.callback = callback;
|
obj.callback = callback;
|
||||||
|
@ -65,7 +75,7 @@ cam.end = function (c, id, ms) {
|
||||||
};
|
};
|
||||||
cam.listen = function () {
|
cam.listen = function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
ipcRenderer.on('cam', function (event, arg) {
|
ipcRenderer.on(cam.id, function (event, arg) {
|
||||||
cam.end(arg.cmd, arg.id, arg.ms);
|
cam.end(arg.cmd, arg.id, arg.ms);
|
||||||
return event.returnValue = true;
|
return event.returnValue = true;
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,6 +3,7 @@ const proj = {};
|
||||||
proj.queue = {};
|
proj.queue = {};
|
||||||
proj.lock = false;
|
proj.lock = false;
|
||||||
proj.lock2 = false;
|
proj.lock2 = false;
|
||||||
|
proj.id = 'projector';
|
||||||
proj.init = function () {
|
proj.init = function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
proj.listen();
|
proj.listen();
|
||||||
|
@ -17,7 +18,7 @@ proj.set = function (dir, callback) {
|
||||||
dir : dir,
|
dir : dir,
|
||||||
id : uuid.v4()
|
id : uuid.v4()
|
||||||
};
|
};
|
||||||
ipcRenderer.sendSync('proj', obj);
|
ipcRenderer.sendSync(proj.id, obj);
|
||||||
|
|
||||||
if (typeof callback !== 'undefined') {
|
if (typeof callback !== 'undefined') {
|
||||||
obj.callback = callback;
|
obj.callback = callback;
|
||||||
|
@ -35,7 +36,7 @@ proj.move = function (callback) {
|
||||||
frame : true,
|
frame : true,
|
||||||
id : uuid.v4()
|
id : uuid.v4()
|
||||||
};
|
};
|
||||||
ipcRenderer.sendSync('proj', obj);
|
ipcRenderer.sendSync(proj.id, obj);
|
||||||
|
|
||||||
if (typeof callback !== 'undefined') {
|
if (typeof callback !== 'undefined') {
|
||||||
obj.callback = callback;
|
obj.callback = callback;
|
||||||
|
@ -54,7 +55,7 @@ proj.set2 = function (dir, callback) {
|
||||||
second : true,
|
second : true,
|
||||||
id : uuid.v4()
|
id : uuid.v4()
|
||||||
};
|
};
|
||||||
ipcRenderer.sendSync('proj', obj);
|
ipcRenderer.sendSync(proj.id, obj);
|
||||||
|
|
||||||
if (typeof callback !== 'undefined') {
|
if (typeof callback !== 'undefined') {
|
||||||
obj.callback = callback;
|
obj.callback = callback;
|
||||||
|
@ -73,7 +74,7 @@ proj.move2 = function (callback) {
|
||||||
second : true,
|
second : true,
|
||||||
id : uuid.v4()
|
id : uuid.v4()
|
||||||
};
|
};
|
||||||
ipcRenderer.sendSync('proj', obj);
|
ipcRenderer.sendSync(proj.id, obj);
|
||||||
|
|
||||||
if (typeof callback !== 'undefined') {
|
if (typeof callback !== 'undefined') {
|
||||||
obj.callback = callback;
|
obj.callback = callback;
|
||||||
|
@ -92,7 +93,7 @@ proj.both = function (callback) {
|
||||||
both : true,
|
both : true,
|
||||||
id : uuid.v4()
|
id : uuid.v4()
|
||||||
};
|
};
|
||||||
ipcRenderer.sendSync('proj', obj);
|
ipcRenderer.sendSync(proj.id, obj);
|
||||||
|
|
||||||
if (typeof callback !== 'undefined') {
|
if (typeof callback !== 'undefined') {
|
||||||
obj.callback = callback;
|
obj.callback = callback;
|
||||||
|
@ -125,7 +126,7 @@ proj.end = function (c, id, ms) {
|
||||||
};
|
};
|
||||||
proj.listen = function () {
|
proj.listen = function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
ipcRenderer.on('proj', function (event, arg) {
|
ipcRenderer.on(proj.id, function (event, arg) {
|
||||||
proj.end(arg.cmd, arg.id, arg.ms);
|
proj.end(arg.cmd, arg.id, arg.ms);
|
||||||
return event.returnValue = true;
|
return event.returnValue = true;
|
||||||
});
|
});
|
||||||
|
@ -137,7 +138,7 @@ proj.setValue = function (val) {
|
||||||
val: val,
|
val: val,
|
||||||
id : uuid.v4()
|
id : uuid.v4()
|
||||||
};
|
};
|
||||||
ipcRenderer.sendSync('proj', obj);
|
ipcRenderer.sendSync(proj.id, obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
proj.setValue2 = function (val) {
|
proj.setValue2 = function (val) {
|
||||||
|
@ -147,7 +148,7 @@ proj.setValue2 = function (val) {
|
||||||
second : true,
|
second : true,
|
||||||
id : uuid.v4()
|
id : uuid.v4()
|
||||||
};
|
};
|
||||||
ipcRenderer.sendSync('proj', obj);
|
ipcRenderer.sendSync(proj.id, obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = proj;
|
module.exports = proj;
|
|
@ -8,9 +8,14 @@ class Camera {
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
constructor(arduino, cfg, ui, dig) {
|
constructor(arduino, cfg, ui, dig) {
|
||||||
this.state = { dir: true, digital: false };
|
this.state = {
|
||||||
|
pos: 0,
|
||||||
|
dir: true,
|
||||||
|
digital: false
|
||||||
|
};
|
||||||
this.arduino = null;
|
this.arduino = null;
|
||||||
this.intval = null;
|
this.intval = null;
|
||||||
|
this.id = 'camera';
|
||||||
this.arduino = arduino;
|
this.arduino = arduino;
|
||||||
this.cfg = cfg;
|
this.cfg = cfg;
|
||||||
this.ui = ui;
|
this.ui = ui;
|
||||||
|
@ -21,7 +26,7 @@ class Camera {
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
async init() {
|
async init() {
|
||||||
this.log = await Log({ label: 'cam' });
|
this.log = await Log({ label: this.id });
|
||||||
this.ipc = require('electron').ipcMain;
|
this.ipc = require('electron').ipcMain;
|
||||||
this.listen();
|
this.listen();
|
||||||
}
|
}
|
||||||
|
@ -29,7 +34,7 @@ class Camera {
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
listen() {
|
listen() {
|
||||||
this.ipc.on('cam', this.listener.bind(this));
|
this.ipc.on(this.id, this.listener.bind(this));
|
||||||
this.ipc.on('intval', this.connectIntval.bind(this));
|
this.ipc.on('intval', this.connectIntval.bind(this));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -55,7 +60,7 @@ class Camera {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
ms = await this.arduino.send('camera', cmd);
|
ms = await this.arduino.send(this.id, cmd);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error(err);
|
this.log.error(err);
|
||||||
|
@ -82,7 +87,7 @@ class Camera {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
ms = await this.arduino.send('camera', cmd);
|
ms = await this.arduino.send(this.id, cmd);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error(err);
|
this.log.error(err);
|
||||||
|
@ -99,7 +104,7 @@ class Camera {
|
||||||
**/
|
**/
|
||||||
exposure(exposure, id) {
|
exposure(exposure, id) {
|
||||||
let cmd = 'E';
|
let cmd = 'E';
|
||||||
this.intval.setExposure('camera', exposure, (ms) => {
|
this.intval.setExposure(this.id, exposure, (ms) => {
|
||||||
this.end(cmd, id, ms);
|
this.end(cmd, id, ms);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -138,7 +143,6 @@ class Camera {
|
||||||
await this.set(arg.dir, arg.id);
|
await this.set(arg.dir, arg.id);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.trace();
|
|
||||||
this.log.error(err);
|
this.log.error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,10 +151,12 @@ class Camera {
|
||||||
await this.move(arg.frame, arg.id);
|
await this.move(arg.frame, arg.id);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.trace();
|
|
||||||
this.log.error(err);
|
this.log.error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (typeof arg.val !== 'undefined') {
|
||||||
|
this.state.pos = arg.val;
|
||||||
|
}
|
||||||
event.returnValue = true;
|
event.returnValue = true;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -175,7 +181,7 @@ class Camera {
|
||||||
message += ' 1 frame';
|
message += ' 1 frame';
|
||||||
}
|
}
|
||||||
this.log.info(message, 'CAMERA', true, true);
|
this.log.info(message, 'CAMERA', true, true);
|
||||||
this.ui.send('cam', { cmd: cmd, id: id, ms: ms });
|
this.ui.send(this.id, { cmd: cmd, id: id, ms: ms });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.exports = function (arduino, cfg, ui, dig) {
|
module.exports = function (arduino, cfg, ui, dig) {
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -7,8 +7,13 @@ class Projector {
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
constructor(arduino, cfg, ui, dig) {
|
constructor(arduino, cfg, ui, dig) {
|
||||||
this.state = { dir: true, digital: false };
|
this.state = {
|
||||||
|
pos: 0,
|
||||||
|
dir: true,
|
||||||
|
digital: false
|
||||||
|
};
|
||||||
this.arduino = null;
|
this.arduino = null;
|
||||||
|
this.id = 'projector';
|
||||||
this.arduino = arduino;
|
this.arduino = arduino;
|
||||||
this.cfg = cfg;
|
this.cfg = cfg;
|
||||||
this.ui = ui;
|
this.ui = ui;
|
||||||
|
@ -27,7 +32,7 @@ class Projector {
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
listen() {
|
listen() {
|
||||||
this.ipc.on('proj', this.listener.bind(this));
|
this.ipc.on(this.id, this.listener.bind(this));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -47,7 +52,7 @@ class Projector {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
ms = await this.arduino.send('projector', cmd);
|
ms = await this.arduino.send(this.id, cmd);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error('Error setting projector direction', err);
|
this.log.error('Error setting projector direction', err);
|
||||||
|
@ -71,7 +76,7 @@ class Projector {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
ms = await this.arduino.send('projector', cmd);
|
ms = await this.arduino.send(this.id, cmd);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error('Error moving projector', err);
|
this.log.error('Error moving projector', err);
|
||||||
|
@ -101,6 +106,7 @@ class Projector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (typeof arg.val !== 'undefined') {
|
else if (typeof arg.val !== 'undefined') {
|
||||||
|
this.state.pos = arg.val;
|
||||||
this.dig.state.frame = arg.val;
|
this.dig.state.frame = arg.val;
|
||||||
}
|
}
|
||||||
event.returnValue = true;
|
event.returnValue = true;
|
||||||
|
@ -127,7 +133,7 @@ class Projector {
|
||||||
message += ' 1 frame';
|
message += ' 1 frame';
|
||||||
}
|
}
|
||||||
this.log.info(message, 'PROJECTOR');
|
this.log.info(message, 'PROJECTOR');
|
||||||
return await this.ui.send('proj', { cmd: cmd, id: id, ms: ms });
|
return await this.ui.send(this.id, { cmd: cmd, id: id, ms: ms });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.exports = function (arduino, cfg, ui, dig) {
|
module.exports = function (arduino, cfg, ui, dig) {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/proj/index.ts"],"names":[],"mappings":";AAAA,iDAAiD;;AAEjD,2BAA4B;AAE5B,MAAM,SAAS;IAUd;;QAEI;IACJ,YAAa,OAAiB,EAAE,GAAS,EAAE,EAAQ,EAAE,GAAS;QAZtD,UAAK,GAAS,EAAE,GAAG,EAAG,IAAI,EAAE,OAAO,EAAG,KAAK,EAAE,CAAC;QAC9C,YAAO,GAAa,IAAI,CAAC;QAYhC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,EAAE,CAAC;IACb,CAAC;IAED;;QAEI;IACJ,KAAK,CAAC,IAAI;QACT,IAAI,CAAC,GAAG,GAAG,MAAM,GAAG,CAAC,EAAE,KAAK,EAAG,MAAM,EAAE,CAAC,CAAA;QACxC,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;QACvC,IAAI,CAAC,MAAM,EAAE,CAAC;IACf,CAAC;IAED;;QAEI;IACI,MAAM;QACb,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/C,CAAC;IAED;;QAEI;IACJ,KAAK,CAAC,GAAG,CAAE,GAAa,EAAE,EAAW;QACpC,IAAI,GAAY,CAAC;QACjB,IAAI,EAAW,CAAC;QAChB,IAAI,GAAG,EAAE;YACR,GAAG,GAAG,IAAI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AU,CAAA;aACrB;iBAAM;gBACN,OAAO,IAAI,SAAS,CAAA;aACpB;YACD,OAAO,IAAI,UAAU,CAAA;SACrB;QACD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;QACnC,OAAO,MAAM,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,EAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAC,CAAC,CAAA;IAChE,CAAC;CACD;AAED,MAAM,CAAC,OAAO,GAAG,UAAU,OAAiB,EAAE,GAAS,EAAE,EAAQ,EAAE,GAAS;IAC3E,OAAO,IAAI,SAAS,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;AAC7C,CAAC,CAAA"}
|
|
@ -8,9 +8,14 @@ class Camera {
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
constructor(arduino, cfg, ui, dig) {
|
constructor(arduino, cfg, ui, dig) {
|
||||||
this.state = { dir: true, digital: false };
|
this.state = {
|
||||||
|
pos: 0,
|
||||||
|
dir: true,
|
||||||
|
digital: false
|
||||||
|
};
|
||||||
this.arduino = null;
|
this.arduino = null;
|
||||||
this.intval = null;
|
this.intval = null;
|
||||||
|
this.id = 'camera';
|
||||||
this.arduino = arduino;
|
this.arduino = arduino;
|
||||||
this.cfg = cfg;
|
this.cfg = cfg;
|
||||||
this.ui = ui;
|
this.ui = ui;
|
||||||
|
@ -21,7 +26,7 @@ class Camera {
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
async init() {
|
async init() {
|
||||||
this.log = await Log({ label: 'cam' });
|
this.log = await Log({ label: this.id });
|
||||||
this.ipc = require('electron').ipcMain;
|
this.ipc = require('electron').ipcMain;
|
||||||
this.listen();
|
this.listen();
|
||||||
}
|
}
|
||||||
|
@ -29,7 +34,7 @@ class Camera {
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
listen() {
|
listen() {
|
||||||
this.ipc.on('cam', this.listener.bind(this));
|
this.ipc.on(this.id, this.listener.bind(this));
|
||||||
this.ipc.on('intval', this.connectIntval.bind(this));
|
this.ipc.on('intval', this.connectIntval.bind(this));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -55,7 +60,7 @@ class Camera {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
ms = await this.arduino.send('camera', cmd);
|
ms = await this.arduino.send(this.id, cmd);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error(err);
|
this.log.error(err);
|
||||||
|
@ -82,7 +87,7 @@ class Camera {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
ms = await this.arduino.send('camera', cmd);
|
ms = await this.arduino.send(this.id, cmd);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error(err);
|
this.log.error(err);
|
||||||
|
@ -99,7 +104,7 @@ class Camera {
|
||||||
**/
|
**/
|
||||||
exposure(exposure, id) {
|
exposure(exposure, id) {
|
||||||
let cmd = 'E';
|
let cmd = 'E';
|
||||||
this.intval.setExposure('camera', exposure, (ms) => {
|
this.intval.setExposure(this.id, exposure, (ms) => {
|
||||||
this.end(cmd, id, ms);
|
this.end(cmd, id, ms);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -138,7 +143,6 @@ class Camera {
|
||||||
await this.set(arg.dir, arg.id);
|
await this.set(arg.dir, arg.id);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.trace();
|
|
||||||
this.log.error(err);
|
this.log.error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,10 +151,12 @@ class Camera {
|
||||||
await this.move(arg.frame, arg.id);
|
await this.move(arg.frame, arg.id);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.trace();
|
|
||||||
this.log.error(err);
|
this.log.error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (typeof arg.val !== 'undefined') {
|
||||||
|
this.state.pos = arg.val;
|
||||||
|
}
|
||||||
event.returnValue = true;
|
event.returnValue = true;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -175,7 +181,7 @@ class Camera {
|
||||||
message += ' 1 frame';
|
message += ' 1 frame';
|
||||||
}
|
}
|
||||||
this.log.info(message, 'CAMERA', true, true);
|
this.log.info(message, 'CAMERA', true, true);
|
||||||
this.ui.send('cam', { cmd: cmd, id: id, ms: ms });
|
this.ui.send(this.id, { cmd: cmd, id: id, ms: ms });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.exports = function (arduino, cfg, ui, dig) {
|
module.exports = function (arduino, cfg, ui, dig) {
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -7,8 +7,13 @@ class Projector {
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
constructor(arduino, cfg, ui, dig) {
|
constructor(arduino, cfg, ui, dig) {
|
||||||
this.state = { dir: true, digital: false };
|
this.state = {
|
||||||
|
pos: 0,
|
||||||
|
dir: true,
|
||||||
|
digital: false
|
||||||
|
};
|
||||||
this.arduino = null;
|
this.arduino = null;
|
||||||
|
this.id = 'projector';
|
||||||
this.arduino = arduino;
|
this.arduino = arduino;
|
||||||
this.cfg = cfg;
|
this.cfg = cfg;
|
||||||
this.ui = ui;
|
this.ui = ui;
|
||||||
|
@ -27,7 +32,7 @@ class Projector {
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
listen() {
|
listen() {
|
||||||
this.ipc.on('proj', this.listener.bind(this));
|
this.ipc.on(this.id, this.listener.bind(this));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -47,7 +52,7 @@ class Projector {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
ms = await this.arduino.send('projector', cmd);
|
ms = await this.arduino.send(this.id, cmd);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error('Error setting projector direction', err);
|
this.log.error('Error setting projector direction', err);
|
||||||
|
@ -71,7 +76,7 @@ class Projector {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
ms = await this.arduino.send('projector', cmd);
|
ms = await this.arduino.send(this.id, cmd);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error('Error moving projector', err);
|
this.log.error('Error moving projector', err);
|
||||||
|
@ -101,6 +106,7 @@ class Projector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (typeof arg.val !== 'undefined') {
|
else if (typeof arg.val !== 'undefined') {
|
||||||
|
this.state.pos = arg.val;
|
||||||
this.dig.state.frame = arg.val;
|
this.dig.state.frame = arg.val;
|
||||||
}
|
}
|
||||||
event.returnValue = true;
|
event.returnValue = true;
|
||||||
|
@ -127,7 +133,7 @@ class Projector {
|
||||||
message += ' 1 frame';
|
message += ' 1 frame';
|
||||||
}
|
}
|
||||||
this.log.info(message, 'PROJECTOR');
|
this.log.info(message, 'PROJECTOR');
|
||||||
return await this.ui.send('proj', { cmd: cmd, id: id, ms: ms });
|
return await this.ui.send(this.id, { cmd: cmd, id: id, ms: ms });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.exports = function (arduino, cfg, ui, dig) {
|
module.exports = function (arduino, cfg, ui, dig) {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/proj/index.ts"],"names":[],"mappings":";AAAA,iDAAiD;;AAEjD,2BAA4B;AAE5B,MAAM,SAAS;IAUd;;QAEI;IACJ,YAAa,OAAiB,EAAE,GAAS,EAAE,EAAQ,EAAE,GAAS;QAZtD,UAAK,GAAS,EAAE,GAAG,EAAG,IAAI,EAAE,OAAO,EAAG,KAAK,EAAE,CAAC;QAC9C,YAAO,GAAa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AC,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;AAC7C,CAAC,CAAA"}
|
|
@ -7,7 +7,11 @@ import delay = require('delay');
|
||||||
/** class representing camera functions **/
|
/** class representing camera functions **/
|
||||||
|
|
||||||
class Camera {
|
class Camera {
|
||||||
private state : any = { dir : true, digital : false };
|
private state : any = {
|
||||||
|
pos : 0,
|
||||||
|
dir : true,
|
||||||
|
digital : false
|
||||||
|
};
|
||||||
private arduino : Arduino = null;
|
private arduino : Arduino = null;
|
||||||
private intval : any = null;
|
private intval : any = null;
|
||||||
private log : any;
|
private log : any;
|
||||||
|
@ -15,6 +19,7 @@ class Camera {
|
||||||
private dig : any;
|
private dig : any;
|
||||||
private ui : any;
|
private ui : any;
|
||||||
private ipc : any;
|
private ipc : any;
|
||||||
|
private id : string = 'camera';
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
@ -30,7 +35,7 @@ class Camera {
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
private async init () {
|
private async init () {
|
||||||
this.log = await Log({ label : 'cam' });
|
this.log = await Log({ label : this.id });
|
||||||
this.ipc = require('electron').ipcMain;
|
this.ipc = require('electron').ipcMain;
|
||||||
this.listen();
|
this.listen();
|
||||||
}
|
}
|
||||||
|
@ -39,7 +44,7 @@ class Camera {
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
private listen () {
|
private listen () {
|
||||||
this.ipc.on('cam', this.listener.bind(this));
|
this.ipc.on(this.id, this.listener.bind(this));
|
||||||
this.ipc.on('intval', this.connectIntval.bind(this));
|
this.ipc.on('intval', this.connectIntval.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +70,7 @@ class Camera {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
ms = await this.arduino.send('camera', cmd);
|
ms = await this.arduino.send(this.id, cmd);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.log.error(err);
|
this.log.error(err);
|
||||||
}
|
}
|
||||||
|
@ -90,7 +95,7 @@ class Camera {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
ms = await this.arduino.send('camera', cmd);
|
ms = await this.arduino.send(this.id, cmd);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.log.error(err);
|
this.log.error(err);
|
||||||
}
|
}
|
||||||
|
@ -107,7 +112,7 @@ class Camera {
|
||||||
**/
|
**/
|
||||||
public exposure (exposure : number, id : string) {
|
public exposure (exposure : number, id : string) {
|
||||||
let cmd : string = 'E';
|
let cmd : string = 'E';
|
||||||
this.intval.setExposure('camera', exposure, (ms : number) => {
|
this.intval.setExposure(this.id, exposure, (ms : number) => {
|
||||||
this.end(cmd, id, ms);
|
this.end(cmd, id, ms);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -143,42 +148,42 @@ class Camera {
|
||||||
private async listener (event : any, arg : any) {
|
private async listener (event : any, arg : any) {
|
||||||
if (typeof arg.dir !== 'undefined') {
|
if (typeof arg.dir !== 'undefined') {
|
||||||
try {
|
try {
|
||||||
await this.set(arg.dir, arg.id)
|
await this.set(arg.dir, arg.id);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.trace()
|
this.log.error(err);
|
||||||
this.log.error(err)
|
|
||||||
}
|
}
|
||||||
} else if (typeof arg.frame !== 'undefined') {
|
} else if (typeof arg.frame !== 'undefined') {
|
||||||
try {
|
try {
|
||||||
await this.move(arg.frame, arg.id)
|
await this.move(arg.frame, arg.id);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.trace()
|
this.log.error(err);
|
||||||
this.log.error(err)
|
|
||||||
}
|
}
|
||||||
|
} else if (typeof arg.val !== 'undefined') {
|
||||||
|
this.state.pos = arg.val;
|
||||||
}
|
}
|
||||||
event.returnValue = true
|
event.returnValue = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
private async end (cmd : string, id : string, ms : number) {
|
private async end (cmd : string, id : string, ms : number) {
|
||||||
let message = ''
|
let message = '';
|
||||||
if (cmd === this.cfg.arduino.cmd.cam_forward) {
|
if (cmd === this.cfg.arduino.cmd.cam_forward) {
|
||||||
message = 'Camera set to FORWARD'
|
message = 'Camera set to FORWARD';
|
||||||
} else if (cmd === this.cfg.arduino.cmd.cam_backward) {
|
} else if (cmd === this.cfg.arduino.cmd.cam_backward) {
|
||||||
message = 'Camera set to BACKWARD'
|
message = 'Camera set to BACKWARD';
|
||||||
} else if (cmd === this.cfg.arduino.cmd.camera) {
|
} else if (cmd === this.cfg.arduino.cmd.camera) {
|
||||||
message = 'Camera '
|
message = 'Camera ';
|
||||||
if (this.state.dir) {
|
if (this.state.dir) {
|
||||||
message += 'ADVANCED'
|
message += 'ADVANCED';
|
||||||
} else {
|
} else {
|
||||||
message += 'REWOUND'
|
message += 'REWOUND';
|
||||||
}
|
}
|
||||||
message += ' 1 frame'
|
message += ' 1 frame';
|
||||||
}
|
}
|
||||||
this.log.info(message, 'CAMERA', true, true)
|
this.log.info(message, 'CAMERA', true, true)
|
||||||
this.ui.send('cam', {cmd: cmd, id : id, ms: ms})
|
this.ui.send(this.id, {cmd: cmd, id : id, ms: ms})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,15 +3,20 @@
|
||||||
import Log = require('log');
|
import Log = require('log');
|
||||||
|
|
||||||
class Projector {
|
class Projector {
|
||||||
private state : any = { dir : true, digital : false };
|
private state : any = {
|
||||||
|
pos : 0,
|
||||||
|
dir : true,
|
||||||
|
digital : false
|
||||||
|
};
|
||||||
private arduino : Arduino = null;
|
private arduino : Arduino = null;
|
||||||
//private dig : Digital = null;
|
|
||||||
private log : any;
|
private log : any;
|
||||||
private cfg : any;
|
private cfg : any;
|
||||||
private ui : any;
|
private ui : any;
|
||||||
private ipc : any;
|
private ipc : any;
|
||||||
private dig : any;
|
private dig : any;
|
||||||
|
|
||||||
|
private id : string = 'projector';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
@ -26,7 +31,7 @@ class Projector {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
async init () {
|
private async init () {
|
||||||
this.log = await Log({ label : 'proj' })
|
this.log = await Log({ label : 'proj' })
|
||||||
this.ipc = require('electron').ipcMain;
|
this.ipc = require('electron').ipcMain;
|
||||||
this.listen();
|
this.listen();
|
||||||
|
@ -36,13 +41,13 @@ class Projector {
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
private listen () {
|
private listen () {
|
||||||
this.ipc.on('proj', this.listener.bind(this));
|
this.ipc.on(this.id, this.listener.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
async set (dir : boolean, id : string) {
|
public async set (dir : boolean, id : string) {
|
||||||
let cmd : string;
|
let cmd : string;
|
||||||
let ms : number;
|
let ms : number;
|
||||||
if (dir) {
|
if (dir) {
|
||||||
|
@ -55,7 +60,7 @@ class Projector {
|
||||||
this.dig.set(dir)
|
this.dig.set(dir)
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
ms = await this.arduino.send('projector', cmd)
|
ms = await this.arduino.send(this.id, cmd)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.log.error('Error setting projector direction', err)
|
this.log.error('Error setting projector direction', err)
|
||||||
}
|
}
|
||||||
|
@ -66,7 +71,7 @@ class Projector {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
async move (frame : any, id : string) {
|
public async move (frame : any, id : string) {
|
||||||
const cmd : string = this.cfg.arduino.cmd.projector;
|
const cmd : string = this.cfg.arduino.cmd.projector;
|
||||||
let ms : number;
|
let ms : number;
|
||||||
if (this.dig.state.enabled) {
|
if (this.dig.state.enabled) {
|
||||||
|
@ -77,7 +82,7 @@ class Projector {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
ms = await this.arduino.send('projector', cmd)
|
ms = await this.arduino.send(this.id, cmd)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.log.error('Error moving projector', err)
|
this.log.error('Error moving projector', err)
|
||||||
}
|
}
|
||||||
|
@ -103,6 +108,7 @@ class Projector {
|
||||||
this.log.error(err)
|
this.log.error(err)
|
||||||
}
|
}
|
||||||
} else if (typeof arg.val !== 'undefined') {
|
} else if (typeof arg.val !== 'undefined') {
|
||||||
|
this.state.pos = arg.val;
|
||||||
this.dig.state.frame = arg.val
|
this.dig.state.frame = arg.val
|
||||||
}
|
}
|
||||||
event.returnValue = true
|
event.returnValue = true
|
||||||
|
@ -127,7 +133,7 @@ class Projector {
|
||||||
message += ' 1 frame'
|
message += ' 1 frame'
|
||||||
}
|
}
|
||||||
this.log.info(message, 'PROJECTOR')
|
this.log.info(message, 'PROJECTOR')
|
||||||
return await this.ui.send('proj', {cmd: cmd, id : id, ms: ms})
|
return await this.ui.send(this.id, {cmd: cmd, id : id, ms: ms})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue