fpp/compiler/tools/fpp-to-cpp/test/state-machine/initial/ChoiceStateMachineAc.ref.cpp
Rob Bocchino ab44e7ffc4 Revise state machine code gen
Add comments
2024-11-20 14:43:21 -08:00

96 lines
2.5 KiB
C++

// ======================================================================
// \title ChoiceStateMachineAc.cpp
// \author Generated by fpp-to-cpp
// \brief cpp file for Choice state machine
// ======================================================================
#include "ChoiceStateMachineAc.hpp"
#include "Fw/Types/Assert.hpp"
namespace FppTest {
namespace SmInitial {
// ----------------------------------------------------------------------
// Constructors and Destructors
// ----------------------------------------------------------------------
ChoiceStateMachineBase ::
ChoiceStateMachineBase()
{
}
ChoiceStateMachineBase ::
~ChoiceStateMachineBase()
{
}
// ----------------------------------------------------------------------
// Initialization
// ----------------------------------------------------------------------
void ChoiceStateMachineBase ::
initBase(const FwEnumStoreType id)
{
this->m_id = id;
// Do the actions for the state machine initial transition
this->action_a(Signal::__FPRIME_AC_INITIAL_TRANSITION);
// Enter the initial target of the state machine
this->enter_C(Signal::__FPRIME_AC_INITIAL_TRANSITION);
}
// ----------------------------------------------------------------------
// Getter functions
// ----------------------------------------------------------------------
ChoiceStateMachineBase::State ChoiceStateMachineBase ::
getState() const
{
return this->m_state;
}
// ----------------------------------------------------------------------
// State and choice entry
// ----------------------------------------------------------------------
void ChoiceStateMachineBase ::
enter_T(Signal signal)
{
// Do the entry actions
this->action_a(signal);
this->action_a(signal);
this->m_state = State::T;
}
void ChoiceStateMachineBase ::
enter_S(Signal signal)
{
// Do the entry actions
this->action_a(signal);
this->m_state = State::S;
}
void ChoiceStateMachineBase ::
enter_C(Signal signal)
{
if (this->guard_g(signal)) {
// Do the actions for the transition
this->action_a(signal);
// Enter the target
this->enter_S(signal);
}
else {
// Do the actions for the transition
this->action_a(signal);
this->action_a(signal);
// Enter the target
this->enter_T(signal);
}
}
}
}