Add devices module after refactor

This commit is contained in:
mmcwilliams 2019-06-24 14:31:26 -04:00
parent 9331a766df
commit ad67e2f010
3 changed files with 482 additions and 482 deletions

View File

@ -1,252 +1,243 @@
const devices = {}; 'use strict';
let devices;
devices.init = function () { class Devices {
'use strict'; constructor() {
devices.listen(); this.id = 'devices';
devices.profiles(); this.init();
gui.overlay(true); }
gui.spinner(true, 'Checking for connected devices...'); init() {
}; this.listen();
devices.profiles = function () { this.profiles();
'use strict'; gui.overlay(true);
const keys = Object.keys(cfg.profiles); gui.spinner(true, 'Checking for connected devices...');
const elem = $('#profile') }
let opt; listen() {
elem.empty(); ipcRenderer.on('ready', this.ready.bind(this));
for (let key of keys) { ipcRenderer.on('intval', this.intvalCb.bind(this));
opt = $('<option>'); ipcRenderer.on('digital', this.digitalCb.bind(this));
opt.val(key); }
opt.text(cfg.profiles[key].label); ready(event, arg) {
elem.append(opt); //console.dir(arg)
} let opt;
elem.on('change', (t) => { let devs = [];
devices.profile($('#profile').val()); let notify = 'Connected to ';
}); let p;
}; gui.spinner(false);
devices.profile = function (profile) { gui.overlay(false);
'use strict'; for (let i in arg) {
log.info(`Changed configuration profile to "${profile}"`, 'DEVICES', true, true); devs.push(arg[i].arduino);
const p = cfg.profiles[profile]; if (arg[i].arduino && arg[i].arduino !== '/dev/fake') {
const keys = Object.keys(p); if (notify === 'Connected to ') {
for (let key of keys) { notify += arg[i].arduino + ' ';
cfg[key] = keys[key] }
} else {
if (typeof p.light !== 'undefined' && p.light === false) { notify += `& ${arg[i].arduino}`;
light.disable(); }
} else { }
light.enable(); opt = $('<option>');
} opt.val(`ARDUINO_${arg[i].arduino}`);
ipcRenderer.send('profile', { profile }) opt.text(arg[i].arduino);
}; $(`#${i}_device`).empty();
devices.listen = function () { $(`#${i}_device`).append(opt);
'use strict'; }
ipcRenderer.on('ready', devices.ready); if (notify !== 'Connected to ') {
ipcRenderer.on('intval', devices.intvalCb); gui.notify('DEVICES', notify);
ipcRenderer.on('filmout', devices.digitalCb); }
}; else {
devices.ready = function (event, arg) { gui.notify('DEVICES', 'Connected to mock devices');
'use strict'; }
//console.dir(arg) if (devs.length > 0) {
let opt; $('#devices').empty();
let devs = []; for (let i of devs) {
let notify = 'Connected to '; opt = $('<option>');
let p; opt.val(i);
gui.spinner(false); opt.text(i);
gui.overlay(false); $('#devices').append(opt);
for (let i in arg) { }
devs.push(arg[i].arduino); }
if (arg[i].arduino && arg[i].arduino !== '/dev/fake') { if (arg && arg.profile) {
if (notify === 'Connected to ') { $('#profile').val(arg.profile);
notify += arg[i].arduino + ' ' log.info(`Using configuration profile "${arg.profile}"`, 'DEVICES', true, true);
} else { p = cfg.profiles[arg.profile];
notify += `& ${arg[i].arduino}` if (typeof p.light !== 'undefined' && p.light === false) {
} light.disable();
} }
opt = $('<option>'); else {
opt.val(`ARDUINO_${arg[i].arduino}`); light.enable();
opt.text(arg[i].arduino); }
$(`#${i}_device`).empty(); //devices.profile(arg.profile)
$(`#${i}_device`).append(opt); }
} seq.set(0, cfg.cmd.camera_forward);
if (notify !== 'Connected to ') { seq.set(1, cfg.cmd.projector_forward);
gui.notify('DEVICES', notify); grid.state(0);
} else { grid.state(1);
gui.notify('DEVICES', 'Connected to mock devices') seq.stats();
} if (arg.projector_second) {
if (devs.length > 0) { //add second row of projector pads to grid
$('#devices').empty(); proj.second.enable();
for (let i of devs) { }
opt = $('<option>'); if (arg.camera_second) {
opt.val(i); //add second row of camera pads to grid
opt.text(i); cam.second.enable();
$('#devices').append(opt); }
} return event.returnValue = true;
} }
if (arg && arg.profile) { profiles() {
$('#profile').val(arg.profile) const keys = Object.keys(cfg.profiles);
log.info(`Using configuration profile "${arg.profile}"`, 'DEVICES', true, true); const elem = $('#profile');
p = cfg.profiles[arg.profile]; let opt;
if (typeof p.light !== 'undefined' && p.light === false) { elem.empty();
light.disable(); for (let key of keys) {
} else { opt = $('<option>');
light.enable(); opt.val(key);
} opt.text(cfg.profiles[key].label);
//devices.profile(arg.profile) elem.append(opt);
} }
elem.on('change', (t) => {
seq.set(0, cfg.cmd.camera_forward); const val = $('#profile').val();
seq.set(1, cfg.cmd.projector_forward); this.profile(val);
grid.state(0); });
grid.state(1); }
seq.stats(); profile(profile) {
log.info(`Changed configuration profile to "${profile}"`, 'DEVICES', true, true);
if (arg.projector_second) { const p = cfg.profiles[profile];
//add second row of projector pads to grid const keys = Object.keys(p);
proj.second.enable(); for (let key of keys) {
} cfg[key] = keys[key];
if (arg.camera_second) { }
//add second row of camera pads to grid if (typeof p.light !== 'undefined' && p.light === false) {
cam.second.enable(); light.disable();
} }
return event.returnValue = true; else {
}; light.enable();
}
devices.intval = function () { ipcRenderer.send('profile', { profile });
'use strict'; }
const url = $('#intval').val(); intval() {
let proceed = false; const url = $('#intval').val();
let obj = { let proceed = false;
connect: true, let obj = {
url : url connect: true,
}; url: url
if ( url !== '' && typeof url !== 'undefined') { };
proceed = confirm(`Are you sure you want to connect to INTVAL3 @ ${url}?`); if (url !== '' && typeof url !== 'undefined') {
} else { proceed = confirm(`Are you sure you want to connect to INTVAL3 @ ${url}?`);
alert('Cannot connect to INTVAL3 url as entered.'); }
} else {
alert('Cannot connect to INTVAL3 url as entered.');
if (proceed) { }
gui.overlay(true); if (proceed) {
gui.spinner(true, `Connecting to INTVAL3 @ ${url}`); gui.overlay(true);
ipcRenderer.send('intval', obj); gui.spinner(true, `Connecting to INTVAL3 @ ${url}`);
} else { ipcRenderer.send('intval', obj);
$('#camera_type_arduino').prop('checked', 'checked'); }
$('#intval').removeClass('active'); else {
} $('#camera_type_arduino').prop('checked', 'checked');
}; $('#intval').removeClass('active');
}
devices.intvalCb = function (evt, args) { }
'use strict'; intvalCb(evt, args) {
let state; let state;
gui.spinner(false); gui.spinner(false);
gui.overlay(false); gui.overlay(false);
if (args.connected && args.connected === true) { if (args.connected && args.connected === true) {
//success state //success state
state = JSON.parse(args.state); state = JSON.parse(args.state);
cam.pos = state.counter; cam.pos = state.counter;
cam.dir = state.frame.dir; cam.dir = state.frame.dir;
$('#intval').val(args.url); $('#intval').val(args.url);
$('#intval').addClass('active'); $('#intval').addClass('active');
$('#camera_type_intval').prop('checked', 'checked'); $('#camera_type_intval').prop('checked', 'checked');
gui.notify('DEVICES', `Connected to INTVAL3 @ ${args.url}`) gui.notify('DEVICES', `Connected to INTVAL3 @ ${args.url}`);
gui.updateState() gui.updateState();
} else { }
$('#camera_type_arduino').prop('checked', 'checked'); else {
$('#intval').removeClass('active'); $('#camera_type_arduino').prop('checked', 'checked');
} $('#intval').removeClass('active');
}; }
}
devices.digitalSelect = function () { digitalSelect() {
'use strict'; const elem = $('#digital');
const elem = $('#digital'); const extensions = ['mpg', 'mpeg', 'mov', 'mkv', 'avi', 'mp4'];
const extensions = ['mpg', 'mpeg', 'mov', 'mkv', 'avi', 'mp4']; dialog.showOpenDialog({
dialog.showOpenDialog({ title: `Select video or image sequence`,
title : `Select video or image sequence`, properties: [`openFile`],
properties : [`openFile`], // openDirectory, multiSelection, openFile defaultPath: 'c:/',
defaultPath: 'c:/', filters: [
filters : [ {
{ name: 'All Files',
name: 'All Files', extensions: ['*']
extensions: ['*'] },
}, ]
] }, (files) => {
}, (files) => { let valid = false;
let valid = false; let path = files[0];
console.dir(files) let displayName;
let path = files[0]; if (path && path !== '') {
let displayName; for (let ext of extensions) {
if (path && path !== '') { if (path.toLowerCase().indexOf(`.${ext}`) !== -1) {
for (let ext of extensions) { valid = true;
if (path.toLowerCase().indexOf(`.${ext}`) !== -1) { }
valid = true; }
} if (!valid)
} return false;
if (!valid) return false; log.info(`Selected video ${path.split('/').pop()}`, 'DIGITAL', true);
log.info(`Selected video ${path.split('/').pop()}`, 'DIGITAL', true); elem.attr('data-file', path);
elem.attr('data-file', path); displayName = path.split('/').pop();
displayName = path.split('/').pop() elem.val(displayName);
elem.val(displayName); $('#video_file').val(displayName);
$('#video_file').val(displayName); }
} });
}) }
digital() {
const elem = $('#digital');
const path = elem.attr('data-file');
const fileName = elem.val();
let proceed = false;
let obj = {
path,
fileName
};
if (path && path !== '') {
proceed = confirm(`Are you sure you want to use ${fileName}?`);
}
if (proceed) {
gui.overlay(true);
gui.spinner(true, `Getting info about ${fileName}`);
ipcRenderer.send('digital', obj);
}
else {
$('#projector_type_digital').prop('checked', 'checked');
$('#digital').removeClass('active');
}
}
digitalCb(evt, args) {
let state;
let color = [255, 255, 255];
gui.spinner(false);
gui.overlay(false);
if (args.valid && args.valid === true) {
//success state
state = JSON.parse(args.state);
$('#digital').addClass('active');
$('#projector_type_digital').prop('checked', 'checked');
gui.notify('DEVICES', `Using video ${state.fileName}`);
seq.set(0, 'PF');
grid.state(0);
seq.set(1, 'CF');
seq.setLight(1, color);
grid.state(1);
if (light.disabled) {
light.enable();
}
$('#seq_loop').val(`${state.frames - 1}`).trigger('change');
gui.updateState();
}
else {
$('#projector_type_digital').prop('checked', 'checked');
$('#digital').removeClass('active');
}
}
} }
devices = new Devices();
devices.digital = function () {
'use strict';
const elem = $('#digital');
const path = elem.attr('data-file');
const fileName = elem.val();
let proceed = false;
let obj = {
path,
fileName
}
if (path && path !== '') {
proceed = confirm(`Are you sure you want to use ${fileName}?`);
}
if (proceed) {
gui.overlay(true);
gui.spinner(true, `Getting info about ${fileName}`);
ipcRenderer.send('filmout', obj)
} else {
$('#projector_type_digital').prop('checked', 'checked');
$('#digital').removeClass('active');
}
};
devices.digitalCb = function (evt, args) {
'use strict';
let state;
let color = [255,255,255];
gui.spinner(false);
gui.overlay(false);
if (args.valid && args.valid === true) {
//success state
state = JSON.parse(args.state);
$('#digital').addClass('active');
$('#projector_type_digital').prop('checked', 'checked');
gui.notify('DEVICES', `Using video ${state.fileName}`);
seq.set(0, 'PF');
grid.state(0);
seq.set(1, 'CF');
seq.setLight(1, color);
grid.state(1);
if (light.disabled) {
light.enable();
}
$('#seq_loop').val(`${state.frames - 1}`).trigger('change');
gui.updateState();
} else {
$('#projector_type_digital').prop('checked', 'checked');
$('#digital').removeClass('active');
}
};
module.exports = devices; module.exports = devices;

