Implicit eventsare built-in events that occur during chart execution when:
The chart wakes up.
The chart enters a state and the state becomes active.
The chart exits a state and the state becomes inactive.
The chart assigns a value to an internal data object.
这些事件是隐式的,是因为你不define or trigger them explicitly. Implicit events are children of the chart in which they occur and are visible only in the parent chart.
The keywordtick
specifies the implicit event generated when a chart wakes up in a discrete-time simulation.
For example, in this chart,Fan
andHeater
are parallel (AND) states. Each state has a pair of substates,On
andOff
. Initially, the substatesFan.Off
andHeater.Off
are active. Each time the chart wakes up, it generates atick
event. The thirdtick
triggers the transition fromHeater.Off
toHeater.On
. Similarly, the fourthtick
triggers the transition fromFan.Off
toFan.On
. On the eighthtick
, the chart transitions back toFan.Off
andHeater.Off
.
For information about the temporal logic operatorafter
, seeControl Chart Execution by Using Temporal Logic.
Note
Thetick
event refers to the chart containing the action being evaluated. The event cannot refer to a different chart.
In Stateflow®charts in Simulink®models, these operators generate implicit events when a chart sets the value of a variable or when a chart enters or exits a state.
Operator | Syntax | Description | Example |
---|---|---|---|
change |
|
Generates an implicit local event when the chart sets the value of the variabledata_name . The variabledata_name cannot be machine-parented data. This implicit event works only with data that is at the chart level or lower in the hierarchy. For machine-parented data, use change detection operators to determine when the data value changes. For more information, seeDetect Changes in Data and Expression Values. |
Define an implicit local event when a state or transition action writes a value to the variable change(Engine.rpm) |
enter |
|
Generates an implicit local event when the specified statestate_name becomes active. |
Define an implicit local event when the chart execution enters the state enter(Fan.On) |
exit |
|
Generates an implicit local event when the specified statestate_name becomes inactive. |
Define an implicit local event when the chart execution exits the state exit(Fan.Off) |
If more than one state or data object has the same name, use dot notation to qualify the name of the state. For more information, seeIdentify Data by Using Dot Notation.
For example, in this chart,Fan
andHeater
are parallel (AND) states. Each state has a pair of substates,On
andOff
. Initially, the substatesFan.Off
andHeater.Off
are active. When the chart wakes up, it generates atick
event that triggers the transition fromFan.Off
toFan.On
. When theFan.Off
becomes inactive, the chart generates another implicit event that triggers the transition fromHeater.Off
toHeater.On
. When the chart execution ends, the substatesFan.On
andHeater.On
are active.
Note
如果相同的隐式活动组织ers multiple transitions in parallel states, the order in which the transitions execute does not necessarily match the execution order of the parallel states. To avoid unexpected behavior and ensure that the transitions execute in the order specified for the parallel states, do not use implicit events. Instead, use transition conditions that call operators such asin
orhasChanged
. For more information, seeCheck State Activity by Using the in OperatorandDetect Changes in Data and Expression Values.
after|change|enter|exit|hasChanged|in