Stateflow    

Labeling States

Every state has a label. A state's label specifies its name and the actions executed when the state is entered, exited, or receives an event while it is active. How to edit the label and the contents it requires are described in the topics that follow.

For more information on state label concepts, see the following:

Editing a State Label

Initially, a state's label is empty. Stateflow indicates this by displaying a ? in the state's label position (upper left corner).

Label unlabeled states as follows:

  1. Select (left-click) the state.
  1. The state turns to its highlight color.

  1. Left-click the ? to edit the label.
  1. An editing cursor appears. You are now free to type a label.

To apply and exit the edit, deselect the object. To reedit the label, simply left-click the label text near the character position you want to edit.

You can also edit the state's label through the properties dialog for the state. See Changing State Properties.

State Label Format

State labels have the following general format.

The entries in this format have the following meanings:

Entry
Description
name
A unique reference to the state
entry actions
Actions executed when a particular state is entered as the result of a transition taken to that state
during actions
Actions that are executed when a state receives an event while it is active with no valid transition away from the state
exit actions
Actions executed when a state is exited as the result of a transition taken away from the state
on event_name actions
Actions executed when a state is active and the specified event event_name occurs
See Defining Events for information on defining and using events.

Entering the Name

Enter the state's name in the first line of the state's label. Names are case sensitive. To avoid naming conflicts, do not assign the same name to sibling states. However, you can assign the same name to states that do not share the same parent.

Entering Entry Actions

Entry actions begin on a new line and consist of the keyword entry (or just en), followed by a colon, followed by one or more action statements on one or more lines. You must separate statements on the same line by a comma or semicolon.

Entering During Actions

During actions have the same format as entry actions except that they begin with the keyword during or dur.

Entering Exit Actions

Exit actions have the same format as entry actions except that they begin with the keyword exit or ex.

Entering On Event_Name Actions

On event_name actions specify an event handler for a state. They have the same format as an entry actions except that they begin with the keyword on, followed by the name of the event, followed by a colon, for example:

A Stateflow diagram can respond to multiple events, with either the same or different actions, when a state is active. If you want more than one type of event to trigger the same action, specify on event_names, where event_names is a comma-separated list of the events that trigger the actions, for example:

If you want different events to trigger different actions, enter multiple on event_name blocks in the state's label, each specifying the action for a particular event or set of events, for example:


  Changing State Properties Outputting State Activity to Simulink