View File

@ -3,3 +3,4 @@
./node_modules/.bin/tsc ./src/lib/ui/grid.ts --outFile ./lib/ui/grid.js --noImplicitAny --lib ES2017 --lib ES2016 --lib dom -t ES2016 ./node_modules/.bin/tsc ./src/lib/ui/grid.ts --outFile ./lib/ui/grid.js --noImplicitAny --lib ES2017 --lib ES2016 --lib dom -t ES2016
./node_modules/.bin/tsc ./src/lib/ui/seq.ts --outFile ./lib/ui/seq.js --noImplicitAny --lib ES2017 --lib ES2016 --lib dom -t ES2016 ./node_modules/.bin/tsc ./src/lib/ui/seq.ts --outFile ./lib/ui/seq.js --noImplicitAny --lib ES2017 --lib ES2016 --lib dom -t ES2016
./node_modules/.bin/tsc ./src/lib/ui/filmout.ts --outFile ./lib/ui/filmout.js --noImplicitAny --lib ES2017 --lib ES2016 --lib dom -t ES2016 ./node_modules/.bin/tsc ./src/lib/ui/filmout.ts --outFile ./lib/ui/filmout.js --noImplicitAny --lib ES2017 --lib ES2016 --lib dom -t ES2016
./node_modules/.bin/tsc ./src/lib/ui/devices.ts --outFile ./lib/ui/devices.js --noImplicitAny --lib ES2017 --lib ES2016 --lib dom -t ES2016

