Exercise 10.5 - SysML -> Simulink with model generation level settings

Exercise 10.5 - SysML -> Simulink with model generation level settings

Objective

This tutorial demonstrates SysML from/to Simulink model generation level using the model generation and comparing/syncing between SysML and Simulink models. The three settings are as follows:

(1) SIMPLE

  • SysML → Simulink: Generate a Simulink model based on the SysML Block/Activity. Only ports are generated. No internal structure is generated.

  • Simulink → SysML: Generate a SysML Block/Activity based on the Simulink model. Only ports are generated. No internal structure is generated.

(2) IMMEDIATE

  • SysML → Simulink: Generate a Simulink model based on the SysML Block/Activity. Simulink model will have ports corresponding to the SysML Block/Activity, and Simulink blocks and signal/bus flows corresponding to the immediate structure (1 level only) of the SysML Block/Activity, i.e. immediate part/reference/shared properties of the SysML Block, or immediate call behavior actions of the SysML Activity.

  • Simulink → SysML: Generate a SysML Block/Activity based on the Simulink model. SysML model will have ports (or pins) corresponding to the Simulink model, and part properties (or call behavior actions) and connectors (or object flows) corresponding to the immediate blocks (1 level only) and signal/bus flows in the Simulink model.

(3) RECURSIVE (default)

  • SysML → Simulink: Generate a Simulink model based on the SysML Block/Activity. Simulink model will have ports corresponding to the SysML Block/Activity, and Simulink blocks and signal/bus flows corresponding to all the part/reference/shared properties (or call behavior actions) in the multi-level SysML Block/Activity hierarchy.

  • Simulink → SysML: Generate a SysML Block/Activity based on the Simulink model. SysML model will have ports (or pins) corresponding to the Simulink model, part properties (or call behavior actions), and connectors (or object flows) corresponding to all the blocks in the multi-level Simulink model hierarchy.

Preparation

This exercise assumes the student has

  • Cameo System Modeler 18.0 - 19.0 (or MagicDraw with SysML plug-in) installed correctly on his or her machine with a valid license for use.

  • Syndeia 3.3 installed as a plugin for Cameo/MagicDraw with a valid license for use.

  • Syndeia Simulink interface, correctly installed with a valid license for use.

  • MATLAB/Simulink R2016b or later installed correctly on his or her machine with a valid license for use.

  • For this tutorial, we are using the MagicDraw model Syndeia_Simulink_Examples.mdzip (get it here - SysML Models, Profiles and Mappings).

Tutorial: From SysML Magicdraw to Simulink

Demonstration 1: Simple Setting

1 Open the SysML project Syndeia_Simulink_Examples (get it here - SysML Models, Profiles and Mappings), and launch the Syndeia dashboard from Model Generation.

Figure 1: Launching the Syndeia dashboard from the Model Generation package

2 Settings in Syndeia Dashboard for Simple are as below. Click Apply.

Figure 2: SysML from/to Simulink model generation level set to SIMPLE in Settings tab of Syndeia Dashboard

3 Select the SysML Block System under Bus Model Package for Model Transform.

Figure 3: System block under Bus Models::Blocks package and System ibd

4 In Syndeia Dashboard Perform Model Transform. Drag Drop SysML Block System from under Bus Models Package as shown here to the Simulink folder Sim33 or folder of your choice.

Click OK to Generate Simulink Model.

Figure 4: Model Transform - Drag and drop SysML Block System from Bus Models package to Simulink Folder

5 The Syndeia dashboard will appear now and a System.slx is created under the Sim33 folder or your folder of choice.

Figure 5: System.slx file created under Simulink folder

6 In Simulink, the model appears as Launch from Syndeia Dashboard directly.

Figure 6: Open Model directly from Syndeia Dashboard

 

7 As with Simple Setting generated in Simulink model is System.slx

Figure 7: System Model in Simulink

8 Compare and Sync to Verify the Simple Setting.

Now go to Connections Search Tab in Syndeia and Click Get All to see the connections. Select Compare Source and Target.

