|
Python YASMIN (Yet Another State MachINe)
|


Public Member Functions | |
| None | __init__ (self, List[State] states, str default_outcome, Dict[str, Dict[State, str]] outcome_map={}) |
| str | execute (self, Blackboard blackboard) |
| None | execute_and_save_state (self, State state, int state_id, Blackboard blackboard) |
| None | cancel_state (self) |
| str | __str__ (self) |
Public Member Functions inherited from yasmin.state.State | |
| None | __init__ (self, Set[str] outcomes) |
| str | __call__ (self, Blackboard blackboard=None) |
| str | __str__ (self) |
| bool | is_canceled (self) |
| bool | is_running (self) |
| Set[str] | get_outcomes (self) |
Protected Attributes | |
| List[State] | _states = states |
| str | _default_outcome = default_outcome |
| dict | _outcome_map = {} |
| dict | _intermediate_outcomes = {} |
| _mutex = Lock() | |
Protected Attributes inherited from yasmin.state.State | |
| Set | _outcomes = set() |
| A set of valid outcomes for this state. | |
| bool | _running = False |
| A flag indicating whether the state is currently running. | |
| bool | _canceled = False |
| A flag indicating whether the state has been canceled. | |
Child class of a State that runs multiple other states in parallel threads.
Attributes:
_states (List[State]): A list of states that will be run in parallel by this state.
_outcome_map (Dict[str, Dict[int, str]]): A dictionary correlating the outcomes of the concurrent states to
outcomes of this state.
_default_outcome (str): A default outcome in case none of the correlations in _outcome_map are satisfied.
_intermediate_outcomes (Dict[str, Optional[str]]): A temporary storage of the parallel states's outcomes.
_mutex (Lock): A mutex to ensure thread safety of _intermediate_outcomes.
| None yasmin.concurrence.Concurrence.__init__ | ( | self, | |
| List[State] | states, | ||
| str | default_outcome, | ||
| Dict[str, Dict[State, str]] | outcome_map = {} ) |
Initializes the Concurrence instance. :param default_outcome: A default outcome in case none of the correlations in outcome_map are satisfied. :param outcome_map: A dictionary correlating the outcomes of the concurrent states to outcomes of this state. :param states: A list of states that will be run in parallel by this state. :raises ValueError: If either the provided outcomes set or states set are empty. :raises ValueError: If the same instance of a state is listed to run concurrently with itself. :raises KeyError: If an intermediate outcome is not registered with the correlated state.
| str yasmin.concurrence.Concurrence.__str__ | ( | self | ) |
Returns a string representation of the concurrence state, listing all states.
Returns:
str: A string representation of the state machine.
| None yasmin.concurrence.Concurrence.cancel_state | ( | self | ) |
Cancels the execution of all states.
Reimplemented from yasmin.state.State.
| str yasmin.concurrence.Concurrence.execute | ( | self, | |
| Blackboard | blackboard ) |
Executes the parallel behavior. :param blackboard: An instance of Blackboard that provides the context for execution. :return: The outcome of the execution as a string.
Reimplemented from yasmin.state.State.
| None yasmin.concurrence.Concurrence.execute_and_save_state | ( | self, | |
| State | state, | ||
| int | state_id, | ||
| Blackboard | blackboard ) |
Executes a state and saves its outcome to the intermediate map. :param state: A state to execute. :param state_id: The internal state ID associated with the state to execute. :param blackboard: An instance of Blackboard that provides the context for execution. :return: None
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |