Book a Demo

Author Topic: Communicating State Machines  (Read 13768 times)

michielper

  • EA User
  • **
  • Posts: 176
  • Karma: +2/-1
    • View Profile
Communicating State Machines
« on: November 04, 2016, 10:25:56 pm »
I am creating models with several state machines that communicate. Communication consists of Triggers that are Effects of Transitions and Guards that correspond to the States of other state machines.

How can I best do this in EA? I have noticed that:
  • It is possible to choose an existing (or ad-hoc created) Activity element as Effect of a Transition
  • It is possible to choose an existing (or ad-hoc created) Trigger element as Trigger of a Transition
However, this is not enough to model relationships between State Machines, because:
  • It is not possible to select an existing Trigger (or list of triggers) as an Effect (via "effect is behaviour")
  • It is not possible to choose an existing State as a Guard (or element in a guard expression)

So, what is your experience, advice or work-around here? Should I choose another tool for my goals?

Thanks, Michiel

Helmut Ortmann

  • EA User
  • **
  • Posts: 970
  • Karma: +42/-1
    • View Profile
Re: Communicating State Machines
« Reply #1 on: November 07, 2016, 05:47:38 pm »
Hi Michiel,

you find information about State Machines:
- http://sparxsystems.com/downloads/whitepapers/UML_Tutorial_Part_2_Introduction.pdf
- Sparx Example Model
- http://sparxsystems.com/resources/demos/index.html
-- Webinar State Machine Simulation
- Package Model Simulation in SPARX Example Model

An effect on a transition can be a behavior (Activity, Interaction, Operation, ..). Select Effect is Behavior on Transition Property.

You can choose an existing trigger in Transition Property.

Look into the Webinar, examine the examples and you will see it's possible to model State Machines. I haven'd experienced any major lack of possibility.

If you want you can simulate a State Machine or even generate code from it.

Ok, as everything it's some work to get the picture.

Kind regards,

Helmut

Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

michielper

  • EA User
  • **
  • Posts: 176
  • Karma: +2/-1
    • View Profile
Re: Communicating State Machines
« Reply #2 on: November 14, 2016, 12:12:54 am »
Hi Helmut,

Thanks for these pointers.
Yes, individual state machines can be modeled easily. However I am talking about a (small) set of interacting state machines.
Have you experience with the modelling of interacting state machines?

Two important and very realistic interactions are:
 
1. The transition of one state machine triggers a transition on another state machine. I cant find a proper way of modeling this in EA: An Effect can be an Activity but it cannot be a Trigger!  I do not see how to model the fact that an Activity results in a Trigger that is input for another state machine.

2. The Guard of one state machine is the State of another state machine. It seems that Guards in EA are nothing more than words without any formal connection to other elements.

So, I will look at the links you sent but I am doubtful if they address my problem...... I definitely hope to be proven otherwise!

Regards, Michiel

RodneyRichardson

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Communicating State Machines
« Reply #3 on: November 16, 2016, 03:50:01 am »
Hi,

1. I'd also like to be able to specify sending a signal (or trigger) to another state machine as an effect. At the moment, we just use a textual convention "send(dest, MY_TRIGGER)", but this is very fragile. If the trigger name changes, the model is broken.

2. On another note, I don't think using the current state of another state machine in a guard is a good idea since conceptually it can change at any point (such as after you've checked the guard, but before you perform the action/effect). I would instead recommend keeping a local state variable to indicate the state that machine was in the last time you heard from it, and use that in your guard. Or better yet, a local state variable indicating the real thing you're interested in (such as "is_connected", or some such).

R.

PeterHeintz

  • EA Practitioner
  • ***
  • Posts: 1001
  • Karma: +59/-18
    • View Profile
Re: Communicating State Machines
« Reply #4 on: November 18, 2016, 07:58:30 pm »
Hi Michielper,
to communicate you need some kind of Event (Message, Change, Time) and someone who causes (behavior) those events. The behavior you specify in the state operations or in the state transitions. This you can do either pure textual (tend to become more easily inconsistent) or by a model (e.g. an Activity).
In you case I would define an Activitiy which sends a signal and assigning this Activitxy to the right behavioral place (see above) of your sending state machine. For the receiving state machine I would define a trigger using the signal to be used on a transition.
Best regards,

Peter Heintz

RodneyRichardson

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Communicating State Machines
« Reply #5 on: November 18, 2016, 10:00:45 pm »
How do you define an Activity which sends a signal?

