State Machine¶
The VYRA Base State Machine follows industrial standards (IEC 61508, IEC 61131-3, ISO 13849) and consists of three hierarchical layers:
Lifecycle States (Existence / startup / shutdown)
Operational States (Activity states)
Health States (Functional and error status)
State Machine Documentation
Overview¶
The three layers are not parallel, but nested within each other:
Lifecycle controls Operational
Operational is regulated by Health
Health can override Lifecycle (escalation)
Layer Influence Rules¶
Each layer may only influence in one direction:
Source |
May Influence |
May NOT Influence |
|---|---|---|
Lifecycle |
Operational + Health |
— |
Operational |
— |
Lifecycle, Health |
Health |
Lifecycle (hard) + Operational (soft) |
— |
Quick Example¶
from vyra_base.state import UnifiedStateMachine
# Initialize state machine
state_machine = UnifiedStateMachine(
module_name="my_module",
enable_lifecycle=True,
enable_health=True
)
# Handle lifecycle events
state_machine.handle_event(EventType.START)
state_machine.handle_event(EventType.INIT_SUCCESS)
# Handle operational events
state_machine.handle_event(EventType.SET_READY)
state_machine.handle_event(EventType.TASK_START)
# Check current states
print(state_machine.get_lifecycle_state()) # Active
print(state_machine.get_operational_state()) # Running
print(state_machine.get_health_state()) # Healthy
See Also¶
3-Layer State Machine Architecture - Complete architecture and layer interactions
State Definitions - All state definitions
State Transitions - Allowed state transitions
Event System - Event system documentation
API Reference - Complete API reference
Quick Reference Guide - Quick reference guide