Merge remote-tracking branch 'origin/development'

# Conflicts:
#	include/etl/version.h
#	support/Release notes.txt
This commit is contained in:
John Wellbelove 2018-11-25 16:20:52 +00:00
parent fe91a72b82
commit 60e55535e2
4 changed files with 60 additions and 10 deletions

View File

@ -93,7 +93,8 @@ namespace etl
const state_id_t next_state_id_,
void (TObject::* const action_)() = nullptr,
bool (TObject::* const guard_)() = nullptr)
: current_state_id(current_state_id_),
: from_any_state(false),
current_state_id(current_state_id_),
event_id(event_id_),
next_state_id(next_state_id_),
action(action_),
@ -101,6 +102,20 @@ namespace etl
{
}
transition(const event_id_t event_id_,
const state_id_t next_state_id_,
void (TObject::* const action_)() = nullptr,
bool (TObject::* const guard_)() = nullptr)
: from_any_state(true),
current_state_id(0),
event_id(event_id_),
next_state_id(next_state_id_),
action(action_),
guard(guard_)
{
}
const bool from_any_state;
const state_id_t current_state_id;
const event_id_t event_id;
const state_id_t next_state_id;
@ -227,7 +242,7 @@ namespace etl
}
//*************************************************************************
///
///
//*************************************************************************
void start(const bool on_entry_initial = true)
{
@ -335,7 +350,7 @@ namespace etl
bool operator()(const transition& t) const
{
return (t.event_id == event_id) && (t.current_state_id == state_id);
return (t.event_id == event_id) && (t.from_any_state || (t.current_state_id == state_id));
}
const event_id_t event_id;

View File

@ -38,7 +38,7 @@ SOFTWARE.
///\ingroup utilities
#define ETL_VERSION_MAJOR 14
#define ETL_VERSION_MINOR 1
#define ETL_VERSION_MINOR 2
#define ETL_VERSION_PATCH 0
#define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) ETL_STRINGIFY(ETL_VERSION_MINOR) ETL_STRINGIFY(ETL_VERSION_PATCH)

View File

@ -1,3 +1,7 @@
===============================================================================
14.2.0
Added 'don't care current state' transition entry option.
===============================================================================
14.1.0
Added hash based random number generator

View File

@ -47,7 +47,8 @@ namespace
STOP,
EMERGENCY_STOP,
STOPPED,
SET_SPEED
SET_SPEED,
ABORT
};
ETL_DECLARE_ENUM_TYPE(EventId, etl::istate_chart::event_id_t)
@ -56,6 +57,7 @@ namespace
ETL_ENUM_TYPE(EMERGENCY_STOP, "Emergency Stop")
ETL_ENUM_TYPE(STOPPED, "Stopped")
ETL_ENUM_TYPE(SET_SPEED, "Set Speed")
ETL_ENUM_TYPE(ABORT, "Abort")
ETL_END_ENUM_TYPE
};
@ -204,19 +206,20 @@ namespace
bool guard;
static const etl::array<MotorControl::transition, 6> transitionTable;
static const etl::array<MotorControl::transition, 7> transitionTable;
static const etl::array<MotorControl::state, 3> stateTable;
};
//***************************************************************************
const etl::array<MotorControl::transition, 6> MotorControl::transitionTable =
const etl::array<MotorControl::transition, 7> MotorControl::transitionTable =
{
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)
MotorControl::transition(StateId::WINDING_DOWN, EventId::STOPPED, StateId::IDLE, &MotorControl::OnStopped),
MotorControl::transition( EventId::ABORT, StateId::IDLE)
};
//***************************************************************************
@ -282,7 +285,7 @@ namespace
CHECK_EQUAL(0, motorControl.stopCount);
CHECK_EQUAL(0, motorControl.stoppedCount);
CHECK_EQUAL(0, motorControl.windingDown);
// Send Start event.
motorControl.guard = false;
motorControl.process_event(EventId::START);
@ -399,7 +402,7 @@ namespace
TEST(test_fsm_emergency_stop)
{
motorControl.ClearStatistics();
// Now in Idle state.
// Send Start event.
@ -431,5 +434,33 @@ namespace
CHECK_EQUAL(0, motorControl.stoppedCount);
CHECK_EQUAL(0, motorControl.windingDown);
}
//*************************************************************************
TEST(test_fsm_abort)
{
motorControl.ClearStatistics();
// Now in Idle state.
// Send Start event.
motorControl.process_event(EventId::START);
// Now in Running state.
motorControl.process_event(EventId::ABORT);
CHECK_EQUAL(StateId::IDLE, int(motorControl.get_state_id()));
// Send Start event.
motorControl.process_event(EventId::START);
// Now in Running state.
// Send Stop event.
motorControl.process_event(EventId::STOP);
// Now in WindingDown state.
motorControl.process_event(EventId::ABORT);
CHECK_EQUAL(StateId::IDLE, int(motorControl.get_state_id()));
}
};
}