Coverage for ion/agents/instrumentagents/instrument_fsm : 79.55%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
|
#!/usr/bin/env python
@file ion/agents/instrumentagents/instrument_agent.py @author Edward Hunter @brief Simple state mahcine for driver and agent classes. """
""" Simple state mahcine for driver and agent classes. """
""" Initialize states, events, handlers. """
""" Return current state. """
""" Start the state machine. Initializes current state and fires the EVENT_ENTER event. """
#if state not in self.states: # return False
return False
""" Handle an event. Call the current state handler passing the event and paramters. @param event A string indicating the event that has occurred. @param params Optional parameters to be sent with the event to the handler. @retval Success/fail if the event was handled by the current state. """
(success,next_state,result) = self.state_handlers[self.current_state](event,params)
#if next_state in self.states: if self.states.has(next_state): self._on_transition(next_state,params)
return (success,result)
""" Handle an event. Call the current state handler passing the event and paramters. @param event A string indicating the event that has occurred. @param params Optional parameters to be sent with the event to the handler. @retval Success/fail if the event was handled by the current state. """
#if next_state in self.states:
""" Call the sequence of events to cause a state transition. Called from on_event if the handler causes a transition. @param next_state The state to transition to. @param params Opional parameters passed from on_event """
self.state_handlers[self.current_state](self.exit_event,params) self.previous_state = self.current_state self.current_state = next_state self.state_handlers[self.current_state](self.enter_event,params)
def _on_transition_async(self,next_state,params): """ Call the sequence of events to cause a state transition. Called from on_event if the handler causes a transition. @param next_state The state to transition to. @param params Opional parameters passed from on_event """
|