Book a Demo

Author Topic: entry function not visible in generated c++ code  (Read 3048 times)

vikrant

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
entry function not visible in generated c++ code
« on: October 30, 2014, 08:18:20 pm »
Hello,
I could generate c++ code from state machine, but entry/exit/do functions entered in state machine are not appearing in auto generated c++ code.  Any special setting  required to get enty/exit functions in c++ code ? I am using 11.0.1107 version
Thanks and Regards,
Vikrant

MMA

  • EA User
  • **
  • Posts: 63
  • Karma: +3/-0
    • View Profile
Re: entry function not visible in generated c++ co
« Reply #1 on: November 06, 2014, 12:10:01 pm »
Hi vikrant,

The entry/do/exit code can be set at "State" element.

Double click on the operations you created in the state | Behavior tab | input "behavior code;" in the Behavior field, "initial code;" in the Initial Code field. The generated result will looks like below:

Note: you can update the template by using "behavior" field or "initial" field. Tools | Source Code Generation Templates | STM_C++_Structured | Stm State Proc Impl | search "$entry_behavior = " and "$entry_code = " | then togging "//" in the strings
-----------------------------
bool MyClass::StateMachine_State1_behavior(StateBehaviorEnum behavior)
{
      switch (behavior) {
            case ENTRY:
            {
                  StringStream ss;
                  ss << m_sInstanceName << "[" << m_sType << "]." << "StateMachine_State1 " << "ENTRY" << endl;
                  GlobalFuncs::trace(ss.str());
                  //behavior code;
                  initial code;
            }
                  break;
            case DO:
            {
                  StringStream ss;
                  ss << m_sInstanceName << "[" << m_sType << "]." << "StateMachine_State1 " << "DO" << endl;
                  GlobalFuncs::trace(ss.str());
            }
                  break;
            case EXIT:
            {
                  StringStream ss;
                  ss << m_sInstanceName << "[" << m_sType << "]." << "StateMachine_State1 " << "EXIT" << endl;
                  GlobalFuncs::trace(ss.str());
            }
                  break;
      }
      
      return true;
}