Book a Demo

Author Topic: C++ code generation from state machine  (Read 3283 times)

CaseyBallentine

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
C++ code generation from state machine
« on: September 19, 2013, 04:28:33 am »
Hello,

I'm having trouble generating C++ code from a state machine. I have the Systems Engineering edition, version 10, and I can generate the IO class from the EAExample project and the state machine code generates fine. However, the very simple state machine I've built into my TestStateMachine class won't generate the state machine code. The basic design of this class is

TestStateMachine
 - mCount:int
 - mTransitionCount:int
 - incrementCount() // just does ++mCount;
 - recordTransition() // sets mCount to 0 then ++mTransitionCount
 - StateMachineImplementation (state machine)
      - Initial (initial state)
      - DoStateOne (state)
          -do - incrementCount()
      - DoStateTwo (state)
          -do - incrementCount()
      - Final (final state)

I have transitions going from initial to DoStateOne with no guards, from DoStateOne to DoStateTwo [mCount > 10]/recordTransition(), from DoStateTwo to DoStateOne [mCount > 15]/recordTransition(), and from DoStateTwo to Final [mTransitionCount > 5].

So it's a really simple state machine, using all behavioral constructs from the TestStateMachineClass. But again, when I generate code, all I get are the constructor, destructor, recordTransition() and incrementCount() method frames.

Any thoughts?

CaseyBallentine

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: C++ code generation from state machine
« Reply #1 on: September 19, 2013, 06:28:37 am »
Well, this is interesting. I created a brand new project out of EA 10 Software Engineering Edition, duplicated the TestStateMachine class in the new project, and the state machine code is generated!

Now I'm trying to figure out why the other, older project won't generate code from the same TestStateMachine model. Some hypotheses:

1) The project was created from EA 7.5 corporate edition originally, then after upgrading to EA 10 systems engineering edition the code generation from behavioral models feature somehow remained blocked.

2) The order in which the TestStateMachine class elements were created somehow prevents the behavioral code generation. In the working case, I had the TestStateMachine class well defined so I added the attributes and operations before adding the state machine. In the non-working case, I first created the state machine within the TestStateMachine class, then added the attributes and operations, then added the behaviors to the states and transitions.

Thoughts?

MMA

  • EA User
  • **
  • Posts: 63
  • Karma: +3/-0
    • View Profile
Re: C++ code generation from state machine
« Reply #2 on: September 24, 2013, 08:26:15 am »
Try.

1. F11 on the Class | Advanced | use "Replace" option

2. Tools | Source Code Generation Templates... | C++ | Are there any templates that were Modified? (The Modified column shows "Yes") Backup the template (copy to an editor for example) and Delete it. (Then EA will use default template). This is to ensure non of your templates were overwritten by the legacy saved ones.

 ;)