Stateflow question: transitions evaluated before state is executed

Hello,
I was wondering wether there is a type of transition in Stateflow which is evaluated before the state is executed.
I have two superstates wich own two substates each inside, so what I want is the transition between the superstates to be evaluated before the substate of the active superstate is executed. Is that possible?

 채택된 답변

Jarrod Rivituso
Jarrod Rivituso 2011년 5월 25일

0 개 추천

Hi Iban,
I believe that is actually the default behavior. Generally, outer transitions (ones on the super states) are tested first, and then inner transitions (ones on the substates) are tested.
Also, I believe if a transition will cause a state to be left at a particular time step, then no "during" action will occur for that state. Is that what you meant by the superstate being "executed"?

댓글 수: 3

Hello Jarrod,
thanks for answering so quickly.
Maybe I didn´t explain very well. You are right, outer transitions are tested first, but my problem is that when my stateflow diagram starts simulating, it evaluates the first transition, which is the default transition, and enters inside the superstate where that default transition points. After entering the superstate, it activates the substate (which does not execute, I don´t know why (by 'execute' I mean to compute the 'during' actions inside the substate)).
Having a fixed step of 0.2 seconds, it takes 0.2 seconds to do that.
The thing is that looking to the outer transitions between the superstates, the superstate that should be activated is not the one that has been activated in the first step (it has been activated by the default transition), but the other one.
In the next step, the outer transitions between superstates are evaluated and it activates the superstate and consequently the substate that I wanted to be activated in the first step. But as I said, it takes 2 steps (0.4 seconds) to do this, and not just 1 as I wanted.
So my question is: Is there any type of transition which is evaluated before the superstate pointed by the default transition is executed?
Thanks in advance.
Hi Iban,
Are you aware that you can set your chart to execute once during the initialization phase of the simulation? This would mean that, at time 0 of your simulation, your chart would already be in the default state (so time 0 would not be used to actually go to the default state).
To do this, select File --> Chart Properties and then enable the "Execute (enter) Chart At Initialization" option.
Let me know if that works for you :)
-Jarrod
Hi Jarrod,
That was great!! I´m quite new with Stateflow and I didn´t know that possibility.
Thanks a lot,
Iban

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Decision Logic에 대해 자세히 알아보기

질문:

2011년 5월 25일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by