Book a Demo

Author Topic: State transition after elapsed time  (Read 3774 times)

Medic

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
State transition after elapsed time
« on: November 13, 2014, 02:19:12 am »
How can I transition from one state to another after some time period?

i.e. transition from State A to state B five seconds after entering state A.

I see the 'time' type under triggers. Or perhaps using a clock for guard?
Cant find any examples on the help for how to achieve this.

Help with the notation greatly appreciated.

Thanks.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: State transition after elapsed time
« Reply #1 on: November 13, 2014, 08:36:14 am »
You could create an event and a transition with a guard timeout. Or simply a transition out of your state with that guard.

q.
« Last Edit: November 13, 2014, 08:37:09 am by qwerty »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: State transition after elapsed time
« Reply #2 on: November 13, 2014, 09:54:25 am »
Create a trigger from a time based event.

However, if you're looking at using it for simulation or state machine generation, neither has an internal clock generating time based events. For generated code though you can just use a signal and then using an external clock to generate signals from time events.

Medic

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: State transition after elapsed time
« Reply #3 on: November 13, 2014, 11:31:55 am »
OK.

I am looking to simulate the state machine and understand from your answer Simon that I cant do that in EA but at least can in the generated code.

Can I use a decrementing counter in the state as a guard condition to exit the state to get something working in simulation?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: State transition after elapsed time
« Reply #4 on: November 13, 2014, 12:17:37 pm »
If simulation is what you want, you can visually debug a generated state machine the same way as a simulation. That may do the job.

A decrementing counter in a guard will probably work, although you don't know the exact time between tests. But it would simulate something similar to a timer. (It's also invalid according to UML because a trigger should never have a side effect)

Medic

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: State transition after elapsed time
« Reply #5 on: November 13, 2014, 01:02:09 pm »
Ok thanks,

Is it possible to simulate timer functions in any of the diagrams?
My application is an elevator. I want to issue a close door event and then test the door sensor 2 seconds later. Depending on the sensor state I then branch one path or the alternate.

thanks for the help!