mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-30 06:18:50 +08:00
Refactored hfsm receive function
This commit is contained in:
parent
e0ef2da603
commit
2d3a80e2b7
@ -101,33 +101,24 @@ namespace etl
|
||||
if (is_started())
|
||||
{
|
||||
etl::fsm_state_id_t next_state_id = p_state->process_event(message);
|
||||
|
||||
if (have_changed_state(next_state_id))
|
||||
{
|
||||
ETL_ASSERT_OR_RETURN(next_state_id < number_of_states, ETL_ERROR(etl::fsm_state_id_exception));
|
||||
|
||||
if (next_state_id != ifsm_state::No_State_Change)
|
||||
{
|
||||
if (have_changed_state(next_state_id))
|
||||
{
|
||||
ETL_ASSERT_OR_RETURN(next_state_id < number_of_states, ETL_ERROR(etl::fsm_state_id_exception));
|
||||
etl::ifsm_state* p_next_state = state_list[next_state_id];
|
||||
etl::ifsm_state* p_root = common_ancestor(p_state, p_next_state);
|
||||
|
||||
do_exits(p_root, p_state);
|
||||
next_state_id = do_enters(p_root, p_next_state, true);
|
||||
|
||||
etl::ifsm_state* p_next_state = state_list[next_state_id];
|
||||
|
||||
etl::ifsm_state* p_root = common_ancestor(p_state, p_next_state);
|
||||
do_exits(p_root, p_state);
|
||||
|
||||
p_state = p_next_state;
|
||||
|
||||
next_state_id = do_enters(p_root, p_next_state, true);
|
||||
|
||||
if (next_state_id != ifsm_state::No_State_Change)
|
||||
{
|
||||
ETL_ASSERT_OR_RETURN(next_state_id < number_of_states, ETL_ERROR(etl::fsm_state_id_exception));
|
||||
p_state = state_list[next_state_id];
|
||||
}
|
||||
}
|
||||
else if (is_self_transition(next_state_id))
|
||||
{
|
||||
p_state->on_exit_state();
|
||||
p_state->on_enter_state();
|
||||
}
|
||||
ETL_ASSERT_OR_RETURN(next_state_id < number_of_states, ETL_ERROR(etl::fsm_state_id_exception));
|
||||
p_state = state_list[next_state_id];
|
||||
}
|
||||
else if (is_self_transition(next_state_id))
|
||||
{
|
||||
p_state->on_exit_state();
|
||||
p_state->on_enter_state();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user