Merge pull request 'Merge the estimates branch' (#79) from estimates into main

Reviewed-on: #79
This commit is contained in:
Matt McWilliams 2023-02-28 15:58:26 -05:00
commit 648bca5b2e
21 changed files with 295 additions and 79 deletions

View File

@ -2497,6 +2497,7 @@ const devices = require('./lib/ui/devices.js');
const filmout = require('./lib/ui/filmout.js');
const mse = require('./lib/ui/mscript.js');
const capper = require('./lib/ui/capper.js');
const timing = require('./lib/ui/timing.js');
const Mscript = require('./lib/mscript');
const { delay } = require('./lib/delay');
const alertObj = require('./lib/ui/alert.js');

View File

@ -1,8 +0,0 @@
/**
* Delay in an async/await function
*
* @param {integer} ms Milliseconds to delay for
*
* @returns {Promise} Promise to resolve after timeout
**/
declare function delay(ms: number): Promise<unknown>;

View File

@ -41,9 +41,16 @@ class Devices {
* local settings object.
**/
listener(event, arg) {
this.log.info(`Saving profile ${arg.profile}`, 'SETTINGS', false, false);
this.settings.update('profile', arg.profile);
this.settings.save();
if (typeof arg.profile !== 'undefined') {
this.log.info(`Saving profile ${arg.profile}`, 'SETTINGS', false, false);
this.settings.update('profile', arg.profile);
this.settings.save();
}
if (typeof arg.timing !== 'undefined') {
this.log.info(`Saving timing info`, 'SETTINGS', false, false);
this.settings.update('timing', arg.timing);
this.settings.save();
}
}
/**
*
@ -510,6 +517,9 @@ class Devices {
light,
profile: this.settings.state.profile
};
if (this.settings.state.timing) {
args.timing = this.settings.state.timing;
}
if (projector_second && projector_second.arduino) {
args.projector_second = projector_second;
this.settings.update('projector_second', projector_second);

File diff suppressed because one or more lines are too long

View File

@ -19,7 +19,8 @@ class Settings {
camera: {},
projector: {},
light: {},
capper: {}
capper: {},
timing: {}
};
this.state = this.freshState();
}

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/settings/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,yBAA0B;AAC1B,6BAA8B;AAC9B,+BAAgC;AAEhC,MAAM,QAAQ;IAeb;;QAEI;IACJ;QAjBQ,SAA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AI,CAAC,IAAI,EAAE,CAAC;SACZ;IACF,CAAC;IACD;;QAEI;IACG,KAAK,CAAC,KAAK;QACjB,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,MAAM,EAAE;YACX,IAAI;gBACH,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAC3B;YAAC,OAAO,GAAG,EAAE;gBACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;aACnB;SACD;QACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAC/B,IAAI,CAAC,OAAO,EAAE,CAAC;IAChB,CAAC;IAAA,CAAC;CACF;AAED,MAAM,CAAC,OAAO,GAAG,IAAI,QAAQ,EAAE,CAAA"}

View File

@ -80,6 +80,7 @@ cam.end = function (c, id, ms) {
}
gui.counterUpdate('cam2', cam.second.pos);
}
timing.update(c, ms);
gui.counterUpdate('cam', cam.pos)
if (typeof cam.queue[id] !== 'undefined') {
if (typeof cam.queue[id].callback !== 'undefined') {
@ -182,6 +183,7 @@ cam.second.end = function (c, id, ms) {
cam.second.pos -= 1;
}
}
timing.update(c, ms);
gui.counterUpdate('cam2', cam.second.pos)
if (typeof cam.second.queue[id] !== 'undefined') {
if (typeof cam.queue[id].callback !== 'undefined') {

View File

@ -83,8 +83,12 @@ class Devices {
else {
light.enable();
}
timing.reset(p);
//devices.profile(arg.profile)
}
if (arg && arg.timing) {
timing.restore(arg.timing);
}
if (arg.projector_second) {
//add second row of projector pads to grid
proj.second.enable();
@ -128,6 +132,7 @@ class Devices {
for (let key of keys) {
cfg[key] = keys[key];
}
timing.reset(p);
if (typeof p.light !== 'undefined' && p.light === false) {
light.disable();
}
@ -135,6 +140,7 @@ class Devices {
light.enable();
}
ipcRenderer.send('profile', { profile });
timing.store();
}
intval() {
const url = $('#intval').val();

File diff suppressed because one or more lines are too long

View File

@ -173,6 +173,7 @@ proj.second.end = function (c, id, ms) {
proj.second.pos -= 1;
}
}
timing.update(c, ms);
gui.counterUpdate('proj2', proj.second.pos);
if (typeof proj.second.queue[id] !== 'undefined') {
if (typeof proj.second.queue[id].callback !== 'undefined') {

View File

@ -51,6 +51,8 @@ class Sequence {
$('#cmd_capper_off').addClass('active');
$('#cmd_capper_on').removeClass('active');
}
this.stats();
timing.store();
}
}
return event.returnValue = true;
@ -178,23 +180,8 @@ class Sequence {
if (!step)
continue;
c = step.cmd;
if (c === cfg.cmd.camera_forward || c === cfg.cmd.camera_backward) {
ms += cfg.arduino.cam.time;
ms += cfg.arduino.cam.delay;
ms += cfg.arduino.serialDelay;
}
if (c === cfg.cmd.projector_forward || c === cfg.cmd.projector_backward) {
ms += cfg.arduino.proj.time;
ms += cfg.arduino.proj.delay;
ms += cfg.arduino.serialDelay;
}
if (c === cfg.cmd.black_forward || c === cfg.cmd.black_backward) {
ms += cfg.arduino.black.before;
ms += cfg.arduino.black.after;
ms += cfg.arduino.cam.time;
ms += cfg.arduino.cam.delay;
ms += cfg.arduino.serialDelay;
}
ms += timing.get(c);
ms += cfg.arduino.serialDelay;
ms += cfg.arduino.sequenceDelay;
if (c === cfg.cmd.camera_forward || c === cfg.cmd.black_forward) {
cam_total++;

File diff suppressed because one or more lines are too long

96
app/lib/ui/timing.js Normal file
View File

@ -0,0 +1,96 @@
'use strict';
let timing;
class Timing {
constructor() {
this.data = {};
this.fromArduino = {
'c': 'cam',
'3': 'cam2',
'4': 'cams',
'b': 'black',
'p': 'proj',
'w': 'proj2',
'x': 'projs'
};
this.fromCmd = {
'CF': 'cam',
'CB': 'cam',
'BF': 'black',
'BB': 'black',
'C2F': 'cam2',
'C2B': 'cam2',
'CCF': 'cams',
'CCB': 'cams',
'CFCB': 'cams',
'CBCF': 'cams',
'PF': 'proj',
'PB': 'proj',
'P2F': 'proj2',
'P2B': 'proj2',
'PPF': 'projs',
'PPB': 'projs',
'PFPB': 'projs',
'PBPF': 'projs'
};
}
reset(profile) {
const keys = Object.keys(profile);
const cmds = Object.keys(cfg.cmd);
let cam;
let proj;
let pad;
for (let key of keys) {
console.log(key);
if (key === 'label') {
continue;
}
else if (key === 'cam') {
cam = 0;
cam += profile[key].time;
cam += profile[key].delay;
cam += profile[key].momentary;
pad = 0;
if (typeof profile['black'] !== 'undefined' && typeof profile['black'].before !== 'undefined' && typeof profile['black'].after !== 'undefined') {
pad = (profile['black'].before + profile['black'].after);
}
this.data['cam'] = cam;
this.data['cam2'] = cam;
this.data['cams'] = cam;
this.data['black'] = cam + pad;
}
else if (key === 'proj') {
proj = 0;
proj += profile[key].time;
proj += profile[key].delay;
proj += profile[key].momentary;
this.data['proj'] = proj;
this.data['proj2'] = proj;
this.data['projs'] = proj;
}
}
}
restore(timing) {
this.data = timing;
}
//update with rolling average
update(c, ms) {
let cmd = this.fromArduino[c];
if (typeof cmd !== 'undefined' && typeof this.data[cmd] !== 'undefined') {
this.data[cmd] = Math.round((this.data[cmd] + ms) / 2);
}
}
//get current value
get(c) {
const cmd = this.fromCmd[c];
if (typeof cmd !== 'undefined' && typeof this.data[cmd] !== 'undefined') {
return this.data[cmd];
}
return 0;
}
store() {
ipcRenderer.send('profile', { timing: this.data });
}
}
timing = new Timing();
module.exports = timing;
//# sourceMappingURL=timing.js.map

1
app/lib/ui/timing.js.map Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"timing.js","sourceRoot":"","sources":["../../src/lib/ui/timing.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,IAAI,MAAe,CAAC;AAMpB,MAAM,MAAM;IAoCX;QAnCO,SAAI,GAAgB,EAE1B,CAAA;QAEO,gBAAW,GAAS;YAC3B,GAAG,EAAG,KAAK;YACR,GAAG,EAAG,MAAM;YACZ,GAAG,EAAG,MAAM;YACZ,GAAG,EAAG,OAAO;YAChB,GAAG,EAAG,MAAM;YACT,GAAG,EAAG,OAAO;YAChB,GAAG,EAAG,OAAO;SACb,CAAA;QAEO,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AAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;SACvD;IACF,CAAC;IAED,mBAAmB;IACZ,GAAG,CAAE,CAAU;QACrB,MAAM,GAAG,GAAY,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACrC,IAAI,OAAO,GAAG,KAAK,WAAW,IAAI,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,WAAW,EAAE;YACxE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACtB;QACD,OAAO,CAAC,CAAC;IACV,CAAC;IAEM,KAAK;QACX,WAAW,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,MAAM,EAAG,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;IACpD,CAAC;CACD;AAED,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;AAEtB,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC"}

View File

@ -20,26 +20,26 @@ const { delay } = require('delay')
//Objects
const mcopy = {}
let SYSTEM;
let log;
let mainWindow;
let arduino;
let menu;
let display;
let ffmpeg;
let ffprobe;
let cam;
let cam2;
let proj;
let proj2;
let light;
let filmout;
let dev;
let cmd;
let seq;
let capper;
let alert;
let server;
let SYSTEM
let log
let mainWindow
let arduino
let menu
let display
let ffmpeg
let ffprobe
let cam
let cam2
let proj
let proj2
let light
let filmout
let dev
let cmd
let seq
let capper
let alert
let server
const cfg = require('./data/cfg.json')
@ -142,12 +142,12 @@ var init = async function () {
app.on('ready', init)
app.on('window-all-closed', () => {
app.quit();
app.quit()
});
app.on('activate', () => {
if (mainWindow === null) {
createWindow();
createWindow()
}
});

View File

@ -23,6 +23,7 @@ const devices = require('./lib/ui/devices.js');
const filmout = require('./lib/ui/filmout.js');
const mse = require('./lib/ui/mscript.js');
const capper = require('./lib/ui/capper.js');
const timing = require('./lib/ui/timing.js');
const Mscript = require('./lib/mscript');
const { delay } = require('./lib/delay');
const alertObj = require('./lib/ui/alert.js');

View File

@ -79,8 +79,12 @@ class Devices {
} else {
light.enable();
}
timing.reset(p);
//devices.profile(arg.profile)
}
if (arg && arg.timing) {
timing.restore(arg.timing);
}
if (arg.projector_second) {
//add second row of projector pads to grid
@ -126,14 +130,17 @@ class Devices {
const p : any = cfg.profiles[profile];
const keys : any[] = Object.keys(p);
for (let key of keys) {
cfg[key] = keys[key]
cfg[key] = keys[key];
}
timing.reset(p);
if (typeof p.light !== 'undefined' && p.light === false) {
light.disable();
} else {
light.enable();
}
ipcRenderer.send('profile', { profile })
timing.store();
}
intval () {

View File

@ -75,6 +75,8 @@ class Sequence {
$('#cmd_capper_off').addClass('active');
$('#cmd_capper_on').removeClass('active');
}
this.stats();
timing.store();
}
}
return event.returnValue = true;
@ -207,28 +209,13 @@ class Sequence {
}
return true;
});
//timing
for (let step of this.grid) {
if (!step) continue
c = step.cmd;
if (c === cfg.cmd.camera_forward || c === cfg.cmd.camera_backward){
ms += cfg.arduino.cam.time;
ms += cfg.arduino.cam.delay;
ms += cfg.arduino.serialDelay;
}
if (c === cfg.cmd.projector_forward || c === cfg.cmd.projector_backward){
ms += cfg.arduino.proj.time;
ms += cfg.arduino.proj.delay;
ms += cfg.arduino.serialDelay;
}
if (c === cfg.cmd.black_forward || c === cfg.cmd.black_backward){
ms += cfg.arduino.black.before;
ms += cfg.arduino.black.after;
ms += cfg.arduino.cam.time;
ms += cfg.arduino.cam.delay;
ms += cfg.arduino.serialDelay;
}
ms += timing.get(c);
ms += cfg.arduino.serialDelay;
ms += cfg.arduino.sequenceDelay;
if (c === cfg.cmd.camera_forward || c === cfg.cmd.black_forward) {

113
app/src/lib/ui/timing.ts Normal file
View File

@ -0,0 +1,113 @@
'use strict';
let timing : Timing;
interface TimingData {
[key: string]: number;
}
class Timing {
public data : TimingData = {
}
private fromArduino : any = {
'c' : 'cam',
'3' : 'cam2',
'4' : 'cams',
'b' : 'black',
'p' : 'proj',
'w' : 'proj2',
'x' : 'projs'
}
private fromCmd : any = {
'CF' : 'cam',
'CB' : 'cam',
'BF' : 'black',
'BB' : 'black',
'C2F': 'cam2',
'C2B': 'cam2',
'CCF' : 'cams',
'CCB' : 'cams',
'CFCB': 'cams',
'CBCF': 'cams',
'PF' : 'proj',
'PB' : 'proj',
'P2F' : 'proj2',
'P2B' : 'proj2',
'PPF' : 'projs',
'PPB' : 'projs',
'PFPB' : 'projs',
'PBPF' : 'projs'
}
constructor () {
}
public reset (profile : any) {
const keys : string[] = Object.keys(profile);
const cmds : string[] = Object.keys(cfg.cmd);
let cam : number;
let proj : number;
let pad : number;
for (let key of keys) {
if (key === 'label') {
continue
} else if (key === 'cam') {
cam = 0;
cam += profile[key].time;
cam += profile[key].delay;
cam += profile[key].momentary;
pad = 0;
if (typeof profile['black'] !== 'undefined' && typeof profile['black'].before !== 'undefined' && typeof profile['black'].after !== 'undefined') {
pad = (profile['black'].before + profile['black'].after);
}
this.data['cam'] = cam
this.data['cam2'] = cam
this.data['cams'] = cam
this.data['black'] = cam + pad
} else if (key === 'proj') {
proj = 0;
proj += profile[key].time;
proj += profile[key].delay;
proj += profile[key].momentary;
this.data['proj'] = proj;
this.data['proj2'] = proj;
this.data['projs'] = proj;
}
}
}
public restore (timing : TimingData) {
this.data = timing;
}
//update with rolling average
public update (c : string, ms : number) {
let cmd : string = this.fromArduino[c];
if (typeof cmd !== 'undefined' && typeof this.data[cmd] !== 'undefined') {
this.data[cmd] = Math.round((this.data[cmd] + ms) / 2);
}
}
//get current value
public get (c : string) : number {
const cmd : string = this.fromCmd[c];
if (typeof cmd !== 'undefined' && typeof this.data[cmd] !== 'undefined') {
return this.data[cmd];
}
return 0;
}
public store () {
ipcRenderer.send('profile', { timing : this.data })
}
}
timing = new Timing();
module.exports = timing;

View File

@ -53,9 +53,16 @@ class Devices {
* local settings object.
**/
private listener (event : any, arg : any){
this.log.info(`Saving profile ${arg.profile}`, 'SETTINGS', false, false);
this.settings.update('profile', arg.profile);
this.settings.save();
if (typeof arg.profile !== 'undefined') {
this.log.info(`Saving profile ${arg.profile}`, 'SETTINGS', false, false);
this.settings.update('profile', arg.profile);
this.settings.save();
}
if (typeof arg.timing !== 'undefined') {
this.log.info(`Saving timing info`, 'SETTINGS', false, false);
this.settings.update('timing', arg.timing);
this.settings.save();
}
}
/**
*
@ -501,7 +508,10 @@ class Devices {
camera,
projector,
light,
profile: this.settings.state.profile
profile: this.settings.state.profile
}
if (this.settings.state.timing) {
args.timing = this.settings.state.timing
}
if (projector_second && projector_second.arduino) {

View File

@ -16,7 +16,8 @@ class Settings {
camera : {},
projector : {},
light : {},
capper : {}
capper : {},
timing : {}
}
public state : any;
/**