Display Art-Net universes as x:y:z (n) format consistently
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { getShortLabel, getFirstName, isSwitch, findInterface } from './nodes.js';
|
||||
import { flowViewData, currentMode, currentView } from './state.js';
|
||||
import { formatUniverse, formatArtmapAddr } from './format.js';
|
||||
|
||||
function scrollToNode(typeid) {
|
||||
const nodeEl = document.querySelector('.node[data-id="' + typeid + '"]');
|
||||
@@ -124,6 +125,7 @@ export function showFlowView(flowSpec) {
|
||||
const universe = parseInt(parts[1], 10);
|
||||
const sourceIdent = parts[2];
|
||||
const protoName = protocol === 'sacn' ? 'sACN' : 'Art-Net';
|
||||
const universeDisplay = formatUniverse(universe, protocol);
|
||||
flowUniverse = universe;
|
||||
flowProtocol = protocol;
|
||||
if (isNaN(universe)) { error = 'Invalid universe'; }
|
||||
@@ -152,7 +154,7 @@ export function showFlowView(flowSpec) {
|
||||
const isDest = destIds.includes(clickedNodeId);
|
||||
if (isSource) {
|
||||
const destNames = destIds.filter(id => id !== clickedNodeId).map(id => getFirstName(nodesByTypeId.get(id))).join(', ');
|
||||
title = protoName + ' ' + universe + ': ' + getFirstName(clickedNode) + ' → ' + (destNames || '?');
|
||||
title = protoName + ' ' + universeDisplay + ': ' + getFirstName(clickedNode) + ' → ' + (destNames || '?');
|
||||
destIds.forEach(destId => {
|
||||
if (destId !== clickedNodeId) {
|
||||
const path = findPath(graph, clickedNodeId, destId);
|
||||
@@ -161,7 +163,7 @@ export function showFlowView(flowSpec) {
|
||||
});
|
||||
} else if (isDest) {
|
||||
const sourceNames = sourceIds.map(id => getFirstName(nodesByTypeId.get(id))).join(', ');
|
||||
title = protoName + ' ' + universe + ': ' + (sourceNames || '?') + ' → ' + getFirstName(clickedNode);
|
||||
title = protoName + ' ' + universeDisplay + ': ' + (sourceNames || '?') + ' → ' + getFirstName(clickedNode);
|
||||
sourceIds.forEach(sourceId => {
|
||||
const path = findPath(graph, sourceId, clickedNodeId);
|
||||
if (path) paths.push({ path, sourceId, destId: clickedNodeId });
|
||||
@@ -171,7 +173,7 @@ export function showFlowView(flowSpec) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
title = protoName + ' Universe ' + universe;
|
||||
title = protoName + ' Universe ' + universeDisplay;
|
||||
sourceIds.forEach(sourceId => {
|
||||
destIds.forEach(destId => {
|
||||
if (sourceId !== destId) {
|
||||
@@ -344,31 +346,26 @@ export function renderFlowPath(pathInfo, nodesByTypeId, flowUniverse, flowProtoc
|
||||
mappingsEl = document.createElement('div');
|
||||
mappingsEl.className = 'flow-artmap-mappings';
|
||||
if (isSourceNode) mappingsEl.classList.add('before-node');
|
||||
const currentPrefix = flowProtocol + ':' + flowUniverse;
|
||||
const nodeName = getFirstName(node);
|
||||
relevantMappings.forEach(m => {
|
||||
const mappingEl = document.createElement('div');
|
||||
mappingEl.className = 'artmap-mapping';
|
||||
const fromSpan = document.createElement('span');
|
||||
fromSpan.className = 'from';
|
||||
fromSpan.textContent = m.from;
|
||||
fromSpan.textContent = formatArtmapAddr(m.from);
|
||||
const arrowSpan = document.createElement('span');
|
||||
arrowSpan.textContent = '→';
|
||||
const toSpan = document.createElement('span');
|
||||
toSpan.className = 'to';
|
||||
toSpan.textContent = m.to;
|
||||
toSpan.textContent = formatArtmapAddr(m.to);
|
||||
mappingEl.appendChild(fromSpan);
|
||||
mappingEl.appendChild(arrowSpan);
|
||||
mappingEl.appendChild(toSpan);
|
||||
mappingEl.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
const fromBase = m.from.split(':').slice(0, 2).join(':');
|
||||
const target = fromBase === currentPrefix ? m.to : m.from;
|
||||
const targetProto = target.split(':')[0];
|
||||
const targetUniverse = parseInt(target.split(':')[1], 10);
|
||||
if (!isNaN(targetUniverse)) {
|
||||
openFlowHash(targetProto, targetUniverse, nodeName);
|
||||
}
|
||||
const fromMatches = m.from.protocol === flowProtocol && m.from.universe === flowUniverse;
|
||||
const target = fromMatches ? m.to : m.from;
|
||||
openFlowHash(target.protocol, target.universe, nodeName);
|
||||
});
|
||||
mappingsEl.appendChild(mappingEl);
|
||||
});
|
||||
@@ -388,11 +385,10 @@ export function renderFlowPath(pathInfo, nodesByTypeId, flowUniverse, flowProtoc
|
||||
}
|
||||
|
||||
function getRelevantMappings(mappings, protocol, universe) {
|
||||
const prefix = protocol + ':' + universe;
|
||||
return mappings.filter(m => {
|
||||
const fromBase = m.from.split(':').slice(0, 2).join(':');
|
||||
const toBase = m.to.split(':').slice(0, 2).join(':');
|
||||
return fromBase === prefix || toBase === prefix;
|
||||
const fromMatches = m.from.protocol === protocol && m.from.universe === universe;
|
||||
const toMatches = m.to.protocol === protocol && m.to.universe === universe;
|
||||
return fromMatches || toMatches;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -26,11 +26,29 @@ export function formatLinkSpeed(bps) {
|
||||
return mbps.toLocaleString() + ' Mbit/s';
|
||||
}
|
||||
|
||||
export function formatUniverse(u) {
|
||||
const net = (u >> 8) & 0x7f;
|
||||
const subnet = (u >> 4) & 0x0f;
|
||||
const universe = u & 0x0f;
|
||||
return net + ':' + subnet + ':' + universe + ' (' + u + ')';
|
||||
export function formatUniverse(u, protocol) {
|
||||
if (protocol === 'artnet') {
|
||||
const net = (u >> 8) & 0x7f;
|
||||
const subnet = (u >> 4) & 0x0f;
|
||||
const universe = u & 0x0f;
|
||||
return net + ':' + subnet + ':' + universe + ' (' + u + ')';
|
||||
}
|
||||
return String(u);
|
||||
}
|
||||
|
||||
export function formatArtmapAddr(addr) {
|
||||
const uniStr = formatUniverse(addr.universe, addr.protocol);
|
||||
let result = addr.protocol + ' ' + uniStr;
|
||||
if (addr.channel_start && addr.channel_end && !(addr.channel_start === 1 && addr.channel_end === 512)) {
|
||||
if (addr.channel_start === addr.channel_end) {
|
||||
result += ' ch' + addr.channel_start;
|
||||
} else {
|
||||
result += ' ch' + addr.channel_start + '-' + addr.channel_end;
|
||||
}
|
||||
} else if (addr.channel_start && addr.channel_start !== 1) {
|
||||
result += ' ch' + addr.channel_start;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function escapeHtml(str) {
|
||||
|
||||
@@ -248,7 +248,7 @@ export function render(data, config) {
|
||||
|
||||
const inputs = sortedInputs.map(u => {
|
||||
const sources = collapseNames(universeOutputs.get(u) || []);
|
||||
const uniStr = formatUniverse(u);
|
||||
const uniStr = formatUniverse(u, 'artnet');
|
||||
if (sources.length > 0) {
|
||||
return { display: sources[0] + ' [' + uniStr + ']', firstTarget: sources[0], universe: u };
|
||||
}
|
||||
@@ -256,7 +256,7 @@ export function render(data, config) {
|
||||
});
|
||||
const outputs = sortedOutputs.map(u => {
|
||||
const dests = collapseNames(universeInputs.get(u) || []);
|
||||
const uniStr = formatUniverse(u);
|
||||
const uniStr = formatUniverse(u, 'artnet');
|
||||
if (dests.length > 0) {
|
||||
return { display: dests[0] + ' [' + uniStr + ']', firstTarget: dests[0], universe: u };
|
||||
}
|
||||
|
||||
@@ -395,7 +395,7 @@ export function renderArtnetTable() {
|
||||
for (let i = 0; i < maxLen; i++) {
|
||||
rows.push({
|
||||
universe: u,
|
||||
universeStr: formatUniverse(u),
|
||||
universeStr: formatUniverse(u, 'artnet'),
|
||||
tx: txNodes[i]?.name || '',
|
||||
txTitle: txNodes[i]?.title || '',
|
||||
rx: rxNodes[i]?.name || '',
|
||||
|
||||
Reference in New Issue
Block a user