Book a Demo

Author Topic: Connecting states to operations  (Read 13523 times)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Connecting states to operations
« on: September 01, 2009, 08:06:38 pm »
Hi,

I'm trying to find a way to model the state aspects of our elements.
Currently I have following:
The element for which we are modelling the state aspects has an attribute (with stereotype state) that represents the state.
The type of this attribute is an enumeration (again with stereotype state) that lists all possible states.
Nested in the class we have a statemachine (with the same name as the state attribute).
The StateMachine contains a state diagram, and for each value in the state enumeration we have a state in the state machine.
Between the states we have of course the transitions with guard condition etc...
The issue that I'm facing right now is how to link the transitions with those operations that perform the transition. I.e if I have states "Open" and "Closed" and a transition between "Open" and "Closed" I whish to know which operations in my model change the state from "Open" to "Closed".
On the other hand I want to know which operations should get triggered when the state is changed from "Open" to "Closed".

Any thoughts or idea's on how to achieve this in EA?

Thanks

Geert

Luis J. Lobo

  • EA User
  • **
  • Posts: 252
  • Karma: +0/-0
  • IT Consultant
    • View Profile
Re: Connecting states to operations
« Reply #1 on: September 01, 2009, 09:13:14 pm »
Double click on the relation "Transition" and go to "Constraints" tab. Then, create a Trigger called, for example, "Trigger 1" of type "Call". This creates a new element in the project browser of type "Trigger" that could be linked to the operation.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Connecting states to operations
« Reply #2 on: September 01, 2009, 09:59:59 pm »
Thanks Luis,

That is indeed one of the options I'm exploring.
There are however two problem with that approach:
1. It pretty complex to navigate from the operations to the transitions (or the other way around). Especially when you don't know on which diagram to look
2. From a UML puristic view this isn't entirely correct. According to the specification we can link a transition with one or more triggers. So far so good. The problem lies in the relation between the Trigger and the operation. Triggers are connected to events. On type of event, the callEvent is connected to an operation. So this would mean that we would have to introduce yet another element to model the relation between the operation and the transition.

Currently I'm thinking to connect the operations that trigger a transition using a tagged value.

For the operations that have to be called when a transition has occurred, I'm thinking of adding one (or more) "StateChanged" operation to the element (or to another element, I'm not sure yet).
This "StateChanged" operation can then be linked to the transition via the Effect (checking "effect is a behaviour" checkbox)
In a sequence diagram I can then model which operations need to be called when the state has changed.

Any all all idea/remarks/insults are welcome.  ;)

Geert

Luis J. Lobo

  • EA User
  • **
  • Posts: 252
  • Karma: +0/-0
  • IT Consultant
    • View Profile
Re: Connecting states to operations
« Reply #3 on: September 01, 2009, 10:37:32 pm »
Currently I'm thinking to connect the operations that trigger a transition using a tagged value.

This approach is very good, and if you define a filter, only operations could be selected in the tagged value field.

For the operations that have to be called when a transition has occurred, I'm thinking of adding one (or more) "StateChanged" operation to the element (or to another element, I'm not sure yet).

This is better than I proposed (create a trigger in the transition calling the operation) from the UML point of view. And the new EA dialog "Select Behavior" make easy to find and select the operation. You can put this "StateChanged" operation directly on the element or create a specific type of element to do this kind of things.

Another way: Create 2 tagged values in the operation: "Launched by" and "Launchs".

Luis J. Lobo

  • EA User
  • **
  • Posts: 252
  • Karma: +0/-0
  • IT Consultant
    • View Profile
Re: Connecting states to operations
« Reply #4 on: September 01, 2009, 10:45:38 pm »
An example of filter may be like this (Go to "Setting | UML..." and the "Tagged Value Types" tab and create a new type, for example "OperationCalled"):

Type=RefGUID;
Values=Operation;
AppliesTo=StateFlow;
« Last Edit: September 01, 2009, 10:52:24 pm by Deiser »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Connecting states to operations
« Reply #5 on: September 01, 2009, 10:58:01 pm »
I thought about creating two tagged values, but I want to keep these kinds of things to a strict minimum.
If EA would help me a bit more then I wouldn't even have to create the one tagged value to keep track of the Operations that trigger a transition.

By the way, I'm using

Type=RefGUIDList;
Values=Operation;
AppliesTo=StateFlow;

As the definition of my tagged values. This allows me to select multiple operations. (Notice the "StateFlow" and not "Transition" as I first tried)

Thanks for your valuable input.

Geert