feat(events): deliver state changes to the configurable operator event center
This commit is contained in:
@@ -8,6 +8,7 @@ import secrets
|
||||
import threading
|
||||
import time
|
||||
|
||||
from .board_event_transitions import ControlTransitions
|
||||
from .rover_diagnostics import RoverDiagnostics
|
||||
from .rover_observation_evidence import ObservationEvidence
|
||||
from .rover_telemetry_policy import DEFAULT_MS, telemetry_stop_ms
|
||||
@@ -25,7 +26,7 @@ class RoverControl:
|
||||
|
||||
def _board(self, node):
|
||||
if node not in self.boards:
|
||||
self.boards[node]={"seen":-1e9,"watch":0,"snapshot":{},"session":None,"relay":None,"diagnostics":RoverDiagnostics(self.clock, self.diagnostic_root / hashlib.sha256(node.encode()).hexdigest()[:24] if self.diagnostic_root is not None else None),"observation":ObservationEvidence(self.clock)}
|
||||
self.boards[node]={"operator_transitions":ControlTransitions(),"seen":-1e9,"watch":0,"snapshot":{},"session":None,"relay":None,"diagnostics":RoverDiagnostics(self.clock, self.diagnostic_root / hashlib.sha256(node.encode()).hexdigest()[:24] if self.diagnostic_root is not None else None),"observation":ObservationEvidence(self.clock)}
|
||||
return self.boards[node]
|
||||
|
||||
def diagnostics(self,node,vehicle):
|
||||
@@ -78,6 +79,7 @@ class RoverControl:
|
||||
if session is None:
|
||||
return
|
||||
b["session"] = None
|
||||
b["operator_transitions"].stop(reason, session, max(0., self.clock() - b["seen"]) * 1000)
|
||||
observed = b["snapshot"] if snapshot is None else snapshot
|
||||
b["diagnostics"].control_stop.record(
|
||||
reason, session, core_instance=self.clock_id,
|
||||
@@ -291,6 +293,8 @@ class RoverControl:
|
||||
s = None
|
||||
command = None
|
||||
if s:
|
||||
if publish and snapshot.get("session_id") == s["id"] and snapshot.get("state") in ("ready", "driving"):
|
||||
b["operator_transitions"].ready(s["id"])
|
||||
command = self._intent(s)
|
||||
command["ttl_ms"] = max(0, min(400, int((s["until"]-self.clock())*1000)))
|
||||
return {"watch": self.clock() < b["watch"] or s is not None or b["diagnostics"].watch_required(), "command": command,
|
||||
|
||||
Reference in New Issue
Block a user