Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Papyrus generate Java code from State Machine Diagram(Papyrus generate Java code from State Machine Diagram)
Papyrus generate Java code from State Machine Diagram [message #1810428] Sat, 10 August 2019 19:57 Go to next message
Dionisie Rosca is currently offline Dionisie RoscaFriend
Messages: 2
Registered: August 2019
Junior Member
I create a state machine diagram following this steps:

1. Build your class diagram (at least one class)
2. In the outline view, right click on the class that should get behaviour defined with a state diagram
3. Select "Add a diagram -> Create a new state machine diagram", the new SM diagram opens
4. Select StateMachine in the palette
5. Click or click-drag into the state machine diagram to position the state machine
6. Start entering states and transitions into the state machine

When I try to generate java code from the class diagram it works fine, but when I try to generate from state machine diagram i got this erro:

No classes or packages produced from the transformation. Nothing is generated.

I don't understand what it's wrong, please help.

Thanks
Re: Papyrus generate Java code from State Machine Diagram [message #1810850 is a reply to message #1810428] Tue, 20 August 2019 15:26 Go to previous messageGo to next message
Ansgar Radermacher is currently offline Ansgar RadermacherFriend
Messages: 461
Registered: March 2011
Location: Paris Saclay, France
Senior Member
Hi,

state-machine code generation is currently only supported for C++, not for Java. The error message is caused by invoking the generator on the diagram and not on the class (e.g. via the model explorer). If you do the latter, you'll get the code for the class without state-machine support.

Sorry

Ansgar
Re: Papyrus generate Java code from State Machine Diagram [message #1818396 is a reply to message #1810850] Fri, 13 December 2019 21:08 Go to previous messageGo to next message
Leonard Reder is currently offline Leonard RederFriend
Messages: 1
Registered: December 2019
Junior Member
Hi,

I am just starting to look at Pyparus as a replacement for the MagicDraw commercial CASE tool. I am interested in creating and generating C++ code from UML Statecharts. We have our own C++ code generator that accepts MagicDraw XMI which we will change if Pyparus proves to be a good option. A couple quick questions:

1. I was able to create a state diagram but I have two problems. First I cannot figure out how to properly insert Guard conditions into the model and diagram. All my guards are either a simple C function call or a simple C expression with some variables. If someone could send me a procedure or pointer to a how to manual for state machine modes and diagram creation in Pyparus that would be create. I know this should not be this hard.

2. I need to create activities in my statecharts as well. My activites are just function calls. Also how to do multiple activities within the entry/exist actions of states?

Thanks for any reply. I would really appreciate it. The Pyparus looks like a good alternative in making if I can get into it.

Regards,

Len
Re: Papyrus generate Java code from State Machine Diagram [message #1818483 is a reply to message #1818396] Tue, 17 December 2019 08:49 Go to previous messageGo to next message
Yoann Farré is currently offline Yoann FarréFriend
Messages: 235
Registered: November 2017
Senior Member
Hi,

1. I don't have a link or a pointer to a doc on that but I can describe the way I use to add guard condition in the transition of a state machine.
a: Select the relevant transition
b: In the "Guard" field, click the "+" button and select a type of constraint. I mainly use "Interaction Constraint".
c: Then you can add a "Specification" by clicking on "+" button.
d: If you add code, chose OpaqueExpression and then select the language you want to use (C++ I mean)
e: Add your code in the body for this language.

I generate code every day using this way.

2/ To add entry or exit behavior:
a: Select the relevant state
b: Add a behavior through the "+"button in the field Exit, Entry or DoActivity
c: Chose OpaqueBehavior
d: It's the same principle than OpaqueExpression to fill the body

HTH.

Regards.
Yoann.
Re: Papyrus generate Java code from State Machine Diagram [message #1818952 is a reply to message #1818483] Fri, 03 January 2020 09:20 Go to previous message
Ansgar Radermacher is currently offline Ansgar RadermacherFriend
Messages: 461
Registered: March 2011
Location: Paris Saclay, France
Senior Member
Hi,

a quick way to edit transitions is to use the embedded xtext editor, which can be invoked by pressing "F2" on a transition.
However, the text editor does not work well for constraints, as it produces opaque expressions with "Natural Language" as language tag. While you can change the tag manually (to C++) after editing, the editor won't show the constraint, if you call it again (it looks for "Natural language" expressions only).

Ansgar
Previous Topic:Decision Node not work I want to use decision node with Moka
Next Topic:Requirements import - Sysml 1.6
Goto Forum:
  


Current Time: Fri Apr 19 09:37:23 GMT 2024

Powered by FUDForum. Page generated in 0.02353 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top