Figure 8: Select Compare Source and Target under the connections tab

9 You can observe the Simple Setting Model Transformation.

Figure 9: Comparison view for ports

10 Now, add a port under System Block in SysML MagicDraw 'p1' as Flow Port and specifications as shown below.

Figure 10: Flow port added to the System block

11 This modified System is now compared and we will sync the same with Simulink.

12 Compare this and the absence of p1 will be highlighted as shown.

Figure 11: Comparison result for ports after p1 removed

13 Now Sync p1, and can verify compare again.

Figure 12: Compare source and target again

14 In Simulink now port p1 appears.

Figure 13: Comparison after port p1 synced

15 In Simulink Model now port p1 appears.

Figure 14: Simulink model showing port p1

16 Now we delete p1 from SysML Model Block System and compare and sync again.

Figure 15: SysML containment tree showing System block after port p1 deleted

17 Compare the connection now and p1 is not in SysML but present in Simulink Model. This can be seen in the Comparison Result tab below.

Figure 16: Comparison result showing port p1 is not in SysML and present in Simulink

18 Sync the connection now as before, and Compare the connection again in the Connections Search tab in Syndeia Dashboard. It now appears in Sync now. The result can be seen in the Comparison Result below.

Figure 17: Comparison result after sync

19 Open now the Simulink Model now has no ‘p1’ port it gets updated when the sync is done with SysML Model.

Figure 18: Simulink model shown after sync to remove port p1

 


Demonstration 2: Immediate Setting

Using the Same Model of SysML System Block with Immediate settings.

2A) Apply setting of Model Reference with Immediate and Click Apply

1 Apply the Settings as shown here.

2 It appears in Settings as shown here.

Figure 19: Syndeia Settings tab

3 Perform Model Transform and Drag Drop SysML Block System from under Bus Models Package as shown here.

Figure 20: Model transform System block from SysML to Simulink

4 This appears after Model Transform as below.

Figure 21: Model transform completed

5 Now go to the Connections Search Tab in Syndeia and Click Get All to see the connections generated.

Figure 22: Connections Search Tab in Syndeia

6 Open the model System. slx in the Simulink folder of your local machine and observe it as a Model References block as per the setting selected.

7 Also, Ports are generated under the Model References Block as required by the Immediate Settings.

Figure 23: Simulink model showing model reference blocks and ports have been generated

2B) Apply setting of Subsystem with Immediate and Click Apply

1 Apply Settings as Immediate and Subsystem.

Figure 24: Syndeia Settings tab

2 Select Model Transform and Generate Simulink Model.

Figure 25: Model transform System block from SysML to Simulink

3 Now going to Connections Search Tab in Syndeia and Click Get All to see the connections.

Figure 26: Connections Search Tab in Syndeia

4 In the Syndeia dashboard Connection Manager tab this appears as below.

Figure 27: Simulink model expanded in Connection manager tab

5 Open Simulink model System.slx and it will appear in Simulink as a Subsystem now.

Figure 28: Simulink model showing subsystems and ports have been generated

Demonstration 3: Recursive Setting

1 Apply Settings as Recursive and Select Model Transform.

Figure 29: Syndeia Settings tab

 

2 Select Generate Simulink Model and Model Transform.

Figure 30: Model transform System block from SysML to Simulink

3 Now go to the Connections Search Tab in Syndeia and Click Get All to see the connections.

Figure 31: Connections Search Tab in Syndeia

4 This appears in the Syndeia Dashboard Connection Manager tab as shown below.

Figure 32: Simulink model shown in Connection manager tab

5 Open System.slx in Simulink as it will show all multi-level hierarchy being generated.

Figure 33: Simulink model showing model reference blocks and ports have been generated recursively

Summary

In this Tutorial page features of SysML to Simulink Model Transformation were enumerated.

Three different settings of Simple, Immediate, and Recursive were introduced and demonstrated.

Features such as Compare, and Sync are common to all settings.