Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

The process of generating Simulink models from SysML (and vice versa) follows the same pattern as other drag-and-drop operations in Syndeia.

The SysML model used in this illustration is the Syndeia Simulink Examples model that is available with the Syndeia plugins, <MagicDraw_Installation>\samples\Syndeia.

The features presented in this section require the Simulink license feature for Syndeia.

Generating Simulink model from SysML block

Follow the instructions below to generate Simulink model structure from a SysML block structure.

  1. Open the model Syndeia Simulink Examples in MagicDraw.
  2. The Model Generation package is the main package and it contains the following three sub-packages, each of which have a SysML block model (Blocks package) and SysML activity model (Activity package).
    1. Basic Models – SysML block and activity models with primitive / atomic flows
    2. Bus Models – SysML block and activity models with complex / non-atomic flows
    3. LibBlock Models – SysML block and activity models using Simulink library blocks
  3. The instructions presented below are for generating Simulink models from SysML block model in Model Generation::Basic Models::Blocks package.


    Figure 138: SysML block and activity model examples for Simulink model generation 

    Open the Internal Block Diagram (IBD) in the System block, as shown in Figure 139 below. It is a multi-level block structure where blocks PartA, PartB, and PartC are further decomposed and have their own internal structures.


    Figure 139: SysML IBD for the System block

  4. Launch the Syndeia Dashboard for the Blocks package. Select a Local File System Repository on the RHS, as shown in Figure 140 below.
  5. Select Model Transform connection type (middle panel), and drag-n-drop the System block to a folder in the local file system repository (RHS), as shown in Figure 140 below.


    Figure 140: Drag-n-drop a SysML block to a folder to generate a Simulink model

  6. Select Generate Simulink model option in the dialog box and click Yes to continue.


     Figure 141: Selection option to generate a Simulink model


    Figure 142: Selection option to generate a Simulink model

  7. Wait for Simulink model to be generated. The log window in the Syndeia dashboard will show several messages as shown below.


    Figure 143: Selection option to generate a Simulink model

  8. Syndeia will finish generating Simulink model structure based on the internal structure of SysML block, as shown in Figure 144 below. Expand top-level model file (System.slx) to view the structure of the Simulink model that is generated. This will load the model using Simulink. Then expand the Simulink model System to see the internal details and compare with the SysML block structure (LHS).


    Figure 144: Simulink model structure generated from SysML block structure

  9. Syndeia uses the following mapping to generate Simulink model structure from the SysML block structure.

    SysML block -> Simulink model
    SysML block part properties -> Simulink model references
    SysML block ports (full, proxy, flow) -> Simulink ports
    SysML block connectors between ports -> Simulink lines with signal/bus flows

    As see in Figure 144 above, a Simulink model were generated for each SysML block in the context of the System block structure. Part properties pA, pB, and pC of the System block were generated as model references with the same name in the Simulink model. Full, proxy, and flow ports of the System block were generated as Simulink ports, and connectors were generated as lines with signal flows.  
     
  10. Right click on the System.slx file or the System Simulink model in the Syndeia Dashboard and select Open. This will open the newly generated Simulink model in Simulink, as shown in Figure 145 below—after re-arranging the layout to match SysML IBD in Figure 139.


    Figure 145: Simulink model opened in Simulink 
     
  11. Click on the Connection Browser tab in the Syndeia Dashboard, right click on the Blocks package and select Refresh. Then, right click on the Blocks package again and select Expand All. You should see a model transform connection created between each block in the structure and the corresponding Simulink model that has been generated. These connections can be used for downstream compare and (potentially) synchronization of SysML and Simulink models.

Figure 146: Syndeia generates model transform connections between SysML blocks and Simulink models

Generating Simulink model from SysML activity 

