Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: vikrant 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
-
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;
}