The Stateflow® API does not currently support the direct creation of supertransitions. Supertransitions are transitions between different levels in a chart. A supertransition can be between a state in a top-level chart and a state in one of its substates, or between states residing in different substates. For a better understanding of supertransitions, see Move Between Levels of Hierarchy by Using Supertransitions.
You can use a workaround for indirectly creating supertransitions. In this example, a supertransition is desired from a junction inside a subchart to a junction outside the subchart. In order to use the Stateflow API to create the supertransition in this example, first use the API to create the superstate as an ordinary state with a transition between its contained junction and a junction outside it.
Now set the IsSubchart
property of the state A to
true
.
This step makes state A
a subchart, and the transition between the
junctions is now a supertransition.
You can also connect supertransitions to and from objects in an existing subchart
(state A
, for example) with these steps:
Save the original position of subchart A
to a temporary workspace variable.
For example, if the subchart A
has the API handle
sA
, store its position with this
command:
sA_pos = sA.Position;
Convert subchart A
to a state by setting
the IsSubchart
property to
false
.
sA.IsSubchart = false;
Ungroup state A
by setting the
IsGrouped
property to
false
.
sA.IsGrouped = false;
Make the necessary transition connections.
See Create Charts by Using the Stateflow API for an example of creating a transition.
Set the IsSubchart
property of state
A
back to true (=1). For example,
sA.IsSubchart = 1;
Assign subchart A
its original
position.
sA.Position = sA_pos;