// ====================================================================== // \title BasicStateMachineAc.cpp // \author Generated by fpp-to-cpp // \brief cpp file for Basic state machine // ====================================================================== #include "Fw/Types/Assert.hpp" #include "state-machine/choice/BasicStateMachineAc.hpp" namespace FppTest { namespace SmChoice { // ---------------------------------------------------------------------- // Constructors and Destructors // ---------------------------------------------------------------------- BasicStateMachineBase :: BasicStateMachineBase() { } BasicStateMachineBase :: ~BasicStateMachineBase() { } // ---------------------------------------------------------------------- // Initialization // ---------------------------------------------------------------------- void BasicStateMachineBase :: initBase(const FwEnumStoreType id) { this->m_id = id; // Enter the initial target of the state machine this->enter_S1(Signal::__FPRIME_AC_INITIAL_TRANSITION); } // ---------------------------------------------------------------------- // Getter functions // ---------------------------------------------------------------------- BasicStateMachineBase::State BasicStateMachineBase :: getState() const { return this->m_state; } // ---------------------------------------------------------------------- // Send signal functions // ---------------------------------------------------------------------- void BasicStateMachineBase :: sendSignal_s() { switch (this->m_state) { case State::S1: // Enter the target this->enter_C(Signal::s); break; case State::S2: break; case State::S3: break; default: FW_ASSERT(0, static_cast(this->m_state)); break; } } // ---------------------------------------------------------------------- // State and choice entry // ---------------------------------------------------------------------- void BasicStateMachineBase :: enter_S3(Signal signal) { // Update the state this->m_state = State::S3; } void BasicStateMachineBase :: enter_S2(Signal signal) { // Update the state this->m_state = State::S2; } void BasicStateMachineBase :: enter_C(Signal signal) { if (this->guard_g(signal)) { // Do the actions for the transition this->action_a(signal); // Enter the target this->enter_S2(signal); } else { // Do the actions for the transition this->action_b(signal); // Enter the target this->enter_S3(signal); } } void BasicStateMachineBase :: enter_S1(Signal signal) { // Update the state this->m_state = State::S1; } } }