Main Content

Use Sequence Diagrams in the Views Gallery

You can author sequence diagrams to describe expected system behavior as a sequence of interactions between components of a System Composer™ architecture model. New lifelines or messages authored on the sequence diagram are automatically reflected in the model. Incorporate model elements in a sequence diagram associated with the model the elements are from. You can create multiple sequence diagrams to represent different operational scenarios of the system.

Sequence diagrams are integrated into the Architecture Views Gallery in System Composer. Lifelines in a sequence diagram correspond to components in an architecture model. Messages in a sequence diagram correspond to the connectors between components in an architecture model.

In this example, you will learn about using sequence diagrams in System Composer with emphasis on how to:

  • Create a sequence diagram and co-create components and connections.

  • Add child lifelines in a sequence diagram.

  • Keep the architecture model and the sequence diagram in sync.

Create a Sequence Diagram

Create a basic architecture model in System Composer.

Architecture model with a sensor and power source.

In the menu, navigate to Views > Architecture Views to open up the Architecture Views Gallery for your model. Select New Sequence Diagram under the new button to create a new sequence diagram.

Select Add Lifeline button from the menu. A box with a vertical dotted line appears on the canvas. This is the new lifeline. Click the down arrow on the lifeline to view available options. Select the component named Sensor to be represented by the lifeline.

A sequence diagram with one sensor lifeline.

Create Sequence Diagram Gates

Select the gutter region, click, and drag to the lifeline. Name the To port Source and the From port Grid. See that a gate called Grid has been created with a message ending on the Sensor lifeline at the port Source.

Message created from root gate grid to message end on lifeline sensor source.

Return to the architecture diagram. Observe that Grid is a root architecture port connected to the Sensor component.

The architecture diagram shows the corresponding structures from the sequence diagram.

Add Child Lifelines in a Sequence Diagram

You can add child lifelines to a sequence diagram to represent model hierarchy and describe the interactions between them.

Select Component > Add Lifeline button from the toolstrip menu. From the list that appears, select the PowerSource component.

Selecting power source as the second lifeline in the sequence diagram.

Child components called Battery and Charger are located inside the PowerSource component.

The power source component with a battery and charger as children.

Select the PowerSource lifeline. Click the down arrow below Component > Add Lifeline, then select Add Child Lifeline Select Battery. The Battery child lifeline is now situated below PowerSource in the hierarchy.

Adding a child lifeline to power source with options battery and charger.

Co-Create Components

The co-creation workflow between the sequence diagram and the architecture model keeps the model synchronized as you make changes to the sequence diagram. Adding both lifelines and messages in a sequence diagram results in updates to the architecture model. This example shows component co-creation.

Select Component > Add Lifeline from the menu. Another box with a vertical dotted line appears on the canvas. In the lifeline box, enter the name of a new component named Machine.

A new component as a lifeline in the sequence diagram machine has been created.

Observe that the Machine component is co-created in the architecture diagram.

A new component has been added to the architecture diagram called machine.

Synchronize Between the Sequence Diagram and the Model

Remove the Machine component from the architecture diagram. Return to the sequence diagram and select Synchronize > Check Consistency. See that the Machine lifeline is highlighted, as it has no corresponding architectural component.

The machine lifeline is not consistent in the sequence diagram.

To restore the Machine component, either remove the Machine lifeline or select the undo button in the architecture model. Click Check Consistency again.

Create Messages in the Sequence Diagram

You can create a message from an existing connection. Draw a line from the Sensor lifeline to the PowerSource lifeline. Start to type InBus, which will automatically fill in as you type. When it does, select InBus.

Add the message between the in bus and out bus ports between lifelines.

The message is created in the sequence diagram.

Added message between the in bus and out bus ports between lifelines.

For more information on using message conditions, fragments, operands, and operand conditions in a sequence diagram, see Define Sequence Diagrams.

Click and Drag from the Model Browser

The Views Gallery model browser located on the bottom left of the canvas, is called Model Components. Click and drag the Charger child component into the sequence diagram.

Click and drag the charger component into the sequence diagram from the model browser.

The sequence diagram is updated with a new component.

The final sequence diagram with all model components.

Use Sequence Diagrams in the Views Gallery Example

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('ArchModel');

Open the Architecture Views Gallery to view the sequence diagram.

openViews(model);

Create a Sequence Diagram from a View

In the MATLAB® Command Window, enter scKeylessEntrySystem. The architecture model opens in the Simulink Editor.

In the menu, navigate to Views > Architecture Views to open the Architecture Views Gallery for the model.

Right-click the Sound System Supplier Breakdown view and select New Sequence Diagram.

Create a new sequence diagram from contents of view.

A new sequence diagram of lifelines is created with all the components from the view.

Created sequence diagram from view.

Related Topics