2023-02-28 19:30:17 +00:00
|
|
|
'use strict';
|
|
|
|
let timing;
|
|
|
|
class Timing {
|
|
|
|
constructor() {
|
|
|
|
this.data = {};
|
2023-02-28 20:55:02 +00:00
|
|
|
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'
|
|
|
|
};
|
2023-02-28 19:30:17 +00:00
|
|
|
}
|
|
|
|
reset(profile) {
|
|
|
|
const keys = Object.keys(profile);
|
|
|
|
const cmds = Object.keys(cfg.cmd);
|
|
|
|
let cam;
|
|
|
|
let proj;
|
2023-02-28 20:55:02 +00:00
|
|
|
let pad;
|
2023-02-28 19:30:17 +00:00
|
|
|
for (let key of keys) {
|
2023-02-28 20:55:02 +00:00
|
|
|
console.log(key);
|
2023-02-28 19:30:17 +00:00
|
|
|
if (key === 'label') {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key === 'cam') {
|
|
|
|
cam = 0;
|
|
|
|
cam += profile[key].time;
|
|
|
|
cam += profile[key].delay;
|
2023-02-28 20:55:02 +00:00
|
|
|
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);
|
2023-02-28 19:30:17 +00:00
|
|
|
}
|
2023-02-28 20:55:02 +00:00
|
|
|
this.data['cam'] = cam;
|
|
|
|
this.data['cam2'] = cam;
|
|
|
|
this.data['cams'] = cam;
|
|
|
|
this.data['black'] = cam + pad;
|
2023-02-28 19:30:17 +00:00
|
|
|
}
|
|
|
|
else if (key === 'proj') {
|
|
|
|
proj = 0;
|
|
|
|
proj += profile[key].time;
|
|
|
|
proj += profile[key].delay;
|
2023-02-28 20:55:02 +00:00
|
|
|
proj += profile[key].momentary;
|
|
|
|
this.data['proj'] = proj;
|
|
|
|
this.data['proj2'] = proj;
|
|
|
|
this.data['projs'] = proj;
|
2023-02-28 19:30:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-02-28 20:55:02 +00:00
|
|
|
restore(timing) {
|
|
|
|
this.data = timing;
|
|
|
|
}
|
2023-02-28 19:30:17 +00:00
|
|
|
//update with rolling average
|
2023-02-28 20:55:02 +00:00
|
|
|
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);
|
2023-02-28 19:30:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//get current value
|
2023-02-28 20:55:02 +00:00
|
|
|
get(c) {
|
|
|
|
const cmd = this.fromCmd[c];
|
|
|
|
if (typeof cmd !== 'undefined' && typeof this.data[cmd] !== 'undefined') {
|
2023-02-28 19:30:17 +00:00
|
|
|
return this.data[cmd];
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2023-02-28 20:55:02 +00:00
|
|
|
store() {
|
|
|
|
ipcRenderer.send('profile', { timing: this.data });
|
|
|
|
}
|
2023-02-28 19:30:17 +00:00
|
|
|
}
|
|
|
|
timing = new Timing();
|
|
|
|
module.exports = timing;
|
|
|
|
//# sourceMappingURL=timing.js.map
|