Somethig wrong in document "Workflow for Exiting a State" in Stateflow

4 次查看(过去 30 天)
in the document stateflow--->chart programming-----> chart simulation semantics----->chart execution------<exit state>, if the current state is not a superstate of the destination state, then go to "perform exit actions of the current state and mark state as inactive". But when click "step in" to check the workflow, I found that stateflow will first perform the exit actions of the child state of the current state, then perform the exit actions of the current state. Is the flow chart in the document wrong ?

回答(1 个)

Purvaja
Purvaja 2025-4-29
Understanding from your question, I guess you are referring to the flowchart given in the link below:
You meant to say that if the condition “Is the current state a superstate of the destination state? does not satisfy, it should “perform exit actions of the current state and mark state as inactive”. But when you tried, you found out that Stateflow will perform the exit actions of the child state of the current state, then perform exit actions of the current state.
Well, that might be because your child state is not the destination state.
I think you have misunderstood the flowchart. The flowchart explains that:
  1. If the current state is a superstate of the destination state, then the current state will not perform exit actions since one of its substates is still active (destination state of the transition). As, given in Simulink documentation (https://www.mathworks.com/help/stateflow/ug/what-do-semantics-mean-for-stateflow-charts.html#:~:text=If%20there%20are%20any%20active%20children%2C%20perform%20the%20exit%20steps%20on%20these%20states%20in%20the%20reverse%20order%20that%20they%20became%20active) a state will become inactive only if all the substates are exited and have become inactive.
Like in this example: Here the destination state is state A2, and so the state A is still active as one of its substate A2 is active.
  1. Whereas if the current state is not a superstate of the destination state, then the current state will become inactive after performing exit actions of all the sub states and ensure they are inactive.
Like in this example: State A has exited and became inactive only after both its substates A1 and A2 has become inactive. Whereas state B being the destination state of the transition is still active.
I hope this helps you. Do share more details and links if you have more doubts regarding this.

类别

Help CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by