34 m_InitialStates = initial_states;
36 for (
int s = 0; s < initial_states.Count(); ++s)
37 m_States.Insert(initial_states[s]);
46 if (
LogManager.IsInventoryHFSMLogEnable())
fsmbDebugPrint(
"[ofsm] " + this.
ToString() +
"::Start(" + initial_events.ToString() +
"), init_state=" + m_InitialStates.ToString());
48 for (
int s = 0; s < m_States.Count(); ++s)
50 m_States[s] = m_InitialStates[s];
53 m_States[s].OnEntry(initial_events[s]);
55 m_States[s].OnEntry(
null);
64 int sc = m_States.Count();
67 for (
int s = 0; s < sc; ++s)
68 if (m_States[s] !=
null)
81 for (
int s = 0; s < m_States.Count(); ++s)
84 m_States[s].OnExit(terminal_events[s]);
86 m_States[s].OnExit(
null);
100 for (
int s = 0; s < m_States.Count(); ++s)
102 m_States[s].OnUpdate(dt);
112 m_Transitions.Insert(t);
122 int count = m_Transitions.Count();
123 for (
int i = 0; i < count; ++i)
126 if (row.m_event.Type() == e.Type())
128 for (
int s = 0; s < m_States.Count(); ++s)
130 if (row.m_srcState.Type() == m_States[s].Type() && row.m_event.Type() == e.Type())
133 bool hasGuard = t.m_guard != NULL;
134 if (!hasGuard || (hasGuard && t.m_guard.GuardCondition(e)))
136 ProcessLocalTransition(s, t, e);
153 if (
LogManager.IsInventoryHFSMLogEnable())
fsmbDebugPrint(
"[ofsm] (local) state=" + t.m_srcState.ToString() +
"-------- event=" + e.ToString() +
"[G=" + t.m_guard.ToString() +
"]/A=" + t.m_action.ToString() +
" --------|> dst=" + t.m_dstState.ToString());
155 m_States[s].OnExit(e);
158 t.m_action.Action(e);
160 m_States[s] = t.m_dstState;
162 if (t.m_dstState != NULL)
164 m_States[s].OnEntry(e);
169 if (
LogManager.IsInventoryHFSMLogEnable())
fsmbDebugPrint(
"[ofsm] terminating fsm: state=" + t.m_srcState.ToString() +
" event=" + e.ToString());