ao_safety ========= Active object evaluating safety events and enforcing protective actions. Inherited Component ------------------- - :doc:`Safety_Manager ` Inherited Requirements ---------------------- - :doc:`REQ-SAF-001 ` - :doc:`REQ-SAF-002 ` - :doc:`REQ-SAF-003 ` - :doc:`REQ-SAF-004 ` - :doc:`REQ-REL-002 ` Relationship Diagram -------------------- .. image:: /_static/sw_unit_uml/ao_safety_572b6978-4204-472b-adc9-dfab6db77544_uml.svg :alt: UML class diagram for ao_safety :class: dblclick-open-image SW Unit Relations ----------------- Outgoing Relations ~~~~~~~~~~~~~~~~~~ .. list-table:: :header-rows: 1 * - Relation - UML Type - Visibility - Target Unit - Description * - :doc:`SWR-005 ` - composition - private - :doc:`sm_protection ` - Safety active object embeds protection state machine. * - :doc:`SWR-014 ` - association - public - :doc:`ao_diagnostics ` - Safety publishes protective-state and fault events to diagnostics. Incoming Relations ~~~~~~~~~~~~~~~~~~ .. list-table:: :header-rows: 1 * - Relation - UML Type - Visibility - Source Unit - Description * - :doc:`SWR-009 ` - dependency - public - :doc:`ao_runtime_supervisor ` - Runtime supervisor dispatches safety events. * - :doc:`SWR-012 ` - association - public - :doc:`ao_control ` - Control and safety coordinate control override behavior. * - :doc:`SWR-022 ` - association - public - :doc:`ao_monitoring ` - Monitoring publishes validated sensor snapshots to safety for protective evaluation. Data Types ---------- .. _dt-3a9ce51f-e052-4a9c-bfca-a8b23c7dbc16: .. raw:: html
ao_safety_contextstruct
Internal runtime context for ao_safety. .. rubric:: Struct Members .. list-table:: :header-rows: 1 * - Name - Type - Description * - protection_state - :ref:`uint8_t ` - Protection state. * - latch_active - :ref:`bool ` - Protection latch state. * - override_active - :ref:`bool ` - Output override active. * - last_transition_tick - :ref:`uint32_t ` - Last protection transition tick. .. _dt-464eb032-db88-464e-88f7-3b897a9e72d5: .. raw:: html
ao_safety_eventstruct
Event payload handled by ao_safety. .. rubric:: Struct Members .. list-table:: :header-rows: 1 * - Name - Type - Description * - signal_id - :ref:`uint16_t ` - Safety event signal id. * - hazard_detected - :ref:`bool ` - Hazard detection input. * - temperature_c - :ref:`int16_t ` - Safety-evaluated temperature. * - clear_request - :ref:`bool ` - Latch clear request. .. _dt-7f1ab59d-66f6-4f1a-bfe6-9efcd95efc0f: .. raw:: html
ao_safety_resultenum
Result code for ao_safety operations. .. rubric:: Enum Members .. list-table:: :header-rows: 1 * - Name - Value - Description * - OK - 0 - Safety evaluation applied. * - PROTECTION_ENTERED - 1 - Entered protection state. * - LATCH_BLOCKED - 2 - Clear denied by latch guard. Attributes ---------- .. list-table:: :header-rows: 1 * - Attribute - Type - Visibility - Description * - ctx - :ref:`ao_safety_context ` - private - Runtime context for ao_safety state timing and error tracking. Methods ------- dispatch ~~~~~~~~ - **Return Type:** :ref:`ao_safety_result ` - **Visibility:** public - **Description:** Process one ao_safety event and update runtime outputs. .. rubric:: Parameters .. list-table:: :header-rows: 1 * - Name - Type - Direction - Description * - event - :ref:`ao_safety_event ` - in - Process one ao_safety event and update runtime outputs. init ~~~~ - **Return Type:** :ref:`ao_safety_result ` - **Visibility:** public - **Description:** Initialize ao_safety runtime state and dependencies. Dynamic Behaviour ----------------- Activity Diagrams ~~~~~~~~~~~~~~~~~ ao_safety_activity ^^^^^^^^^^^^^^^^^^ .. uml:: @startuml start :Receive IF_SensorSnapshot and IF_FanCommand context; if (temp > 85C?) then (yes) :Set protective request; elseif (voltage < 18V?) then (yes) :Set protective request; elseif (voltage > 30V?) then (yes) :Set protective request; elseif (sensor invalid?) then (yes) :Set protective request; else (no) :Evaluate clear condition; endif :Dispatch sm_protection event; :Publish IF_OperatingStatus and IF_FaultEvent; stop @enduml This activity diagram details ao_safety hazard evaluation across temperature voltage and signal validity conditions and documents the decision path that emits protection events and status updates consumed by diagnostics and indication services. Timing Diagrams ~~~~~~~~~~~~~~~ ao_safety_timing ^^^^^^^^^^^^^^^^ .. uml:: @startuml robust "ao_safety" as SAFE scale max 1200 width concise "hazard event" as H @0 H is asserted SAFE is evaluate @300 SAFE is protective_entry @800 SAFE is outputs_disabled @1000 SAFE is status_published @enduml This timing diagram captures protective entry latency from hazard assertion through evaluation and output shutdown to final status publication supporting verification of one second protection response requirements. 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-002_Protection_And_Fault_Propagation ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. uml:: @startuml hide footbox title Control-Safety-Diagnostics Fault Propagation participant ao_control participant ao_safety participant ao_diagnostics ao_control -> ao_safety : IF_FanCommand(command_request) ao_safety --> ao_control : IF_FanCommand(override_feedback) ao_control -> ao_diagnostics : IF_OperatingStatus(control_status) alt protection or fault detected ao_control -> ao_diagnostics : IF_FaultEvent(control_fault) ao_safety -> ao_diagnostics : IF_OperatingStatus(protection_state) end @enduml Control and safety coordinate fan command decisions and publish operating/fault status into diagnostics for downstream handling. 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.