Book a Demo

Author Topic: Should transition actions be able to create events  (Read 5888 times)

kenty

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Should transition actions be able to create events
« on: December 20, 2006, 12:04:34 am »
According to Harel's original paper, the action that forms part of a transition can be a triggering event for another part of the system (pg 256 of "Statecharts: A visual formalism for complex systems").  This means that if a transition is occuring, the transition can generate triggering events to affect other parts of the system.  Extreme care must be taken so that infinite loops DO NOT occur because of this.  

An example of an infinite loop is shown below:



In this diagram, as soon as either eventA or eventB is triggered there will be an infinite loop.  This is because the triggering events generate the other triggering event as part of its transition action, which in turn affects the other concurrent region.  This very simple example is obvious to the naked eye, but cannot be detected using current automated tools.  Worst still, this may occur in more complicated projects which have many states, concurrent regions and triggering events.

EA Model only has a textual description as part of this field.  Perhaps this should be converted into a list of events so that we can accurately model this.  This is so that we can accurately tell where each triggering event is used.  Once we have this relationship then we can check for the above mentioned problem because we can then check for never ending event generation within the statechart.  This in itself is very useful because obviously an infinite loop as shown above is erronous and will cause extreme problems in an implementation.
« Last Edit: December 20, 2006, 12:05:46 am by kenty »

jeshaw2

  • EA User
  • **
  • Posts: 701
  • Karma: +0/-0
  • I'm a Singleton, what pattern are you?
    • View Profile
Re: Should transition actions be able to create ev
« Reply #1 on: December 22, 2006, 08:27:30 pm »
What about events which are external to the object being modeled?  EA would not necessarily be aware of those even though the subject model responds to them.
Verbal Use Cases aren't worth the paper they are written upon.

kenty

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Should transition actions be able to create ev
« Reply #2 on: December 22, 2006, 10:02:23 pm »
Quote
What about events which are external to the object being modeled?  EA would not necessarily be aware of those even though the subject model responds to them.


Sorry, I am not entirely sure what you are talking about.  If you mean: what about about external events causing an infinite loop because the originator of the external event responds to the reciprocal event.  Then yes, this is a problem.  

My solution to this is to make the statechart model larger so that it encompasses both systems in concurrent regions.  In the first concurrent region you have the statemachine that you are modelling/implementing.  In subsequent concurrent regions, you have the other statemachines that interact with your system.  These will be approximations based on your understanding of these systems, to be refined as you interact with it in real life.  Therefore instead of modelling your statemachine, you will also model its interaction with outside systems.

This solution may seem far fetched, but I see no reason why statecharts cannot model the "world" so to speak.  Technically speaking, the external system and the system you are modelling can be considered a single "system".

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: Should transition actions be able to create ev
« Reply #3 on: December 23, 2006, 01:41:39 am »
Statemodel newbie statement. :)  Isn't this question upside down?  ???

If a machine behaves according to a state model then aren't events the things that drive the transitions? Shouldn't the model respond to events rather then invoke them?

or did I miss the point.

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.

kenty

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Should transition actions be able to create ev
« Reply #4 on: December 23, 2006, 06:24:03 am »
Quote
Statemodel newbie statement. :)  Isn't this question upside down?  ???

If a machine behaves according to a state model then aren't events the things that drive the transitions? Shouldn't the model respond to events rather then invoke them?

or did I miss the point.

bruce


You are correct that state machines respond to events but you missed the point.  I am talking about state machines generating events and what the consequences are.  The notation for a state transition is e [ b ]/a where
e = triggering event
b = boolean condition that must be true for the transition to take place (optional)
a = the action or activity to perform

According to Harel, a can be a single or multiple triggering events.  This is so that one part of the statemachine can affect the other.  This makes it easy for one concurrent region to affect another due to a response to certain external triggering events.  The danger being a really bad inifinite loop, which would mean the system would never settle into a state.