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 itsExternalAccess
attribute set toobserve
ornone
, but not tomodify
.The default
Access
attribute value ispublic
, and the corresponding default value for theExternalAccess
attribute ismodify
. Therefore, if you do not set theAccess
attribute for amodecharts
declaration section, you must explicitly set itsExternalAccess
attribute toobserve
ornone
. For example:modecharts (ExternalAccess = observe) ... end
If you set the
Access
attribute toprivate
orprotected
, then the default value for theExternalAccess
attribute isobserve
. Therefore, you do not have to set theExternalAccess
attribute value explicitly, for example:modecharts (Access = protected) ... end
Set the
ExternalAccess
attribute tonone
if 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