Simulation along the trip's route ("Simulate driving the route" when there is one, POST /api/sim/gnss {"trip": true}), random trips after it
This commit is contained in:
1 parent
07a4d363ec
commit
7fcac61c99
5 files changed
+38
-9
No files matched your search
@@ -176,6 +176,7 @@ export class DashboardControl {
|
||||
this._lastAt = 0;
|
||||
this._offFixes = 0;
|
||||
this._sentKm = undefined; // the new route drawn by the next fix
|
||||
this._simLabel();
|
||||
}));
|
||||
this._trace = []; // [lon, lat] fixes TRACE_STEP_M apart, for /api/road
|
||||
this._road = null; // its last answer
|
||||
@@ -340,7 +341,8 @@ export class DashboardControl {
|
||||
// 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: "{}" }
|
||||
// along the route when there is one (the shared trip's), else from a random place
|
||||
const options = on === true ? { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(this._route ? { trip: true } : {}) }
|
||||
: on === false ? { method: "DELETE" } : {};
|
||||
try {
|
||||
const response = await fetch("/api/sim/gnss", options);
|
||||
@@ -354,7 +356,11 @@ export class DashboardControl {
|
||||
this._simStatus.hidden = false;
|
||||
this._simStatus.textContent = `Simulation: ${e.message}`;
|
||||
}
|
||||
this._simButton.textContent = this._simRunning ? "Stop the simulation" : "Simulate driving from the map center";
|
||||
this._simLabel();
|
||||
}
|
||||
|
||||
_simLabel() {
|
||||
if (this._simButton) this._simButton.textContent = this._simRunning ? "Stop the simulation" : this._route ? "Simulate driving the route" : "Simulate driving from a random place";
|
||||
}
|
||||
|
||||
_save() {
|
||||
|
||||
Reference in new issue
Block a user