Main Content

transitions

Define transitions between modes in mode chart

Syntax

transitions from_mode -> to_mode : predicate_condition end     

Description

transitions begins a transitions declaration block in a mode chart. The transitions block, terminated by an end keyword, can contain one or more transition constructs.

Generally, each transition construct has the following syntax:

from_mode -> to_mode : predicate_condition

where:

  • from_mode is the mode active before the transition.

  • to_mode is the mode active after the transition.

  • predicate_condition is the expression that needs to be true for the transition to happen.

For example, if a mode chart declares two modes, m1 and m2, the following syntax specifies that the system transitions from mode m1 to mode m2 when the p1 predicate is true:

transitions
    m1 -> m2 : p1
end

To implement a state reset, mode charts can contain instantaneous modes and compound transitions. Compound transitions have the following syntax:

from_mode -> instantaneous_mode -> to_mode : predicate_condition

where:

  • from_mode is the mode active before the transition.

  • instantaneous_mode is the mode active for one event iteration during the transition. Only one instantaneous mode is allowed per transition, therefore, a compound transition cannot contain more than three modes.

  • to_mode is the mode active after the transition. For a compound transition, to_mode can be the same as from_mode.

  • predicate_condition is the expression that needs to be true for the transition to happen.

For example, in this compound transition, when predicate t becomes true, the system transitions from mode A to mode B, performs one event iteration, and then immediately transitions to mode C.

A -> B -> C : t

Transition Precedence and Execution Rules

If multiple predicates become true simultaneously, the transition priority is defined by the order they are listed. For example, a mode chart declares three modes, m1, m2, and m3, and defines the following transitions:

transitions
    m1 -> m2 : p1
    m1 -> m3 : p2
end

If predicates p1 and p2 become true simultaneously, the system transitions from mode m1 to mode m2 (the first transition listed).

At initialization time, the solver sets the initial mode first, and then checks the transitions. If a transition predicate is true at initialization time, the system might start in a different mode than that listed first (or specified by the initial construct). For example, consider a mode chart that declares two modes, m1 and m2, and defines the following transition:

transitions
    m1 -> m2 : p1
end

If predicate p1 is true at initialization time, the system immediately transitions from mode m1 (the first mode listed) to mode m2, and simulation starts in mode m2.

Similarly, if a transition predicate is still true after completing the transition, the system can enter an infinite loop and eventually generate an error. This modeling error is more prevalent with compound transitions, where, after completing the transition, the system often ends up in the same mode where it was before entering the transition. To avoid this situation, try to model compound transitions in such a way that the instantaneous mode invalidates the predicate. For more information, see State Reset Example.

Version History

Introduced in R2017a