Main Content

modecharts

Declare mode charts that include operating modes and transitions

Parent Section: component

Syntax

modecharts (ExternalAccess = value)
    mc1 = modechart
    ...
    end
end

Description

modecharts begins a mode charts declaration section, which is terminated by an end keyword. modecharts is a top-level section in a component file. It can contain one or more modechart constructs. Each modechart construct declares one mode chart. A mode chart declaration must describe a complete set of operating modes and transition rules between these modes.

For example, the following syntax declares two mode charts, mc1 and mc2.

modecharts (ExternalAccess = observe)
    mc1 = modechart
    ...
    end
    mc2 = modechart
    ...
    end
end

modechart is a named construct. It is terminated by an end keyword. A modechart construct contains a complete textual representation of the mode chart: modes, transitions, and an optional initial mode specification. If you omit the initial mode specification, then the first mode listed in the modes section is active at the start of simulation.

modecharts (ExternalAccess = observe)
     mc1 = modechart
        modes
           ...        
	  end
        transitions
           ...
        end
        initial
           ...
        end
     end
end

A mode chart is defined within the scope of its parent component. In other words, its equations and predicates reference the component members, such as parameters and variables.

For a detailed example of using modecharts, see Switch with Hysteresis.

Member Accessibility Attribute Values

A modecharts declaration section has the following attributes:

  • Access — Defines the read and write access.

  • ExternalAccess — Sets the visibility in the user interface.

A mode chart cannot be modifiable in the user interface. Therefore, the following rules apply:

  • A modecharts declaration section can have its ExternalAccess attribute set to observe or none, but not to modify.

  • The default Access attribute value is public, and the corresponding default value for the ExternalAccess attribute is modify. Therefore, if you do not set the Access attribute for a modecharts declaration section, you must explicitly set its ExternalAccess attribute to observe or none. For example:

    modecharts (ExternalAccess = observe)
       ...
    end
    
  • If you set the Access attribute to private or protected, then the default value for the ExternalAccess attribute is observe. Therefore, you do not have to set the ExternalAccess attribute value explicitly, for example:

    modecharts (Access = protected)
       ...
    end
    

    Set the ExternalAccess attribute to none if you do not want the mode chart to be visible anywhere outside the language. For example:

    modecharts (Access = private,ExternalAccess = none)
       ...
    end
    

Version History

Introduced in R2017a