Visualize using a sequence diagram
Presentation
This tutorial focuses on using the sequence diagram object in Virtual Bench to visualize dynamic system interactions. At its core, this virtual bench element represents lifelines, where flows appear dynamically during the visualization. In this tutorial, we will focus on the specific usage of the sequence diagram to represent the inter-system connections between models that the user has previously created. For this, we will go through the example of a Heating System.
Preparing the Models in Papyrus Designer
First, the user must have designed several models within Papyrus Designer. Each model will correspond to a lifeline in the visualized sequence diagram. The Heating System is divided into the following models:
- A Temperature Sensor, for the System to understand its Environment in order to adjust the system.
- A Central Control System, to receive data, make decisions, and control the System.
- A Radiator, connected to the Central Control System, receiving the orders, and producing heat. It is possible to instantiate the Radiator several times for the visualization. This means that the Central Control System may communicate to more than one Radiator.
Here is an example of the set of models you can aim for in this tutorial.



Creating a Visualization in Virtual Bench
Preparing the visualization
When your models are ready, generate each executable and export each .xml file. You can now transition to the visualization in Virtual Bench.
Configuring the new executables in Virtual Bench
Follow these steps to properly configure the new executables in Virtual Bench.
Step 1: Create new executables
Open Virtual Bench and, for each model, configure it in Project Resources:
- In the left sidebar, under Project, click Resources, then open the Models tab.
- Click New to create a model, or Edit an existing one.
- In the General tab, set the model Name (e.g. Radiator).

- In the Data tab, import the previously generated XML file (here My_project.xml): drag and drop the file into the import area, or click Browse files. Once the file is uploaded, review the Model Data Comparison if needed, then click Confirm Import.

- Open the Connectivity tab and click Add path to specify the path to the
.exefile you previously generated from your model (e.g. Radiator_defaultNode_My_project in the Debug folder).

- Click Save to confirm the model configuration.
Step 2: Complete Flow Configurations
Create the Model Parts
We will have to create Model Parts manually. A Model Part is what will allow the sequence diagram to understand what should be treated as a lifeline.
For each model, open Project Resources → Models → Edit, then go to the Model Parts tab and click New:

- Add an internal Model Part for the system defined by the model (e.g. a Radiator internal model part in the Radiator model). Set the Name (e.g. Radiator) and choose type Internal, then click Save.

- Only after creating all necessary internal Model Parts in every model, add a Model Part for every system each model interacts with (e.g. a CentralControlSystem model part in the Radiator model). Choose type Other Model, then select the Linked Model and Linked Model Part, and click Save.

- Also add external model parts for external actors that are not another model (e.g. the Environment model part in the Radiator model). Set the Name (e.g. Environment) and choose type External, then click Save.

Repeat these steps for every model in the project (Radiator, CentralControlSystem, TemperatureSensor, etc.).
Here is an example of what it could look like after creating all the needed Model Parts:
- In the Radiator model: Radiator (Internal), Model part 1 (Other Model → CentralControlSystem), Environment (External).

- In the CentralControlSystem model: CentralControlSystem (Internal), Radiator and Temperature_Sensor (Other Model).

- In the TemperatureSensor model: TemperatureSensor (Internal), CentralControlSystem (Other Model), Environment (External).

Configure the flows in each model
Each flow is defined by a source and a target, both based on Model Parts. These need to be explicitly configured.
For each model, open Project Resources → Models → Edit, then go to the Flows tab. For each flow, click Edit (pencil icon):

Select the correct Sources and Targets for the flow, then click Save. For example, for transmit_heat: source Radiator, target Environment.

Apply these steps for each flow in every model.
Mappings
Each flow that travels from one model to another must be linked through a controller. The controller listens to a flow on the source model and triggers the corresponding flow on the target model.
Create a controller for each inter-model link (for example, from CentralControlSystem to Radiator):
- When prompted, choose Create to create a new controller, then click Create.