I tried adding an Activity which comprised:
ActivityInitial -> Send -> ActivityFinal
but I can't see a way to link the Send to the "Signal".

PeterHeintz

  • EA Practitioner
  • ***
  • Posts: 1001
  • Karma: +59/-18
    • View Profile
Re: Communicating State Machines
« Reply #6 on: November 18, 2016, 10:57:38 pm »
"Send" represents an event (wording in EA is somehow confusing).

What you need is the thing that sends the signal.
To do that drag and drop an action into you diagram. After dropping you have to select the type of action. Choose "Send Signal" and add the signal to the action in the properties afterwards.
Best regards,

Peter Heintz

michielper

  • EA User
  • **
  • Posts: 176
  • Karma: +2/-1
    • View Profile
Re: Communicating State Machines
« Reply #7 on: November 28, 2016, 01:17:01 am »
But Peter, an Action cannot be the effect of a transition in EA.... It is impossible to specify anything else than an Activity! So we still have the problem of linking state machines in a clear way.

@Rodney: There are good reasons foe wanting to use the state of one machine as the guard of another, certainly when creating conceptual models. Such models must be simple and clear. Introducing intermediate variables make diagrams complex and are something you will do when coding the stuff later.

PeterHeintz

  • EA Practitioner
  • ***
  • Posts: 1001
  • Karma: +59/-18
    • View Profile
Re: Communicating State Machines
« Reply #8 on: November 28, 2016, 07:45:16 pm »
An activity is somehow the container of actions. So you need an activity having an activity diagram where you drop the right type of action in.
Best regards,

Peter Heintz

michielper

  • EA User
  • **
  • Posts: 176
  • Karma: +2/-1
    • View Profile
Re: Communicating State Machines
« Reply #9 on: November 29, 2016, 12:31:10 am »
Ok Peter, but this doesnt seem to work. An activity can invoke an Action which can be a Send Signal action (right pointing pentagram). But it cannot invoke a Trigger! But a Transition can only be triggered by a Trigger, not by a Send Signal action. So I'm kind of stuck here!

So the problem is that the output of a Transition is of a type (Activity) that cannot be connected to the input of a transition (Trigger).
It is completely unclear to me why Triggers should not be allowed as both input and output of transitions, that would make perfect sense and life very much easier! Or at least allow Triggers in an Activity diagram. Because the strange thing is that on the one hand State Charts and Activity Diagrams are connected via the Effects which can only be Activities, but on the other hand they are completely disconnected and do not allow for each others elements to be mixed in one model. Very annoying!

Michiel

PeterHeintz

  • EA Practitioner
  • ***
  • Posts: 1001
  • Karma: +59/-18
    • View Profile
Re: Communicating State Machines
« Reply #10 on: November 29, 2016, 01:16:35 am »
Yes, a transition can only be triggered by a trigger. But a trigger can specify the event which causes the trigger. In the EA you have to set the right event type and event specification (Type/Specification) within your trigger.
Events and triggers are not the same thing. See below from UML 2.5 spec.


13.4.5 Event [Abstract Class]
13.4.5.1 Description
An Event is the specification of some occurrence that may potentially trigger effects by an object.

13.4.11 Trigger [Class]
13.4.11.1 Description
A Trigger specifies a specific point at which an Event occurrence may trigger an effect in a Behavior. A Trigger may be qualified by the Port on which the Event occurred.
Best regards,

Peter Heintz

michielper

  • EA User
  • **
  • Posts: 176
  • Karma: +2/-1
    • View Profile
Re: Communicating State Machines
« Reply #11 on: November 29, 2016, 05:20:37 am »
Ok, but I dont see how this solves the problem that a Trigger cannot be invoked from within an Activity (the only element allowed as Effect). EA does not support the use of  a Trigger in an Activity diagram.

PeterHeintz

  • EA Practitioner
  • ***
  • Posts: 1001
  • Karma: +59/-18
    • View Profile
Re: Communicating State Machines
« Reply #12 on: November 29, 2016, 07:52:52 pm »
In the activity diagram you need an action doing something like changing a value, calling an operation or sending a asynchronous signal (what we talked about).
So when using a signal you need to do the following in your activity diagram:
- define the signal,
- send the signal with a SendSignal action

In your state machine you need to define:
- the transaction and
- the Trigger having the signal assigned to.
That’s it.

Or in other words you do not have to invoke a Trigger but you have to invoke an action causing an event (signal in our case).

According UML a trigger is a “Specification” and it makes no sense to invoke specifications (at least in UML context).
Best regards,

Peter Heintz