Diagnostics Messages

System health and safety monitoring types.

from horus import Heartbeat, DiagnosticStatus, EmergencyStop, SafetyStatus

Heartbeat

Node alive signal — publish periodically to indicate health.

hb = horus.Heartbeat(node_name="motor_ctrl", node_id=1, timestamp_ns=horus.timestamp_ns())
FieldTypeDefaultDescription
node_namestr""Name of the sending node
node_idint0Numeric node identifier
timestamp_nsint0Timestamp in nanoseconds

DiagnosticStatus

Diagnostic report from a subsystem.

status = horus.DiagnosticStatus(component="battery", level=0, message="OK")
# level: 0=OK, 1=WARN, 2=ERROR, 3=FATAL
FieldTypeDefaultDescription
levelint00=OK, 1=WARN, 2=ERROR, 3=FATAL
codeint0Diagnostic error code
messagestr""Human-readable status message
componentstr""Component name
timestamp_nsint0Timestamp in nanoseconds

EmergencyStop

E-stop signal — safety-critical.

estop = horus.EmergencyStop(engaged=True, reason="obstacle detected", timestamp_ns=horus.timestamp_ns())
FieldTypeDefaultDescription
engagedboolTrueWhether the E-stop is engaged
reasonstr""Reason for engagement
timestamp_nsint0Timestamp in nanoseconds

SafetyStatus

Overall safety monitoring state. Created with no parameters — read state via getters.

safety = horus.SafetyStatus()

# Read-only getters
safety.enabled       # bool
safety.estop_engaged # bool
safety.watchdog_ok   # bool
safety.limits_ok     # bool
safety.comms_ok      # bool
safety.mode          # int
safety.fault_code    # int
safety.timestamp_ns  # int
GetterTypeDescription
enabledboolSafety system enabled
estop_engagedboolEmergency stop is engaged
watchdog_okboolWatchdog is healthy
limits_okboolAll limits within bounds
comms_okboolCommunications healthy
modeintCurrent safety mode
fault_codeintActive fault code
timestamp_nsintTimestamp in nanoseconds

NodeHeartbeat

Per-node health heartbeat with state and health level.

nhb = horus.NodeHeartbeat(state=1, health=0)
# state and health are u8 integer codes
FieldTypeDefaultDescription
stateint0Node state (u8)
healthint0Node health level (u8)

ResourceUsage

System resource monitoring.

usage = horus.ResourceUsage(
    cpu_percent=45.0,
    memory_bytes=268435456,
    memory_percent=12.5,
    timestamp_ns=horus.timestamp_ns(),
)
FieldTypeDefaultDescription
cpu_percentfloat0.0CPU usage percentage
memory_bytesint0Memory usage in bytes
memory_percentfloat0.0Memory usage percentage
timestamp_nsint0Timestamp in nanoseconds

DiagnosticReport

Aggregated diagnostic report. Values are added via helper methods, not constructor args.

report = horus.DiagnosticReport(component="motors", level=0)
report.add_value("temperature", 45.2)
report.add_string("firmware", "v2.1.0")
FieldTypeDefaultDescription
componentstr""Component being reported on
levelint0Overall diagnostic level
MethodDescription
add_value(key, value)Add a numeric diagnostic value
add_string(key, value)Add a string diagnostic value

DiagnosticValue

Single key-value diagnostic entry.

dv = horus.DiagnosticValue(key="temperature", value="45.2")
FieldTypeDefaultDescription
keystr""Diagnostic key
valuestr""Diagnostic value

See Also