Follow the instructions below to generate Simulink model structure from a SysML activity structure.

  1. Open the model Syndeia Simulink Examples.
  2. The Model Generation package is the main package and it contains the following three sub-packages, each of which have a SysML block model (Blocks package) and SysML activity model (Activity package).
    1. Basic Models – SysML block and activity models with primitive / atomic flows
    2. Bus Models – SysML block and activity models with complex / non-atomic flows
    3. LibBlock Models – SysML block and activity models using Simulink library blocks


      Figure 147: SysML block and activity model examples for Simulink model generation

  3. The instructions presented below are for generating Simulink models from SysML block model in Model Generation::Basic Models::Activity package.
  4. Double click on the Overall Mission activity model to open the activity diagram, as shown in Figure 148 below. It is a multi-level activity structure where Mission A, Mission B, and Mission C activities are further decomposed.


    Figure 148: Overall Mission activity model in SysML

  5. Launch the Syndeia Dashboard for the Activity package. Select a Local File System Repository on the RHS, as shown in Figure 140 below.
  6. Select Model Transform connection type (middle panel), and drag-n-drop the Overall Mission activity to a folder in the local file system repository (RHS), as shown in Figure 149 below.


    Figure 149: Drag-n-drop a SysML activity to a folder to generate a Simulink model

  7. Click Yes to continue.


     Figure 150: Click Yes to continue

  8. Wait for Simulink model to be generated. The log window in the Syndeia dashboard will show several messages as shown below.


    Figure 151: Messages in the Syndeia Dashboard indicating the generation of Simulink models

  9. Syndeia will finish generating Simulink model structure based on the activity structure of SysML activity, as shown in Figure 152 below. Expand top-level model file (Overall_Mission.slx) to view the structure of the Simulink model that is generated. Then expand the Simulink model Overall_Mission to see the internal details.

     
    Figure 152: Simulink model structure generated from SysML activity structure

  10. Syndeia uses the following mapping to generate Simulink model structure from the SysML activity structure.
    1. SysML activity -> Simulink model
    2. SysML activity call behavior actions -> Simulink model references
    3. SysML activity parameter nodes -> Simulink ports
    4. SysML activity object flows -> Simulink lines with signal/bus flows

      As see in Figure 152 above, Simulink models were generated for each SysML activities in the context of the Overall Mission activity. Call behavior actions ma, mb, and mc of the Overall Mission activity were generated as model references with the same name in the Simulink model. Activity parameter nodes were generated as Simulink ports, and object flows were generated as lines with signal flows.
       
  11.  Right click on the Overall_MIssion.slx file or the Overall_Mission Simulink model in the Syndeia Dashboard and select Open. This will open the newly generated Simulink model in Simulink, as shown in Figure 145 below—after re-arranging the layout to match SysML activity diagram in Figure 148.


     Figure 153: Simulink model opened in Simulink

  12. Click on the Connection Browser tab in the Syndeia Dashboard, right click on the Activity package and select Refresh. Then, right click on the Activity package again and select Expand All. You should see a model transform connection created between each activity in the structure and the corresponding Simulink model that has been generated. These connections can be used for downstream compare and (potentially) synchronization of SysML and Simulink models.

Figure 154: Syndeia generates model transform connections between SysML activities and Simulink models

Compare SysML block_activity connection with Simulink model

The model transform connections between SysML block/activity and corresponding Simulink models, as generated in sections 2.15.1 and 2.15.2 above, make it possible to compare the SysML block/activity structure and the Simulink model downstream. In this section, we will first demonstrate the compare operation when SysML block/activity is changed followed by the demonstration of compare operation when Simulink models are changed.


Compare operation when SysML model is changed

  1. In the Blocks package in MagicDraw, create a new block B11 with an input flow port in1 and output flow port out1, both typed by Integer value type.
  2. In the Internal Block Diagram for the block PartB1, add a new part property pb11 typed by the new block B11, and create connectors as shown below.

     
    Figure 155: Add part property pb11 (of type PartB11) in the block PartB1

  3. Click on the Connection Browser tab, select the connection under PartB1, right click and select Compare SysML and Target, as shown below in Figure 156.


     Figure 156: Compare the connection between PartB1 and corresponding Simulink model

  4. The Comparison Result tab will open and show the comparison table, as shown in Figure 157. This may take few seconds as Syndeia launches Simulink and queries the model. Green rows indicate in-sync and red rows indicate out-of-sync elements. The table shows that property pb11 is new in SysML (does not exist in Simulink) and so are the 2 connectors added in the IBD in Figure 155.


    Figure 157: Comparison results

  5. Next, we will make changes to the activity model. In the Activity package in MagicDraw, create a new activity Mission B11 in with one input activity parameter b11In1 and one output activity parameter b11Out1, both typed by Integer.
     
  6. In the activity diagram for the existing activity Mission B1, add a call behavior action mb11 typed by the activity Mission B11, and create new object flows as shown below.


    Figure 158: Add call behavior action mb11 (of type Mission B11) in Mission B1 activity

  7. Click on the Connection Browser tab, select the connection under Activity::Mission B1, right click and select Compare SysML and Target, as shown below.


    Figure 159: Compare the connection between MissionB1 and corresponding Simulink model

  8. The Comparison Result tab will open and show the comparison table. This may take few seconds as Syndeia launches MATLAB/Simulink and queries the model. Green rows indicate in-sync and red rows indicate out-of-sync elements. The table shows that call behavior action mb11 is new in SysML (does not exist in Simulink) and so are the 2 object flows in Mission B1—added in the activity model shown in Figure 158.

     

