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
modechartsdeclaration section can have itsExternalAccessattribute set toobserveornone, but not tomodify.The default
Accessattribute value ispublic, and the corresponding default value for theExternalAccessattribute ismodify. Therefore, if you do not set theAccessattribute for amodechartsdeclaration section, you must explicitly set itsExternalAccessattribute toobserveornone. For example:modecharts (ExternalAccess = observe) ... endIf you set the
Accessattribute toprivateorprotected, then the default value for theExternalAccessattribute isobserve. Therefore, you do not have to set theExternalAccessattribute value explicitly, for example:modecharts (Access = protected) ... endSet the
ExternalAccessattribute tononeif you do not want the mode chart to be visible anywhere outside the language. For example:modecharts (Access = private,ExternalAccess = none) ... end
Examples
Version History
Introduced in R2017a