35 """A StateUndefinedException is thrown by 36 an SMC-generated state machine whenever a transition is taken 37 and there is no state currently set. This occurs when a 38 transition is issued from within a transition action.""" 43 """A TransitionUndefinedException is thrown by 44 an SMC-generated state machine whenever a transition is taken 46 - Is not explicitly defined in the current state. 47 - Is not explicitly defined in the current FSM's default state. 48 - There is no Default transition in the current state.""" 53 """base State class""" 60 """Returns the state's printable name.""" 64 """Returns the state's unique identifier.""" 69 """The user can derive FSM contexts from this class and interface 70 to them with the methods of this class. 72 The finite state machine needs to be initialized to the starting 73 state of the FSM. This must be done manually in the constructor 86 """Returns the debug flag's current setting.""" 90 """Sets the debug flag. 91 A true value means debugging is on and false means off.""" 95 """Returns the stream to which debug output is written.""" 99 """Sets the debug output stream.""" 103 """Returns the current state.""" 105 raise StateUndefinedException
109 """Is this state machine already inside a transition? 110 True if state is undefined.""" 117 """Returns the current transition's name. 118 Used only for debugging purposes.""" 122 """Clears the current state.""" 127 """Returns the state which a transition left. 132 """Sets the current state to the specified state.""" 133 if not isinstance(state, State):
134 raise ValueError(
"state should be a statemap.State")
137 self._debug_stream.write(
"NEW STATE : %s\n" % self._state.getName())
140 """Returns True if the state stack is empty and False otherwise.""" 144 """Returns the state stack's depth.""" 148 """Push the current state on top of the state stack 149 and make the specified state the current state.""" 150 if not isinstance(state, State):
151 raise ValueError(
"state should be a statemap.State")
152 if self.
_state is not None:
153 self._state_stack.append(self.
_state)
156 self._debug_stream.write(
"PUSH TO STATE : %s\n" % self._state.getName())
159 """Make the state on top of the state stack the current state.""" 162 self._debug_stream.write(
"POPPING ON EMPTY STATE STACK.\n")
163 raise ValueError(
"empty state stack")
165 self.
_state = self._state_stack.pop()
167 self._debug_stream.write(
"POP TO STATE : %s\n" % self._state.getName())
170 """Remove all states from the state stack."""
def emptyStateStack(self)
def getPreviousState(self)
def isStateStackEmpty(self)
def __init__(self, name, id)
def pushState(self, state)
def getStateStackDepth(self)
def setDebugStream(self, stream)
def setState(self, state)
def __init__(self, state)
def setDebugFlag(self, flag)