29#ifndef ETL_HFSM_INCLUDED
30#define ETL_HFSM_INCLUDED
48 hfsm(etl::message_router_id_t
id)
60 void start(
bool call_on_enter_state =
true) ETL_OVERRIDE
63 if (p_state == ETL_NULLPTR)
65 p_state = state_list[0];
68 if (call_on_enter_state)
72 if (next_state != ifsm_state::No_State_Change)
74 p_state = state_list[next_state];
84 virtual void reset(
bool call_on_exit_state =
false) ETL_OVERRIDE
86 if ((p_state != ETL_NULLPTR) && call_on_exit_state)
88 do_exits(ETL_NULLPTR, p_state);
91 p_state = ETL_NULLPTR;
103 if (next_state_id != ifsm_state::No_State_Change)
109 if (p_next_state != p_state)
112 do_exits(p_root, p_state);
114 p_state = p_next_state;
116 next_state_id = do_enters(p_root, p_next_state,
true);
118 if (next_state_id != ifsm_state::No_State_Change)
121 p_state = state_list[next_state_id];
134 size_t depth1 = get_depth(s1);
135 size_t depth2 = get_depth(s2);
140 s1 = adjust_depth(s1, depth1 - depth2);
144 s2 = adjust_depth(s2, depth2 - depth1);
164 while (s != ETL_NULLPTR)
195 if ((p_root != p_target) && (p_target->p_parent != ETL_NULLPTR))
197 if (p_target->p_parent != p_root)
200 do_enters(p_root, p_target->p_parent,
false);
204 p_target->p_parent->p_active_child = p_target;
211 if (activate_default_children)
213 while (p_target->p_default_child != ETL_NULLPTR)
215 p_target = p_target->p_default_child;
216 p_target->p_parent->p_active_child = p_target;
217 next_state = p_target->on_enter_state();
235 while (p_current->p_active_child != ETL_NULLPTR)
237 p_current = p_current->p_active_child;
241 while (p_current != p_root)
243 p_current->on_exit_state();
244 p_current = p_current->p_parent;
Exception for null state pointer.
Definition: fsm.h:112
Exception for forbidden state chages.
Definition: fsm.h:164
Exception for invalid state id.
Definition: fsm.h:125
The FSM class.
Definition: fsm.h:325
void receive(const etl::imessage &message) ETL_OVERRIDE
Top level message handler for the FSM.
Definition: fsm.h:398
void receive(const etl::imessage &message) ETL_OVERRIDE
Top level message handler for the HFSM.
Definition: hfsm.h:99
void start(bool call_on_enter_state=true) ETL_OVERRIDE
Definition: hfsm.h:60
virtual void reset(bool call_on_exit_state=false) ETL_OVERRIDE
Definition: hfsm.h:84
hfsm(etl::message_router_id_t id)
Constructor.
Definition: hfsm.h:48
Interface class for FSM states.
Definition: fsm.h:198
etl::fsm_state_id_t get_state_id() const
Gets the id for this state.
Definition: fsm.h:223
#define ETL_ASSERT(b, e)
Definition: error_handler.h:316
bitset_ext
Definition: absolute.h:38
uint_least8_t fsm_state_id_t
Allow alternative type for state id.
Definition: fsm.h:75