Incredibly close to #80 and #81. Can get state confirmation at startup. Can send exposure string and get confirmation after. Cannot get state outside of initial confirmation. Something is either locked or failing to wait?
This commit is contained in:
parent
5133295f38
commit
0cc167b3a6
|
@ -693,6 +693,9 @@ button:focus {
|
|||
#settings > div.right .cam_time {
|
||||
height: 111px;
|
||||
}
|
||||
#settings > div.right > div {
|
||||
width: 270px;
|
||||
}
|
||||
#settings > div > div {
|
||||
width: 360px;
|
||||
}
|
||||
|
@ -745,8 +748,9 @@ button:focus {
|
|||
width: 200px;
|
||||
}
|
||||
#settings button {
|
||||
margin-top: -1px;
|
||||
margin-top: 0px;
|
||||
float: right;
|
||||
padding: 8px 16px 9px;
|
||||
}
|
||||
#settings input[type=radio] {
|
||||
float: right;
|
||||
|
|
|
@ -462,10 +462,12 @@
|
|||
<div class="proj_time">
|
||||
<h4>Projector Time (ms)</h4>
|
||||
<input type="number" readonly id="proj_time" value="0" />
|
||||
<button id="submit_proj_time" class="hide">✓</button>
|
||||
</div>
|
||||
<div class="cam_time">
|
||||
<h4>Camera Time (ms)</h4>
|
||||
<input type="number" readonly id="cam_time" value="0" />
|
||||
<button id="submit_cam_time" class="hide" onclick="cam.exposure($('#cam_time').val());">✓</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
.cam_time{
|
||||
height: 111px;
|
||||
}
|
||||
& > div {
|
||||
width: 270px;
|
||||
}
|
||||
}
|
||||
}
|
||||
> div > div{
|
||||
|
@ -49,8 +52,9 @@
|
|||
width: 200px;
|
||||
}
|
||||
button{
|
||||
margin-top: -1px;
|
||||
float: right;
|
||||
margin-top: 0px;
|
||||
float: right;
|
||||
padding: 8px 16px 9px;
|
||||
}
|
||||
input[type=radio]{
|
||||
float: right;
|
||||
|
|
|
@ -30,7 +30,7 @@ class Arduino {
|
|||
this.known = KNOWN;
|
||||
this.alias = {};
|
||||
this.serial = { connect: {}, projector: {}, camera: {}, light: {} };
|
||||
this.hasState = { projector: false, camera: false, light: false };
|
||||
this.hasState = {};
|
||||
this.baud = 57600;
|
||||
this.queue = {};
|
||||
this.timer = 0;
|
||||
|
@ -93,7 +93,7 @@ class Arduino {
|
|||
**/
|
||||
async sendAsync(device, cmd) {
|
||||
return new Promise((resolve, reject) => {
|
||||
//this.log.info(`${device} -> ${cmd}`)
|
||||
this.log.info(`${device} -> ${cmd}`);
|
||||
this.queue[cmd] = (ms) => {
|
||||
return resolve(ms);
|
||||
};
|
||||
|
@ -108,8 +108,9 @@ class Arduino {
|
|||
async send(serial, cmd) {
|
||||
const device = this.alias[serial];
|
||||
let results;
|
||||
//this.log.info(`${cmd} -> ${serial}`)
|
||||
this.log.info(`${cmd} -> ${serial}`);
|
||||
if (this.locks[serial]) {
|
||||
this.log.warning(`Serial ${serial} is locked`);
|
||||
return false;
|
||||
}
|
||||
this.timer = new Date().getTime();
|
||||
|
@ -175,6 +176,8 @@ class Arduino {
|
|||
async state(serial, confirm = false) {
|
||||
const device = confirm ? this.alias['connect'] : this.alias[serial];
|
||||
let results;
|
||||
this.log.info(serial);
|
||||
this.log.info(device);
|
||||
if (this.locks[serial]) {
|
||||
return null;
|
||||
}
|
||||
|
@ -221,7 +224,7 @@ class Arduino {
|
|||
delete this.queue[data];
|
||||
}
|
||||
else if (data[0] === cfg.arduino.cmd.state) {
|
||||
complete = this.queue[cfg.arduino.cmd.state](ms);
|
||||
complete = this.queue[cfg.arduino.cmd.state](data);
|
||||
delete this.queue[cfg.arduino.cmd.state];
|
||||
return data;
|
||||
}
|
||||
|
@ -278,7 +281,6 @@ class Arduino {
|
|||
});
|
||||
}
|
||||
confirmEnd(data) {
|
||||
this.log.info(data);
|
||||
if (data === cfg.arduino.cmd.connect
|
||||
|| data === cfg.arduino.cmd.projector_identifier
|
||||
|| data === cfg.arduino.cmd.camera_identifier
|
||||
|
@ -306,7 +308,7 @@ class Arduino {
|
|||
this.confirmExec = {};
|
||||
}
|
||||
else if (data[0] === cfg.arduino.cmd.state) {
|
||||
this.queue[cfg.arduino.cmd.state](0);
|
||||
this.queue[cfg.arduino.cmd.state](data);
|
||||
delete this.queue[cfg.arduino.cmd.state];
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -161,28 +161,43 @@ class Camera {
|
|||
async exposure(exposure, id) {
|
||||
const cmd = this.cfg.arduino.cmd.camera_exposure;
|
||||
const str = `${exposure}`;
|
||||
const started = +new Date();
|
||||
let ms;
|
||||
let confirmState;
|
||||
if (this.intval) {
|
||||
return this.intval.setExposure(this.id, exposure, (ms) => {
|
||||
return this.end(cmd, id, ms);
|
||||
});
|
||||
}
|
||||
else if (this.arduino.hasState[id]) {
|
||||
else if (this.arduino.hasState[this.id]) {
|
||||
this.log.info(`Sending cmd ${cmd}`);
|
||||
try {
|
||||
ms = await this.arduino.send(this.id, cmd);
|
||||
ms = this.arduino.send(this.id, cmd);
|
||||
}
|
||||
catch (err) {
|
||||
this.log.error('Error sending camera exposure command', err);
|
||||
}
|
||||
await delay_1.delay(1);
|
||||
this.log.info(`Sending str ${str}`);
|
||||
try {
|
||||
this.arduino.sendString(this.id, str);
|
||||
ms = await this.arduino.sendString(this.id, str);
|
||||
}
|
||||
catch (err) {
|
||||
this.log.error('Error sending camera exposure string', err);
|
||||
}
|
||||
await delay_1.delay(1);
|
||||
this.log.info(`Sent str ${str}`);
|
||||
await ms;
|
||||
this.log.info(`Sent cmd ${cmd}`);
|
||||
await delay_1.delay(1);
|
||||
this.log.info(`Sending state request`);
|
||||
try {
|
||||
confirmState = await this.arduino.state(this.id, false);
|
||||
}
|
||||
catch (err) {
|
||||
this.log.error(`Error confirming set state`, err);
|
||||
}
|
||||
console.dir(confirmState);
|
||||
ms = (+new Date()) - started;
|
||||
return await this.end(cmd, id, ms);
|
||||
}
|
||||
return 0;
|
||||
|
@ -256,6 +271,14 @@ class Camera {
|
|||
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;
|
||||
}
|
||||
/**
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -134,6 +134,9 @@ class Devices {
|
|||
catch (err) {
|
||||
this.log.error('Error checking state capability', err);
|
||||
}
|
||||
if (this.arduino.hasState[device.toString()]) {
|
||||
this.arduino.hasState[type] = true;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
/**
|
||||
|
@ -471,10 +474,17 @@ class Devices {
|
|||
if (!this.connected.projector) {
|
||||
await this.fakeProjector();
|
||||
}
|
||||
else if (this.arduino.hasState['projector']) {
|
||||
p.state = true;
|
||||
}
|
||||
p.arduino = this.connected.projector;
|
||||
if (!this.connected.camera) {
|
||||
await this.fakeCamera();
|
||||
}
|
||||
else if (this.arduino.hasState['camera']) {
|
||||
c.state = true;
|
||||
c.exposure = true;
|
||||
}
|
||||
c.arduino = this.connected.camera;
|
||||
if (!this.connected.light) {
|
||||
await this.fakeLight();
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -81,7 +81,7 @@ cam.end = function (c, id, ms) {
|
|||
gui.counterUpdate('cam2', cam.second.pos);
|
||||
}
|
||||
timing.update(c, ms);
|
||||
gui.counterUpdate('cam', cam.pos)
|
||||
gui.counterUpdate('cam', cam.pos);
|
||||
if (typeof cam.queue[id] !== 'undefined') {
|
||||
if (typeof cam.queue[id].callback !== 'undefined') {
|
||||
cam.queue[id].callback(ms);
|
||||
|
@ -91,15 +91,13 @@ cam.end = function (c, id, ms) {
|
|||
}
|
||||
};
|
||||
|
||||
cam.exposure = function (exposure, callback) {
|
||||
cam.exposure = function (exposure) {
|
||||
var obj = {
|
||||
id : uuid(),
|
||||
exposure
|
||||
}
|
||||
ipcRenderer.sendSync(cam.id)
|
||||
if (typeof callback !== 'undefined') {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
log.info(`Setting exposure: ${exposure}`);
|
||||
ipcRenderer.sendSync(cam.id, obj);
|
||||
}
|
||||
|
||||
cam.listen = function () {
|
||||
|
|
|
@ -33,14 +33,9 @@ class Devices {
|
|||
let devs = [];
|
||||
let notify = 'Connected to ';
|
||||
let p;
|
||||
//@ts-ignore
|
||||
yield delay(1000);
|
||||
try {
|
||||
gui.spinner(false);
|
||||
gui.overlay(false);
|
||||
}
|
||||
catch (err) {
|
||||
log.error(err);
|
||||
if (arg.camera && arg.camera.exposure) {
|
||||
$('#submit_cam_time').removeClass('hide');
|
||||
$('#cam_time').removeAttr('readonly');
|
||||
}
|
||||
for (let i in arg) {
|
||||
devs.push(arg[i].arduino);
|
||||
|
@ -106,6 +101,15 @@ class Devices {
|
|||
grid.state(0);
|
||||
grid.state(1);
|
||||
seq.stats();
|
||||
//@ts-ignore
|
||||
yield delay(1000);
|
||||
try {
|
||||
gui.spinner(false);
|
||||
gui.overlay(false);
|
||||
}
|
||||
catch (err) {
|
||||
log.error(err);
|
||||
}
|
||||
return event.returnValue = true;
|
||||
});
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -28,15 +28,12 @@ class Devices {
|
|||
let devs : any[] = [];
|
||||
let notify : string = 'Connected to ';
|
||||
let p : any;
|
||||
//@ts-ignore
|
||||
await delay(1000);
|
||||
|
||||
try {
|
||||
gui.spinner(false);
|
||||
gui.overlay(false);
|
||||
} catch (err) {
|
||||
log.error(err);
|
||||
if (arg.camera && arg.camera.exposure) {
|
||||
$('#submit_cam_time').removeClass('hide');
|
||||
$('#cam_time').removeAttr('readonly');
|
||||
}
|
||||
|
||||
for (let i in arg) {
|
||||
devs.push(arg[i].arduino);
|
||||
if (arg[i].arduino && arg[i].arduino !== '/dev/fake') {
|
||||
|
@ -56,7 +53,7 @@ class Devices {
|
|||
if (notify !== 'Connected to ') {
|
||||
gui.notify('DEVICES', notify);
|
||||
} else {
|
||||
gui.notify('DEVICES', 'Connected to mock devices')
|
||||
gui.notify('DEVICES', 'Connected to mock devices');
|
||||
}
|
||||
|
||||
if (devs.length > 0) {
|
||||
|
@ -104,12 +101,22 @@ class Devices {
|
|||
grid.state(1);
|
||||
seq.stats();
|
||||
|
||||
//@ts-ignore
|
||||
await delay(1000);
|
||||
|
||||
try {
|
||||
gui.spinner(false);
|
||||
gui.overlay(false);
|
||||
} catch (err) {
|
||||
log.error(err);
|
||||
}
|
||||
|
||||
return event.returnValue = true;
|
||||
}
|
||||
|
||||
profiles () {
|
||||
const keys : string[] = Object.keys(cfg.profiles);
|
||||
const elem : any = $('#profile')
|
||||
const elem : any = $('#profile');
|
||||
let opt;
|
||||
elem.empty();
|
||||
for (let key of keys) {
|
||||
|
|
|
@ -37,7 +37,7 @@ class Arduino {
|
|||
private known : string[] = KNOWN;
|
||||
private alias : any = {};
|
||||
private serial : any = { connect : {}, projector : {}, camera : {}, light : {} };
|
||||
private hasState : any = { projector : false, camera : false, light : false };
|
||||
private hasState : any = { };
|
||||
private baud : number = 57600;
|
||||
private queue : any = {};
|
||||
private timer : number = 0;
|
||||
|
@ -101,7 +101,7 @@ class Arduino {
|
|||
**/
|
||||
async sendAsync (device : string, cmd : string) {
|
||||
return new Promise ((resolve, reject) => {
|
||||
//this.log.info(`${device} -> ${cmd}`)
|
||||
this.log.info(`${device} -> ${cmd}`)
|
||||
this.queue[cmd] = (ms : number) => {
|
||||
return resolve(ms)
|
||||
}
|
||||
|
@ -117,8 +117,9 @@ class Arduino {
|
|||
async send (serial : string, cmd : string) {
|
||||
const device : any = this.alias[serial]
|
||||
let results : any
|
||||
//this.log.info(`${cmd} -> ${serial}`)
|
||||
this.log.info(`${cmd} -> ${serial}`)
|
||||
if (this.locks[serial]) {
|
||||
this.log.warning(`Serial ${serial} is locked`)
|
||||
return false
|
||||
}
|
||||
this.timer = new Date().getTime()
|
||||
|
@ -185,7 +186,8 @@ class Arduino {
|
|||
async state (serial : string, confirm : boolean = false) : Promise<string>{
|
||||
const device : string = confirm ? this.alias['connect'] : this.alias[serial]
|
||||
let results : string
|
||||
|
||||
this.log.info(serial)
|
||||
this.log.info(device)
|
||||
if (this.locks[serial]) {
|
||||
return null
|
||||
}
|
||||
|
@ -233,7 +235,7 @@ class Arduino {
|
|||
eventEmitter.emit('arduino_end', data)
|
||||
delete this.queue[data]
|
||||
} else if (data[0] === cfg.arduino.cmd.state) {
|
||||
complete = this.queue[cfg.arduino.cmd.state](ms)
|
||||
complete = this.queue[cfg.arduino.cmd.state](data)
|
||||
delete this.queue[cfg.arduino.cmd.state]
|
||||
return data
|
||||
} else if (data[0] === cfg.arduino.cmd.error) {
|
||||
|
@ -291,7 +293,6 @@ class Arduino {
|
|||
}
|
||||
|
||||
confirmEnd (data : string) {
|
||||
this.log.info(data)
|
||||
if ( data === cfg.arduino.cmd.connect
|
||||
|| data === cfg.arduino.cmd.projector_identifier
|
||||
|| data === cfg.arduino.cmd.camera_identifier
|
||||
|
@ -322,7 +323,7 @@ class Arduino {
|
|||
this.confirmExec(null, data)
|
||||
this.confirmExec = {}
|
||||
} else if (data[0] === cfg.arduino.cmd.state) {
|
||||
this.queue[cfg.arduino.cmd.state](0)
|
||||
this.queue[cfg.arduino.cmd.state](data)
|
||||
delete this.queue[cfg.arduino.cmd.state]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -164,25 +164,41 @@ class Camera {
|
|||
public async exposure (exposure : number, id : string) {
|
||||
const cmd : string = this.cfg.arduino.cmd.camera_exposure;
|
||||
const str : string = `${exposure}`;
|
||||
const started : number = +new Date();
|
||||
let ms : any;
|
||||
let confirmState : 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]) {
|
||||
} else if (this.arduino.hasState[this.id]) {
|
||||
this.log.info(`Sending cmd ${cmd}`);
|
||||
try {
|
||||
ms = await this.arduino.send(this.id, cmd);
|
||||
ms = this.arduino.send(this.id, cmd);
|
||||
} catch (err) {
|
||||
this.log.error('Error sending camera exposure command', err);
|
||||
}
|
||||
|
||||
await delay(1);
|
||||
this.log.info(`Sending str ${str}`);
|
||||
try {
|
||||
this.arduino.sendString(this.id, str);
|
||||
ms = await this.arduino.sendString(this.id, str);
|
||||
} catch (err) {
|
||||
this.log.error('Error sending camera exposure string', err);
|
||||
}
|
||||
await delay(1);
|
||||
this.log.info(`Sent str ${str}`);
|
||||
await ms;
|
||||
this.log.info(`Sent cmd ${cmd}`);
|
||||
await delay(1);
|
||||
this.log.info(`Sending state request`);
|
||||
try {
|
||||
confirmState = await this.arduino.state(this.id, false);
|
||||
} catch (err) {
|
||||
this.log.error(`Error confirming set state`, err);
|
||||
}
|
||||
console.dir(confirmState);
|
||||
ms = (+new Date()) - started;
|
||||
return await this.end(cmd, id, ms);
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -151,6 +151,10 @@ class Devices {
|
|||
this.log.error('Error checking state capability', err)
|
||||
}
|
||||
|
||||
if (this.arduino.hasState[device.toString()]) {
|
||||
this.arduino.hasState[type] = true;
|
||||
}
|
||||
|
||||
return type
|
||||
}
|
||||
/**
|
||||
|
@ -458,11 +462,16 @@ class Devices {
|
|||
|
||||
if (!this.connected.projector) {
|
||||
await this.fakeProjector()
|
||||
} else if (this.arduino.hasState['projector']) {
|
||||
p.state = true
|
||||
}
|
||||
p.arduino = this.connected.projector
|
||||
|
||||
if (!this.connected.camera) {
|
||||
await this.fakeCamera()
|
||||
} else if (this.arduino.hasState['camera']) {
|
||||
c.state = true
|
||||
c.exposure = true
|
||||
}
|
||||
c.arduino = this.connected.camera
|
||||
|
||||
|
|
Loading…
Reference in New Issue