lint all the things

This commit is contained in:
sparks-alec
2022-02-14 03:25:37 -05:00
parent e5c8f242ab
commit 454b134745
30 changed files with 909 additions and 446 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.
+2
View File
@@ -0,0 +1,2 @@
<p><em>Art-Net</em> requires no configuration.</p>
<p>Art-Net™ Designed by and Copyright Artistic Licence Holdings Ltd</p>
+119
View File
@@ -0,0 +1,119 @@
const _ = require('lodash');
exports.defaultName = "Art-Net";
exports.connectionType = 'UDPsocket';
exports.heartbeatInterval = 10000;
exports.searchOptions = {
type: 'UDPsocket',
searchBuffer: Buffer.from([65, 114, 116, 45, 78, 101, 116, 0x00, 0x00, 0x20, 0x00, 0x0e, 0x00, 0x00]),
devicePort: 6454,
listenPort: 6454,
validateResponse (msg, info, devices) {
return msg.toString('utf8', 0, 7) === "Art-Net";
}
};
exports.defaultPort = 6454;
exports.ready = function ready(device) {
const d = device;
d.data.universes = {};
d.data.orderedUniverses = [];
};
exports.data = function data(device, buf) {
if(buf.length < 18){
return
}
const univ = buf.readUInt8(14);
const d = device;
let u = d.data.universes[univ];
if(!u){
d.data.universes[univ] = {};
u = d.data.universes[univ];
}
u.sequence = buf.readUInt8(12);
u.net = buf.readUInt8(15);
u.opCode = buf.readUInt8(9);
u.version = buf.readUInt16BE(10);
u.slots = Array.prototype.slice.call(buf, 18);
d.data.ip = d.addresses[0];
if(!_.includes(d.data.orderedUniverses, univ)){
d.data.orderedUniverses.push(univ);
d.data.orderedUniverses.sort();
u.slotElems = [];
u.slotElemsSet = false;
d.draw();
updateElementsCache(d, d.data.universes, d.data.orderedUniverses);
}
device.update("universeData", {
u: univ,
universe: u
});
};
exports.heartbeat = function heartbeat(device) {
};
let lastUpdate = Date.now();
exports.update = function update(device, document, updateType, updateData){
const data = updateData;
const doc = document;
if(updateType === "universeData" && data.universe){
if(Date.now() - lastUpdate > 1000){
lastUpdate = Date.now();
updateElementsCache(device, device.data.universes, device.data.orderedUniverses);
}
const $elem = doc.getElementById(`universe-${data.u}`);
if($elem && data.universe.slotElemsSet){
for(let i = 0; i < 512; i++){
data.universe.slotElems[i].innerText = data.universe.slots[i];
}
doc.getElementById(`universe-${data.u}-sequence`).innerText = data.universe.sequence;
}else{
device.draw();
updateElementsCache(device, device.data.universes, device.data.orderedUniverses);
}
}else if(updateType === "elementCache"){
data.orderedUniverses.forEach(univ => {
for(let i = 0; i < 512; i++){
data.universes[univ].slotElems[i] = doc.getElementById(`${univ}-${i}`);
}
data.universes[univ].slotElemsSet = true;
});
}
}
function updateElementsCache(device, univ, ordered){
device.update("elementCache", {
universes: univ,
orderedUniverses: ordered
});
}
+29
View File
@@ -0,0 +1,29 @@
table {
margin-bottom: 50px;
background-color: #333;
}
td,
th {
width: 35px;
}
td {
background-color: black;
text-align: center;
border-radius: 3px;
color: white;
font-size: 13px;
}
th {
background-color: #222;
color: #ccc;
font-size: 11px;
}
td.data {
padding: 7px;
font-size: 12px;
text-align: left;
}
td.data em {
font-size: 14px;
color: #008bd2;
}
+64
View File
@@ -0,0 +1,64 @@
<header>
<h1><%= data.source %> Art-Net</h1>
</header>
<div id="universes">
<% data.orderedUniverses.forEach(univ => {
let universe = data.universes[univ];
%>
<table id="universe-<%= univ %>">
<tr>
<td class="data" colspan="2">
Universe
<br><em><%= univ %></em>
</td>
<td class="data" colspan="2">
Sub-Net
<br><em><%= universe.net %></em>
</td>
<td class="data" colspan="2">
Sequence
<br><em id="universe-<%= univ %>-sequence"><%= universe.sequence %></em>
</td>
<td class="data" colspan="2">
OpCode
<br><em><%= universe.opCode %></em>
</td>
<td class="data" colspan="2">
Version
<br><em><%= universe.version %></em>
</td>
<td class="data" colspan="4">
IP
<br><em><%= data.ip %></em>
</td>
<td class="data" colspan="3"></td>
</tr>
<tr>
<th></th>
<% for(col=1; col<=16; col++){ %>
<th><%= col %></th>
<% } %>
</tr>
<% let slot = 0; %>
<% for(row=0; row<32; row++){ %>
<tr>
<th><%= row*16+1 %></th>
<% for(col=0; col<16; col++){ %>
<% slot++%>
<td id="<%= univ %>-<%= row*16+col %>" title="<%= univ %>/<%= slot %>"><%= universe.slots[slot-1] %></td>
<% } %>
</tr>
<% } %>
</table>
<% }); %>
</div>