Author Topic: Events and their use.  (Read 2257 times)

ChrisBD

  • EA User
  • **
  • Posts: 60
  • Karma: +0/-0
    • View Profile
Events and their use.
« on: February 01, 2010, 11:33:25 pm »
I'm looking at showing events within UML diagrams.
I realise that for State Machine Diagrams events are the transitions between states.
I can see that use of send and receive elements on activity diagrams can also show events.
What about class diagrams though. Are events shown using the <<signal>> class element and if so, how do I show that it is handled by a specific class on that class diagram?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 8158
  • Karma: +191/-22
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Events and their use.
« Reply #1 on: February 02, 2010, 12:08:47 am »
Chris,

It depends on what exactly you are trying to model. What exactly is the nature of those events you are talking about?

I think you are mixing up a few things.
  • Transitions are not equal to events. (they may be triggered by an event, but they are definitely not the same concept). Transition:
    Quote
    A transition is a directed relationship between a source vertex and a target vertex. It may be part of a compound

transition, which takes the state machine from one state configuration to another, representing the complete response of
the state machine to an occurrence of an event of a particular type.[/quote]
  • An event is:
    Quote
    An event is the specification of some occurrence that may potentially trigger effects by an object.
  • A signal:
    Quote
    A signal is a specification of send request instances communicated between objects. The receiving object handles the

received request instances as specified by its receptions. The data carried by a send request (which was passed to it by the
send invocation occurrence that caused that request) are represented as attributes of the signal. A signal is defined
independently of the classifiers handling the signal occurrence.[/quote]
  • A SignalEvent:
    Quote
    A signal event represents the receipt of an asynchronous signal instance. A signal event may, for example, cause a state

machine to trigger a transition.[/quote]
[/list]
As you can see these are all distinct (meta) concepts with their own definition.

So if you can describe what exactly you are trying to model, we may be able to point you to the right (meta) concept to use.

Geert

ChrisBD

  • EA User
  • **
  • Posts: 60
  • Karma: +0/-0
    • View Profile
Re: Events and their use.
« Reply #2 on: February 02, 2010, 12:59:43 am »
Okay.
Perhaps I wasn't clear when I said that events were transitions between states in a state machine. I accept that transitions only occur because of some event (even if that may just be that the processing within one state has completed).

I'm trying to put together some simple examples of how events and interrupts should be implemented in EA for people who have never used a UML modelling tool before, and this includes hardware as well as software engineers. As you can imagine the semantics of an event and an interrupt differs widely between these areas of expertise.

I am using a series of examples to illustrate a standard way of how our project teams should use EA.

My simple example is for making tea. On the class diagram I want to show a Kettle class that accepts an ElectricityOn event at which point it should start to heat the water or an ElectricityOff event to cease heating the water. I realise that this may not be the best example of an event, but it has to be generic and easy to describe to all parties.

Looking at the examples that you give it looks as if I'll need a SignalEvent.

So I'm back to my original question and using my example, how do I show an ElectricityOn event being handled by the Kettle class?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 8158
  • Karma: +191/-22
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Events and their use.
« Reply #3 on: February 02, 2010, 01:22:05 am »
You could use a statemachine to do that.
The statemachine could have then have two states: on/off
Then the "on" state could have a doActivity that specifies it heats the water. (you could link that do an operation on the kettle class).

The statemachine could be nested under the Kettle class.

If you want you can always show both the signalEvent as the Kettle class on a class diagram. EA allows to put any type of element on (almost) any type of diagram.
If you want to visualize the relation between the Kettle class and the events I would use some sort of dependency.

This is just one way of expressing this. As usual there is no single correct answer to such a question.

Geert

ChrisBD

  • EA User
  • **
  • Posts: 60
  • Karma: +0/-0
    • View Profile
Re: Events and their use.
« Reply #4 on: February 02, 2010, 01:35:51 am »
Thank you Geert.
In a nut shell you've hit the nail on the head of the problems that we're having.

EA (and probably any other UML tool) is too easy going about how we can go about showing how a system is put together and one of the difficult things is the varying ways in which you can show the same information on the same diagram type in so many ways.

I've already produced a Kettle Class state machine, in the manner that you describe (although it has states idle and heating) in order to show how to label transitions etc.

So I'm looking at showing how an ElectrictyOn event relates to a Kettle class Heating operation.

I'll have a look at associations.

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: Events and their use.
« Reply #5 on: February 02, 2010, 04:00:15 am »
Hi chris,

May be to give a more realistic sample for your 'Kettle' choose one like I have at home:
An automatic water boiling kettle, which I start turning on the electricity and it will stop heating automatically when the bimetal sensor notes that the heated water is boiling.
So you'll have a nice example for what's an event in the heating state: Reaching the temperature of boiling water causes the kettle to leave 'heating' state (guess to 'idle' in your sample).

