Book a Demo

Author Topic: Code Generation for State Machine ACTIONs  (Read 5668 times)

Welcome

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Code Generation for State Machine ACTIONs
« on: December 02, 2015, 08:44:53 pm »
Dear, after spending some time searching the google, here I posted.

In the state machine, for each state, the ACTIONs such as entry/do/exit are specified using activity diagrams.
When codes are generated, all ACTIONs are commented out like below.
How could I generate ACTIONs without comments? Is there any options or just I got something wrong?

public boolean StateMachine_TopState_Idle_behavior(StateBehaviorEnum behavior)
      {
            switch (behavior)
            {
                  case ENTRY:
                  {
                        StringBuilder ss = new StringBuilder();
                        ss.append(m_sInstanceName + "[" + m_sType + "].StateMachine_TopState_Idle ENTRY\n");
                        GlobalFuncs.trace(ss.toString());
                  }
                  break;
                  case DO:
                  {
                        StringBuilder ss = new StringBuilder();
                        ss.append(m_sInstanceName + "[" + m_sType + "].StateMachine_TopState_Idle DO\n");
                        GlobalFuncs.trace(ss.toString());
                        //doIdle; <-- doIdle() is desired!!
                        //
                  }
                  break;
                  case EXIT:
                  {
                        StringBuilder ss = new StringBuilder();
                        ss.append(m_sInstanceName + "[" + m_sType + "].StateMachine_TopState_Idle EXIT\n");
                        GlobalFuncs.trace(ss.toString());
                  }
                  break;
            }
      
            return true;
      }

MMA

  • EA User
  • **
  • Posts: 63
  • Karma: +3/-0
    • View Profile
Re: Code Generation for State Machine ACTIONs
« Reply #1 on: December 03, 2015, 11:23:49 am »
There is a Behavior tab, on which there are two things:
#1. Behavior text field; For example, you input "Hello"
#2. The Initial Code button, e.g. you input "World"
The generated code will be:
//Hello
World

This is specified @ Package | Code Engineering | Code Generation Templates | STM_Java_Structured | Stm State Proc

Search following string:
public boolean %stmStateFQName%_behavior(StateBehaviorEnum behavior)
in which function $entry_behavior is corresponding to #1 and $entry_code is corresponding to #2
Then you can edit the template to suit your needs.

Note: specify the behavior to another behavior element (e.g. Activity, Statemachine, Operation, Interation) is not supported by executable simulation at the moment. The workaround is to type the function call's name and arguments(if any) in the field. e.g. foo(bar);
« Last Edit: December 03, 2015, 11:37:15 am by milesma »

Welcome

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Code Generation for State Machine ACTIONs
« Reply #2 on: December 08, 2015, 11:45:55 am »
WoW,
How would you know such details?
It works as you said, and it helps me a lot to walk through state machine code generation.
Sorry for being late to post this reply  ;)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Code Generation for State Machine ACTIONs
« Reply #3 on: December 08, 2015, 08:46:32 pm »
Quote
How would you know such details?
As a Sparx employee that should be mandatory, I guess.

q.

MMA

  • EA User
  • **
  • Posts: 63
  • Karma: +3/-0
    • View Profile
Re: Code Generation for State Machine ACTIONs
« Reply #4 on: December 09, 2015, 09:37:38 am »
Quote
Quote
How would you know such details?
As a Sparx employee that should be mandatory, I guess.

q.

You are correct.

Besides, we are making the help system on this area more thorough... ;)