- #6 Config tab by serial: the empty legacy edit form stays hidden (settings are read-only until phase 5); the settings box shows from the start, 'Not read yet', and a different unit's settings are never left on screen. - #10 A start/stop that went out but was not confirmed is no longer called 'failed'. The route now adds 'sent' (acknowledged / unknown) and 'audit_id' to a ChangeUnconfirmed -- same status, same message -- and the page says 'Start monitoring not confirmed: <what happened, audit record>'. - #12 Device tab by serial: the empty legacy Compliance/Project tables are hidden behind a pointer to the Config tab; a Micromate's Firmware card reads 'Thor line (version not read)' (its version string is in 0x01, undecoded). - #16 A 504 with nothing sent adds: the connection opened, so the modem is reachable -- another program (THOR or Blastware) may be holding the line, or the unit is busy. Measured 2026-10-29: THOR polling leaves SFM a 0-byte 504. New logic lives in sfm/static/device_routing.js (firmwareLabel, deviceErrorText, changeErrorText, serialPanes) under Node tests; the page glue in sfm_webapp.js only applies them. Checked in jsdom against the real page (served at a fake origin, /static from disk): all four, legacy mode unchanged, no script errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
This commit is contained in:
1 parent
2b886c4f39
commit
8123d75d72
7 files changed
+163
-22
No files matched your search
@@ -154,4 +154,42 @@ function downloadSummary(body) {
|
||||
if (body.inserted === false) return `already stored — ${body.stored_filename}`;
|
||||
return `stored ${body.stored_filename}, ${body.filesize} bytes, check: ${(body.detail || {}).check}`;
|
||||
}
|
||||
|
||||
// A Micromate's version string lives in 0x01, undecoded; which firmware line it
|
||||
// runs comes free with every reply (bench finding #12).
|
||||
const FIRMWARE_LINES = { thor: 'Thor line (version not read)', blastware: 'Blastware line (version not read)' };
|
||||
function firmwareLabel(info) {
|
||||
const i = info || {};
|
||||
return i.firmware_version || i.firmware || FIRMWARE_LINES[(i.detail || {}).firmware_line] || '—';
|
||||
}
|
||||
|
||||
// A failed device request's message. A 504 is a unit that took the connection
|
||||
// but never answered: while THOR polls a Micromate, SFM's connection is accepted
|
||||
// and gets 0 bytes (measured 2026-10-29, bench finding #16). The hint is left
|
||||
// off once a change was sent -- its own message says what happened.
|
||||
const NO_REPLY_HINT = 'the connection opened, so the modem is reachable — another program (THOR or '
|
||||
+ "Blastware) may be holding this unit's line, or the unit is busy (e.g. its sensor check)";
|
||||
function errorDetail(body, statusText) {
|
||||
const b = body || {}, d = b.detail;
|
||||
return b.outcome ? changeSummary(b) : typeof d === 'string' ? d : d ? (d.message || JSON.stringify(d)) : statusText;
|
||||
}
|
||||
function deviceErrorText(status, body, unit, statusText) {
|
||||
const text = errorDetail(body, statusText);
|
||||
return status === 504 && !(body || {}).sent && unit && unit.host ? `${text} — ${NO_REPLY_HINT}` : text;
|
||||
}
|
||||
|
||||
// A start/stop that went out (or may have) is not "failed": its body carries
|
||||
// `sent` (ChangeUnconfirmed, bench finding #10), and its message says what the
|
||||
// unit did and names the audit record.
|
||||
function changeErrorText(verb, status, body, unit, statusText) {
|
||||
if ((body || {}).sent) return `${verb} monitoring not confirmed: ${errorDetail(body, statusText)}`;
|
||||
return `${verb} monitoring failed: ${deviceErrorText(status, body, unit, statusText)}`;
|
||||
}
|
||||
|
||||
// By serial, settings are read-only until phase 5: no empty legacy edit form or
|
||||
// legacy tables, and the settings box shows from the start (#6, #12).
|
||||
function serialPanes(bySerial, settingsRead) {
|
||||
return { configForm: !bySerial, settingsBox: bySerial, settingsPlaceholder: bySerial && !settingsRead,
|
||||
legacyDeviceTables: !bySerial };
|
||||
}
|
||||
/* </device-routing> */
|
||||
@@ -73,9 +73,7 @@ async function deviceFetch(action, params = {}, opts = {}) {
|
||||
const r = await deviceRequest(action, params, opts);
|
||||
const body = await r.json().catch(() => ({}));
|
||||
if (!r.ok) {
|
||||
const d = body.detail;
|
||||
const err = new Error(body.outcome ? changeSummary(body)
|
||||
: typeof d === 'string' ? d : d ? (d.message || JSON.stringify(d)) : r.statusText);
|
||||
const err = new Error(deviceErrorText(r.status, body, currentUnit(), r.statusText));
|
||||
err.status = r.status; err.body = body;
|
||||
throw err;
|
||||
}
|
||||
@@ -102,6 +100,22 @@ function applyControls() {
|
||||
chr.title = s4;
|
||||
document.getElementById('ch-series-note').textContent = s4;
|
||||
setMonitorButtons();
|
||||
applyConfigPanes();
|
||||
}
|
||||
|
||||
// The Config tab by serial (#6): settings are read-only until phase 5, so the
|
||||
// empty legacy edit form stays hidden and the settings box shows from the start.
|
||||
// A different unit's settings are never left on screen.
|
||||
let settingsShownFor = null;
|
||||
function applyConfigPanes() {
|
||||
const serial = normSerial(currentUnit().serial);
|
||||
const p = serialPanes(Boolean(serial), Boolean(serial) && settingsShownFor === serial);
|
||||
document.getElementById('cfg-form').style.display = p.configForm ? '' : 'none';
|
||||
document.getElementById('cfg-settings').style.display = p.settingsBox ? 'block' : 'none';
|
||||
if (p.settingsPlaceholder) {
|
||||
settingsShownFor = null;
|
||||
renderTextTable('cfg-settings-table', [['Settings', 'Not read yet — press Read from Device']]);
|
||||
}
|
||||
}
|
||||
|
||||
async function hangUp() {
|
||||
@@ -430,8 +444,7 @@ async function changeMonitoring(action) {
|
||||
if (body.outcome) {
|
||||
setStatus(changeSummary(body), r.ok ? 'ok' : 'error');
|
||||
} else {
|
||||
const d = body.detail;
|
||||
setStatus(`${verb} monitoring failed: ${typeof d === 'string' ? d : d ? JSON.stringify(d) : r.statusText}`, 'error');
|
||||
setStatus(changeErrorText(verb, r.status, body, currentUnit(), r.statusText), 'error');
|
||||
}
|
||||
} catch (e) {
|
||||
// No reply is not "nothing sent": the request may have reached the unit.
|
||||
@@ -454,7 +467,7 @@ function populateDeviceTab() {
|
||||
const cardData = [
|
||||
{ label:'Serial Number', value: unitInfo.serial || '—' },
|
||||
{ label:'Series', value: confirmedSeries(currentUnit()) ?? '—' },
|
||||
{ label:'Firmware', value: unitInfo.firmware_version || unitInfo.firmware || '—' },
|
||||
{ label:'Firmware', value: firmwareLabel(unitInfo) },
|
||||
{ label:'DSP', value: unitInfo.dsp_version || (unitInfo.detail || {}).dsp_version || '—' },
|
||||
{ label:'Model', value: unitInfo.model || '—' },
|
||||
{ label:'Manufacturer', value: unitInfo.manufacturer || (unitInfo.detail || {}).manufacturer || '—' },
|
||||
@@ -471,6 +484,11 @@ function populateDeviceTab() {
|
||||
cards.appendChild(c);
|
||||
}
|
||||
|
||||
// The legacy settings tables are empty by serial (#12); the Config tab reads them.
|
||||
const legacy = serialPanes(serialMode(), false).legacyDeviceTables;
|
||||
document.getElementById('dev-legacy-tables').hidden = !legacy;
|
||||
document.getElementById('dev-serial-note').hidden = legacy;
|
||||
|
||||
// Compliance table
|
||||
const cc = unitInfo.compliance_config || {};
|
||||
const RECORDING_MODE_LABELS = {0: 'Single Shot', 1: 'Continuous', 3: 'Histogram', 4: 'Histogram + Continuous'};
|
||||
@@ -713,6 +731,7 @@ async function readSettingsBySerial() {
|
||||
try {
|
||||
const st = await deviceFetch('settings');
|
||||
renderTextTable('cfg-settings-table', settingsRows(st));
|
||||
settingsShownFor = normSerial(st.serial);
|
||||
document.getElementById('cfg-settings').style.display = 'block';
|
||||
document.getElementById('cfg-form').style.display = 'none';
|
||||
setCfgStatus(`Settings read from ${st.serial}.`, 'ok');
|
||||
|
||||
Reference in new issue
Block a user