mirror of
https://github.com/stagehacks/Cue-View.git
synced 2026-08-14 18:23:39 +00:00
fasted data updates/draws
This commit is contained in:
+65
-4
@@ -1,3 +1,7 @@
|
||||
let _ = require('lodash');
|
||||
const fs = require('fs');
|
||||
|
||||
|
||||
exports.defaultName = 'ETC Eos';
|
||||
exports.connectionType = 'osc';
|
||||
exports.searchOptions = {
|
||||
@@ -26,14 +30,20 @@ exports.data = function (device, osc) {
|
||||
const p = osc.address.split('/');
|
||||
p.shift();
|
||||
|
||||
//console.log(address)
|
||||
|
||||
if (p[1] == 'out' && p[2] == 'show' && p[3] == 'name') {
|
||||
device.data.showName = osc.args[0];
|
||||
device.data.cuelists = {};
|
||||
this.deviceInfoUpdate(device, 'defaultName', osc.args[0]);
|
||||
|
||||
|
||||
} else if (osc.address == '/eos/out/get/cuelist/count') {
|
||||
for (let i = 0; i < osc.args[0]; i++) {
|
||||
device.send(`/eos/get/cuelist/index/${i}`);
|
||||
}
|
||||
|
||||
|
||||
} else if (
|
||||
p[1] == 'out' &&
|
||||
p[2] == 'get' &&
|
||||
@@ -42,6 +52,8 @@ exports.data = function (device, osc) {
|
||||
) {
|
||||
device.data.cuelists[p[4]] = {};
|
||||
device.send(`/eos/get/cue/${p[4]}/count`);
|
||||
|
||||
|
||||
} else if (
|
||||
p[1] == 'out' &&
|
||||
p[2] == 'get' &&
|
||||
@@ -51,6 +63,8 @@ exports.data = function (device, osc) {
|
||||
for (let i = 0; i < osc.args[0]; i++) {
|
||||
device.send(`/eos/get/cue/${p[4]}/index/${i}`);
|
||||
}
|
||||
|
||||
|
||||
} else if (
|
||||
p[1] == 'out' &&
|
||||
p[2] == 'get' &&
|
||||
@@ -90,8 +104,13 @@ exports.data = function (device, osc) {
|
||||
),
|
||||
};
|
||||
|
||||
// console.log(p[4]+" "+p[5]+" "+p[6]+" updated")
|
||||
device.draw();
|
||||
device.update("cueData", {
|
||||
cue: device.data.cuelists[p[4]][p[5]],
|
||||
cueNumber: p[5],
|
||||
uid: osc.args[1]
|
||||
});
|
||||
|
||||
|
||||
} else if (p[1] == 'out' && p[2] == 'get' && p[3] == 'cue' && p.length == 6) {
|
||||
// console.log("cue "+p[4]+" "+p[5]+" deleted")
|
||||
|
||||
@@ -100,6 +119,8 @@ exports.data = function (device, osc) {
|
||||
|
||||
delete device.data.cuelists[p[4]][p[5]];
|
||||
device.draw();
|
||||
|
||||
|
||||
} else if (
|
||||
p[1] == 'out' &&
|
||||
p[2] == 'get' &&
|
||||
@@ -109,23 +130,30 @@ exports.data = function (device, osc) {
|
||||
if (osc.args.length == 3) {
|
||||
device.data.cuelists[p[4]][p[5]][0].extlinks = osc.args[2];
|
||||
}
|
||||
|
||||
|
||||
} else if (
|
||||
p[1] == 'out' &&
|
||||
p[2] == 'event' &&
|
||||
p[3] == 'cue' &&
|
||||
p[6] == 'fire'
|
||||
) {
|
||||
// explore replacing this with /eos/out/active/cue
|
||||
device.data.activeCue = p[5];
|
||||
|
||||
device.draw();
|
||||
device.update("activeCue", {uid: device.data.cuelists[p[4]][p[5]][0].uid});
|
||||
|
||||
|
||||
} else if (p[1] == 'out' && p[2] == 'notify' && p[3] == 'cue') {
|
||||
const cueList = p[4];
|
||||
const listIndex = p[6];
|
||||
const listCount = p[7];
|
||||
const cueNumber = osc.args[1];
|
||||
console.log(cueNumber+" changed")
|
||||
|
||||
device.send(`/eos/get/cue/${cueList}/${cueNumber}`);
|
||||
// console.log("SENT /eos/get/cue/"+cueList+"/"+cueNumber);
|
||||
|
||||
|
||||
} else if (
|
||||
p[2] == 'cmd' ||
|
||||
p[2] == 'ping' ||
|
||||
@@ -134,11 +162,44 @@ exports.data = function (device, osc) {
|
||||
) {
|
||||
} else if (p[3] == 'version') {
|
||||
device.data.version = osc.args[0];
|
||||
|
||||
|
||||
} else {
|
||||
// console.log(osc);
|
||||
|
||||
}
|
||||
// console.log(p)
|
||||
};
|
||||
|
||||
let cueTemplate = _.template(fs.readFileSync(`./plugins/eos/cue.ejs`));
|
||||
|
||||
exports.update = function(device, doc, updateType, data){
|
||||
|
||||
if(updateType == "cueData"){
|
||||
$elem = doc.getElementById(data.uid);
|
||||
|
||||
if($elem){
|
||||
$elem.outerHTML = cueTemplate({
|
||||
q: data.cue,
|
||||
cueNumber: data.cueNumber,
|
||||
isActive: false
|
||||
});
|
||||
|
||||
}else{
|
||||
device.draw();
|
||||
|
||||
}
|
||||
|
||||
}else if(updateType == "activeCue"){
|
||||
$elem = doc.getElementById(data.uid);
|
||||
$elem.scrollIntoView({behavior: "smooth", block: "center"});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
exports.heartbeat = function (device) {
|
||||
device.send('/eos/ping');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user