Skip to main content



      Home
Home » Modeling » UML2 » how to generate code for statemachine?
how to generate code for statemachine? [message #476431] Fri, 26 October 2007 08:55 Go to next message
Eclipse UserFriend
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 #476445 is a reply to message #476431] Wed, 31 October 2007 11:12 Go to previous messageGo to next message
Eclipse UserFriend
Nobody has an idea?
Re: how to generate code for statemachine? [message #476454 is a reply to message #476445] Mon, 05 November 2007 09:59 Go to previous messageGo to next message
Eclipse UserFriend
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 #476455 is a reply to message #476454] Mon, 05 November 2007 11:00 Go to previous messageGo to next message
Eclipse UserFriend
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 #476460 is a reply to message #476455] Wed, 07 November 2007 09:53 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: how to generate code for statemachine? [message #476462 is a reply to message #476460] Wed, 07 November 2007 10:06 Go to previous message
Eclipse UserFriend
Thanks so far James. I did not think on extending
org.eclipse.uml2.codegen.ecore\templates....So that is the best idea for
my purpose :)

greets
Jan
Re: how to generate code for statemachine? [message #625348 is a reply to message #476431] Wed, 31 October 2007 11:12 Go to previous message
Eclipse UserFriend
Nobody has an idea?
Re: how to generate code for statemachine? [message #625428 is a reply to message #476445] Mon, 05 November 2007 09:59 Go to previous message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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
Re: how to generate code for statemachine? [message #625438 is a reply to message #476460] Wed, 07 November 2007 10:06 Go to previous message
Eclipse UserFriend
Thanks so far James. I did not think on extending
org.eclipse.uml2.codegen.ecore\templates....So that is the best idea for
my purpose :)

greets
Jan
Previous Topic:Re: UMLProfile vs Ecore
Next Topic:[Announce] MDT 1.1 development plan
Goto Forum:
  


Current Time: Sun Aug 31 16:33:22 EDT 2025

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

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

Back to the top