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:
parent
4c0aa4220c
commit
fc2593c6ee
|
@ -2496,6 +2496,7 @@ const devices = require('./lib/ui/devices.js');
|
|||
const filmout = require('./lib/ui/filmout.js');
|
||||
const mse = require('./lib/ui/mscript.js');
|
||||
const Mscript = require('./lib/mscript');
|
||||
const { delay } = require('./lib/delay');
|
||||
let log;
|
||||
|
||||
/******
|
||||
|
|
|
@ -1,4 +1,13 @@
|
|||
'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;
|
||||
class Devices {
|
||||
constructor() {
|
||||
|
@ -15,76 +24,79 @@ class Devices {
|
|||
ipcRenderer.on('intval', this.intvalCb.bind(this));
|
||||
}
|
||||
ready(event, arg) {
|
||||
//console.dir(arg)
|
||||
let opt;
|
||||
let devs = [];
|
||||
let notify = 'Connected to ';
|
||||
let p;
|
||||
try {
|
||||
gui.spinner(false);
|
||||
gui.overlay(false);
|
||||
console.log('got here');
|
||||
}
|
||||
catch (err) {
|
||||
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}`;
|
||||
}
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
//console.dir(arg)
|
||||
let opt;
|
||||
let devs = [];
|
||||
let notify = 'Connected to ';
|
||||
let p;
|
||||
//@ts-ignore
|
||||
yield delay(1000);
|
||||
try {
|
||||
gui.spinner(false);
|
||||
gui.overlay(false);
|
||||
}
|
||||
opt = $('<option>');
|
||||
opt.val(`ARDUINO_${arg[i].arduino}`);
|
||||
opt.text(arg[i].arduino);
|
||||
$(`#${i}_device`).empty();
|
||||
$(`#${i}_device`).append(opt);
|
||||
}
|
||||
if (notify !== 'Connected to ') {
|
||||
gui.notify('DEVICES', notify);
|
||||
}
|
||||
else {
|
||||
gui.notify('DEVICES', 'Connected to mock devices');
|
||||
}
|
||||
if (devs.length > 0) {
|
||||
$('#devices').empty();
|
||||
for (let i of devs) {
|
||||
catch (err) {
|
||||
log.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>');
|
||||
opt.val(i);
|
||||
opt.text(i);
|
||||
$('#devices').append(opt);
|
||||
opt.val(`ARDUINO_${arg[i].arduino}`);
|
||||
opt.text(arg[i].arduino);
|
||||
$(`#${i}_device`).empty();
|
||||
$(`#${i}_device`).append(opt);
|
||||
}
|
||||
}
|
||||
if (arg && arg.profile) {
|
||||
$('#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();
|
||||
if (notify !== 'Connected to ') {
|
||||
gui.notify('DEVICES', notify);
|
||||
}
|
||||
else {
|
||||
light.enable();
|
||||
gui.notify('DEVICES', 'Connected to mock devices');
|
||||
}
|
||||
//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;
|
||||
if (devs.length > 0) {
|
||||
$('#devices').empty();
|
||||
for (let i of devs) {
|
||||
opt = $('<option>');
|
||||
opt.val(i);
|
||||
opt.text(i);
|
||||
$('#devices').append(opt);
|
||||
}
|
||||
}
|
||||
if (arg && arg.profile) {
|
||||
$('#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 {
|
||||
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() {
|
||||
const keys = Object.keys(cfg.profiles);
|
||||
|
|
|
@ -22,6 +22,7 @@ const devices = require('./lib/ui/devices.js');
|
|||
const filmout = require('./lib/ui/filmout.js');
|
||||
const mse = require('./lib/ui/mscript.js');
|
||||
const Mscript = require('./lib/mscript');
|
||||
const { delay } = require('./lib/delay');
|
||||
let log;
|
||||
|
||||
/******
|
||||
|
|
|
@ -33,19 +33,20 @@ class Devices {
|
|||
ipcRenderer.on('intval', this.intvalCb.bind(this));
|
||||
}
|
||||
|
||||
ready (event : any, arg : any) {
|
||||
async ready (event : any, arg : any) {
|
||||
//console.dir(arg)
|
||||
let opt : any;
|
||||
let devs : any[] = [];
|
||||
let notify : string = 'Connected to ';
|
||||
let p : any;
|
||||
//@ts-ignore
|
||||
await delay(1000);
|
||||
|
||||
try {
|
||||
gui.spinner(false);
|
||||
gui.overlay(false);
|
||||
console.log('got here');
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
log.error(err);
|
||||
}
|
||||
for (let i in arg) {
|
||||
devs.push(arg[i].arduino);
|
||||
|
|
Loading…
Reference in New Issue