how to generate code for statemachine? [message #476431] |
Fri, 26 October 2007 08:55  |
Eclipse User |
|
|
|
Hello NG,
after a long time I'm back again ;) Well I have a UML modeling tool
where you can add several scripts. So I wrote a script that transforms a
model to a .uml-file that I can work with that model in Eclipse ecore.
But it woul be perfect if I it was possible to generate sourcecode from
that uml-file. I know that you can generate the base classes but no
other UML-elements like statemachines or sequence diagrams. What I am
thinking about is that a statemachine models behaviour of a class. That
means that via a switch-statement it is possible to represent the whole
functionality of a statemachine. So is this possible?
greets
Jan
|
|
|
|
|
|
|
|
|
Re: how to generate code for statemachine? [message #625428 is a reply to message #476445] |
Mon, 05 November 2007 09:59  |
Eclipse User |
|
|
|
Hi Jan,
Yes, what you are suggesting sounds possible ( in fact I believe that the
older IBM-XDE did exactly that ... they even had "state machine debugging
" ). I remember googling this a while back and came up with some projects
based on EMF that considered state machines.
Some random thoughts:
1. Consider modifying the .jet templates in the UML project to help with
code generation.
2. Consider adding "body conditions" on operations and add a language of
"JAVA" or "OCL", then specify the java code you want to get emitted as the
body of the operation. ( see
http://wiki.eclipse.org/index.php/MDT_1.0_New_and_Noteworthy #2.1_M7 )
3. Consider using profiles to extend functionality.
Cheers,
- James.
"Jan Reimann" <eclipse@janreimone.de> wrote in message
news:fga61h$nsj$1@build.eclipse.org...
> Nobody has an idea?
|
|
|
Re: how to generate code for statemachine? [message #625430 is a reply to message #476454] |
Mon, 05 November 2007 11:00  |
Eclipse User |
|
|
|
Thanks James for your ideas.
> 1. Consider modifying the .jet templates in the UML project to help with
> code generation.
What are those templates? and where to find them?
> 2. Consider adding "body conditions" on operations and add a language of
> "JAVA" or "OCL", then specify the java code you want to get emitted as the
> body of the operation. ( see
> http://wiki.eclipse.org/index.php/MDT_1.0_New_and_Noteworthy #2.1_M7 )
Sounds good. Thanks for the link as well - in fact it is noteworthy ;)
I'll play around a bit with that possibility allthough I think that it's
not possbible completely generate the statemachine-functionality. But I
find it very interesting.
> 3. Consider using profiles to extend functionality.
To model statemachines or how do you mean this?
greets
Jan
|
|
|
Re: how to generate code for statemachine? [message #625436 is a reply to message #476455] |
Wed, 07 November 2007 09:53  |
Eclipse User |
|
|
|
Hi Jan,
Some comments below ...
"Jan Reimann" <eclipse@janreimone.de> wrote in message
news:fgnemt$jpr$1@build.eclipse.org...
> Thanks James for your ideas.
>
>> 1. Consider modifying the .jet templates in the UML project to help with
>> code generation.
> What are those templates? and where to find them?
Have a look in org.eclipse.uml2.codegen.ecore\templates\model for example.
Those templates extend the EMF code generator templates. You can customize
them to produce code that would be suitable for statemachines.
>
>> 2. Consider adding "body conditions" on operations and add a language of
>> "JAVA" or "OCL", then specify the java code you want to get emitted as
>> the body of the operation. ( see
>> http://wiki.eclipse.org/index.php/MDT_1.0_New_and_Noteworthy #2.1_M7 )
> Sounds good. Thanks for the link as well - in fact it is noteworthy ;)
> I'll play around a bit with that possibility allthough I think that it's
> not possbible completely generate the statemachine-functionality. But I
> find it very interesting.
This may or may not help you out. It might be a way to allow users to
customize code (ie, they could type in some java code for a body of an
operation). It could be exposed as a feature of your tool?
>
>> 3. Consider using profiles to extend functionality.
> To model statemachines or how do you mean this?
( I should have elaborated :( ) If you want to extend UML metatypes with
meta-attributes that would be relevant to statemachines, you could do so
with a profile. For example, if you wanted to indicate that a user could
generate a statemachine from a particular class then you could stereotype
the class with <<statemachine>> and add whatever values were relevant to
statemachines ( I'm just babbling now ).
You could in addition extend the UMLToEcore converters in UMLUtil to
consider such stereotypes when producing an Ecore representation that would
be used in code generation.
>
> greets
> Jan
|
|
|
|
Powered by
FUDForum. Page generated in 0.03680 seconds