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 compare/sync 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, and 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

  • Rhapsody supported version installed correctly on his or her machine with a valid license for use.

  • Syndeia installed as a plugin for Rhapsody 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.

  • In this tutorial, we will see the Rhapsody model available as Syndeia_Simulink_Examples.rpyx (Get it here - SysML Models, Profiles and Mappings.)

Tutorial: From SysML Rhapsody to Simulink

Demonstration 1: Simple Setting

1 Open the SysML project Syndeia_Simulink_Examples.rpyx (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 This will open Syndeia Dashboard.

3 Settings in Syndeia Dashboard for Simple as shown below.

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

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

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

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

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

6 Click OK to Generate Simulink Model in folder Sim33 or folder on your local machine.

7 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

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

Figure 6: System Model in Simulink

9 Compare and Sync to Verify the Simple Setting.

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

 

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

10 The Compare result is shown as below in the Comparison Result tab.

Figure 8: Comparison view for ports

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

Figure 9: Flow port added to the System block

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

Figure 10: Comparison result for ports after p1 removed

13 Now Sync p1, and can verify compare again from the Connections Search tab as shown below.

Figure 11: Sync Source to Target

14 This now shows in Comparison Result as below.

(Rhapsody Figure 10 changed to match MD)

15 In Simulink it shows as below.

Figure 13: Simulink model showing port p1

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

Figure 14: Deleting port p1 from System block in SysML containment tree

17 Now Compare from Connections Search Tab.

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

18 Sync the connection now as before and in Syndeia Dashboard it appears in Sync.

Figure 16: 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 Rhapsody System Block with Immediate settings.

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

1 Apply the Settings as shown here.

Figure 18: Syndeia Settings tab

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

Figure 19: Model transform System block from SysML to Simulink

3 This appears after Model Transform as below.

Figure 20: Model transform completed

4 In Simulink this appears as below.

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

5 The connections are generated as shown below. From Connections Search tab click Get ALL to get these connections.

Figure 22: Connection Search tab click Get All

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

1 Apply Settings as Immediate and Subsystem.

Figure 23: Syndeia Settings tab

2 Select Model Transform and Generate Simulink Model.

Figure 24: 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 25: Connections Search Tab in Syndeia

4 Open Simulink Model it should appear as below.

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

Demonstration 3: Recursive Setting

1 Apply Settings as Recursive and Select Recursive and Select Model Transform.

Figure 27: Syndeia Settings tab

2 Select Generate Simulink Model and Model Transform.

Figure 28: 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 29: Connections Search Tab in Syndeia

4 In Syndeia Dashboard it appears as below.

Figure 30: Simulink model shown in Connection manager tab

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

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

 


Summary

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

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

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