Author Topic: How would you model a timeout condition in a statechart?  (Read 4350 times)

mse

  • EA User
  • **
  • Posts: 303
  • Karma: +1/-0
    • View Profile
How would you model a timeout condition in a statechart?
« on: November 20, 2020, 08:09:53 pm »
I would like to model a transition in a statechart whereby the signal is not received for a certain time. How could I do this?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: How would you model a timeout condition in a statechart?
« Reply #1 on: November 20, 2020, 08:55:52 pm »
Just use a transition with that signal. There is no "interruptible region" like in an AD. So you have to model that explicitely.

q.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: How would you model a timeout condition in a statechart?
« Reply #2 on: November 20, 2020, 08:56:58 pm »
Hello,

From the preceding state, draw a transition to a Fork.
From the Fork, draw one transition to the next "normal" state with constraint type Signal and a guard "Signal received" or similar.
From the Fork, draw one transition to the "timed out" state with constraint type Time (specification value can be set to the wait time, eg "10s") and a guard "Timeout".

All paths from a Fork are followed in a non-specified order (could be sequential, could be parallel), so you need the guards to specify the condition that must be fulfilled for each transition to be followed. If (and only if) they are mutually exclusive, only one transition will be followed.

HTH,


/Uffe
My theories are always correct, just apply them to the right reality.

YannM

  • EA User
  • **
  • Posts: 22
  • Karma: +0/-0
    • View Profile
Re: How would you model a timeout condition in a statechart?
« Reply #3 on: December 01, 2020, 03:23:34 am »
Hi Uffe,

I don't get your point with the transition which has a constraint type Time (specification value can be set to the wait time, eg "10s") and a guard "Timeout".
I never succeeded using the constraint Time ... it has no effect in my State Machine.

To solve my issues I use two events from a state, one is triggered when the timeout is expired, the other one is for the proper event awaited.
However the "timeout" delay can never be simulated in EA.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: How would you model a timeout condition in a statechart?
« Reply #4 on: December 06, 2020, 08:25:19 pm »
Hi again,

I never succeeded using the constraint Time ... it has no effect in my State Machine.
...
However the "timeout" delay can never be simulated in EA.

I see: you're trying to execute/simulate the state machine. In the OP you said "model" and the procedure I outlined should work for that, but execution is a whole nother problem.

State machine execution is (as so much else in EA) a partial implementation that works for a sales demo but breaks down as soon as you try to incorporate any but the most trivial model constructs.
So while you can syntactically and semantically express a timeout in a UML state machine, you can't get EA to execute it.

You can always try to request that feature from Sparx.


/Uffe
My theories are always correct, just apply them to the right reality.