Stateflow    

After Operator

Syntax

after(n, E)

where E is the base event for the operator and n is any expression that evaluates to a positive integer value.

Semantics

The after operator is true if the base event E has occurred n times since the operator's associated state was activated. Otherwise, it is false.

Usage

The following example illustrate use of the after operator in a transition expression.

This example permits a transition out of the associated state only if there have been 10 occurrences of the CLK event since the state was activated and the temp data item has the value COLD.

The next example illustrates usage of event notation for temporal logic conditions in transition expressions.

This example is semantically equivalent to the first example.

The next example illustrates setting a transition condition for any event visible in the associated state while it is activated.

This example permits a transition out of the associated state on any event after 10 occurrences of the CLK event since activation of the state.

The next two examples underscore the semantic distinction between an after condition on its own base event and an after condition on a nonbase event.

The first expression says that the transition must occur as soon as 10 CLK events have occurred after activation of the associated state. The second expression says that the transition may occur no sooner than 10 CLK events after activation of the state, but possibly later, depending on when the ROTATION event occurs.

The next example illustrates usage of an after event in a state's during action.

This example causes the Heater_on state to display a status message each CLK cycle, starting 5*BASE_DELAY clock cycles after activation of the state. Note the use of event notation to express the after condition in this example. Use of conditional notation is not allowed in state during actions.


 Temporal Logic Operators Before Operator