Book a Demo

Author Topic: How to create source code from StateMachine  (Read 7134 times)

Eugen Wiebe

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
How to create source code from StateMachine
« on: February 25, 2010, 09:18:01 pm »
If you have a state machine in your EA project, how it is possible to create source code from it?
I also could write an add-in or sth like that, but how to do it? Is there a plactical guide to it? Or are there already finished plug-ins which I could look at?

Thank you

Eugen Wiebe

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: How to create source code from StateMachine
« Reply #1 on: February 25, 2010, 09:19:13 pm »
I have forgotten to say: I am a C# developer. Perhaps it helps

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: How to create source code from StateMachine
« Reply #2 on: February 25, 2010, 11:36:01 pm »
Hi,

What did you try already? For C++ state machine code is generated, if the statemachine is bound to (part of) a classifier.

WBR
Günther
« Last Edit: February 25, 2010, 11:36:19 pm by Makulik »

Eugen Wiebe

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: How to create source code from StateMachine
« Reply #3 on: February 25, 2010, 11:45:54 pm »
Could you explain little bit more please? How to bound a state machine to (part of) a classifier?

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: How to create source code from StateMachine
« Reply #4 on: February 25, 2010, 11:50:50 pm »
Just go to the classifier (in project view) right-click and select 'Add->State Machine' from the menu.
If you already have your FSM, create a new class and drag your state machine on it.

HTH
Günther

Eugen Wiebe

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: How to create source code from StateMachine
« Reply #5 on: February 26, 2010, 12:49:20 am »
Do anybody know an example file which is able to generate C++ source code from model? If yes, where I could find it?

Is it also possible to implement a custom generator (Model->Source)?

Eugen Wiebe

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: How to create source code from StateMachine
« Reply #6 on: February 26, 2010, 01:11:57 am »
I think I have the point:
http://www.sparxsystems.com.au/uml_tool_guide/code_engineering/code_generation_from_behaviora.html

says that "Software code generation from behavioral models is available in the Business and Software Engineering, Systems Engineering and Ultimate editions of Enterprise Architect."

And I use the Corporate Edition
 :(

Eugen Wiebe

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: How to create source code from StateMachine
« Reply #7 on: February 26, 2010, 09:31:48 pm »
I used the trial edition and selected Ultimate License at startup (version 7.5) and I am still not able to generate source code from state machine.
My state machine is in a class and I have done the points as said in http://www.sparxsystems.com.au/uml_tool_guide/code_engineering/code_generation_from_behaviora.html

1. I use Ultimate (trial) edition
2. My state machine is in a class
3. Object oriented support is set to TRUE for C

What I am doing wrong?

Could anybody explain step by step how to generate source code from state machine?

Thank you

Eugen Wiebe

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: How to create source code from StateMachine
« Reply #8 on: March 02, 2010, 08:07:14 pm »
Nobody who knows? Nobody who could help? Nobody who ever auto-created source code from state machine(s). I know there are special tools on the market which can generate source code from state machine model (e.g. VisualState from IAR, but it is expensive: 2000Eur for max 250 states). So if I (would) have EA Ultimate, why not use it?

Thanks

Happy

  • EA User
  • **
  • Posts: 55
  • Karma: +0/-0
    • View Profile
Re: How to create source code from StateMachine
« Reply #9 on: March 02, 2010, 08:34:40 pm »
Hi Eugen,

from what I've read in the link you posted before, I would assume, that it should be possible to generate code when using the right EA edition.

However I also use Corporate Edition only and cannot try it.

Have you considered the note "To be able to generate code from behavioral models, all behavioral constructs should be contained within a Class."?

Which 7.5 build are you using?

Cheers,
H.

Eugen Wiebe

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: How to create source code from StateMachine
« Reply #10 on: March 02, 2010, 09:04:11 pm »
Hello Happy,
I have tried with Ultimate Edition (Trial edition set to ultimate, I expect that the trial Ultimate Edition should behave like real Ultimate Edition, only with time limit)

I have added State Diagram into a C++ class, the class code is generated, but there is nothing from State Diagram in it.

I use EA 7.5 Build 850 (7.5.850)

Nizam Mohamed

  • EA User
  • **
  • Posts: 193
  • Karma: +1/-0
    • View Profile
Re: How to create source code from StateMachine
« Reply #11 on: March 03, 2010, 09:09:02 am »
Eugen,
     YOu seem to've followed most steps and have chosen a right edition, but may I suggest you to double check the following.

"I have added State Diagram into a C++ class,"

>> Did you add a state machine element or a state diagram? Please add a state machine element ( you can do so by right clicking on the class and choosing "Add -> StateMachine"
>> Please ensure you've chosen "Replace(Overwrite) existing source file" (refer http://www.sparxsystems.com/uml_tool_guide/code_engineering/cgo_codegen.html ).
>> Please refer to the sample models in the EaExample.eap(supplied with the installer) "Project Models.Systems Engineering Model.Implementation Model.Software"

HTH

Expedito

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: How to create source code from StateMachine
« Reply #12 on: March 28, 2010, 06:57:42 am »
I have followed the demo in the example and I have created a new project with a state machine diagram within a class and I can't generate source code. I'm interested in C#.
Any help?
Thank you.

Eugen Wiebe

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: How to create source code from StateMachine
« Reply #13 on: March 29, 2010, 07:05:28 pm »
@Nizam:
Yes, you are right. The best way to start is the EAExample (which is part of installation). If you have the right edition (e.g. Ultimate) then you can generate source code from state machine (which is inside a class !)

@Expedito:
Which Edition do you have? It will not work even with Corporate Edition.
You need higher editions (Business and Software Engineering, Systems Engineering and Ultimate editions)
You can use the Trial Edition of EA and set to Ultimate Edition at startup.

Then:
1. Create new Project
2. Create a class package
3. Add a Class Diagram to it
4. Add a class to Class Diagram
5. In Project Prowser->Right click on the created class->Add->State Machine
6. In Project Browser->Right click on the class->Generate Source Code
7. The source code will be generated to the specified file and state machine source code will be embedded into this class file generated source code (if you have the right EA edition)

Expedito

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: How to create source code from StateMachine
« Reply #14 on: March 30, 2010, 03:09:43 am »
Thank you Eugen.
I have remade the project and this time it has worked. I think the first time I didn't delete the class, which seems to be necessary in every new generation.