8 A state machine that can be locked. 9 When locked, no transition can be done regardless of the resulting outcome. 10 However, if any outcome would be triggered, the outcome will be stored 11 and the state won't be executed anymore until it is unlocked and the stored outcome is set. 13 path_for_switch =
None 16 super(LockableStateMachine, self).
__init__(*args, **kwargs)
28 Looks for the current state (traversing all state machines down to the real state). 30 @return: The current state (not state machine) 33 while isinstance(container._current_state, smach.StateMachine):
34 container = container._current_state
35 return container._current_state
39 if LockableStateMachine.path_for_switch
is not None and LockableStateMachine.path_for_switch.startswith(self.
_get_path()):
40 path_segments = LockableStateMachine.path_for_switch.replace(self.
_get_path(),
"", 1).split(
"/")
41 wanted_state = path_segments[1]
42 self._set_current_state(wanted_state)
43 if len(path_segments) <= 2:
44 LockableStateMachine.path_for_switch =
None 50 return transition_target
in self._states
54 if outcome
is None or outcome ==
'None':
56 transition_target = self._transitions[state][outcome]
61 return "" if self.
_parent is None else self._parent._get_path() +
"/" + self.
name 69 return self._parent.lock(path)
79 return self._parent.unlock(path)
92 for state
in self._states:
94 if isinstance(state, smach.StateMachine):
95 result = state.is_locked_inside()
97 result = state.is_locked()
108 for state
in self._states:
109 if state.is_locked():
111 elif isinstance(state, smach.StateMachine):
112 return state.get_locked_state()
def __init__(self, args, kwargs)
def get_locked_state(self)
def transition_allowed(self, state, outcome)
def _get_deep_state(self)
def is_locked_inside(self)
def _is_internal_transition(self, transition_target)