ao_runtime_supervisor
=====================
Top-level active object driving startup and dispatching periodic and asynchronous events.
Inherited Component
-------------------
- :doc:`Runtime_Manager `
Inherited Requirements
----------------------
- :doc:`REQ-REL-001 `
- :doc:`REQ-REL-004 `
Relationship Diagram
--------------------
.. image:: /_static/sw_unit_uml/ao_runtime_supervisor_46acab8f-6426-46ac-9b10-6f02a2ca442d_uml.svg
:alt: UML class diagram for ao_runtime_supervisor
:class: dblclick-open-image
SW Unit Relations
-----------------
Outgoing Relations
~~~~~~~~~~~~~~~~~~
.. list-table::
:header-rows: 1
* - Relation
- UML Type
- Visibility
- Target Unit
- Description
* - :doc:`SWR-001 `
- composition
- private
- :doc:`evt_dispatcher `
- Runtime supervisor owns event dispatch lifecycle.
* - :doc:`SWR-002 `
- composition
- private
- :doc:`evt_timer_service `
- Runtime supervisor owns timer event service.
* - :doc:`SWR-003 `
- composition
- private
- :doc:`sm_operation_mode `
- Runtime supervisor embeds operation mode state machine.
* - :doc:`SWR-007 `
- dependency
- public
- :doc:`ao_monitoring `
- Runtime supervisor dispatches monitoring events.
* - :doc:`SWR-008 `
- dependency
- public
- :doc:`ao_control `
- Runtime supervisor dispatches control events.
* - :doc:`SWR-009 `
- dependency
- public
- :doc:`ao_safety `
- Runtime supervisor dispatches safety events.
* - :doc:`SWR-010 `
- dependency
- public
- :doc:`ao_diagnostics `
- Runtime supervisor dispatches diagnostics events.
* - :doc:`SWR-011 `
- dependency
- public
- :doc:`ao_modbus_server `
- Runtime supervisor dispatches communication events.
Data Types
----------
.. _dt-dcf0726b-8673-4cf0-a148-e44248d4b8ca:
.. raw:: html
ao_runtime_supervisor_contextstruct
Internal runtime context for ao_runtime_supervisor.
.. rubric:: Struct Members
.. list-table::
:header-rows: 1
* - Name
- Type
- Description
* - lifecycle_state
- :ref:`uint8_t `
- Runtime lifecycle state.
* - ready_gate_mask
- :ref:`uint16_t `
- Startup readiness mask.
* - degraded_active
- :ref:`bool `
- Degraded mode active.
* - watchdog_ok
- :ref:`bool `
- Watchdog health state.
.. _dt-07c7671e-791b-47c7-8ad0-23404e203237:
.. raw:: html
ao_runtime_supervisor_eventstruct
Event payload handled by ao_runtime_supervisor.
.. rubric:: Struct Members
.. list-table::
:header-rows: 1
* - Name
- Type
- Description
* - signal_id
- :ref:`uint16_t `
- Supervisor event signal id.
* - source_unit_id
- :ref:`uint16_t `
- Event source unit identifier.
* - gate_id
- :ref:`uint8_t `
- Readiness gate identifier.
* - fault_present
- :ref:`bool `
- Fault condition input.
.. _dt-c8e3f24a-4682-48e3-ae1a-6d49b30d8e37:
.. raw:: html
ao_runtime_supervisor_resultenum
Result code for ao_runtime_supervisor operations.
.. rubric:: Enum Members
.. list-table::
:header-rows: 1
* - Name
- Value
- Description
* - OK
- 0
- Lifecycle transition applied.
* - INIT_TIMEOUT
- 1
- Initialization timed out.
* - DEGRADED_ENTERED
- 2
- Entered degraded lifecycle.
Attributes
----------
.. list-table::
:header-rows: 1
* - Attribute
- Type
- Visibility
- Description
* - ctx
- :ref:`ao_runtime_supervisor_context `
- private
- Runtime context for ao_runtime_supervisor state timing and error tracking.
Methods
-------
dispatch
~~~~~~~~
- **Return Type:** :ref:`ao_runtime_supervisor_result `
- **Visibility:** public
- **Description:** Process one ao_runtime_supervisor event and update runtime outputs.
.. rubric:: Parameters
.. list-table::
:header-rows: 1
* - Name
- Type
- Direction
- Description
* - event
- :ref:`ao_runtime_supervisor_event `
- in
- Process one ao_runtime_supervisor event and update runtime outputs.
init
~~~~
- **Return Type:** :ref:`ao_runtime_supervisor_result `
- **Visibility:** public
- **Description:** Initialize ao_runtime_supervisor runtime state and dependencies.
Dynamic Behaviour
-----------------
State Machines
~~~~~~~~~~~~~~
ao_runtime_supervisor_state
^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. uml::
@startuml
hide empty description
[*] --> Boot
Boot --> Init_Subsystems : EVT_BOOT
Init_Subsystems : entry / init_timer_service()
Init_Subsystems : entry / init_dispatcher()
Init_Subsystems : entry / init_active_objects()
Init_Subsystems --> Run : EVT_INIT_OK [timer_ready && dispatcher_ready && required_aos_ready]
Init_Subsystems --> Degraded : EVT_INIT_FAIL [init_timeout || required_service_failed]
Run : do / dispatch_periodic_events()
Run : do / dispatch_async_events()
Run --> Degraded : EVT_FATAL_FAULT
Degraded : do / minimal_safe_dispatch()
Degraded --> Run : EVT_RESET [fault_cleared && watchdog_ok && required_services_ready]
Degraded --> Shutdown : EVT_SHUTDOWN_REQ
Shutdown : entry / publish_shutdown_status()
Shutdown : do / stop_active_objects_orderly()
Shutdown --> [*] : EVT_ALL_STOPPED
@enduml
Runtime supervisor lifecycle with explicit readiness gates degraded entry and recovery criteria and controlled shutdown completion conditions.
Sequence Diagrams
~~~~~~~~~~~~~~~~~
SEQ-001_Runtime_Event_Orchestration
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. uml::
@startuml
hide footbox
title Runtime Event Orchestration
participant ao_runtime_supervisor
participant evt_timer_service
participant evt_dispatcher
participant ao_monitoring
participant ao_control
participant ao_safety
participant ao_diagnostics
participant ao_modbus_server
ao_runtime_supervisor -> evt_timer_service : init periodic tick
ao_runtime_supervisor -> evt_dispatcher : init event loop
loop each scheduler tick
evt_timer_service -> ao_runtime_supervisor : tick event
ao_runtime_supervisor -> evt_dispatcher : dispatch cycle
evt_dispatcher -> ao_monitoring : monitor_event
evt_dispatcher -> ao_control : control_event
evt_dispatcher -> ao_safety : safety_event
evt_dispatcher -> ao_diagnostics : diagnostics_event
evt_dispatcher -> ao_modbus_server : comms_event
end
@enduml
Primary runtime interoperability sequence showing scheduler tick propagation through dispatcher fan-out and deterministic active-object processing order across monitoring control safety diagnostics and communication units.
SEQ-004_Modbus_Event_Servicing
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. uml::
@startuml
hide footbox
title Modbus Server Event Servicing
participant ao_runtime_supervisor
participant ao_modbus_server
participant hal_event_adapter
ao_runtime_supervisor -> ao_modbus_server : dispatch comms_event
ao_modbus_server -> hal_event_adapter : request UART I/O
hal_event_adapter --> ao_modbus_server : uart_rx/tx completion
ao_modbus_server -> hal_event_adapter : publish protocol response
@enduml
Runtime-driven communication events are processed by the Modbus server through hardware-adapted UART event exchange.
SEQ-005_Startup_To_Ready
^^^^^^^^^^^^^^^^^^^^^^^^
.. uml::
@startuml
hide footbox
participant ao_runtime_supervisor
participant evt_timer_service
participant evt_dispatcher
participant ao_monitoring
participant ao_control
participant ao_safety
participant ao_diagnostics
participant ao_modbus_server
ao_runtime_supervisor -> evt_timer_service : init()
ao_runtime_supervisor -> evt_dispatcher : init()
ao_runtime_supervisor -> ao_monitoring : init()
ao_runtime_supervisor -> ao_control : init()
ao_runtime_supervisor -> ao_safety : init()
ao_runtime_supervisor -> ao_diagnostics : init()
ao_runtime_supervisor -> ao_modbus_server : init()
group readiness gates
evt_timer_service --> ao_runtime_supervisor : EVT_TIMER_READY
evt_dispatcher --> ao_runtime_supervisor : EVT_DISPATCH_READY
ao_monitoring --> ao_runtime_supervisor : EVT_AO_READY
ao_control --> ao_runtime_supervisor : EVT_AO_READY
ao_safety --> ao_runtime_supervisor : EVT_AO_READY
ao_diagnostics --> ao_runtime_supervisor : EVT_AO_READY
ao_modbus_server --> ao_runtime_supervisor : EVT_AO_READY
end
ao_runtime_supervisor -> evt_dispatcher : EVT_INIT_OK / start Run
@enduml
Startup lifecycle sequence with explicit readiness gates before entering Run state.
SEQ-006_Degraded_Entry_And_Recovery
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. uml::
@startuml
hide footbox
participant ao_runtime_supervisor
participant evt_dispatcher
participant ao_control
participant ao_safety
participant ao_diagnostics
ao_runtime_supervisor -> evt_dispatcher : dispatch cycle
alt degraded entry criteria met
note over ao_runtime_supervisor: init_timeout OR required_service_failed OR fatal_fault
ao_runtime_supervisor -> ao_control : EVT_DEGRADED
ao_runtime_supervisor -> ao_safety : EVT_DEGRADED
ao_runtime_supervisor -> ao_diagnostics : EVT_DEGRADED
ao_runtime_supervisor -> evt_dispatcher : restrict noncritical events
end
ao_runtime_supervisor -> evt_dispatcher : periodic degraded dispatch
alt recovery criteria met
note over ao_runtime_supervisor: fault_cleared AND watchdog_ok AND required_services_ready
ao_runtime_supervisor -> evt_dispatcher : EVT_RESET
ao_runtime_supervisor -> ao_control : EVT_RECOVERY
ao_runtime_supervisor -> ao_safety : EVT_RECOVERY
ao_runtime_supervisor -> ao_diagnostics : EVT_RECOVERY
end
@enduml
Lifecycle sequence for degraded entry triggers and guarded recovery back to Run.
SEQ-007_Controlled_Shutdown
^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. uml::
@startuml
hide footbox
participant ao_runtime_supervisor
participant evt_dispatcher
participant ao_control
participant ao_safety
participant ao_diagnostics
participant ao_modbus_server
ao_runtime_supervisor -> evt_dispatcher : EVT_SHUTDOWN_REQ
ao_runtime_supervisor -> ao_control : stop outputs to safe state
ao_runtime_supervisor -> ao_safety : keep protective policy active
ao_runtime_supervisor -> ao_diagnostics : publish shutdown status
ao_runtime_supervisor -> ao_modbus_server : stop comm servicing
ao_modbus_server --> ao_runtime_supervisor : EVT_STOPPED
ao_diagnostics --> ao_runtime_supervisor : EVT_STOPPED
ao_safety --> ao_runtime_supervisor : EVT_STOPPED
ao_control --> ao_runtime_supervisor : EVT_STOPPED
evt_dispatcher --> ao_runtime_supervisor : EVT_STOPPED
ao_runtime_supervisor -> ao_runtime_supervisor : EVT_ALL_STOPPED / Shutdown complete
@enduml
Controlled shutdown sequence defining stop ordering and completion criteria.