Just a suggestion,
GŁnther

P.S.: Miro Samek published this wonderful article about state machine diagrams and modelling: http://www.embedded.com/215801043?pgno=5
Have a look at it

ChrisBD

  • EA User
  • **
  • Posts: 60
  • Karma: +0/-0
    • View Profile
Re: Events and their use.
« Reply #6 on: February 02, 2010, 06:49:20 pm »
Makulik, that's more or less what I have. As Geert suggested I've placed that state machine under my Kettle class.

I'm mainly looking at how to show the Kettle class accepting an event that starts the heating process i.e. switches it from idle to heating in the state machine.

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: Events and their use.
« Reply #7 on: February 02, 2010, 10:43:23 pm »
Quote
I'm mainly looking at how to show the Kettle class accepting an event that starts the heating process i.e. switches it from idle to heating in the state machine.
Quote
... which I start turning on the electricity ...
Hard to use an electromechanical device as sample, which has usually no software at all. Consider the class being a simulation, give it an operation 'switchOn()' or s.th. alike ...

HTH
GŁnther

Nizam Mohamed

  • EA User
  • **
  • Posts: 190
  • Karma: +0/-0
    • View Profile
Re: Events and their use.
« Reply #8 on: February 03, 2010, 11:51:13 am »
Hope you've tried creating a Signal(name = ElectricityOn) and adding a Trigger ( Type = Signal , Specification - choose the "ElectricityOn" signal from the dropdown combo) to the transition from Idle to Heating state.

This apparently describes that the transition is fired by the SignalEvent.

Note: ATM, The Signal element should be inside the StateMachine element to be shown in the Specification combo, but in the forthcoming version of EA (8.0), considerable enhancements have been made in this domain (Trigger, Signals, etc) which would enable you to choose any valid model element.

christian

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Events and their use.
« Reply #9 on: February 18, 2010, 09:04:48 pm »
Hi,
I also want a simple example to show (me) how a state machine works with events/signals.
I created the same "kettle" example stated above with two states idle and process. I have 4 transitions:
1. from init to idle, no signal
2. from idle to process, signal SProcess
3. from process to idle, signal SIdle
4. from idle to final, signal SEnd

But now, as suggested I need to send a signal somewhere. Therefore I thought I could use the send block in an activity diagram as this is shown in documentation (somewher I can't remember). But I don't know how to design this and how to bind the signals to the send element.

Could you please help? Is there an example somewhere which shows this?

Thanx
Christian
« Last Edit: February 18, 2010, 09:06:28 pm by christian »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 8158
  • Karma: +191/-22
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Events and their use.
« Reply #10 on: February 18, 2010, 09:28:56 pm »
Christian,

In order to send a signal from an activity specification you can use the SendSignalAction.
Normally for that action you should then specifiy which signal it sends. I've just tried this in 7.5.850 but unfortunately EA didn't allow me to link the signal with the SendSignalAction.
Maybe they have improved that in 8.0?
If I were to use this in 7.5 I would probably link the action with the signal using a dependency.

Geert

christian

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Events and their use.
« Reply #11 on: February 18, 2010, 10:16:13 pm »
Hi Geert,

thank you for your repy. But, could you tell if code generation does work if I use the "workaround" you propose? Because I want to generate the state machine and sending signal example.

Christian

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 8158
  • Karma: +191/-22
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Events and their use.
« Reply #12 on: February 18, 2010, 10:53:29 pm »
Christian,

I don't use code generation, so I really don't know.
My guess is that the code generation will not take this into account.

Geert

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: Events and their use.
« Reply #13 on: February 19, 2010, 12:10:34 am »
Quote
Hi Geert,

thank you for your repy. But, could you tell if code generation does work if I use the "workaround" you propose? Because I want to generate the state machine and sending signal example.

Christian
Hi Christian,

Before you start using EA's code generation facilities to implement your state machines, I urgently recommend to get some background about the other (state of the art) opportunities how to implement FSMs. As far I remember you want to use this for teaching. You should mention the various implementation approaches (switch/case if/else monolithic, State Design Pattern, Transition Table Lookup) independently from the EA generated state machine code.

I beg you to educate a new generation of software developers/architects for us that comes with a sound background knowledge of what they're supposed to do.

Just my 0.02 EUR
GŁnther

christian

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Events and their use.
« Reply #14 on: February 19, 2010, 12:20:27 am »
Hi GŁnther,

thank you for your comments. I have a project where I need FSMs... that's why I need them. I am familiar with FSM, but not how to model them in EA.

You have the kettle example above and maybe it was no problem for you to send me the example or to share it generally to help me and others with the FSM problem.

Thank you
Christian