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())
| Field | Type | Default | Description |
|---|---|---|---|
node_name | str | "" | Name of the sending node |
node_id | int | 0 | Numeric node identifier |
timestamp_ns | int | 0 | Timestamp 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
| Field | Type | Default | Description |
|---|---|---|---|
level | int | 0 | 0=OK, 1=WARN, 2=ERROR, 3=FATAL |
code | int | 0 | Diagnostic error code |
message | str | "" | Human-readable status message |
component | str | "" | Component name |
timestamp_ns | int | 0 | Timestamp in nanoseconds |
EmergencyStop
E-stop signal — safety-critical.
estop = horus.EmergencyStop(engaged=True, reason="obstacle detected", timestamp_ns=horus.timestamp_ns())
| Field | Type | Default | Description |
|---|---|---|---|
engaged | bool | True | Whether the E-stop is engaged |
reason | str | "" | Reason for engagement |
timestamp_ns | int | 0 | Timestamp 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
| Getter | Type | Description |
|---|---|---|
enabled | bool | Safety system enabled |
estop_engaged | bool | Emergency stop is engaged |
watchdog_ok | bool | Watchdog is healthy |
limits_ok | bool | All limits within bounds |
comms_ok | bool | Communications healthy |
mode | int | Current safety mode |
fault_code | int | Active fault code |
timestamp_ns | int | Timestamp 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
| Field | Type | Default | Description |
|---|---|---|---|
state | int | 0 | Node state (u8) |
health | int | 0 | Node 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(),
)
| Field | Type | Default | Description |
|---|---|---|---|
cpu_percent | float | 0.0 | CPU usage percentage |
memory_bytes | int | 0 | Memory usage in bytes |
memory_percent | float | 0.0 | Memory usage percentage |
timestamp_ns | int | 0 | Timestamp 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")
| Field | Type | Default | Description |
|---|---|---|---|
component | str | "" | Component being reported on |
level | int | 0 | Overall diagnostic level |
| Method | Description |
|---|---|
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")
| Field | Type | Default | Description |
|---|---|---|---|
key | str | "" | Diagnostic key |
value | str | "" | Diagnostic value |
See Also
- Emergency Stop Recipe — Complete E-stop pattern
- Safety Monitor — Graduated degradation
- Rust Diagnostics Messages — Rust equivalent