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: 713 B

Binary file not shown.
+1
View File
@@ -0,0 +1 @@
<p><em>sACN</em> requires no configuration.</p>
+158
View File
@@ -0,0 +1,158 @@
const _ = require('lodash');
exports.defaultName = 'sACN Universe';
exports.connectionType = 'multicast';
exports.defaultPort = 5568;
exports.heartbeatInterval = 5000;
exports.searchOptions = {
type: "multicast",
address: getMulticastGroup(1),
port: 5568,
validateResponse (msg, info) {
return msg.toString('utf8', 4, 13) === "ASC-E1.17";
},
};
exports.defaultPort = 5568;
exports.ready = function ready(device) {
const d = device;
d.data.universes = {};
d.data.source = "Unknown Source";
d.data.orderedUniverses = [];
// device.draw();
for(let i = 1; i <= 16; i++){
d.connection.addMembership(getMulticastGroup(i));
}
};
exports.data = function data(device, buf) {
const univ = buf.readUInt16BE(113);
const d = device;
let u = d.data.universes[univ];
if(!u){
d.data.universes[univ] = {};
u = d.data.universes[univ];
}
u.sequence = buf.readUInt8(111);
u.priority = buf.readUInt8(108);
u.cid = buf.toString('hex', 22, 38);
u.slots = Array.prototype.slice.call(buf, 126);
if(buf.readUInt8(125) !== 0){
u.startCode = buf.readUInt8(125);
}
d.data.source = buf.toString('utf8', 44, 108);
d.displayName = `${d.data.source} sACN`;
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);
}
d.update("universeData", {
u: univ,
universe: u,
startCode: u.startCode
});
};
exports.heartbeat = function heartbeat(device) {
};
let lastUpdate = Date.now();
exports.update = function update(device, doc, updateType, updateData){
const d = device;
const data = updateData;
if(updateType === "universeData" && data.universe){
if(Date.now() - lastUpdate > 1000){
lastUpdate = Date.now();
updateElementsCache(d, d.data.universes, d.data.orderedUniverses);
}
const $elem = doc.getElementById(`universe-${data.u}`);
if($elem && data.universe.slotElemsSet){
if(data.universe.priority > 0){
for(let i = 0; i < 512; i++){
data.universe.slotElems[i].innerText = data.universe.slots[i];
}
const $code = doc.getElementById(`universe-${data.u}-code`);
if(data.startCode === 0xDD){
$code.innerText = "Net3"
}else if(data.startCode === 0x17){
$code.innerText = "Text"
}else if(data.startCode === 0xCF){
$code.innerText = "SIP"
}else if(data.startCode === 0xCC){
$code.innerText = "RDM"
}
}
}else{
d.draw();
updateElementsCache(d, d.data.universes, d.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
});
}
// From https://github.com/hhromic/e131-node/blob/master/lib/e131.js
function getMulticastGroup(universe) {
if (universe < 1 || universe > 63999) {
throw new RangeError('universe should be in the range [1-63999]');
}
return `239.255.${universe >> 8}.${universe & 0xff}`;
}
+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: #ff0033;
}
+58
View File
@@ -0,0 +1,58 @@
<header>
<h1><%= data.source %> sACN (E1.31)</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">
Priority
<br><em><%= universe.priority %></em>
</td>
<td class="data" colspan="7">
CID
<br><em><%= universe.cid %></em>
</td>
<td class="data" colspan="4">
IP
<br><em><%= data.ip %></em>
</td>
<td class="data" colspan="2">
Flavor
<br><em id="universe-<%= univ %>-code">0</em>
</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>