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 });
const intval_1 = require("intval");
const processing_1 = require("processing");
const delay_1 = require("delay");
/** class representing camera functions **/
class Camera {
/**
@ -157,11 +158,34 @@ class Camera {
/**
*
**/
exposure(exposure, id) {
let cmd = 'E';
this.intval.setExposure(this.id, exposure, (ms) => {
this.end(cmd, id, ms);
});
async exposure(exposure, id) {
const cmd = this.cfg.arduino.cmd.camera_exposure;
const str = `${exposure}`;
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) {
message += 'Cameras both MOVED 1 frame each';
}
else if (cmd === this.cfg.arduino.camera_exposure) {
message += 'Camera set exposure';
}
message += ` ${ms}ms`;
this.log.info(message);
this.ui.send(this.id, { cmd: cmd, id: id, ms: ms });
return ms;
}
}
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;
}
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) {
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.exposure = function (exposure, callback) {
var obj = {
id : uuid(),
exposure
}
ipcRenderer.sendSync(cam.id)
if (typeof callback !== 'undefined') {
callback();
}
}
cam.listen = function () {
'use strict';
ipcRenderer.on(cam.id, function (event, arg) {

View File

@ -161,11 +161,31 @@ class Camera {
/**
*
**/
public exposure (exposure : number, id : string) {
let cmd : string = 'E';
this.intval.setExposure(this.id, exposure, (ms : number) => {
this.end(cmd, id, ms);
});
public async exposure (exposure : number, id : string) {
const cmd : string = this.cfg.arduino.cmd.camera_exposure;
const str : string = `${exposure}`;
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) {
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
}
@ -265,10 +291,13 @@ class Camera {
message += ' 1 frame';
} else if (cmd === this.cfg.arduino.cmd.camerass) {
message += 'Cameras both MOVED 1 frame each';
} else if (cmd === this.cfg.arduino.camera_exposure) {
message += 'Camera set exposure';
}
message += ` ${ms}ms`
this.log.info(message);
this.ui.send(this.id, {cmd: cmd, id : id, ms: ms});
return ms;
}
}

View File

@ -636,6 +636,16 @@ class Commands {
}
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) {

1
src/globals.d.ts vendored
View File

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