Methods in place for setting exposure

This commit is contained in:
Matt McWilliams 2023-07-05 15:17:45 -04:00
parent a7db072dc6
commit 4539c6d897
8 changed files with 102 additions and 12 deletions

View File

@ -2,6 +2,7 @@
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const intval_1 = require("intval"); const intval_1 = require("intval");
const processing_1 = require("processing"); const processing_1 = require("processing");
const delay_1 = require("delay");
/** class representing camera functions **/ /** class representing camera functions **/
class Camera { class Camera {
/** /**
@ -157,11 +158,34 @@ class Camera {
/** /**
* *
**/ **/
exposure(exposure, id) { async exposure(exposure, id) {
let cmd = 'E'; const cmd = this.cfg.arduino.cmd.camera_exposure;
this.intval.setExposure(this.id, exposure, (ms) => { const str = `${exposure}`;
this.end(cmd, id, ms); let ms;
}); if (this.intval) {
return this.intval.setExposure(this.id, exposure, (ms) => {
return this.end(cmd, id, ms);
});
}
else if (this.arduino.hasState[id]) {
try {
ms = await this.arduino.send(this.id, cmd);
}
catch (err) {
this.log.error('Error sending camera exposure command', err);
}
await delay_1.delay(1);
try {
this.arduino.sendString(this.id, str);
}
catch (err) {
this.log.error('Error sending camera exposure string', err);
}
await delay_1.delay(1);
await ms;
return await this.end(cmd, id, ms);
}
return 0;
} }
/** /**
* *
@ -274,9 +298,13 @@ class Camera {
else if (cmd === this.cfg.arduino.cmd.camerass) { else if (cmd === this.cfg.arduino.cmd.camerass) {
message += 'Cameras both MOVED 1 frame each'; message += 'Cameras both MOVED 1 frame each';
} }
else if (cmd === this.cfg.arduino.camera_exposure) {
message += 'Camera set exposure';
}
message += ` ${ms}ms`; message += ` ${ms}ms`;
this.log.info(message); this.log.info(message);
this.ui.send(this.id, { cmd: cmd, id: id, ms: ms }); this.ui.send(this.id, { cmd: cmd, id: id, ms: ms });
return ms;
} }
} }
module.exports = function (arduino, cfg, ui, filmout, second) { module.exports = function (arduino, cfg, ui, filmout, second) {

File diff suppressed because one or more lines are too long

View File

@ -627,6 +627,16 @@ class Commands {
} }
return ms; return ms;
} }
async camera_exposure(cmd) {
let ms;
try {
ms = await this.cam.exposure(cmd.light);
}
catch (err) {
throw err;
}
return ms;
}
} }
module.exports = function (cfg, proj, cam, light, alert, cam2, proj2, capper) { module.exports = function (cfg, proj, cam, light, alert, cam2, proj2, capper) {
return new Commands(cfg, proj, cam, light, alert, cam2, proj2, capper); return new Commands(cfg, proj, cam, light, alert, cam2, proj2, capper);

File diff suppressed because one or more lines are too long

View File

@ -90,6 +90,18 @@ cam.end = function (c, id, ms) {
cam.lock = false; cam.lock = false;
} }
}; };
cam.exposure = function (exposure, callback) {
var obj = {
id : uuid(),
exposure
}
ipcRenderer.sendSync(cam.id)
if (typeof callback !== 'undefined') {
callback();
}
}
cam.listen = function () { cam.listen = function () {
'use strict'; 'use strict';
ipcRenderer.on(cam.id, function (event, arg) { ipcRenderer.on(cam.id, function (event, arg) {

View File

@ -161,11 +161,31 @@ class Camera {
/** /**
* *
**/ **/
public exposure (exposure : number, id : string) { public async exposure (exposure : number, id : string) {
let cmd : string = 'E'; const cmd : string = this.cfg.arduino.cmd.camera_exposure;
this.intval.setExposure(this.id, exposure, (ms : number) => { const str : string = `${exposure}`;
this.end(cmd, id, ms); let ms : any;
}); if (this.intval) {
return this.intval.setExposure(this.id, exposure, (ms : number) => {
return this.end(cmd, id, ms);
});
} else if (this.arduino.hasState[id]) {
try {
ms = await this.arduino.send(this.id, cmd);
} catch (err) {
this.log.error('Error sending camera exposure command', err);
}
await delay(1);
try {
this.arduino.sendString(this.id, str);
} catch (err) {
this.log.error('Error sending camera exposure string', err);
}
await delay(1);
await ms;
return await this.end(cmd, id, ms);
}
return 0;
} }
/** /**
@ -230,6 +250,12 @@ class Camera {
} catch (err) { } catch (err) {
this.log.error(err) this.log.error(err)
} }
} else if (typeof arg.exposure !== 'undefined') {
try {
await this.exposure(arg.exposure, arg.id);
} catch (err) {
this.log.error(err);
}
} }
event.returnValue = true event.returnValue = true
} }
@ -265,10 +291,13 @@ class Camera {
message += ' 1 frame'; message += ' 1 frame';
} else if (cmd === this.cfg.arduino.cmd.camerass) { } else if (cmd === this.cfg.arduino.cmd.camerass) {
message += 'Cameras both MOVED 1 frame each'; message += 'Cameras both MOVED 1 frame each';
} else if (cmd === this.cfg.arduino.camera_exposure) {
message += 'Camera set exposure';
} }
message += ` ${ms}ms` message += ` ${ms}ms`
this.log.info(message); this.log.info(message);
this.ui.send(this.id, {cmd: cmd, id : id, ms: ms}); this.ui.send(this.id, {cmd: cmd, id : id, ms: ms});
return ms;
} }
} }

View File

@ -636,6 +636,16 @@ class Commands {
} }
return ms; return ms;
} }
public async camera_exposure (cmd : any) {
let ms : number;
try {
ms = await this.cam.exposure(cmd.light);
} catch (err) {
throw err;
}
return ms;
}
} }
module.exports = function (cfg : any, proj : any, cam : any, light : any, alert : any, cam2 : any, proj2 : any, capper : any) { module.exports = function (cfg : any, proj : any, cam : any, light : any, alert : any, cam2 : any, proj2 : any, capper : any) {

1
src/globals.d.ts vendored
View File

@ -19,6 +19,7 @@ interface Device {
} }
interface Arduino { interface Arduino {
hasState : any;
send (id : string, cmd : string) : number; send (id : string, cmd : string) : number;
sendString (id : string, str : string) : any; sendString (id : string, str : string) : any;
enumerate () : any; enumerate () : any;