From 2ab1d8d346d035341174c7434e5357a7b94fea84 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 12 Sep 2018 17:35:59 +0100 Subject: [PATCH] Swapped event and current state parameters for state transition --- include/etl/state_chart.h | 10 +++++----- test/test_state_chart.cpp | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/etl/state_chart.h b/include/etl/state_chart.h index 94667279..18fab61b 100644 --- a/include/etl/state_chart.h +++ b/include/etl/state_chart.h @@ -86,21 +86,21 @@ namespace etl //************************************************************************* struct transition { - transition(const event_id_t event_id_, - const state_id_t current_state_id_, + transition(const state_id_t current_state_id_, + const event_id_t event_id_, const state_id_t next_state_id_, void (TObject::* const action_)() = nullptr, bool (TObject::* const guard_)() = nullptr) - : event_id(event_id_), - current_state_id(current_state_id_), + : current_state_id(current_state_id_), + event_id(event_id_), next_state_id(next_state_id_), action(action_), guard(guard_) { } - const event_id_t event_id; const state_id_t current_state_id; + const event_id_t event_id; const state_id_t next_state_id; void (TObject::* const action)(); bool (TObject::* const guard)(); diff --git a/test/test_state_chart.cpp b/test/test_state_chart.cpp index 2134ed6b..6cfb651c 100644 --- a/test/test_state_chart.cpp +++ b/test/test_state_chart.cpp @@ -211,12 +211,12 @@ namespace //*************************************************************************** const etl::array MotorControl::transitionTable = { - MotorControl::transition(EventId::START, StateId::IDLE, StateId::RUNNING, &MotorControl::OnStart, &MotorControl::Guard), - MotorControl::transition(EventId::START, StateId::IDLE, StateId::IDLE, &MotorControl::Null, &MotorControl::NotGuard), - MotorControl::transition(EventId::STOP, StateId::RUNNING, StateId::WINDING_DOWN, &MotorControl::OnStop), - MotorControl::transition(EventId::STOPPED, StateId::WINDING_DOWN, StateId::IDLE, &MotorControl::OnStopped), - MotorControl::transition(EventId::EMERGENCY_STOP, StateId::RUNNING, StateId::IDLE, &MotorControl::OnStop), - MotorControl::transition(EventId::SET_SPEED, StateId::RUNNING, StateId::RUNNING, &MotorControl::OnSetSpeed) + MotorControl::transition(StateId::IDLE, EventId::START, StateId::RUNNING, &MotorControl::OnStart, &MotorControl::Guard), + MotorControl::transition(StateId::IDLE, EventId::START, StateId::IDLE, &MotorControl::Null, &MotorControl::NotGuard), + MotorControl::transition(StateId::RUNNING, EventId::STOP, StateId::WINDING_DOWN, &MotorControl::OnStop), + MotorControl::transition(StateId::RUNNING, EventId::EMERGENCY_STOP, StateId::IDLE, &MotorControl::OnStop), + MotorControl::transition(StateId::RUNNING, EventId::SET_SPEED, StateId::RUNNING, &MotorControl::OnSetSpeed), + MotorControl::transition(StateId::WINDING_DOWN, EventId::STOPPED, StateId::IDLE, &MotorControl::OnStopped) }; //***************************************************************************