19 sys.path.insert(1,
"../")
23 from StateMachine
import *
30 state = [RTC.INACTIVE_STATE, RTC.ACTIVE_STATE, RTC.ERROR_STATE]
35 self._sm.setNOP(self.nullAction)
37 self._sm.setEntryAction(RTC.ACTIVE_STATE, self.on_activated)
38 self._sm.setEntryAction(RTC.ERROR_STATE,self.on_aborting)
39 self._sm.setPreDoAction(RTC.ACTIVE_STATE, self.on_reset)
40 self._sm.setDoAction(RTC.ACTIVE_STATE, self.on_execute)
41 self._sm.setPostDoAction(RTC.ACTIVE_STATE, self.on_state_update)
42 self._sm.setExitAction(RTC.ACTIVE_STATE, self.on_deactivated)
43 self._sm.setExitAction(RTC.ERROR_STATE, self.on_reset)
44 self._sm.setTransitionAction(self.transition)
46 self._sm.setListener(self)
48 st.prev = RTC.INACTIVE_STATE
49 st.curr = RTC.INACTIVE_STATE
50 st.next = RTC.INACTIVE_STATE
51 self._sm.setStartState(st)
52 self._sm.goTo(RTC.INACTIVE_STATE)
55 OpenRTM_aist.Manager.instance().shutdownManager()
67 print "on_deactivated." 87 print "on_state_update." 96 self._sm.setNOP(self.nullAction)
100 self.assertEqual(self._sm.getStates().curr, RTC.INACTIVE_STATE)
101 self.assertEqual(self._sm.getStates().prev, RTC.INACTIVE_STATE)
102 self.assertEqual(self._sm.getStates().next, RTC.INACTIVE_STATE)
105 st.prev = RTC.ERROR_STATE
106 st.curr = RTC.ERROR_STATE
107 st.next = RTC.ERROR_STATE
108 self._sm.setStartState(st)
110 self.assertEqual(self._sm.getStates().curr, RTC.ERROR_STATE)
111 self.assertEqual(self._sm.getStates().prev, RTC.ERROR_STATE)
112 self.assertEqual(self._sm.getStates().next, RTC.ERROR_STATE)
115 self.assertEqual(self._sm.getState(), RTC.INACTIVE_STATE)
118 self.assertEqual(self._sm.isIn(RTC.INACTIVE_STATE),
True)
121 self._sm.goTo(RTC.INACTIVE_STATE)
133 if __name__ ==
'__main__':
def on_aborting(self, st)
def on_state_update(self, st)
def on_activated(self, st)
def on_deactivated(self, st)