Author and Simulate Basic Colors Sequence Diagram with Enumerations
This example shows how to author and simulate a sequence diagram containing a variable of datatype Simulink.IntEnumType
.
Define BasicColors.m
Enumeration
Create an enumeration
class called BasicColors
and define Red(0)
, Yellow(1)
, and Blue(2)
as the enumerated values.
classdef BasicColors < Simulink.IntEnumType enumeration Red(0) Yellow(1) Blue(2) end
Open Enumeration Example Model
Open the EnumExample.slx
architecture model that contains a sequence diagram that implements the BasicColors
enumeration.
model = systemcomposer.openModel("EnumExample");
Double-click the source
component to inspect the Stateflow® Chart (Stateflow) block.
The output data port, data
, is typed by the BasicColors
enumeration in this state chart where the color changes from Red
to Yellow
as the model simulates.
Open Enumeration Sequence Diagram
Navigate to Modeling > Sequence Diagram to open the Architecture Views Gallery and access the EnumSequenceDiagram
sequence diagram. Click Run to simulate the sequence diagram.
As the inEnum
destination port inherits a value of 1 from the BasicColors
enumeration, indicating a change from Red (0)
to Yellow (1)
, the sequence diagram executes successfully.
See Also
Tools
Functions
openViews
|sim
|getInteraction
|getInteractions
|open
|next
|current
|reset
Objects
systemcomposer.arch.Model
|systemcomposer.interaction.Interaction
|systemcomposer.interaction.Iterator
|systemcomposer.interaction.Lifeline
|systemcomposer.interaction.MessageEvent
|systemcomposer.interaction.FormalGate
|systemcomposer.interaction.Message
|systemcomposer.interaction.Fragment
|systemcomposer.interaction.RootFragment
|systemcomposer.interaction.AltFragment
|systemcomposer.interaction.OptFragment
|systemcomposer.interaction.LoopFragment
|systemcomposer.interaction.SeqFragment
|systemcomposer.interaction.StrictFragment
|systemcomposer.interaction.ParFragment
|systemcomposer.interaction.Operand
|systemcomposer.interaction.Annotation
|Simulink.SimulationInput
|Simulink.SimulationOutput
Related Topics
- Describe System Behavior Using Sequence Diagrams
- Pivot Between Lifelines and Components in Views Gallery
- Compose Architectures Visually
- Define Port Interfaces Between Components
- Implement Component Behavior Using Simulink
- Implement Component Behavior Using Stateflow Charts
- Implement Component Behavior Using Simscape