A sequence diagram is a behavior diagram that represents the interaction between structural elements of an architecture as a sequence of message exchanges. You can use sequence diagrams to describe how the parts of a static system interact.
You can use sequence diagrams in System Composer™ by accessing the Architecture Views Gallery. Sequence diagrams are integrated with architecture models. For more information on how to create and use sequence diagrams with an architectural model, see Use Sequence Diagrams in the Views Gallery.
In this example, you will learn about the basic terminology and functions of a sequence diagram in two stages.
Add lifelines and messages with trigger conditions and constraint conditions to represent interactions.
Include fragments and operands with constraint conditions to further specify the behavior of the interaction.
Create a new sequence diagram by navigating to Views > Architecture Views. The Architecture Views Gallery opens. Select New Sequence Diagram under the button to create a new sequence diagram.
A new sequence diagram called
SequenceDiagram is created in the
View Browser and the Sequence Diagram tab becomes active. Select Component >
to add an element lifeline. A new lifeline with a
vertical dashed line is created without a name.
Name the lifeline
Element 1 and create a second lifeline,
Select the vertical dotted line for the
Element 1 lifeline. Click
and drag to the
Element 2 lifeline. Specify the
To and From message ends as
Click on the message to see where to place the message condition. Enter a trigger condition with one of the following trigger events:
For example, the message trigger condition could be specified as follows:
falling(In.elem1 + 5)
The signal name
In.elem1 must be a signal element in a signal
interface associated with the port. For more information on interface management, see
The trigger condition must be in this form:
triggerEvent(signalName (+|-) positiveReal)
A message trigger condition activates on a zero-crossing event when the value of the port signal is zero, starting from the specified value.
Add a constraint condition using a MATLAB® boolean expression in square brackets. Constraint conditions consist of a boolean expression acting on a signal name.
[In.elem2 >= 1]
The constraint condition is an additional check after the trigger condition.
Only destination elements are supported for trigger conditions and constraints. In
Out is a source element and cannot be
You can use composite fragments to enable control structures in sequence diagrams. Operands within composite fragments can be further specified with operand conditions composed of MATLAB boolean expressions between signal names.
To access a menu of fragments:
Click and drag to select the message.
Pause on the ellipsis (...) that appears to access the action bar.
A list of composite fragments appears:
Alt Fragment fragment is added to the sequence diagram
Select the composite fragment to enter an operand condition. Choose a fully qualified signal name and use a constraint condition relation.
Element 2/In.elem2 > 0
The constraint determines when the alternative operand is accepted.
The message inside the operand can be executed only if the constraint condition is true.
Highlight the first operand under the
Alt Fragment composite
fragment and select Fragment > Add Operand > Insert After. A
second operand is added.
Add a constraint condition relation to the second operand.
Element 2/In.elem1 ~= 5
The second operand in an
Alt Fragment fragment represents an
elseif condition for which the message will not be executed.
You can view the final product of the workflow example for this topic.
Open the System Composer model that contains the sequence diagram.
model = systemcomposer.openModel('ArchModelDefine');
Open the Architecture Views Gallery to view the sequence diagram.