diff --git a/src/rov_mission/rov_mission/cockpit_bridge.py b/src/rov_mission/rov_mission/cockpit_bridge.py index c65ca34..9916728 100644 --- a/src/rov_mission/rov_mission/cockpit_bridge.py +++ b/src/rov_mission/rov_mission/cockpit_bridge.py @@ -64,6 +64,9 @@ class CockpitBridge(Node): # -1 initial value indicates no data received yet 'rov-failsafe': -1, + # Cause text for W1 status line, e.g. "Heartbeat Lost" + 'rov-failsafe-cause': '', + # Depth in metres below surface (positive = deeper) 'rov-depth': 0.0, @@ -225,6 +228,41 @@ class CockpitBridge(Node): with self._lock: self._values['rov-failsafe'] = int(msg.assessment_state) + # ------------------------------------------------------------ + # rov-failsafe-cause — cause text for the W1 widget status line + # (e.g. "Heartbeat Lost", "Vehicle Disconnected"). + # + # SHORTCUT: FailsafeStatus.msg has no dedicated cause field, so + # this parses it out of msg.message, which failsafe_monitor + # builds as either: + # " | Assessment: | State: | Battery: %" + # (a comms-loss cause prefix is present — see + # failsafe_monitor._publish_status, DIR-7 cause-text + # requirement) + # or, when nominal: + # "Assessment: | State: | Battery: %" + # (no distinct cause — the leading segment IS the Assessment + # field, not a cause) + # + # Take the substring before the first "|", stripped of + # whitespace. If that leading segment itself starts with + # "Assessment:" there is no real cause prefix (nominal case) — + # publish an empty string instead of "Assessment: GREEN" etc. + # + # This is a string-parsing shortcut, not the proper fix. The + # correct implementation is a dedicated cause field on + # FailsafeStatus.msg (e.g. `string cause`), set directly by + # failsafe_monitor instead of being smuggled inside the + # human-readable message string — do this the next time + # FailsafeStatus.msg is revised. Reference: W1 cause-text + # display. + # ------------------------------------------------------------ + leading_segment = msg.message.split('|', 1)[0].strip() + if leading_segment.startswith('Assessment:'): + self._values['rov-failsafe-cause'] = '' + else: + self._values['rov-failsafe-cause'] = leading_segment + def _depth_cb(self, msg: Float64): """Update depth in metres from Float64 message.""" with self._lock: