Resolves #34. Added delay lib to renderer and added a magic delay before ending devices.ready(). Just works. Move on and don't question it.

This commit is contained in:
sixteenmillimeter 2020-01-09 18:06:18 -05:00
parent 4c0aa4220c
commit fc2593c6ee
4 changed files with 82 additions and 67 deletions

View File

@ -2496,6 +2496,7 @@ const devices = require('./lib/ui/devices.js');
const filmout = require('./lib/ui/filmout.js'); const filmout = require('./lib/ui/filmout.js');
const mse = require('./lib/ui/mscript.js'); const mse = require('./lib/ui/mscript.js');
const Mscript = require('./lib/mscript'); const Mscript = require('./lib/mscript');
const { delay } = require('./lib/delay');
let log; let log;
/****** /******

View File

@ -1,4 +1,13 @@
'use strict'; 'use strict';
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
let devices; let devices;
class Devices { class Devices {
constructor() { constructor() {
@ -15,76 +24,79 @@ class Devices {
ipcRenderer.on('intval', this.intvalCb.bind(this)); ipcRenderer.on('intval', this.intvalCb.bind(this));
} }
ready(event, arg) { ready(event, arg) {
//console.dir(arg) return __awaiter(this, void 0, void 0, function* () {
let opt; //console.dir(arg)
let devs = []; let opt;
let notify = 'Connected to '; let devs = [];
let p; let notify = 'Connected to ';
try { let p;
gui.spinner(false); //@ts-ignore
gui.overlay(false); yield delay(1000);
console.log('got here'); try {
} gui.spinner(false);
catch (err) { gui.overlay(false);
console.error(err);
}
for (let i in arg) {
devs.push(arg[i].arduino);
if (arg[i].arduino && arg[i].arduino !== '/dev/fake') {
if (notify === 'Connected to ') {
notify += arg[i].arduino + ' ';
}
else {
notify += `& ${arg[i].arduino}`;
}
} }
opt = $('<option>'); catch (err) {
opt.val(`ARDUINO_${arg[i].arduino}`); log.error(err);
opt.text(arg[i].arduino); }
$(`#${i}_device`).empty(); for (let i in arg) {
$(`#${i}_device`).append(opt); devs.push(arg[i].arduino);
} if (arg[i].arduino && arg[i].arduino !== '/dev/fake') {
if (notify !== 'Connected to ') { if (notify === 'Connected to ') {
gui.notify('DEVICES', notify); notify += arg[i].arduino + ' ';
} }
else { else {
gui.notify('DEVICES', 'Connected to mock devices'); notify += `& ${arg[i].arduino}`;
} }
if (devs.length > 0) { }
$('#devices').empty();
for (let i of devs) {
opt = $('<option>'); opt = $('<option>');
opt.val(i); opt.val(`ARDUINO_${arg[i].arduino}`);
opt.text(i); opt.text(arg[i].arduino);
$('#devices').append(opt); $(`#${i}_device`).empty();
$(`#${i}_device`).append(opt);
} }
} if (notify !== 'Connected to ') {
if (arg && arg.profile) { gui.notify('DEVICES', notify);
$('#profile').val(arg.profile);
log.info(`Using configuration profile "${arg.profile}"`, 'DEVICES', true, true);
p = cfg.profiles[arg.profile];
if (typeof p.light !== 'undefined' && p.light === false) {
light.disable();
} }
else { else {
light.enable(); gui.notify('DEVICES', 'Connected to mock devices');
} }
//devices.profile(arg.profile) if (devs.length > 0) {
} $('#devices').empty();
seq.set(0, cfg.cmd.camera_forward); for (let i of devs) {
seq.set(1, cfg.cmd.projector_forward); opt = $('<option>');
grid.state(0); opt.val(i);
grid.state(1); opt.text(i);
seq.stats(); $('#devices').append(opt);
if (arg.projector_second) { }
//add second row of projector pads to grid }
proj.second.enable(); if (arg && arg.profile) {
} $('#profile').val(arg.profile);
if (arg.camera_second) { log.info(`Using configuration profile "${arg.profile}"`, 'DEVICES', true, true);
//add second row of camera pads to grid p = cfg.profiles[arg.profile];
cam.second.enable(); if (typeof p.light !== 'undefined' && p.light === false) {
} light.disable();
return event.returnValue = true; }
else {
light.enable();
}
//devices.profile(arg.profile)
}
seq.set(0, cfg.cmd.camera_forward);
seq.set(1, cfg.cmd.projector_forward);
grid.state(0);
grid.state(1);
seq.stats();
if (arg.projector_second) {
//add second row of projector pads to grid
proj.second.enable();
}
if (arg.camera_second) {
//add second row of camera pads to grid
cam.second.enable();
}
return event.returnValue = true;
});
} }
profiles() { profiles() {
const keys = Object.keys(cfg.profiles); const keys = Object.keys(cfg.profiles);

View File

@ -22,6 +22,7 @@ const devices = require('./lib/ui/devices.js');
const filmout = require('./lib/ui/filmout.js'); const filmout = require('./lib/ui/filmout.js');
const mse = require('./lib/ui/mscript.js'); const mse = require('./lib/ui/mscript.js');
const Mscript = require('./lib/mscript'); const Mscript = require('./lib/mscript');
const { delay } = require('./lib/delay');
let log; let log;
/****** /******

View File

@ -33,19 +33,20 @@ class Devices {
ipcRenderer.on('intval', this.intvalCb.bind(this)); ipcRenderer.on('intval', this.intvalCb.bind(this));
} }
ready (event : any, arg : any) { async ready (event : any, arg : any) {
//console.dir(arg) //console.dir(arg)
let opt : any; let opt : any;
let devs : any[] = []; let devs : any[] = [];
let notify : string = 'Connected to '; let notify : string = 'Connected to ';
let p : any; let p : any;
//@ts-ignore
await delay(1000);
try { try {
gui.spinner(false); gui.spinner(false);
gui.overlay(false); gui.overlay(false);
console.log('got here');
} catch (err) { } catch (err) {
console.error(err); log.error(err);
} }
for (let i in arg) { for (let i in arg) {
devs.push(arg[i].arduino); devs.push(arg[i].arduino);