Skip to content

fsm

controller.fsm

Module that implements drunc finite state machine.

Functions

get_fsm_architecture()

Return the FSM states and events as a dictionary.

The states will be the keys and the valid events for each state a list of values with their corresponding target state. All in all, this provides the whole architecture of the FSM.

Returns:

Type Description
dict[str, dict[str, str]]

The states and events as a dictionary.

Source code in controller/fsm.py
def get_fsm_architecture() -> dict[str, dict[str, str]]:
    """Return the FSM states and events as a dictionary.

    The states will be the keys and the valid events for each state a list of
    values with their corresponding target state. All in all, this provides the whole
    architecture of the FSM.

    Returns:
        The states and events as a dictionary.
    """
    return {
        state: {event: EVENTS[event] for event in events}
        for state, events in STATES.items()
    }