Contents

Control Chart Execution Using Implicit Events

What Are Implicit Events?

Implicit events are built-in events that occur when a chart executes:

  • Chart waking up

  • Entry into a state

  • Exit from a state

  • Value assigned to an internal data object

These events are implicit because you do not define or trigger them explicitly. Implicit events are children of the chart in which they occur and are visible only in the parent chart.

Keywords for Implicit Events

To reference implicit events, action statements use this syntax:

event(object)

where event is the name of the implicit event and object is the state or data in which the event occurs.

Each keyword below generates implicit events in the action language notation for states and transitions.

Implicit Event

Meaning

change(data_name) or chg(data_name)

Specifies and implicitly generates a local event when Stateflow® software writes a value to the variable data_name.

The variable data_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, see Detect Changes in Data Values.

enter (state_name) or en(state_name)

Specifies and implicitly generates a local event when the specified state_name is entered.

exit (state_name) or ex(state_name)

Specifies and implicitly generates a local event when the specified state_name is exited.

tick

Specifies and implicitly generates a local event when the chart of the action being evaluated awakens.

wakeup

Same as the tick keyword.

If more than one object has the same name, use the dot operator to qualify the name of the object with the name of its parent. These examples are valid references to implicit events:

enter(switch_on)
en(switch_on)
change(engine.rpm)

    Note:   The tick (or wakeup) event refers to the chart containing the action being evaluated. The event cannot refer to a different chart by argument.

Transition Between States Using Implicit Events

This example illustrates use of implicit tick events.

Fan and Heater are parallel (AND) superstates. The first time that an event awakens the Stateflow chart, the states Fan.Off and Heater.Off become active.

Assume that you are running a discrete-time simulation. Each time that the chart awakens, a tick event broadcast occurs. After four broadcasts, the transition from Fan.Off to Fan.On occurs. Similarly, after three broadcasts, the transition from Heater.Off to Heater.On occurs.

For information about the after operator, see Control Chart Execution Using Temporal Logic.

Execution Order of Transitions with Implicit Events

Suppose that:

  • Your chart contains parallel states.

  • In multiple parallel states, the same implicit event is used to guard a transition from one substate to another.

When multiple transitions are valid in the same time step, the transitions execute based on the order in which they were created in the chart. This order does not necessarily match the activation order of the parallel states that contain the transitions. For example, consider the following chart:

When the transition from IV.HERE to IV.THERE occurs, the condition ex(IV.HERE) is valid for the transitions from A to B for the parallel states I, II, and III. The three transitions from A to B execute in the order in which they were created: in state I, then II, and finally III. This order does not match the activation order of those states.

To ensure that valid transitions execute in the same order that the parallel states become active, use the in operator instead of implicit enter or exit events:

With this modification, the transitions from A to B occur in the same order as activation of the parallel states. For more information about the in operator, see Check State Activity.

Was this topic helpful?