feat(cockpit_bridge): publish rov-failsafe-cause text for W1 status line
This commit is contained in:
parent
1b0050dd6f
commit
dbe95150e3
@ -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:
|
||||
# "<cause> | Assessment: <state> | State: <fsm> | Battery: <pct>%"
|
||||
# (a comms-loss cause prefix is present — see
|
||||
# failsafe_monitor._publish_status, DIR-7 cause-text
|
||||
# requirement)
|
||||
# or, when nominal:
|
||||
# "Assessment: <state> | State: <fsm> | Battery: <pct>%"
|
||||
# (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:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user