Figure 160: Comparison results

In general, Syndeia can detect the following types of changes in the SysML model when comparing with a connected Simulink model:

  1. Addition/removal of part properties in a block and call behavior actions in an activity
  2. Addition/removal of connectors in a block and object flows in an activity
  3. Addition/removal of full/proxy/flow ports in a block and activity parameter nodes in an activity
  4. Rewiring of connectors in a block and object flows in an activity, e.g. changing the source and/or target ends.
  5. Changing names and type of part properties in a block and call behavior actions in an activity
  6. Changing names and types of flow ports in a block and activity parameter nodes in an activity

Compare operation when Simulink model is changed

  1. Create a new Simulink model PartC11 with:
    1. two inports with names and types as in1: double and in2: int32
    2. two outports with names and types as out1: double and out2: boolean
  2. In the existing Simulink model PartC1, add a new model reference block pointing to the new model PartC11, and connect lines between ports, as shown below. Save the PartC1 Simulink model.


    Figure 161: Add a new model reference block for PartC11 in the Simulink model for PartC1
     
  3. In the Syndeia Dashboard, click on the Connection Browser tab, select the connection under Blocks::PartC1 block, right click, and select Compare SysML & Target.


    Figure 162: Run compare on the connection between PartC1 and corresponding Simulink model

  4. The Comparison Result tab will open and show the comparison table. This may take few seconds as Syndeia launches MATLAB/Simulink and queries the model. Green rows indicate in-sync and red rows indicate out-of-sync elements. The table shows the new block pc11:PartC11 added to the Simulink model that does not exist in SysML, and the 4 new lines added to PartC1 Simulink model that do not exist in SysML.


    Figure 163: Comparison results

  5. Similarly, you can add repeat the steps 1-4 for a Simulink model connected to a SysML activity.


In general, Syndeia can detect the following types of changes in the Simulink model when comparing with a connected SysML modelAddition/removal of model reference blocks or library blocks

  1. Addition/removal of lines (block connections)
  2. Addition/removal of inports and outport.
  3. Rewiring of lines in a Simulink model
  4. Changing names and type of model reference blocks
  5. Changing names and types of inports and outports

Using Simulink library blocks to generate ready-to-execute Simulink models

Syndeia 3.0 enables users to use any Simulink library block in SysML block structure or SysML activity structure when generating Simulink models. This results in ready-to-execute Simulink models. The package Model Generation::LibBlock Models in the Syndeia Simulink Examples SysML model has example block and activity models that use library blocks. Figure 164 illustrates an example SysML internal block structure that uses 4 Simulink library blocks—Bus Selector, Gain, Not, and Bus Creator. 

Figure 164: SysML internal block structure using Simulink library blocks


The package Model Generation::LibBlock Models::Blocks::Simulink LibBlocks in the Syndeia Simulink Examples model includes several blocks defined for representing Simulink library blocks. 
Follow the general rules below to define a Simulink library block in SysML.

  1. Create a SysML block or activity, and assign it the Simulink_Library_Block stereotype available in the Syndeia profile
  2. Add a value property (for SysML blocks) or property (for SysML activities) called name and typed by the String value type. The default value of this property must be the exact name of the Simulink library block in the Simulink library. Activity models in Rhapsody are not allowed to have properties. Use local tags instead.
  3. Similarly, you may add other properties as required when using the Simulink library blocks, e.g. Add block uses a property Input with value ++ to indicate addition of two input arguments.
  4. Define flow with primitive value types (Real, Integer, Boolean) to represent the inputs and output of a Simulink library block.
  5. The input and output ports must be numbered in ascending alphanumeric manner, ending with numbers 1, 2, 3, and so on. For example, input ports on a Simulink library block must be named in1, in2, in3, etc. and output ports on a Simulink library block must be named out1, out2, out3, etc.
  • No labels