View File

@ -10,256 +10,264 @@ declare var log : any;
declare var w2popup : any; declare var w2popup : any;
declare var cam : any; declare var cam : any;
declare var proj : any; declare var proj : any;
declare var light : any;
declare var grid : any;
declare var ipcRenderer : any;
declare var dialog : any;
const devices = {}; let devices : Devices;
devices.init = function () { class Devices {
'use strict'; private id : string = 'devices';
devices.listen(); constructor () {
devices.profiles(); this.init();
gui.overlay(true);
gui.spinner(true, 'Checking for connected devices...');
};
devices.profiles = function () {
'use strict';
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) => { init () {
devices.profile($('#profile').val()); this.listen();
}); this.profiles();
}; gui.overlay(true);
devices.profile = function (profile) { gui.spinner(true, 'Checking for connected devices...');
'use strict';
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]
} }
if (typeof p.light !== 'undefined' && p.light === false) { listen () {
light.disable(); ipcRenderer.on('ready', this.ready.bind(this));
} else { ipcRenderer.on('intval', this.intvalCb.bind(this));
light.enable(); ipcRenderer.on('digital', this.digitalCb.bind(this));
} }
ipcRenderer.send('profile', { profile })
}; ready (event : any, arg : any) {
devices.listen = function () { //console.dir(arg)
'use strict'; let opt : any;
ipcRenderer.on('ready', devices.ready); let devs : any[] = [];
ipcRenderer.on('intval', devices.intvalCb); let notify : string = 'Connected to ';
ipcRenderer.on('digital', devices.digitalCb); let p : any;
};
devices.ready = function (event, arg) { gui.spinner(false);
'use strict'; gui.overlay(false);
//console.dir(arg)
let opt; for (let i in arg) {
let devs = []; devs.push(arg[i].arduino);
let notify = 'Connected to '; if (arg[i].arduino && arg[i].arduino !== '/dev/fake') {
let p; if (notify === 'Connected to ') {
gui.spinner(false); notify += arg[i].arduino + ' '
gui.overlay(false); } else {
for (let i in arg) { notify += `& ${arg[i].arduino}`
devs.push(arg[i].arduino); }
if (arg[i].arduino && arg[i].arduino !== '/dev/fake') { }
if (notify === 'Connected to ') { opt = $('<option>');
notify += arg[i].arduino + ' ' opt.val(`ARDUINO_${arg[i].arduino}`);
} else { opt.text(arg[i].arduino);
notify += `& ${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) {
opt = $('<option>');
opt.val(i);
opt.text(i);
$('#devices').append(opt);
} }
} }
opt = $('<option>');
opt.val(`ARDUINO_${arg[i].arduino}`); if (arg && arg.profile) {
opt.text(arg[i].arduino); $('#profile').val(arg.profile)
$(`#${i}_device`).empty(); log.info(`Using configuration profile "${arg.profile}"`, 'DEVICES', true, true);
$(`#${i}_device`).append(opt); p = cfg.profiles[arg.profile];
} if (typeof p.light !== 'undefined' && p.light === false) {
if (notify !== 'Connected to ') { light.disable();
gui.notify('DEVICES', notify); } else {
} else { light.enable();
gui.notify('DEVICES', 'Connected to mock devices') }
} //devices.profile(arg.profile)
if (devs.length > 0) {
$('#devices').empty();
for (let i of devs) {
opt = $('<option>');
opt.val(i);
opt.text(i);
$('#devices').append(opt);
} }
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 (arg && arg.profile) {
$('#profile').val(arg.profile) profiles () {
log.info(`Using configuration profile "${arg.profile}"`, 'DEVICES', true, true); const keys : string[] = Object.keys(cfg.profiles);
p = cfg.profiles[arg.profile]; const elem : any = $('#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 : any) => {
const val : string = $('#profile').val() as string;
this.profile(val);
});
}
profile (profile : string) {
log.info(`Changed configuration profile to "${profile}"`, 'DEVICES', true, true);
const p : any = cfg.profiles[profile];
const keys : any[] = Object.keys(p);
for (let key of keys) {
cfg[key] = keys[key]
}
if (typeof p.light !== 'undefined' && p.light === false) { if (typeof p.light !== 'undefined' && p.light === false) {
light.disable(); light.disable();
} else { } else {
light.enable(); light.enable();
} }
//devices.profile(arg.profile) ipcRenderer.send('profile', { profile })
} }
seq.set(0, cfg.cmd.camera_forward); intval () {
seq.set(1, cfg.cmd.projector_forward); const url : string = $('#intval').val() as string;
grid.state(0); let proceed : boolean = false;
grid.state(1); let obj : any = {
seq.stats(); connect: true,
url : url
};
if (arg.projector_second) { if ( url !== '' && typeof url !== 'undefined') {
//add second row of projector pads to grid proceed = confirm(`Are you sure you want to connect to INTVAL3 @ ${url}?`);
proj.second.enable(); } else {
} alert('Cannot connect to INTVAL3 url as entered.');
if (arg.camera_second) {
//add second row of camera pads to grid
cam.second.enable();
}
return event.returnValue = true;
};
devices.intval = function () {
'use strict';
const url = $('#intval').val();
let proceed = false;
let obj = {
connect: true,
url : url
};
if ( url !== '' && typeof url !== 'undefined') {
proceed = confirm(`Are you sure you want to connect to INTVAL3 @ ${url}?`);
} else {
alert('Cannot connect to INTVAL3 url as entered.');
}
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');
}
};
devices.intvalCb = function (evt, args) {
'use strict';
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');
}
};
devices.digitalSelect = function () {
'use strict';
const elem = $('#digital');
const extensions = ['mpg', 'mpeg', 'mov', 'mkv', 'avi', 'mp4'];
dialog.showOpenDialog({
title : `Select video or image sequence`,
properties : [`openFile`], // openDirectory, multiSelection, openFile
defaultPath: 'c:/',
filters : [
{
name: 'All Files',
extensions: ['*']
},
]
}, (files) => {
let valid = false;
console.dir(files)
let path = files[0];
let displayName;
if (path && path !== '') {
for (let ext of extensions) {
if (path.toLowerCase().indexOf(`.${ext}`) !== -1) {
valid = true;
}
}
if (!valid) return false;
log.info(`Selected video ${path.split('/').pop()}`, 'DIGITAL', true);
elem.attr('data-file', path);
displayName = path.split('/').pop()
elem.val(displayName);
$('#video_file').val(displayName);
} }
})
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 : any, args : any) {
let state : any;
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');
}
}
digitalSelect () {
const elem : any = $('#digital');
const extensions : string[] = ['mpg', 'mpeg', 'mov', 'mkv', 'avi', 'mp4'];
dialog.showOpenDialog({
title : `Select video or image sequence`,
properties : [`openFile`], // openDirectory, multiSelection, openFile
defaultPath: 'c:/',
filters : [
{
name: 'All Files',
extensions: ['*']
},
]
}, (files : string[]) => {
let valid : boolean = false;
let path : string = files[0];
let displayName : string;
if (path && path !== '') {
for (let ext of extensions) {
if (path.toLowerCase().indexOf(`.${ext}`) !== -1) {
valid = true;
}
}
if (!valid) return false;
log.info(`Selected video ${path.split('/').pop()}`, 'DIGITAL', true);
elem.attr('data-file', path);
displayName = path.split('/').pop()
elem.val(displayName);
$('#video_file').val(displayName);
}
})
}
digital () {
const elem : any = $('#digital');
const path : string = elem.attr('data-file');
const fileName : string = elem.val();
let proceed : boolean = false;
let obj : any = {
path,
fileName
}
if (path && path !== '') {
proceed = confirm(`Are you sure you want to use ${fileName}?`);
}
if (proceed) {
gui.overlay(true);
gui.spinner(true, `Getting info about ${fileName}`);
ipcRenderer.send('digital', obj)
} else {
$('#projector_type_digital').prop('checked', 'checked');
$('#digital').removeClass('active');
}
}
digitalCb (evt : any, args : any) {
let state : any;
let color : number[] = [255, 255, 255];
gui.spinner(false);
gui.overlay(false);
if (args.valid && args.valid === true) {
//success state
state = JSON.parse(args.state);
$('#digital').addClass('active');
$('#projector_type_digital').prop('checked', 'checked');
gui.notify('DEVICES', `Using video ${state.fileName}`);
seq.set(0, 'PF');
grid.state(0);
seq.set(1, 'CF');
seq.setLight(1, color);
grid.state(1);
if (light.disabled) {
light.enable();
}
$('#seq_loop').val(`${state.frames - 1}`).trigger('change');
gui.updateState();
} else {
$('#projector_type_digital').prop('checked', 'checked');
$('#digital').removeClass('active');
}
}
} }
devices.digital = function () { devices = new Devices();
'use strict';
const elem = $('#digital');
const path = elem.attr('data-file');
const fileName = elem.val();
let proceed = false;
let obj = {
path,
fileName
}
if (path && path !== '') {
proceed = confirm(`Are you sure you want to use ${fileName}?`);
}
if (proceed) {
gui.overlay(true);
gui.spinner(true, `Getting info about ${fileName}`);
ipcRenderer.send('digital', obj)
} else {
$('#projector_type_digital').prop('checked', 'checked');
$('#digital').removeClass('active');
}
};
devices.digitalCb = function (evt, args) {
'use strict';
let state;
let color = [255,255,255];
gui.spinner(false);
gui.overlay(false);
if (args.valid && args.valid === true) {
//success state
state = JSON.parse(args.state);
$('#digital').addClass('active');
$('#projector_type_digital').prop('checked', 'checked');
gui.notify('DEVICES', `Using video ${state.fileName}`);
seq.set(0, 'PF');
grid.state(0);
seq.set(1, 'CF');
seq.setLight(1, color);
grid.state(1);
if (light.disabled) {
light.enable();
}
$('#seq_loop').val(`${state.frames - 1}`).trigger('change');
gui.updateState();
} else {
$('#projector_type_digital').prop('checked', 'checked');
$('#digital').removeClass('active');
}
};
module.exports = devices; module.exports = devices;