Aller au contenu principal

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.

Sequence diagram of the temperature sensor model.
Sequence diagram of the central control system.
Sequence diagram of the radiator.

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:

  1. In the left sidebar, under Project, click Resources, then open the Models tab.
  2. Click New to create a model, or Edit an existing one.
  3. In the General tab, set the model Name (e.g. Radiator).
Edit model dialog with the General tab open; the Name field is set to Radiator.
  1. 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.
Edit model dialog with the Data tab open; My_project.xml is uploaded.
  1. Open the Connectivity tab and click Add path to specify the path to the .exe file you previously generated from your model (e.g. Radiator_defaultNode_My_project in the Debug folder).
Edit model dialog with the Connectivity tab open.
  1. 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 ResourcesModelsEdit, then go to the Model Parts tab and click New:

Edit model dialog with the Model Parts tab open.
  • 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.
Model part configuration with Name Radiator and type Internal.
  • 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.
Model part configuration with type Other Model.
  • 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.
Model part configuration with Name Environment and type External.

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).
Radiator model Model Parts tab summary.
  • In the CentralControlSystem model: CentralControlSystem (Internal), Radiator and Temperature_Sensor (Other Model).
CentralControlSystem model Model Parts tab summary.
  • In the TemperatureSensor model: TemperatureSensor (Internal), CentralControlSystem (Other Model), Environment (External).
TemperatureSensor model Model Parts tab summary.
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 ResourcesModelsEdit, then go to the Flows tab. For each flow, click Edit (pencil icon):

Edit model dialog with the Flows tab open.

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

Edit flow transmit_heat dialog.

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):

  1. When prompted, choose Create to create a new controller, then click Create.
Create or reuse controller dialog.
  1. Step 1 — General information: set the controller Name (e.g. SendPowerCommandFromCCStoRadiator), then click Next.
Controller configuration step 1.
  1. 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.
Controller configuration step 2.
  1. 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.
Controller configuration step 3.

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.

Behaviours tab with two inter-model controllers.

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:

  1. From the project page, click + New Scenario.
  2. Enter a Scenario name (e.g. heating_system_Radiator).
  3. Optionally keep Open scenario after creation checked to open the scenario as soon as it is created.
  4. Optionally select Labels to apply to the scenario.
  5. Click Create Scenario.
Create New Scenario dialog.

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

  1. 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).
Model Instances tab with WS Radiator, WS CentralControlSystem and WS TemperatureSensor.
  1. For each model instance, open the menu and click Edit to open Model Instance configuration.

  2. 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.

  3. 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
Model Instance configuration for WS Radiator with model part instances.
  • WS CentralControlSystem: CentralControlSystem, Radiator, TemperatureSensor
Model Instance configuration for WS CentralControlSystem with model part instances.
  • WS TemperatureSensor: TemperatureSensor, Environment, CentralControlSystem
Model Instance configuration for WS TemperatureSensor with model part instances.

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.

Controller application configuration.

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.

  1. In any HMI environment, in Edit Mode, add a Sequence Diagram by drag & dropping the element. It should display "No Selected Life Line".
Sequence Diagram drag and drop.
  1. 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.
Context menu with Edit Parts and Flows under Diagram.
  1. 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.
Edit Diagram Parts and Flows dialog with model parts and flows selected.
Note

You can still change the order later by right-clicking on the sequence diagram and choosing Edit Parts and Flows.

Note

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.

  1. The sequence diagram is updated with the selected lifelines and flows.
Configured sequence diagram with Environment, TemperatureSensor, CentralControlSystem and Radiator lifelines.

Run the scenario

  1. 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.
User Request trigger button.
  1. Run the scenario. After the initial temperature acquisition from the Environment, the scenario should unfold, displaying the different flows step by step.
Final visualized sequence diagram.

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.