This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

How Events Work in Stateflow Charts

What Is an Event?

An event is a Stateflow® object that can trigger actions in one of these objects:

  • A Simulink® triggered subsystem

  • A Simulink function-call subsystem

  • A Stateflow chart

When to Use Events

Use events when you want to:

Although Stateflow software does not limit the number of events you can use in a chart, the underlying C compiler enforces a theoretical limit of (2^31)-1 events for the generated code.

 When should I use conditions instead of events?

Types of Events

An explicit event is an event that you define and can have one of the following scopes.

LocalEvent that can occur anywhere in a Stateflow machine but is visible only in the parent object (and descendants of the parent). See Directed Event Broadcasting.
Input from SimulinkEvent that occurs in a Simulink block but is broadcast to a Stateflow chart. See Activate a Stateflow Chart Using Input Events.
Output to SimulinkEvent that occurs in a Stateflow chart but is broadcast to a Simulink block. See Activate a Simulink Block Using Output Events.

An implicit event is a built-in event that broadcasts automatically during chart execution (see Control Chart Execution Using Implicit Events).

Where You Can Use Events

You can define explicit events at these levels of the Stateflow hierarchy.

An event you define in a...Is visible to...
ChartThe chart and all states and substates
SubchartThe subchart and all states and substates
StateThe state and all substates

Diagnostic for Detecting Unused Events

If you have unused events in your chart, a warning message appears during simulation with a list of events you can remove. By removing objects that have no effect on simulation, you can reduce the size of your model. This diagnostic checks for usage of Stateflow events, except for the following types:

  • Function-call input events

  • Edge-triggered input events

After you select an event for removal, a dialog box confirms your choice. In this dialog box, you can specify that other deletions occur without confirmation. If you prevent the confirmation dialog box from appearing, you can reenable it at any time by typing at the command prompt:

sfpref('showDeleteUnusedConfGui', 1)

You can control the level of diagnostic action for unused events in the Diagnostics > Stateflow pane of the Model Configuration Parameters dialog box. For more information, see the documentation for the Unused data, events, messages, and functions (Simulink) diagnostic.

Was this topic helpful?