Book a Demo

Author Topic: Code Engineering of Behavioural Models  (Read 4885 times)

hamedsheida

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Code Engineering of Behavioural Models
« on: April 13, 2009, 06:08:22 pm »
I don't know how can I generate code from a activity or sequence diagram in EA 7.5 ? please help me .

Kevin G. Watson

  • EA User
  • **
  • Posts: 217
  • Karma: +0/-0
  • I love EVERYTHING including Microsoft
    • View Profile
Re: Code Engineering of Behavioural Models
« Reply #1 on: April 14, 2009, 02:28:59 am »
hi'ya

Try this.... add a new class, add an activity diagram to the class.  Drag an Initial, action and Final to diagram... use the quick link to pass control from initial to action and repeat for action to final.

From the action properties dialog, add something like int a = 2 + 2 ; in the behaviour effects text field. ADDED TEXT, tick show on diagram, click save    click ok, the statement will appear in the action as text.

The project browser will show the class as owning an activity diagram and bits we've dropped onto the diagram.

If you generate source code for the class, 'Generate Source' from class context menu ( I presume from further up the heirachy too ) ... you ought to see the resultant code generated ( 'View Source' from class context menu).

If the expression returns a bool, you should use a choice, with a guard condition brtn == true... if then else.... oh and merge the non terminal paths ( else it should cause block structure to be malformed ) with a diamond thingie  ( you end up with a whole bundle of diamonds if you writes well iffy code; like input validiation checks)

Kevin [smiley=2vrolijk_08.gif]

How does it handle switch type selection? ( more an expansion region perhaps, like foreach

Kevin
« Last Edit: April 17, 2009, 08:30:34 am by badboyabout »

Kevin G. Watson

  • EA User
  • **
  • Posts: 217
  • Karma: +0/-0
  • I love EVERYTHING including Microsoft
    • View Profile
Re: Code Engineering of Behavioural Models
« Reply #2 on: April 14, 2009, 02:32:18 am »
my collegues gone just gone home, Im gonna nip into his den and demo what I said ...  Kevin [smiley=2vrolijk_08.gif]

Kevin G. Watson

  • EA User
  • **
  • Posts: 217
  • Karma: +0/-0
  • I love EVERYTHING including Microsoft
    • View Profile
Re: Code Engineering of Behavioural Models
« Reply #3 on: April 14, 2009, 03:23:04 am »
Oops.... that would be a vision of how it oughta work.

The helps not very clear is it?

I did it the other day.... off to janes office, hope she's still got the model thingie...

k

Kevin G. Watson

  • EA User
  • **
  • Posts: 217
  • Karma: +0/-0
  • I love EVERYTHING including Microsoft
    • View Profile
Re: Code Engineering of Behavioural Models
« Reply #4 on: April 14, 2009, 09:45:13 am »
I have done it....


but Jane wasn't that impressed enough to cherish the model.

 [smiley=2vrolijk_08.gif]kevin

Kevin G. Watson

  • EA User
  • **
  • Posts: 217
  • Karma: +0/-0
  • I love EVERYTHING including Microsoft
    • View Profile
Re: Code Engineering of Behavioural Models
« Reply #5 on: April 14, 2009, 09:52:23 am »
And not much more luck with Sequence Codegen either.. .


I'd like to know where the diagram has gone too by way.   the code snip is just what I'd expect, following my unrepeated success other night

Kevin G. Watson

  • EA User
  • **
  • Posts: 217
  • Karma: +0/-0
  • I love EVERYTHING including Microsoft
    • View Profile
Re: Code Engineering of Behavioural Models
« Reply #6 on: April 14, 2009, 09:58:32 am »
Is this progress?


 [smiley=2vrolijk_08.gif] [smiley=bath.gif] Kevin

Nizam Mohamed

  • EA User
  • **
  • Posts: 193
  • Karma: +1/-0
    • View Profile
Re: Code Engineering of Behavioural Models
« Reply #7 on: April 15, 2009, 10:38:05 am »
Please refer to the "Systems Engineering Model -> Implementation Model" in the EAExample.eap file supplied, for sample behavioral models. Please try generating code for each of the software and hardware language models, to get an idea of how different programmatic paradigms are modeled in UML.

Kevin G. Watson

  • EA User
  • **
  • Posts: 217
  • Karma: +0/-0
  • I love EVERYTHING including Microsoft
    • View Profile
Re: Code Engineering of Behavioural Models
« Reply #8 on: April 16, 2009, 11:49:42 am »
Hi'ya Nizam, thanks for that head up... actually it does work like I said, at least it seems to...... I've got it doc'ed in One Note

will check back in the morning.

I'm aiming at illustrating the 'Effects' of actions ( currently a textual notation... if ya showing effects in ya diagram ).

Connecting source expressions to model elements, appears to get lost in translation... I'm not attempting to do that anyhow... oh no, get rid of textual low level languages all togeather. Trace and inspect visually

I shall have to sneak a peek at rational Rose Realtime edition before doing statefull ( Tau did something with Activity diagrams ... who was that? ).

Kevin [smiley=2vrolijk_08.gif]



Nizam Mohamed

  • EA User
  • **
  • Posts: 193
  • Karma: +1/-0
    • View Profile
Re: Code Engineering of Behavioural Models
« Reply #9 on: April 16, 2009, 05:15:01 pm »
Hi Kevin, your illustrations were cool and informative, i just wanted to provide some more examples on top of it.

W.r.t to Effects of actions, We are aiming at adding more extensive support for other action types in upcoming builds. ( create variable action, write variable action, etc ) which will apparently reduce the necessity for textually tampering the model elements

Kevin G. Watson

  • EA User
  • **
  • Posts: 217
  • Karma: +0/-0
  • I love EVERYTHING including Microsoft
    • View Profile
Re: Code Engineering of Behavioural Models
« Reply #10 on: April 17, 2009, 07:11:01 am »
that, well cool.,.