- Step 1 — General information: set the controller Name (e.g. SendPowerCommandFromCCStoRadiator), then click Next.

- Step 2 — Event configuration: set the triggering Model and Flow on the source model (e.g. Heating_System CentralControlSystem, event Send Flow, flow send_temperature_data), then click Next.

- Step 3 — Sequence diagram: add an action from the controller to the target model and define the mapping (e.g. send send_power_command to heating_system Radiator with
value = Heating_System CentralControlSystem send_temperature_data.value), then finish the wizard.

Repeat these steps for all the inter-model links that you can think of. In our case, there are only two: SendTemeratureData Application 1 and SendPowerCommand Application 1, visible in the Behaviours tab once the controllers are applied.

You will apply each controller in the scenario after adding the model part instances (see below).
Creating a New Scenario in Virtual Bench
Create a new scenario in Virtual Bench:
- From the project page, click + New Scenario.
- Enter a Scenario name (e.g. heating_system_Radiator).
- Optionally keep Open scenario after creation checked to open the scenario as soon as it is created.
- Optionally select Labels to apply to the scenario.
- Click Create Scenario.

Before creating and using the sequence diagram, you will need to instantiate the previously created model parts in your scenario, then apply the controllers you created for inter-model mappings.
Step 1: Add model part instances
- In the scenario, open the Model Instances tab and create a model instance for each model using + (e.g. WS Radiator, WS CentralControlSystem, WS TemperatureSensor).

-
For each model instance, open the ⋮ menu and click Edit to open Model Instance configuration.
-
Open the Model parts instances tab and click + New for each model part to instantiate. Choose the model part and click Save. If the model part references another model, select the related model instance when asked.
-
Repeat for every model instance until all model parts are configured. Here is what it should look like for each model:
- WS Radiator: Radiator, CentralControlSystem, Environment

- WS CentralControlSystem: CentralControlSystem, Radiator, TemperatureSensor

- WS TemperatureSensor: TemperatureSensor, Environment, CentralControlSystem

Step 2: Apply controllers
For each controller created in the Mappings section, open the Controller application configuration, select the controller to apply, then assign the Trigger websocket (source model, e.g. WS CentralControlSystem) and the Action websocket (target model, e.g. WS Radiator). Click Save.

Repeat for every inter-model controller. In our case, there are only two (see the Behaviours tab summary in the Mappings section above).
Step 3: Set up the Sequence Diagram
In our case, we will be configuring the Sequence Diagram, to visualize operational flows between our models.
- In any HMI environment, in Edit Mode, add a Sequence Diagram by drag & dropping the element. It should display "No Selected Life Line".

- Right-click the Sequence Diagram element and choose Edit Parts and Flows in the Diagram section. You can also select the element or double-click it, then open the Diagram flows tab in the right-hand panel.

- In the Edit Diagram Parts and Flows dialog, select all model part instances in the order you want them to appear from left to right, then select all eligible flows you want in the visualization. In our case, select them all. Click Save.

You can still change the order later by right-clicking on the sequence diagram and choosing Edit Parts and Flows.
External actors such as "Environment", whose Model Parts have been instantiated more than once, may appear several times. If you gave them the same name (in our case "Environment"), such actors will be merged and appear as one unique lifeline.
- The sequence diagram is updated with the selected lifelines and flows.

Run the scenario
- Create a way to trigger the first flows of your scenario. In our case, the Environment giving its measure to the temperature sensor should be the initial trigger. Create a button to visualize the initial trigger, along with the associated mapping.

- Run the scenario. After the initial temperature acquisition from the Environment, the scenario should unfold, displaying the different flows step by step.

Conclusion
By following this tutorial, you've learned how to visualize dynamic system interactions at an operational level, using sequence diagrams in Virtual Bench. After configuring your scenario and flows, you were able to create a sequence diagram that visualizes how models interact with each other. You should now be able to use this knowledge with more complex sequences.