Author Topic: State Machines  (Read 4596 times)

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
State Machines
« on: April 04, 2004, 06:49:58 pm »
  ???
How do I associate a state machine diagram with a particular element.  Even more significantly, can I associate it with a specific attribute of that element.
I am sure I have done this before.

Object X of class X-type can be in one of three states (Busy, Waiting, Free), indicated by attribute "Status".
What I am trying to do is map the methods of X to their applicability in the states.

"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

thomaskilian

  • Guest
Re: State Machines
« Reply #1 on: April 05, 2004, 01:54:14 am »
Hi,
why not just place the diagram underneath the element?

Cheers, Thomas

Oscar

  • EA User
  • **
  • Posts: 65
  • Karma: +0/-0
    • View Profile
Re: State Machines
« Reply #2 on: April 05, 2004, 07:06:04 am »
That (a class object on the state diagram) was my first reaction too (have used it on a previous, non EA, project).
But that's to obvious.

I think Bruce want's some formal association between the state machine diagram and the class object.

I've looked into it today but could not find any way to link a state machine to a class.

Cheers,
Oscar


Bruno.Cossi

  • EA User
  • **
  • Posts: 803
  • Karma: +0/-0
    • View Profile
Re: State Machines
« Reply #3 on: April 05, 2004, 07:38:20 am »
That's what we do - create a child diagram underneath the class.

Bruno

Quote
Hi,
why not just place the diagram underneath the element?

Cheers, Thomas


sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: State Machines
« Reply #4 on: April 05, 2004, 06:14:58 pm »
I have tried "placing it under the class" in the project tree and this results in correct generation of code (C#) using state subclassing.

This is fine - however, if I want to implement using a state variable, there is no way (?) to indicate/force that approach except by separating the state diagram and the class in the tree (e.g. by putting the state diagram under an instance object.)  

My real problem is this.  In the state diagram I want to specify certain methods of the class as event handlers and other actions.   EA (4) doesn't seem to allow me to select predefined methods for this purpose.

Similarly, methods added to the class states directly in the state diagram dont show up in the class diagram.

Any ideas?

Bruce
"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

Oscar

  • EA User
  • **
  • Posts: 65
  • Karma: +0/-0
    • View Profile
Re: State Machines
« Reply #5 on: April 06, 2004, 12:47:11 am »
When the statechart is placed under the class in the project tree you can pick variables from the class attributes when setting the "run state" of a state element.

So EA 'knows' the class attributes.

Haven't found a way to do the same for operations (fi. like in a sequence diagram).

Maybe it's a bug or a feature request.

Oscar


mchiuminatto

  • EA User
  • **
  • Posts: 113
  • Karma: +0/-0
    • View Profile
Re: State Machines
« Reply #6 on: April 06, 2004, 08:28:40 pm »
Try dragging the operations from the class in the tree to the state element in the diagram.
Regards.

Marcello

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: State Machines
« Reply #7 on: April 06, 2004, 09:06:07 pm »
You bloody rippers Oscar and Marcello! :D
"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

Oscar

  • EA User
  • **
  • Posts: 65
  • Karma: +0/-0
    • View Profile
Re: State Machines
« Reply #8 on: April 07, 2004, 12:42:27 am »
Thanks Marcello
You opened up my mind. Gues I was playing by the rules to much  ;)


But from a pure point of view I still can't appriciate it.

I would like to have the operations on the transition flow and not in the state element.

Another drawback is that the operations in the state diagram are not coupled to the operations in the class(diagram). When you change the operation-name in the class the name in the state element does not change.
The same applies to class-attributes, even if you used the "run state" dialog to define it.

I still would like to see the pick-mechanism as used in the sequence diagram.

Oscar