| Stateflow User's Guide | ![]() |
Adding Event Triggers to Transitions
If you want a transition to respond only to a specific event, you specify an event trigger for the transition in its label. An event trigger limits the response of its transition to the occurrence of the named event.
In this topic, you add an event trigger to each of the transitions between the On and Off states of the Controller Stateflow diagram with the following steps:
SFcontrol1 you build in Building an On-Off Control Model and save it as SFcontrol2.
?) appears next to the point on the transition that you clicked as shown.
The transition label that you entered (on_switch) is an event trigger. Event triggers are part of the syntax for transition labels. A transition event trigger watches for the event it is named after. If the event on_switch occurs and the Off state is active, the transition to the On state is taken. The transition is not taken for any other event. This provides the Stateflow diagram the ability to change the active state from the Off state to the On state when it receives a specific event that is meant to turn the device on.
on_switch label to a point outside its transition and then click an empty part of the diagram.
off_switch as shown.
Event triggers control the execution of the transitions that they guard. Before you added the event triggers, the transitions from the Off to the On state and the On to the Off state take place in response to any event. Now the Stateflow diagram responds only to the events named in the event triggers.
| Guarding Transitions with Event Triggers | Adding Multiple Trigger Events to a Stateflow Chart | ![]() |
© 1994-2005 The MathWorks, Inc.