Nodes describe themselves: an SDO client (Can::Sdo) reads each esphome-canopen node's TPDOs and entities (type, name, unit, range) on its first heartbeat, cached by the TPDO layout hash, decoded with no hand-written signals — can.json keeps aliases (with unit conversion) and foreign devices; design doc (NPS planning, cockpit instruments, Unigrid band) with color tokens, the dashboard in cockpit colors; starting the simulation turns the GNSS follow on, the GNSS position an arrow by its course
CI / check (push) Successful in 23s
CI / deploy (push) Successful in 17s

This commit is contained in:
randy committed 2026-11-30 19:51:03 +01:00
1 parent ce290f2162
commit e92f01db12
12 files changed
+713 -76

No files matched your search

+4 -8
View File
@@ -1,5 +1,5 @@
import { isLoggedIn } from "/js/auth.js";
import { onRouteChanged, requestReroute } from "/js/panels.js";
import { onRouteChanged, requestReroute, requestGnssFollow } from "/js/panels.js";
// The car's dashboard over the map, off the CAN signals (GET /api/can,
// names from data/can.json): one inclinometer — compass ring around a rear
@@ -251,17 +251,17 @@ export class DashboardControl {
}
// GNSS simulation on the server (POST/DELETE /api/sim/gnss): random
// driving from a random place in the offline countries, the map jumping
// there with the first fix; on = true / false, null = just read the state.
// driving from a random place in the offline countries, the GNSS control
// turned on to follow it; on = true / false, null = just read the state.
async _simulate(on) {
const options = on === true ? { method: "POST", headers: { "Content-Type": "application/json" }, body: "{}" }
: on === false ? { method: "DELETE" } : {};
this._jumpToFix = on === true;
try {
const response = await fetch("/api/sim/gnss", options);
const state = await response.json();
if (!response.ok) throw new Error(state.error || `HTTP ${response.status}`);
this._simRunning = state.running;
if (on === true && state.running) requestGnssFollow(); // the map follows the simulated position
this._simStatus.hidden = !state.error;
this._simStatus.textContent = state.error ? `Simulation stopped: ${state.error}` : "";
} catch (e) {
@@ -305,10 +305,6 @@ export class DashboardControl {
// Date has 1 s resolution: +1 so a fresh value isn't "stale"
return [key, s && now - s.at < STALE_S + 1 ? s.value : null];
}));
if (this._jumpToFix && this._simRunning && this._values.lat != null) {
this._jumpToFix = false;
this._map.jumpTo({ center: [this._values.lon, this._values.lat], zoom: Math.max(this._map.getZoom(), 15) });
}
this._updateCourse(this._values);
this._navigate();
this._status.textContent = this._simRunning ? "Simulated GNSS" : data.available ? "" : "CAN is off on this server";