2019-06-24 18:31:26 +00:00
|
|
|
'use strict';
|
2020-01-09 23:06:18 +00:00
|
|
|
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());
|
|
|
|
});
|
|
|
|
};
|
2020-01-10 21:43:12 +00:00
|
|
|
/// <reference path ="jquery.d.ts"/>
|
2019-06-24 18:31:26 +00:00
|
|
|
let devices;
|
|
|
|
class Devices {
|
|
|
|
constructor() {
|
|
|
|
this.id = 'devices';
|
|
|
|
}
|
|
|
|
init() {
|
|
|
|
this.listen();
|
2024-04-07 03:37:30 +00:00
|
|
|
this.layoutProfiles();
|
2019-06-24 18:31:26 +00:00
|
|
|
gui.overlay(true);
|
|
|
|
gui.spinner(true, 'Checking for connected devices...');
|
|
|
|
}
|
|
|
|
listen() {
|
|
|
|
ipcRenderer.on('ready', this.ready.bind(this));
|
|
|
|
ipcRenderer.on('intval', this.intvalCb.bind(this));
|
2022-04-30 19:58:17 +00:00
|
|
|
ipcRenderer.on('processing', this.processingCb.bind(this));
|
2020-09-29 17:57:59 +00:00
|
|
|
ipcRenderer.on('error_state', this.errorState.bind(this));
|
2019-06-24 18:31:26 +00:00
|
|
|
}
|
|
|
|
ready(event, arg) {
|
2020-01-09 23:06:18 +00:00
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
2024-04-06 23:53:04 +00:00
|
|
|
log.info("Devices ready");
|
2020-01-09 23:06:18 +00:00
|
|
|
let opt;
|
|
|
|
let devs = [];
|
|
|
|
let notify = 'Connected to ';
|
|
|
|
let p;
|
2024-04-06 23:37:29 +00:00
|
|
|
if (typeof arg.camera !== 'undefined' && typeof arg.camera.exposure !== undefined) {
|
2023-07-11 02:33:16 +00:00
|
|
|
$('#submit_cam_time').removeClass('hide');
|
|
|
|
$('#cam_time').removeAttr('readonly');
|
2020-01-09 23:06:18 +00:00
|
|
|
}
|
|
|
|
for (let i in arg) {
|
2024-04-07 00:10:14 +00:00
|
|
|
if (typeof arg[i].arduino !== 'undefined' && arg[i].arduino !== '/dev/fake') {
|
|
|
|
devs.push(arg[i].arduino);
|
2020-01-09 23:06:18 +00:00
|
|
|
if (notify === 'Connected to ') {
|
|
|
|
notify += arg[i].arduino + ' ';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
notify += `& ${arg[i].arduino}`;
|
|
|
|
}
|
|
|
|
}
|
2019-06-24 18:31:26 +00:00
|
|
|
opt = $('<option>');
|
2020-01-09 23:06:18 +00:00
|
|
|
opt.val(`ARDUINO_${arg[i].arduino}`);
|
|
|
|
opt.text(arg[i].arduino);
|
|
|
|
$(`#${i}_device`).empty();
|
|
|
|
$(`#${i}_device`).append(opt);
|
2019-06-24 18:31:26 +00:00
|
|
|
}
|
2020-01-09 23:06:18 +00:00
|
|
|
if (notify !== 'Connected to ') {
|
|
|
|
gui.notify('DEVICES', notify);
|
2019-06-24 18:31:26 +00:00
|
|
|
}
|
|
|
|
else {
|
2020-01-09 23:06:18 +00:00
|
|
|
gui.notify('DEVICES', 'Connected to mock devices');
|
2019-06-24 18:31:26 +00:00
|
|
|
}
|
2020-01-09 23:06:18 +00:00
|
|
|
if (devs.length > 0) {
|
|
|
|
$('#devices').empty();
|
|
|
|
for (let i of devs) {
|
|
|
|
opt = $('<option>');
|
|
|
|
opt.val(i);
|
|
|
|
opt.text(i);
|
|
|
|
$('#devices').append(opt);
|
|
|
|
}
|
|
|
|
}
|
2024-04-06 23:37:29 +00:00
|
|
|
if (typeof arg !== 'undefined' && typeof arg.profile !== 'undefined') {
|
2024-04-07 03:37:30 +00:00
|
|
|
yield devices.profile(arg.profile);
|
2020-01-09 23:06:18 +00:00
|
|
|
}
|
2024-04-06 23:37:29 +00:00
|
|
|
if (typeof arg !== 'undefined' && typeof arg.timing !== 'undefined') {
|
2023-02-28 20:55:02 +00:00
|
|
|
timing.restore(arg.timing);
|
|
|
|
}
|
2024-04-07 00:00:54 +00:00
|
|
|
if (typeof arg !== 'undefined' && typeof arg.projector_second !== 'undefined') {
|
2020-01-09 23:06:18 +00:00
|
|
|
//add second row of projector pads to grid
|
|
|
|
proj.second.enable();
|
|
|
|
}
|
2024-04-07 00:00:54 +00:00
|
|
|
if (typeof arg !== 'undefined' && typeof arg.camera_second !== 'undefined') {
|
2020-01-09 23:06:18 +00:00
|
|
|
//add second row of camera pads to grid
|
|
|
|
cam.second.enable();
|
|
|
|
}
|
2024-04-07 00:00:54 +00:00
|
|
|
if (typeof arg !== 'undefined' && typeof arg.capper !== 'undefined') {
|
2022-07-15 22:11:26 +00:00
|
|
|
//add capper features to grid
|
2022-07-13 19:21:26 +00:00
|
|
|
capper.enable();
|
|
|
|
}
|
2022-07-15 22:11:26 +00:00
|
|
|
seq.set(0, cfg.cmd.camera_forward);
|
|
|
|
seq.set(1, cfg.cmd.projector_forward);
|
|
|
|
grid.state(0);
|
|
|
|
grid.state(1);
|
|
|
|
seq.stats();
|
2023-07-11 02:33:16 +00:00
|
|
|
try {
|
|
|
|
gui.spinner(false);
|
|
|
|
gui.overlay(false);
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
log.error(err);
|
|
|
|
}
|
2020-01-09 23:06:18 +00:00
|
|
|
return event.returnValue = true;
|
|
|
|
});
|
2019-06-24 18:31:26 +00:00
|
|
|
}
|
2024-04-07 03:37:30 +00:00
|
|
|
profile(profile) {
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
log.info(`Changed configuration profile to "${profile}"`, 'DEVICES', true, true);
|
|
|
|
const p = cfg.profiles[profile];
|
|
|
|
const keys = Object.keys(p);
|
|
|
|
for (let key of keys) {
|
|
|
|
cfg[key] = keys[key];
|
|
|
|
}
|
|
|
|
$('#profile').val(profile);
|
|
|
|
timing.reset(p);
|
|
|
|
if (typeof p.light !== 'undefined' && p.light === false) {
|
|
|
|
yield light.disable();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
yield light.enable();
|
|
|
|
}
|
|
|
|
yield ipcRenderer.invoke('profile', { profile });
|
|
|
|
yield timing.store();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
layoutProfiles() {
|
2019-06-24 18:31:26 +00:00
|
|
|
const keys = Object.keys(cfg.profiles);
|
|
|
|
const elem = $('#profile');
|
|
|
|
let opt;
|
|
|
|
elem.empty();
|
|
|
|
for (let key of keys) {
|
|
|
|
opt = $('<option>');
|
|
|
|
opt.val(key);
|
|
|
|
opt.text(cfg.profiles[key].label);
|
|
|
|
elem.append(opt);
|
|
|
|
}
|
|
|
|
elem.on('change', (t) => {
|
|
|
|
const val = $('#profile').val();
|
|
|
|
this.profile(val);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
intval() {
|
|
|
|
const url = $('#intval').val();
|
|
|
|
let proceed = false;
|
|
|
|
let obj = {
|
|
|
|
connect: true,
|
2022-04-30 19:58:17 +00:00
|
|
|
url
|
2019-06-24 18:31:26 +00:00
|
|
|
};
|
|
|
|
if (url !== '' && typeof url !== 'undefined') {
|
|
|
|
proceed = confirm(`Are you sure you want to connect to INTVAL3 @ ${url}?`);
|
|
|
|
}
|
|
|
|
else {
|
2022-04-30 19:58:17 +00:00
|
|
|
alert('Cannot connect to INTVAL3 URL as entered.');
|
2019-06-24 18:31:26 +00:00
|
|
|
}
|
|
|
|
if (proceed) {
|
|
|
|
gui.overlay(true);
|
|
|
|
gui.spinner(true, `Connecting to INTVAL3 @ ${url}`);
|
|
|
|
ipcRenderer.send('intval', obj);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$('#camera_type_arduino').prop('checked', 'checked');
|
|
|
|
$('#intval').removeClass('active');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
intvalCb(evt, args) {
|
|
|
|
let state;
|
|
|
|
gui.spinner(false);
|
|
|
|
gui.overlay(false);
|
|
|
|
if (args.connected && args.connected === true) {
|
|
|
|
//success state
|
|
|
|
state = JSON.parse(args.state);
|
|
|
|
cam.pos = state.counter;
|
|
|
|
cam.dir = state.frame.dir;
|
|
|
|
$('#intval').val(args.url);
|
|
|
|
$('#intval').addClass('active');
|
|
|
|
$('#camera_type_intval').prop('checked', 'checked');
|
|
|
|
gui.notify('DEVICES', `Connected to INTVAL3 @ ${args.url}`);
|
|
|
|
gui.updateState();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$('#camera_type_arduino').prop('checked', 'checked');
|
|
|
|
$('#intval').removeClass('active');
|
|
|
|
}
|
|
|
|
}
|
2022-04-30 19:58:17 +00:00
|
|
|
processing() {
|
|
|
|
const url = $('#processing').val();
|
|
|
|
let proceed = false;
|
|
|
|
let obj = {
|
|
|
|
url
|
|
|
|
};
|
|
|
|
if (url !== '' && typeof url !== 'undefined') {
|
|
|
|
proceed = confirm(`Are you sure you want to connect to Processing @ ${url}?`);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
alert('Cannot connect to Processing URL as entered.');
|
|
|
|
}
|
|
|
|
if (proceed) {
|
|
|
|
gui.overlay(true);
|
|
|
|
gui.spinner(true, `Connecting to Processing @ ${url}`);
|
|
|
|
ipcRenderer.send('processing', obj);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$('#camera_type_arduino').prop('checked', 'checked');
|
|
|
|
$('#processing').removeClass('active');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
processingCb() {
|
|
|
|
gui.spinner(false);
|
|
|
|
gui.overlay(false);
|
|
|
|
}
|
2020-09-29 17:57:59 +00:00
|
|
|
errorState() {
|
|
|
|
gui.spinner(false);
|
|
|
|
gui.overlay(false);
|
|
|
|
gui.notify('DEVICES', `Hardware error detected`);
|
|
|
|
gui.warn('Error', 'Hardware error detected. Please address before continuing.');
|
|
|
|
}
|
2019-02-08 19:28:57 +00:00
|
|
|
}
|
2019-06-24 18:31:26 +00:00
|
|
|
devices = new Devices();
|
|
|
|
module.exports = devices;
|
2020-01-10 21:43:12 +00:00
|
|
|
//# sourceMappingURL=devices.js.map
|