Aller au contenu principal

Simulate using a sequence diagram

Presentation

This tutorial focuses on using the sequence diagram object in Virtual Bench to visualize and simulate dynamic system interactions. At its core, this virtual bench element represents lifelines, where flows appear dynamically during the simulation. 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 simulated 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 simulation. 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, in which it measures data and transmit it to the central control system . Sequence diagram of the central control system in which the temperature sensor measures data and transmit it to the central control system which then choose to send a power command to the radiator. Sequence diagram of the radiator, in which the power command is received and allows the radiator to adjust its heat production.

Creating a Simulation in Virtual Bench

Preparing the simulation

When your models are ready, generate each executable and export each .xml file. You can now transition to the simulation 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, create a new executable:

While the Project tab is opened, a small '+' sign is highlighted in front of the Executables folder.
  • Name the new executable (e.g. Radiator), and specify the path to the .exe file you previously generated from your model (in order to use the launcher).
  • Import the previously generated XML file (Here Radiator.xml).

Step 2: Complete Flow Configurations

  1. 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 (therefore, for each executable in Virtual Bench), add an internal Model Part of the system defined by the executable. (e.g. A radiator internal model part in the Radiator executable.)

      In the Radiator Executable, one of the folder called Model Parts has an highlighted '+' icon next to it. In the Model Part Configuration Radiator, the title of the model part is Radiator, and internal has been selected as type.
    • Only after creating all necessary internal Model Parts in every executable, add a Model Part for every system each executable interacts with. (e.g. A CentralControlSystem model part in the Radiator executable.). Choose the Other Model type and select the correct Model Part Link, in the referenced executable.

      In the Model Part Configuration Radiator, the title of the model part is CentralControlSystem, and Other Model has been selected as type.
    • Also add external model parts in case you have external actors that are not another executable. (e.g. The Environment model part in the Radiator executable.)

      In the Model Part Configuration Radiator, the title of the model part is Environment, and External has been selected as type.

    Here is an example of what it could look like after creating all the needed Model Parts:

    In the Radiator executable, the Radiator is set as Internal and the CentralControlSystem is set as Other Model. In the CentralControlSystem executable, the CentralControlSystem is set as Internal, and the Radiator and the Temperature Sensor are set as Other Model. In the TemperatureSensor executable, the TemperatureSensor is set as Internal, and the CentralControlSystem is set as Other Model.
  2. Configure the flows in the executable:

    Each flow is defined by a source and a target, both of which are based on Model Parts. However, these need to be explicitly configured.

    • For each flow of each executable, click on the configuration wheel next to the flow.

      In the Radiator Executable, in the Flows folders, a wheel icon next to the flow transmit_heat is highlighted.
    • Now select both the correct source and the target of your flow, then click "Save".

      In the produce_heat flow configuration, the Radiator (internal) has been selected as a source, and the Environment (external) has been selected as a target.
    • Apply those steps for each flow.

Mappings

Each flow that travels from one executable to another needs a corresponding flow on the other side. This step ensure that those two flows are linked together, using a Model to Model type mapping.

  • Click on the '+' icon next to the "Model to model mappings" folder in the Project tab in order to add a new mapping.

  • Create the model to model mapping by selecting the source executable as well as the flow it sends, and the target executable as well as the flow it receives.

    In the model to model mapping creation popup, the Model to simu executable is TemperatureSensor, and its associated flow is send_temperature_data. The Simu to model executable is CentralControlSystem, and its associated flow is also send_temperature_data.
  • Click "Save", and if needed, map the parameters between them to transmit any needed data before clicking "Save" again.

    In the contract between 2 flows, value is associated with value.
  • Repeat these steps for all the inter-model links that you can think of. In our case, there are only two:

    In the Model to model mappings folder, there are two mappings. The first one is send_temperature data, going from the TemperatureSensor to the CentralControlSystem. The second one is send_power_commands, going from the CentralControlSystem to the Radiator.

Creating a New Scenario in Virtual Bench

Create a new scenario in Virtual Bench.

Before creating and using the sequence diagram, you will need to instantiate the previously created model parts in your scenario, as well as the model to model mappings.


Step 1: Create the Websockets

In the Scenario tab, in the Websockets folder, create a new websocket for each executable.

In the websocket creation popup, the selected executable is the TemperatureSensor, the name of the Websocket is WSTemperatureSensor, and its port has been set by default to 9002.

Step 2: Add model part instances

  1. Ensure that every websocket has been created.

    In the Websockets folder, we can see WSTemperatureSensor, WSCentralControlSystem, and WSRadiator
  2. For each Websocket, you will find a folder called "Model part instances", click on the '+' icon next to it.

    In the Scenario tab, in the Websockets folder, under the new WSTemperatureSensor Websocket, there is an add icon next to the Model part instances folder
  3. From there, you can choose a model part, and click Save. If the model part references another model, choose the related Websocket when asked.

  4. Repeat this step, as many times as there are Model Parts to instantiate.

  5. You should now see all the instances under the Model part instances folder, as such:

    In Model part instances, we can see the following instances for the WSTemperatureSensor: TemperatureSensor, CentralControlSystem and Environment. For the WSCentralControlSystem, we can see TemperatureSensor, CentralControlSystem and Radiator. For the Radiator, we can see CentralControlSystem, Radiator and Environment.

Step 3: Add model to model mapping instances

In the scenario tab, in the "Model to model mapping instances" folder, instantiate the mappings that you have previously created.

In the inter-executable mapping popup, the mapping send_temperature_data has been selected between the WSTemperatureSensor and the WSCentralControlSystem Websockets.

Do this until there are no model to model mappings to instantiate. In our case, there are two instances to add.


Step 4: 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 context, in Edit Mode, add a Sequence Diagram by drag & dropping the element. The sequence diagram should not be configured and should display "No Selected Life Line".

    In Edit Mode, in an HMI context, a sequence diagram has been dragged and dropped into the scenario zone. The sequence diagram shows a unique empty lifeline saying No Selected Life Line.
  2. By selecting the element or double-clicking on it, open the element tab to the right-hand side. Open the Diagram flows tab, by clicking on it.

    Among all the icons of the element tab, there is an icon called Diagram Flows, represented by a double edged arrow.
  3. Select all model part instances in the order you want them to appear from left to right.

    Note

    You can still change the order later by right clicking on the sequence diagram, and choosing the "Edit and sort model parts/flows" option.

    Note

    The 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 will appear as one unique lifeline.

  4. Automatically, you should see all the eligible flows, relative to their sources and targets. If you want them in the simulation, select them too. In our case we will be selecting them all.

    All model part instances are selected, and all the eligible flows are selected.
  5. Click "Save", this should update the sequence diagram.


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 simulate the initial trigger, along with the associated mapping.

    A red button, whose text is User Request
  2. Run the scenario. After the initial temperature acquisition from the Environment, the scenario should unfold, displaying the different flows step by step.

    The sequence diagram displays four arrows, that represent a signal transmission between the Environment and the Temperature Sensor, then between the Temperature Sensor and the Central Control System, then again between the Central Control System and the Radiator, and finally between the Radiator and the Environment.

Conclusion

By following this tutorial, you’ve learned how to visualize and simulate 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.