Identify Data by Using Dot Notation
To specify the path from the parent state to a data object, a qualified data name uses dot notation. Dot notation is a way to identify data at a specific level of the Stateflow® chart hierarchy. The first part of a qualified data name identifies the parent object. Subsequent parts identify the children along a hierarchical path.
For example, in this chart, the symbol data
resides in the substate
aa
of the state a
. The state and transition actions use
qualified data names to refer to this symbol.
In the default transition, the action uses the qualified data name
a.aa.data
to specify a path from the chart to the top-level statea
, to the substateaa
, and finally todata
.In state
a
, the entry action uses the qualified data nameaa.data
to specify a path from the substateaa
todata
.In state
b
, the entry action uses the qualified data namea.aa.data
to specify a path from the chart to the statea
, to the substateaa
, and then todata
.
Resolution of Qualified Data Names
During simulation, Stateflow resolves the qualified data name by performing a localized search of the chart hierarchy for a matching data object. The search begins at the hierarchy level where the qualified data name appears:
For a state action, the starting point is the state containing the action.
For a transition label, the starting point is the parent of the transition source.
The resolution process searches each level of the chart hierarchy for a path to the data. If a data object matches the path, the process adds that data object to the list of possible matches. Then, the process continues the search one level higher in the hierarchy. The resolution process stops after it searches the chart level of the hierarchy. If a unique match exists, the qualified data name resolves to the matching path. Otherwise, the resolution process fails. Simulation stops, and you see an error message.
This flow chart illustrates the different stages in the process for resolving qualified data names.
Best Practices for Using Dot Notation
Resolving qualified data names:
Does not perform an exhaustive search of all data.
Does not stop after finding the first match.
To improve the chances of finding a unique search result when resolving qualified data names:
Use specific paths in qualified data names.
Give states unique names.
Use states and boxes as enclosures to limit the scope of the path resolution search.
Examples of Qualified Data Name Resolution
Search Produces No Matches
In this chart, the entry action in state b
contains the qualified data
name aa.data
. If the symbol data
resides in state
aa
, then Stateflow cannot resolve the qualified data name.
This table lists the different stages in the resolution process for the qualified data
name aa.data
.
Stage | Description | Result |
---|---|---|
1 | Starting in state b , search for an object aa
that contains data . | No match found. |
2 | Move up to the next level of the hierarchy (the chart level). Search for an object
aa that contains data . | No match found. |
The search ends at the chart level with no match found for
aa.data
, resulting in an error.
To avoid this error, in the entry action of state b
, specify the data
with the more specific qualified data name a.aa.data
.
Search Produces Multiple Matches
In this chart, the entry action in state a
contains two instances of
the qualified data name aa.data
. If both states named aa
contain a data object named data
, then Stateflow cannot resolve the qualified data name.
This table lists the different stages in the resolution process for the qualified data
name aa.data
.
Stage | Description | Result |
---|---|---|
1 | Starting in state a , search for an object aa
that contains data . | Match found. |
2 | Move up to the next level of the hierarchy (the chart level). Search for an object
aa that contains data . | Match found. |
The search ends at the chart level with two matches found for
aa.data
, resulting in an error.
To avoid this error:
Use a more specific qualified data name. For instance:
To specify the data object in the substate of state
a
, use the qualified data namea.aa.data
.To specify the data object in the top-level state
aa
, use the qualified data name/aa.data
.
Rename one of the states containing
data
.Enclose the top-level state
aa
in a box or in another state. Adding an enclosure prevents the search process from detecting data in the top-level state.