CAN: a node that misses 3 heartbeats is flagged silent (one journal line when it stops and when it's back, red in /can.html); /can.html tables as wide as their content, numeric headers aligned with their values
This commit is contained in:
1 parent
5c023619ec
commit
500acf9fd5
3 files changed
+51
-7
No files matched your search
+7
-5
@@ -12,12 +12,12 @@
|
||||
header { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; margin-bottom: 12px; }
|
||||
h1 { font-size: 1.2rem; margin: 0; }
|
||||
h2 { font-size: 0.8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 20px 0 6px; }
|
||||
#status { color: var(--muted); font-size: 0.85rem; }
|
||||
#status { color: var(--muted); font-size: 0.85rem; } #status.bad { color: var(--bad); }
|
||||
.scroll { overflow-x: auto; }
|
||||
table { border-collapse: collapse; font-size: 0.85rem; min-width: 100%; }
|
||||
table { border-collapse: collapse; font-size: 0.85rem; }
|
||||
th, td { padding: 6px 12px 6px 0; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
|
||||
th { color: var(--muted); font-weight: 500; }
|
||||
td.num { font-variant-numeric: tabular-nums; text-align: right; }
|
||||
.num { font-variant-numeric: tabular-nums; text-align: right; }
|
||||
code { font: 0.85rem ui-monospace, SFMono-Regular, Menlo, monospace; }
|
||||
.ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); }
|
||||
.stale td { opacity: 0.5; }
|
||||
@@ -74,7 +74,7 @@
|
||||
for (const f of data.frames) if (f.node != null) (roles[f.node] ||= new Set()).add(f.role);
|
||||
fill("nodes", Object.entries(data.nodes).sort((a, b) => a[0] - b[0]).map(([id, n]) => {
|
||||
const emcy = n.emcy ? `<code>${hex(n.emcy.code, 4)}</code> reg <code>${hex(n.emcy.register, 2)}</code> ${n.emcy.code === 0 ? "(reset)" : ""} · ${age(n.emcy.at)}` : "—";
|
||||
return `<tr class="${stale(n.seen_at) ? "stale" : ""}"><td>${nodeName(id)}</td><td class="${STATE_CLASS[n.state] || ""}">${esc(n.state || "no heartbeat")}</td><td>${age(n.seen_at)}</td><td class="${n.emcy?.code ? "bad" : ""}">${emcy}</td><td>${[...(roles[id] || [])].sort().map(esc).join(", ")}</td></tr>`;
|
||||
return `<tr class="${stale(n.seen_at) && !n.silent ? "stale" : ""}"><td>${nodeName(id)}</td><td class="${n.silent ? "bad" : STATE_CLASS[n.state] || ""}">${n.silent ? "silent (heartbeat stopped)" : esc(n.state || "no heartbeat")}</td><td>${age(n.seen_at)}</td><td class="${n.emcy?.code ? "bad" : ""}">${emcy}</td><td>${[...(roles[id] || [])].sort().map(esc).join(", ")}</td></tr>`;
|
||||
}), "No CANopen node heard yet.", 5);
|
||||
|
||||
fill("signals", Object.entries(data.signals).sort().map(([name, s]) =>
|
||||
@@ -100,7 +100,9 @@
|
||||
const date = Date.parse(response.headers.get("Date"));
|
||||
if (date) clockOffset = Math.abs(date / 1000 - Date.now() / 1000) > 2 ? date / 1000 - Date.now() / 1000 : 0;
|
||||
render(last = await response.json());
|
||||
status.textContent = `updated ${new Date().toLocaleTimeString()}`;
|
||||
const silent = Object.keys(last.nodes).filter((id) => last.nodes[id].silent);
|
||||
status.className = silent.length ? "bad" : "";
|
||||
status.textContent = (silent.length ? `⚠ node ${silent.join(", ")} silent · ` : "") + `updated ${new Date().toLocaleTimeString()}`;
|
||||
} catch (e) {
|
||||
status.textContent = `can't reach the server: ${e.message}`;
|
||||
} finally {
|
||||
|
||||
Reference in new issue
Block a user