From fae4775c8aa1925f6c51985f4582208334dc5c03 Mon Sep 17 00:00:00 2001 From: sparks-alec Date: Mon, 7 Feb 2022 02:05:29 -0500 Subject: [PATCH] fasted data updates/draws --- plugins/eos/cue.ejs | 83 +++++++++++++++++++++++++++++++++++++ plugins/eos/main.js | 69 +++++++++++++++++++++++++++++-- plugins/eos/template.ejs | 89 ++++++---------------------------------- 3 files changed, 160 insertions(+), 81 deletions(-) create mode 100644 plugins/eos/cue.ejs diff --git a/plugins/eos/cue.ejs b/plugins/eos/cue.ejs new file mode 100644 index 0000000..6dbd73e --- /dev/null +++ b/plugins/eos/cue.ejs @@ -0,0 +1,83 @@ + + +<% for(var partNumber in q){ %> + + <% var part = q[partNumber] %> + + + <% if(part.scene.length>0 && partNumber==0){ %> + + +
<%= part.scene %> + + <% } %> + + <% if(isActive){ %> + +<% }else{ %> + +<% } %> + + <% if(partNumber!=0){ %> +      P<%= partNumber %> + <% }else{ %> +  <%= cueNumber %> + <% } %> + + <% if(partNumber!=0 || part.partcount==0){ %> + + + <% if(part.uptimeduration == part.downtimeduration || part.downtimeduration==-1){ %> + <%= prettyDuration(part.uptimedelay) || "" %><%= prettyDuration(part.uptimeduration, true) %> + <% }else{ %> + <%= prettyDuration(part.uptimedelay) || "" %><%= prettyDuration(part.uptimeduration, true) %> + <%= prettyDuration(part.downtimeduration, true) %> + <% } %> + + <%= prettyDuration(part.focustimeduration, true) %> + <%= prettyDuration(part.colortimeduration, true) %> + <%= prettyDuration(part.beamtimeduration, true) %> + <%= prettyDuration(part.duration) %> + + <% }else{ %> + + + + + + + <% } %> + + <%= part.mark %> + <%= part.block %> + <%= part.assert %> + + <%= (part.follow>=0)? "F"+prettyDuration(part.follow) : "" %> + <%= (part.hang>=0)? "H"+prettyDuration(part.hang) : "" %> + + + <%= (partNumber==0 ? "": "   ") %> + <%= part.label %> + + <%= part.extlinks %> + + + + +<% } %> + + + +<% +function prettyDuration(milliseconds, box){ + if(milliseconds==-1){ + return ""; + } + var num = Math.round(milliseconds/100)/10; + if(box){ + return "
"+num+"
"; + } + return num; + +} +%> \ No newline at end of file diff --git a/plugins/eos/main.js b/plugins/eos/main.js index bc85366..26d1773 100644 --- a/plugins/eos/main.js +++ b/plugins/eos/main.js @@ -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'); }; diff --git a/plugins/eos/template.ejs b/plugins/eos/template.ejs index 439c5e6..daf77b8 100644 --- a/plugins/eos/template.ejs +++ b/plugins/eos/template.ejs @@ -1,8 +1,13 @@

<%= listName %>

-

<%= data.version %>

+

Eos <%= data.version %>

+<% + const fs = require('fs'); + let cueTemplate = _.template(fs.readFileSync(`./plugins/eos/cue.ejs`)); +%> + <% for(var i in data.cuelists){ %> List <%= i %> @@ -28,69 +33,12 @@ <% for(var j=0; j <% var q = data.cuelists[i][cues[j]] %> - <% for(var partNumber in q){ %> - - <% var p = q[partNumber] %> - - - <% if(p.scene.length>0 && partNumber==0){ %> - - -
<%= p.scene %> - - <% } %> - - <% if(cues[j]==data.activeCue+""){ %> - - <% }else{ %> - - <% } %> - - <% if(partNumber!=0){ %> -      P<%= partNumber %> - <% }else{ %> -  <%= cues[j] %> - <% } %> - - <% if(partNumber!=0 || p.partcount==0){ %> - - - <% if(p.uptimeduration == p.downtimeduration || p.downtimeduration==-1){ %> - <%= prettyDuration(p.uptimedelay) || "" %><%= prettyDuration(p.uptimeduration, true) %> - <% }else{ %> - <%= prettyDuration(p.uptimedelay) || "" %><%= prettyDuration(p.uptimeduration, true) %> - <%= prettyDuration(p.downtimeduration, true) %> - <% } %> - - <%= prettyDuration(p.focustimeduration, true) %> - <%= prettyDuration(p.colortimeduration, true) %> - <%= prettyDuration(p.beamtimeduration, true) %> - <%= prettyDuration(p.duration) %> - - <% }else{ %> - - - - - - - <% } %> - - <%= p.mark %> - <%= p.block %> - <%= p.assert %> - - <%= (p.follow>=0)? "F"+prettyDuration(p.follow) : "" %> - <%= (p.hang>=0)? "H"+prettyDuration(p.hang) : "" %> - - - <%= (partNumber==0 ? "": "   ") %> - <%= p.label %> - - <%= p.extlinks %> - - - <% } %> + <%= cueTemplate({ + q: q, + cues: cues, + cueNumber: cues[j], + isActive: (cues[j]==data.activeCue+"") + }) %> <% } %> @@ -98,16 +46,3 @@ <% } %> -<% - function prettyDuration(milliseconds, box){ - if(milliseconds==-1){ - return ""; - } - var num = Math.round(milliseconds/100)/10; - if(box){ - return "
"+num+"
"; - } - return num; - - } -%> \ No newline at end of file