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



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

  4. Launch the Syndeia Dashboard for the Blocks package. Select a Local File System Repository on the RHS.
  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).



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





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



  8. Syndeia will finish generating Simulink model structure based on the internal structure of SysML block. 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).



  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

    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—after re-arranging the layout to match SysML IBD.


     
  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.

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



  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. It is a multi-level activity structure where Mission A, Mission B, and Mission C activities are further decomposed.



  5. Launch the Syndeia Dashboard for the Activity package. Select a Local File System Repository on the RHS.
  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).



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



  9. Syndeia will finish generating Simulink model structure based on the activity structure of SysML activity. 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.

     

  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

      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—after re-arranging the layout to match SysML activity diagram.



  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.

Compare SysML block_activity connection with Simulink model

The model transform connections between SysML block/activity and corresponding Simulink models 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.

     

  3. Click on the Connection Browser tab, select the connection under PartB1, right click and select Compare SysML and Target.



  4. The Comparison Result tab will open and show the comparison table. 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.



  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.



  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.



  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.

     

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.


     
  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.



  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.



  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. An example SysML internal block structure that uses 4 Simulink library blocks—Bus Selector, Gain, Not, and Bus Creator. 


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