![Abstract geometric design with overlapping colored triangles and a stylized checkmark (no text or symbols)](.vortex-opensplice-dds-simulink-guide/ab4c2cfc0d736a86686c7d1f622acc06a606b369f9c69c2a6b4d60ab52494d0f.jpg)

# ORTEX

# OpenSplice Simulink Guide

Release 6.x

# Contents

# 1 Introduction 1

1.1 DDS
1.2 Simulink 2

# 2 Installation 3

2.1 System Requirements 3
2.2 OpenSplice (OSPL) and DDS Simulink Installation . . 3
2.3 OpenSplice (OSPL) Configuration . 3

2.3.1 Linux 3
2.3.2 Windows 4

2.4 Simulink Setup 4
2.5 Examples 5

# 3 Vortex DDS Blocks 6

3.1 Optional DDS Blocks and Ports 6
3.2 QoS Profiles 6
3.3 Simulink Block Sample Time 7

# 4 Simulink Bus to DDS Topic Mapping 8

4.1 Generate Simulink bus definitions from an IDL file 8
4.2 Overriding default values for Vortex.idlImportSl 9

4.2.1 Overriding struct and enum names 9
4.2.2 Changing unbound string maximum sizes 10
4.2.3 Changing sequence attributes 11

4.3 Add Simulink bus definitions using bus editor . 11
4.4 Bus definition limitations 12

# 5 QoS Provider 13

5.1 QoS Provider File 13
5.2 QoS Profile 13
5.3 Setting QoS Profile in Simulink 14
5.4 Known Limitations 15

# 6 Topic Block 16

6.1 Topic Block Parameters 16

6.1.1 Topic Tab 17
6.1.2 Ports Tab 17
6.1.3 QoS Tab 17

# 7 Domain Block 18

7.1 Domain Block Parameters 18

7.1.1 Domain Tab 18
7.1.2 QoS Tab . 19

# 8 Publisher Block 20

8.1 Publisher Block Parameters 20

8.1.1 Ports Tab 20
8.1.2 QoS Tab 21

# 9 Subscriber Block 22

9.1 Subscriber Block Parameters . 22

9.1.1 Ports Tab 22
9.1.2 QoS Tab . 23

# 10 Writer Block 24

10.1 Writer Block Parameters 25

10.1.1 Data Tab . 25
10.1.2 Ports Tab 25
10.1.3 QoS Tab 25

# 11 Reader Block 26

11.1 Reader Block Parameters . 27

11.1.1 Data Tab 27
11.1.2 Ports Tab 28
11.1.3 QoS Tab 28
11.1.4 Filters Tab 29

# 12 Tutorial 30

12.1 Create ShapeType Bus Using Simulink Bus Editor 30

12.1.1 Open the bus editor from the MATLAB command window 30
12.1.2 Add a new BUS named ShapeType . . . 30

12.1.2.1 Select Add Bus button 30
12.1.2.2 Set Bus name and Key . . . . 31

12.1.3 Add BusElements 31

12.1.3.1 Add color 32
12.1.3.2 Add x . . . 33
12.1.3.3 Add y 33
12.1.3.4 Add shapesize . . . 34

12.1.4 Export BUS objects 34

12.2 Create ShapeType Using IDL 35

12.2.1 Create IDL File 35
12.2.2 Generate Simulink bus definitions from an IDL file 35
12.2.3 Model Explorer 36

12.3 Shapes Write Model 36

12.3.1 Create a new Simulink model . 36

12.3.1.1 Start Simulink . . . . 36
12.3.1.2 Add a new blank model 37
12.3.1.3 Save As... 37
12.3.1.4 Model Settings . . . . 38

12.3.2 Add Simulink DDS Blocks 38

12.3.2.1 Open the Simulink Library Browser 38
12.3.2.2 Add a Domain block . 40
12.3.2.3 Set domain block properties . . . 40
12.3.2.4 Add blocks (Topic, Publisher, and Writer) . . 40
12.3.2.5 Connect Domain to Topic and Publisher 41
12.3.2.6 Set Topic Block Parameters . . 42
12.3.2.7 Connect Topic, Publisher and Writer Blocks & Set Writer Block Parameters . . 43
12.3.2.8 Add a Bus Creator to Set Sample Data . . . 44
12.3.2.9 Add Bus Creator Inputs . . . 44

12.4 Shapes Read Model 49

12.4.1 Create a new Simulink model 49

12.4.1.1 Start Simulink 50
12.4.1.2 Add a new blank model 50
12.4.1.3 Save As... 50
12.4.1.4 Model Settings . . . . 51

12.4.2 Add Simulink DDS Blocks 52

12.4.2.1 Open the Simulink Library Browser 52
12.4.2.2 Add all required blocks (Topic and Reader) . . . . 52
12.4.2.3 Toggle off optional ports 52
12.4.2.4 Set Topic Block Parameters . . 54
12.4.2.5 Set Reader Block Parameters 55
12.4.2.6 Connect Topic and Reader . . . . 56

12.4.2.7 Add a Bus Selector to read and display sample data . . . 56
12.4.2.8 Set Bus Selector Block Parameters . . 56
12.4.2.9 Add Bus Selector outputs . . 57

12.5 Running Simulations 59

12.5.1 Setup Write Model 59
12.5.2 Setup Read Model 59
12.5.3 Run Simulations 59

13 Generating C code with Simulink Coder 61

13.1 Prerequisites for C generation 61
13.2 Preparing for C generation 61
13.3 Generating code 61
13.4 Cross-compilation of models . 63
13.5 Running built models . 64

14 Troubleshooting 65

15 Appendix A 66

15.1 Simulink Bus to DDS Mapping 66

15.1.1 Workflow 1: Using idlpp to Generate Simulink Bus and Type Descriptor . 66
15.1.2 Workflow 2: Manually Modeling DDS data in the Simulink Bus Editor 67

16 Contacts & Notices 69

16.1 Contacts 69
16.2 Notices 69

# 1

# Introduction

The DDS Simulink Integration provides users with DDS custom blocks to model DDS communication between Simulink models and pure DDS applications.

# 1.1 DDS

# What is DDS?

“The Data Distribution Service (DDS™) is a middleware protocol and API standard for data-centric connectivity from the Object Management Group® (OMG®). It integrates the components of a system together, providing low-latency data connectivity, extreme reliability, and a scalable architecture that business and mission-critical Internet of Things (IoT) applications need.”

“The main goal of DDS is to share the right data at the right place at the right time, even between time-decoupled publishers and consumers. DDS implements global data space by carefully replicating relevant portions of the logically shared dataspace.” DDS specification

![Based on the provided flowchart, here are the labeled blocks and their connections:\n\n**Labeled Blocks:**\n*   **Data-Object** (top oval)\n*   **Publisher** (left box)\n*   **DataWriter** (left box)\n*   **Subscriber** (right upper box)\n*   **DataReader** (right upper box)\n*   **Subscriber** (right lower box)\n*   **DataReader** (right lower box)\n\n**Connections:**\n*   **DataWriter** to **Publisher**: A solid arrow labeled 'data values'.\n*   **Publisher** to **Subscriber** (both instances): A dashed line labeled 'dissemination' connects the Publisher to a vertical dashed line that branches into arrows pointing to both Subscriber blocks.\n*   **Subscriber** (both instances) to **DataReader** (both instances): A solid arrow labeled 'data values' connects each Subscriber to its corresponding DataReader.\n*   **Left Group** (Publisher/DataWriter area) to **Data-Object**: A dashed arrow points to the Data-Object, labeled 'Identified by means of the Topic'.\n*   **Right Group** (Subscriber/DataReader area) to **Data-Object**: A dashed arrow points to the Data-Object, labeled 'Identified by means of the Topic'.](.vortex-opensplice-dds-simulink-guide/6d7d0e0aa9c06adf6b6294dadb79f3aaf98688c5e17dfe65d86036999f67fb4a.jpg)

# Further Documentation

http://portals.omg.org/dds/

http://ist.adlinktech.com/

# 1.2 Simulink

# What is Simulink?

“Simulink® is a block diagram environment for multidomain simulation and Model-Based Design. It supports system-level design, simulation, automatic code generation, and continuous test and verification of embedded systems. Simulink provides a graphical editor, customizable block libraries, and solvers for modeling and simulating dynamic systems. It is integrated with MATLAB®, enabling you to incorporate MATLAB algorithms into models and export simulation results to MATLAB for further analysis.” Simulink Help

# 2

# Installation

This section describes the procedure to install the Vortex DDS Simulink Integration on a Linux or Windows platform.

# 2.1 System Requirements

• Operating System: Windows or Linux
• MATLAB Simulink installed
• Java 1.7 or greater

# 2.2 OpenSplice (OSPL) and DDS Simulink Installation

# Steps:

1. Install OSPL. The DDS Simulink Integration is included in this installer.
2. Setup OSPL license. Copy the license.lic file into the appropriate license directory.
/INSTALLDIR/ADLINK/Vortex\_v2/license
3. MATLAB and Simulink files are contained in a tools/matlab folder
Example: /INSTALLDIR/ADLINK/Vortex\_v2/Device/VortexOpenSplice/6.8.x/HDE/x86\_64.linux/tools/matlab

# 2.3 OpenSplice (OSPL) Configuration

By default OSPL uses single process configuration.

If however, shared memory configuration is used, additional OSPL configuration steps need to be taken to work with MATLAB Simulink.

# 2.3.1 Linux

OSPL-9882 Linux: MATLAB/Simulink hangs when connecting to shared memory domain

Description On Linux, a MATLAB script or Simulink model connecting to a Vortex OpenSplice domain via shared memory will hang.

Resolution MATLAB, like Java applications requires that the environment variable LD\_PRELOAD be set to reference the active Java installations libjsig.so library. The MATLAB user interface uses Java, and thus requires the same signal handling strategy as Java applications connecting to Vortex OpenSplice. The precise syntax for setting the LD\_PRELOAD environment variable will depend on the shell being used.

The libjsig.so file you specify in LD\_PRELOAD should match the Java installation used by MATLAB. By default, MATLAB uses a private java installation. If you have not explicitly specified a MATLAB java version (by setting the MATLAB\_JAVA environment variable), you should use the libjsig.so library that ships with MATLAB. You can find the library with the following command:

find MATLAB-install-dir -name libjsig.so

# As an example, MATLAB R2016b installed in the default location, LD\_PROLOAD should contain:

/usr/local/MATLAB/R2016b/sys/java/jre/glnxa64/jre/lib/amd64/libjsig.so

If you have set MATLAB\_JAVA, then you should use the libjsig.so from that installation. For example, on Oracle JVMs, LD\_PRELOAD should contain this value:

\$JAVA\_HOME/jre/lib/amd64/libjsig.so

# 2.3.2 Windows

OSPL-10018 MATLAB: Shared Memory Database Address on Windows needs to be changed from default

Description On a Windows 64-bit system, an OpenSplice system configured with Shared Memory, MATLAB cannot connect to the OpenSplice domain if the Shared Memory Database Address is set to its default value of 0x40000000. The error log (ospl-error.log) will show entries such as: Report : Can not Map View Of file: Attempt to access invalid address. Internals : OS Abstraction/code/os\_sharedmem.c/1764/0/1487951812.565129500

Resolution Use the configuration editor to change the default data base address. Use the ‘Domain’ tab, and select the ‘Database’ element in the tree. If necessary, right click the Database element to add an ‘Address’ element. Change the address. In general, a larger number is less likely to be problematic. On a test machine, appending two zeros to the default address allowed for successful connections.

# 2.4 Simulink Setup

# Steps:

1. Open command shell and run script to setup environment variables.

# Linux

• Open a Linux terminal.
• Navigate to directory containing release.com file.
/INSTALLDIR/ADLINK/Vortex\_v2/Device/VortexOpenSplice/6.8.x/HDE/x86\_64.linux
• Run release.com. (Type in “. release.com” at command line.)

# Windows

• Open a command prompt.
• Navigate to directory containing release.bat file.
INSTALLDIR/ADLINK/Vortex\_v2/Device/VortexOpenSplice/6.8.x/HDE/x86\_64.win64
• Run release.bat. (Type in “release.bat” at command line.)

2. Start MATLAB using the SAME command shell used in Step 1.

NOTE: If MATLAB is NOT started from a command shell with the correct OSPL environment variables set, exceptions will occur when attempting to use DDS Simulink blocks.

3. In MATLAB, navigate to file “Vortex\_DDS\_Block\_Set.mltbx” by typing:

```javascript
cd(fullfile(getenv('OSPL_HOME'), 'tools', 'matlab'))
```

# 2.4. Simulink Setup

4. Double click on the file “Vortex\_DDS\_Block\_Set.mltbx”. This will bring up a dialog entitled Install Vortex\_DDS\_Block\_Set. Select Install.

![The image shows a round, orange button centered on a dark grey background. In the middle of the button is a black 'X' symbol. The button has a glossy appearance with a gradient that transitions from a lighter orange at the top to a darker orange at the bottom.](.vortex-opensplice-dds-simulink-guide/1f135e8e34230df356b2921c6d5d9faf91c7c364829ac7f7366b7de301a465f5.jpg)

# Install Vortex\_DDs\_Block\_Set

![Abstract geometric pattern composed of multicolored triangles forming a V-shape (no text or symbols)](.vortex-opensplice-dds-simulink-guide/1069320776a16d7496c81ea71dc3f2d7a15621a10076d4777361492bc6e04c01.jpg)

Vortex\_DDs\_Block\_Set by ADLINKUpdated on 02 Oct 2017

Version: 6.8.2

A block set for participating in a Vortex DDs domain.

![The image displays a cropped view of a software interface featuring two rectangular buttons side-by-side. The button on the left contains the text 'Install', and the button on the right contains the text 'Cancel'. Both buttons have a light background with black text centered within them.](.vortex-opensplice-dds-simulink-guide/4f33fd41f7829fdba21d701bf6dbe0a8e9e6fed058eda78f208e3574b8f5af10.jpg)

Setup is complete!

# 2.5 Examples

Example models have been provided in the examples folder.

../tools/matlab/examples/simulink

# 3

# Vortex DDS Blocks

The DDS Simulink Integration provides a block library with custom blocks to model reading and writing data with DDS.

The Vortex DDS Simulink block library provides blocks which correspond to DDS entities. (Each DDS block is covered in its own section in this user guide.)

The following DDS block types are provided:

• Topic
• Domain
• Publisher
• Subscriber
• Writer
• Reader

# 3.1 Optional DDS Blocks and Ports

Some of the DDS blocks are optional. (Domain, Publisher and Subscriber)

When the optional blocks are not added to model diagrams, defaults are used. This allows for simpler model diagrams. If the model requires block parameter customization, the optional blocks can be added to a model to use non-default settings.

Many of the ports for the DDS blocks are also optional. They can be toggled on or off in the Block Parameters dialog, in the Ports tab.

# 3.2 QoS Profiles

In DDS - “The Data-Distribution Service (DDS) relies on the usage of QoS. A QoS (Quality of Service) is a set of characteristics that controls some aspect of the behavior of the DDS Service.”

Each DDS block has an associated QoS profile. By default, the OSPL default profile is used. An XML file that specifies QoS profiles can be used to set the QoS of a DDS block.

The QoS profile of a block is set in the QoS tab of the Block Parameters dialog. (This dialog is opened by double clicking on a selected block.)

Please see section QoS Provider for more information.

# 3.3 Simulink Block Sample Time

“What is sample time?”

“The sample time of a block is a parameter that indicates when, during simulation, the block produces outputs and if appropriate, updates its internal state.” -Simulink documentation

The DDS blocks have different sample times set. The only DDS block that allows for the user specification of a sample time is the Reader block. A reader’s sample time can be set in the Block Parameters Data tab.

A sample time of 0 means that the block step will only execute once.

A sample time of -1 means that the block will inherit its sample time from its inputs or from the parent model.

<table><tr><td>DDS Block Type</td><td>Sample Time</td></tr><tr><td>Topic</td><td>-1 (inherits) uneditable</td></tr><tr><td>Domain</td><td>-1 (inherits) uneditable</td></tr><tr><td>Publisher</td><td>-1 (inherits) uneditable</td></tr><tr><td>Subscriber</td><td>-1 (inherits) uneditable</td></tr><tr><td>Writer</td><td>-1 (inherits) uneditable</td></tr><tr><td>Reader</td><td>default -1 (inherits) editableInherits from inputs or modelValid values: -1 and Numeric &gt;0</td></tr></table>

# 4

# Simulink Bus to DDS Topic Mapping

Simulink data is represented in buses whose types are not compatible with DDS topic data types.

When using the Simulink Vortex DDS library, the user must create Simulink buses that will be mapped to DDS topic types.

The Vortex DDS Reader, Writer and Topic blocks have block parameters that require a Simulink bus type. On data writes, the Simulink bus types are converted to DDS topic types and on data reads, the DDS topic types are converted to Simulink bus types.

The user can generate/create the Simulink bus definitions by either generating them from an IDL file, or by using the Simulink bus editor.

# 4.1 Generate Simulink bus definitions from an IDL file

DDS Topic Types can be described in an IDL file. The public Vortex.idlImportSl function can be called to generate Simulink bus definitions from an IDL file.

# idlImportSl(IDLFILENAME,DICTIONARYFILE)

Given an IDLFILENAME, invokes the idlpp tool to generate a MATLAB script. This script is then used to create Simulink.Bus objects and import them into the specified data dictionary DICTIO-NARYFILE. The values are inserted into the ‘Design Data’ section of the data dictionary. If the target data dictionary already contains definitions for the bus or enum names, they are overwritten. If idlpp returns non-zero, the function returns immediately with the error code.

Input Arguments:

IDLFILENAME A character array with the value of the IDL file name to process.

DICTIONARYFILE A character array with the value of the data dictionary file name.

# Steps:

1. In the IDL file, ensure that any topic structures have the OSPL specific annotation pragma keylist defined.

If you want a given IDL structure to serve as the topic type, the structure requires an OSPL specific annotation. The #pragma keylist &lt;data-type-name&gt; &lt;key&gt;\* declaration should be defined after the structure declaration.

IMPORTANT NOTE: The IDL file has to have a blank line after the pragma keylist declaration. (BUG)

More information can be found at: IDLPreProcGuide\_

2. In MATLAB, navigate to the directory that contains the IDL file. Set this directory to be the MATLAB Current Folder.

3. Call the idlImportSl function in the MATLAB command window.

Example: >> Vortex.idlImportSl(‘ShapeType.idl’, ‘shape.sldd’)

# 4.2 Overriding default values for Vortex.idlImportSl

The Vortex.idlImportSl function makes a number assumptions when generating a Simulink data dictionary from your IDL file. These are documented in the following table:

<table><tr><td>IDL Element</td><td>Default Simulink Equivalent</td></tr><tr><td>struct name</td><td>Unqualified bus name</td></tr><tr><td>enum name</td><td>Unqualified enum name</td></tr><tr><td>sequence&lt; T, N&gt; name</td><td>seqN_T</td></tr><tr><td>sequence&lt; T&gt; name</td><td>seq_T</td></tr><tr><td>unbounded string</td><td>maximum 256 characters</td></tr><tr><td>unbounded sequence</td><td>maximum 16 elements</td></tr></table>

The following subsections illustrate how to override each of these defaults.

# 4.2.1 Overriding struct and enum names

IDL allows you to describe a hierarchical set of namespaces for structs and enums by defining modules. Simulink, however, has a flat namespace for all busses and enumerations. This can present problems when the same unqualified struct name is used to two or more different modules.

Consider the following idl:
```txt
module A {
    enum Status {
    INFO,
    WARNING,
    ERROR
    };
    struct Message {
    long id;
    Status status;
    };
    #pragma keylist Message id
};

module B {
    enum Status {
    SUCCESS,
    FAILURE
    };
    struct Message {
    long id;
    Status status;
    };
    #pragma keylist Message id
};
```

In it, both Status and Message are used in the context of both module A and module B. When you run Vortex.idlImportSl against it, you will receive the following messages:

```txt
Error: IDL element B::Status translates to the Simulink artifact named Status, which already corresponds to another IDL element A::Status.
Edit the idl_defaults.properties file to assign unique Simulink names to each IDL element.
```

```txt
Error: IDL element B::Message translates to the Simulink artifact named Message, which already corresponds to another IDL element A::Message.
Edit the idl_defaults.properties file to assign unique Simulink names to each IDL element.
```

To help you solve the problem, the IDL import function generates a properties file with the same name as the original IDL file, but with a properties extension. Here is the generated properties file:

# 4.2. Overriding default values for Vortex.idlImportSl

```txt
# &lt;initial comments removed for brevity&gt;
#
# To change the generated Simulink element, change one or more values in this file, and then
# re-run the IDL import.
A::Message#name = Message
A::Status#name = Status
B::Message#name = Message
B::Status#name = Status
```

The properties file shows the names the IDL import attempted to used. Each line is of the format:

```txt
&lt;qualified-IDL-name&gt;#name = &lt;simulink-name&gt;
```

You can modify any value after the equals sign (=), to create a unique name. Once you have finished editing the properties file, re-run the IDL import to update actual Simulink entities.

Suppose we make the following changes to the properties file:

```autohotkey
A::Message#name = MessageA
A::Status#name = StatusA
B::Message#name = Message
B::Status#name = Status
```

On re-running Vortex.idlImportSl, the generated Simulink data dictionary would have contents as seen in the figure below.

![Model Explorer\nFile Edit View Tools Add Help\nSearch: by Name\nName:\nSearch\nModel Hierarchy\nSimulink Root\nBase Workspace\nidl defaults\nDesign Data\nContents of: ...lpp/idl_defaults.sldd' (only) Filter Conte...\nColumn View: Dictionary Obj e Show Details 6 object(s)\nName Status Value DataType Dimens\nMessage\nMessageA\nMessageATypeDescriptor '(M... char\nMessageTypeDescriptor '(M... char\nStatus\nStatusA\nSimulink.Bus: MessageA\nBus elements (read only)\nName Data/Bus Type Complexity\nid int32 real\nstatus Enum: StatusA real\nCode generation options\nData scope: Auto\nHeader file:\nAlignment: -1\nDescriptions\nRevert Help Apply\nContents Search Results](.vortex-opensplice-dds-simulink-guide/517689b78a8f2abca70d5a7b0c94be0c73524af0a09189f03d03a8cd04d34b37.jpg)

Figure 4.1: View of generated Simulink Data Dictionary, showing renamed busses and enumerations.

# 4.2.2 Changing unbound string maximum sizes

Although IDL unbound strings can be of any length, in Simulink they are mapped to fixed length arrays of int8. The default length the Vortex.idlImportSl assigns to such arrays is 256 characters. You can change this default value, per string, using the generated properties file.

# 4.2. Overriding default values for Vortex.idlImportSl

Suppose we modify A::Message to contain a string field:
```txt
module A {
    enum Status {
    INFO,
    WARNING,
    ERROR
    };
    struct Message {
    long id;
    Status status;
    string body;
    };
    #pragma keylist Message id
};
```

On running the IDL import, the properties file would be updated to show a new line:

```txt
A::Message.body#stringMax = 256
```

Changes the value to something new (say 128), and rerun the IDL import to update the generated Simulink bus.

# 4.2.3 Changing sequence attributes

IDL import generates a simulink bus for each IDL sequence discovered. For an unbound sequence, the default name for such sequences is seq\_T, where T is the type of elements in the sequence. For bounded sequences, the default sequence name is seqN\_T, where N is the declared upper bound of the sequence.

The following IDL enhances our example IDL to use a sequence of string field for the body attribute:

```txt
module A {
    enum Status {
    INFO,
    WARNING,
    ERROR
    };
    struct Message {
    long id;
    Status status;
    sequence&lt;string&gt; body;
    };
    #pragma keylist Message id
};
```

On running IDL import, the generated property file now contains the following lines:

```txt
A::Message.seq_string#name = seq_string
A::Message.seq_string#seqMax = 16
A::Message.seq_string#stringMax = 256
```

You can edit the value of A::Message.seq\_string#name to change the name of the generated Simulink bus representing the sequences. You can change the maximum number of elements stored in the Simulink representation of the sequence by editing A::Message.seq\_string#seqMax. Finally, because the type of elements in this sequence are unbounded strings, you can also change the maximum size of each string in the sequence (A::Message.seq\_string#stringMax).

# 4.3 Add Simulink bus definitions using bus editor

Users can also model the Simulink buses using the Simulink bus editor.

Please see Tutorial for an example with detailed steps.

# 4.3. Add Simulink bus definitions using bus editor

# 4.4 Bus definition limitations

The DDS Simulink integration has some limitations. Provided below is a table of unsupported types. Some of these bus definition limitations will be removed in later release(s).

Please refer to Appendix A for more detailed implementation details.

<table><tr><td>Unsupported Simulink Types</td></tr><tr><td>long long</td></tr><tr><td>unsigned long long</td></tr><tr><td>wchar</td></tr><tr><td>wstring</td></tr><tr><td>any</td></tr><tr><td>long double</td></tr><tr><td>union</td></tr><tr><td>inheritance</td></tr></table>

See also IDL PreProcessor Guide chapter Keys.

# 5

# QoS Provider

Each Vortex DDS block has a QoS that can be set using the Block Parameters.

The following section explains how the QoS is set for a DDS entity using the QoS Provider.

# 5.1 QoS Provider File

Quality of Service for DDS entities is set using XML files based on the XML schema file DDS\_QoSProfile.xsd. These XML files contain one or more QoS profiles for DDS entities. An example with a default QoS profile for all entity types can be found at DDS\_DefaultQoS.xml.

Note: Sample QoS Profile XML files can be found in the examples directories.

# 5.2 QoS Profile

A QoS profile consists of a name. The file contains QoS elements for one or more DDS entities. A skeleton file without any QoS values is displayed below to show the structure of the file.

```xml
&lt;dds xmlns="http://www.omg.org/dds/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="file:DDS_QoSProfile.xsd"&gt;
    &lt;qos_profile name="DDS QoS Profile Name"&gt;
    &lt;datareader_qos&gt;&lt;/datareader_qos&gt;
    &lt;datawriter_qos&gt;&lt;/datawriter_qos&gt;
    &lt;domainparticipant_qos&gt;&lt;/domainparticipant_qos&gt;
    &lt;subscriber_qos&gt;&lt;/subscriber_qos&gt;
    &lt;publisher_qos&gt;&lt;/publisher_qos&gt;
    &lt;topic_qos&gt;&lt;/topic_qos&gt;
    &lt;/qos_profile&gt;
&lt;/dds&gt;
```

# Example: Specify Publisher Partition

The example below specifies the publisher’s partitions as A and B.

```xml
&lt;publisher_qos&gt;
    &lt;partition&gt;
    &lt;name&gt;
    &lt;element&gt;A&lt;/element&gt;
    &lt;element&gt;B&lt;/element&gt;
    &lt;/name&gt;
    &lt;/partition&gt;
&lt;/publisher_qos&gt;
```

# 5.3 Setting QoS Profile in Simulink

QoS profiles are set using the Simulink block’s parameters dialog under the QoS tab. If the QoS File parameter is set to None the default QoS settings will be used. The Reset button sets the parameters to the default values.

![Block Parameters: Subscriber\nSubscriber\nParameters\nPorts QoS\nQoS File: None Browse ...\nQoS Profile: Default\nReset\nOK Cancel Help Apply](.vortex-opensplice-dds-simulink-guide/3690753e6344f7ea94af8e1bb49f8fab961dd6b941fe5016517141529b782393.jpg)

A QoS Provider file can be selected by browsing to the XML file. Once the file is chosen the file name is displayed and the user is presented with a drop down list of all QoS Providers in the file.

![Block Parameters: Subscriber\nSubscriber\nParameters\nPorts QoS\nQoS File: Shapes_Demo_QoS.xml Browse ...\nQoS Profile: DDS Shapes_Demo_Profile\nReset\nOK Cancel Help Apply](.vortex-opensplice-dds-simulink-guide/1ea252ffd15a2c02856c7100f2efc525244b4f4f2a72f7723fcbc219b10ce785.jpg)

Note: Seeing the QoS Profile in the drop down list only guarantees the QoS Profile exists in the file. It does not mean the qos tag exists for the entity. The user is responsible for verifying the entity qos tag exists in the file.

# 5.3. Setting QoS Profile in Simulink

Simulink block annotations are visible by default to display the QoS File Name and the QoS Profile settings.

![psub](.vortex-opensplice-dds-simulink-guide/207b6ae979e6338b492210dc8150ba961062e02e1455b8ceda2e79695dc1f42e.jpg)

Subscriber

# 5.4 Known Limitations

See QoS Provider Known Limitations for a list of limitations on QoS Provider support.

# 6

# Topic Block

The topic block represents a DDS topic type. The DDS topic corresponds to a single data type. In DDS, data is distributed by publishing and subscribing topic data samples.

For a DDS Topic type definition, a corresponding BUS should be defined in the MATLAB workspace. The name of the BUS and the fields and field types should correspond to the DDS topic IDL definition.

In Simulink, a BUS definition can be used as an input or output signal of the Simulink building blocks.

![The diagram depicts a single large rectangular block with the label '**Topic**' centered below it. Inside the block, there are three elements arranged horizontally:\n\n1.  On the left side, there is the text **')pp'** with an arrow pointing inward into the block.\n2.  In the center, there is an icon depicting a list with three green bullet points.\n3.  On the right side, there is the text **'topic)'** with an arrow pointing outward from the block.](.vortex-opensplice-dds-simulink-guide/959f7035b9fa50c4c2a6bc6b4a39c0a6ad23bdadeb1b1d99d10a4d777f6c3fc3.jpg)

<table><tr><td>Port Type</td><td>Optional</td><td>Name</td><td>Description</td><td>Output consumed by</td></tr><tr><td>Input</td><td>yes</td><td>pp</td><td>DDS Domain Participant entity instance</td><td></td></tr><tr><td>Output</td><td>no</td><td>topic</td><td>DDS Topic entity instance</td><td>Writer, Reader</td></tr></table>

# 6.1 Topic Block Parameters

![Block Parameters: Topic\nTopic\nParameters\nTopic	Ports	QoS\nBus Type:.bus	)))\nTopic Name:\nOK	Cancel	Help	Apply](.vortex-opensplice-dds-simulink-guide/73bd0bb065f8039949cc3c94fb7252f34752f804c473ee8e5703b83d5b3944b1.jpg)

# 6.1.1 Topic Tab

The output port named topic, needs to be configured by the user. No defaults are provided. To configure the topic output port, edit the required parameters in the Block Parameters / Topic tab. The following topic parameters must be specified: Bus Type and Topic Name.

# 6.1.2 Ports Tab

The Ports tab allows the user to toggle on or off optional ports.

# 6.1.3 QoS Tab

The QoS tab is used to set the QoS profile. By default, the OSPL default profile is used.

In DDS - The Data-Distribution Service (DDS) relies on the usage of QoS. A QoS (Quality of Service) is a set of characteristics that controls some aspect of the behavior of the DDS Service.

Each DDS block has an associated QoS profile. By default, the OSPL default profile is used. An XML file that specifies QoS profiles can be used to set the QoS of a DDS block.

# 7

# Domain Block

The Domain block represents a DDS domain participant entity.

In DDS - “A domain participant represents the local membership of the application in a domain. A domain is a distributed concept that links all the applications able to communicate with each other. It represents a communication plane: only the publishers and subscribers attached to the same domain may interact.”

This block is optional on a DDS Simulink model diagram. If it is not present on a model diagram, a default participant will be created by either a topic, writer or reader block.

![pp\nDomain](.vortex-opensplice-dds-simulink-guide/5a0309def5bb7baf684474cbb4aeab4503363017dbc30cade037517d323f3302.jpg)

<table><tr><td>Port Type</td><td>Optional</td><td>Name</td><td>Description</td><td>Output consumed by</td></tr><tr><td>Output</td><td>no</td><td>pp</td><td>DDS Domain Participant entity instance</td><td>Publisher, Subscriber, Topic</td></tr></table>

# 7.1 Domain Block Parameters

![Block Parameters: Domain\nDomain\nParameters\nDomain QoS\nDomain Id:\nDDS_DOMAIN_DEFAULT\nOK Cancel Help Apply](.vortex-opensplice-dds-simulink-guide/1f586767f53137ad1dc692cfef90c02dabc78204046aececfc34c79f54aff45e.jpg)

# 7.1.1 Domain Tab

The domain id is read only. The domain id is the OSPL default domain id specified in the OSPL configuration file.

# 7.1.2 QoS Tab

The QoS tab is used to set the QoS profile. By default, the OSPL default profile is used.

In DDS - The Data-Distribution Service (DDS) relies on the usage of QoS. A QoS (Quality of Service) is a set of characteristics that controls some aspect of the behavior of the DDS Service.

Each DDS block has an associated QoS profile. By default, the OSPL default profile is used. An XML file that specifies QoS profiles can be used to set the QoS of a DDS block.

# 8

# Publisher Block

The Publisher block represents a DDS publisher entity.

In DDS, a publisher is “an object responsible for data distribution. It may publish data of different data types.”

This block is optional on a DDS Simulink model diagram. If it is not present on a model diagram, each writer will create a default publisher.

![The image shows a rectangular box with a black border. Inside the box, a large blue arrow points to the right. To the left of the blue arrow is the text 'pp', preceded by a small black arrow pointing to the right. To the right of the blue arrow is the text 'ppub', followed by a small black arrow pointing to the right.](.vortex-opensplice-dds-simulink-guide/18ffc1306a40800515c89744b50ae2767a9ec190ecddf51625d0300fc371bf8a.jpg)
Publisher

<table><tr><td>Port Type</td><td>Optional</td><td>Name</td><td>Description</td><td>Output consumed by</td></tr><tr><td>Input</td><td>yes</td><td>pp</td><td>DDS Domain Participant entity instance</td><td></td></tr><tr><td>Output</td><td>no</td><td>ppub</td><td>DDS Publisher entity instance</td><td>Writer</td></tr></table>

# 8.1 Publisher Block Parameters

![Block Parameters: Publisher\nPublisher\nParameters\nPorts QoS\nIn Ports:\n✓ Participant\nOK Cancel Help Apply](.vortex-opensplice-dds-simulink-guide/7f018203f2f9361a705101d6bfbe2859e0a1da30f9e0f0b551b7ea848040d104.jpg)

# 8.1.1 Ports Tab

The Ports tab allows the user to toggle on or off optional ports.

# 8.1.2 QoS Tab

The QoS tab is used to set the QoS profile. By default, the OSPL default profile is used.

In DDS - The Data-Distribution Service (DDS) relies on the usage of QoS. A QoS (Quality of Service) is a set of characteristics that controls some aspect of the behavior of the DDS Service.

Each DDS block has an associated QoS profile. By default, the OSPL default profile is used. An XML file that specifies QoS profiles can be used to set the QoS of a DDS block.

# 9

# Subscriber Block

The Subscriber block represents a DDS subscriber entity.

In DDS, a subscriber is “an object responsible for receiving published data and making it available to the receiving application. It may receive and dispatch data of different specified types.”

This block is optional on a DDS Simulink model diagram. If it is not present on a model diagram, each reader will create its own default subscriber.

![Based on the visual evidence, here is the description of the flowchart/block diagram:\n\n**Labeled Blocks:**\n*   There is a single large rectangular block. Inside the block, there is a blue arrow pointing to the left.\n\n**Connections:**\n*   **Left Side:** A right-pointing arrow (head `)`) enters the left side of the block, labeled **'pp'**.\n*   **Right Side:** A left-pointing arrow (head `(`) enters the right side of the block, labeled **'psub'**.](.vortex-opensplice-dds-simulink-guide/2d77f18b782bbb3610b4e3a2d096c0005c3c2318799038904d2e2d2c984f22d9.jpg)

Subscriber

<table><tr><td>Port Type</td><td>Optional</td><td>Name</td><td>Description</td><td>Output consumed by</td></tr><tr><td>Input</td><td>yes</td><td>pp</td><td>DDS Domain Participant entity instance</td><td></td></tr><tr><td>Output</td><td>no</td><td>psub</td><td>DDS Subscriber entity instance</td><td>Reader</td></tr></table>

# 9.1 Subscriber Block Parameters

![Block Parameters: Subscriber\nSubscribers\nParameters\nPorts QoS\nIn Ports:\n✓ Participant\nOK Cancel Help Apply](.vortex-opensplice-dds-simulink-guide/e68351bd55cb89291bd550f1965be62d4f86565a34e8fbbc4d3f878f8352c959.jpg)

# 9.1.1 Ports Tab

The Ports tab allows the user to toggle on or off optional ports.

# 9.1.2 QoS Tab

The QoS tab is used to set the QoS profile. By default, the OSPL default profile is used.

In DDS - The Data-Distribution Service (DDS) relies on the usage of QoS. A QoS (Quality of Service) is a set of characteristics that controls some aspect of the behavior of the DDS Service.

Each DDS block has an associated QoS profile. By default, the OSPL default profile is used. An XML file that specifies QoS profiles can be used to set the QoS of a DDS block.

# 10

# Writer Block

The Writer block represents a DDS data writer entity.

In DDS - “The DataWriter is the object the application must use to communicate to a publisher the existence and value of data-objects of a given type.”

![The image displays a block diagram featuring a central rectangular box labeled **Writer** at the bottom.\n\n**Inside the box:**\n*   A pencil icon.\n*   The text **samples written**.\n\n**Inputs (Left side):**\nFour items have arrows pointing into the left side of the box:\n*   **ppub**\n*   **topic**\n*   **data**\n*   **action**\n\n**Outputs (Right side):**\nTwo items have arrows pointing out of the right side of the box:\n*   **status**\n*   **samples written**](.vortex-opensplice-dds-simulink-guide/e397b001e93a8fa20ee976ebd803851f379938ed4b65fcdf07da3968b3f98f1e.jpg)

<table><tr><td>Port Type</td><td>Op-tional</td><td>Name</td><td>Description</td><td>Output consumed by</td></tr><tr><td>Input</td><td>yes</td><td>ppub</td><td>DDS Publisher entity instance</td><td></td></tr><tr><td>Input</td><td>no</td><td>topic</td><td>DDS Topic entity instance</td><td></td></tr><tr><td>Input</td><td>no</td><td>data</td><td>BUS</td><td></td></tr><tr><td>Input</td><td>yes</td><td>action</td><td>0 write, 1 dispose, 2 write dispose, 3 no operation</td><td></td></tr><tr><td>Output</td><td>yes</td><td>status</td><td>0 for successful writer creation</td><td></td></tr><tr><td>Output</td><td>yes</td><td>samples written</td><td>Number of samples written</td><td>User</td></tr></table>

# 10.1 Writer Block Parameters

![Block Parameters: Writer\nWriter\nParameters\nData	Ports	QoS\nInput Data Type: bus	)))\nBus Width: 1\nWait for\nReader Available	Timeout(s): 0\nWrite after timeout\nOK	Cancel	Help	Apply](.vortex-opensplice-dds-simulink-guide/481b40c60a151d5f5969f93f09c2a00154f078964b3849bad36f3aa6f9f0b3f2.jpg)

# 10.1.1 Data Tab

The Data tab is used to set the input data type (BUS) for the data input port and the bus width.

The bus width is the maximum number of samples that can be written per block step. The user must configure the source blocks that feed the Writer’s data port so that it produces an array of the right size.

Valid values for the bus width are: integers >= 1.

The Reader Available field in the Wait for section is used for specifying if the Writer should wait for the Reader to become available. The associated Timeout field is to specify how long (in seconds) the Writer should wait for the Reader to become available.

The Write after timeout field can only be enabled when the Reader Available field is checked. It specifies if the Writer should write after the Wait for Reader Available timeout.

# 10.1.2 Ports Tab

The Ports tab allows the user to toggle on or off optional ports.

# 10.1.3 QoS Tab

The QoS tab is used to set the QoS profile. By default, the OSPL default profile is used.

In DDS - The Data-Distribution Service (DDS) relies on the usage of QoS. A QoS (Quality of Service) is a set of characteristics that controls some aspect of the behavior of the DDS Service.

Each DDS block has an associated QoS profile. By default, the OSPL default profile is used. An XML file that specifies QoS profiles can be used to set the QoS of a DDS block.

# 11

# Reader Block

The Reader block represents a DDS data reader entity.

In DDS - “To access the received data, the application must use a typed DataReader attached to the subscriber.”

![The diagram depicts a single rectangular block labeled **Reader** at the bottom. It features the following connections:\n\n**Inputs (Left Side):**\n*   **psub** (indicated by an arrow pointing into the block)\n*   **topic** (indicated by an arrow pointing into the block)\n\n**Outputs (Right Side):**\n*   **status** (indicated by an arrow pointing out of the block)\n*   **data** (indicated by an arrow pointing out of the block)\n*   **info** (indicated by an arrow pointing out of the block)\n*   **samples read** (indicated by an arrow pointing out of the block)\n\nInside the block, there is a blue icon of a pair of glasses.](.vortex-opensplice-dds-simulink-guide/f01dd34c1fd634bb7da8908ba04221c15301a30dcb2483ce4b7d25f35dc54a8f.jpg)

<table><tr><td>Port Type</td><td>Optional</td><td>Name</td><td>Description</td><td>Output consumed by</td></tr><tr><td>Input</td><td>yes</td><td>psub</td><td>DDS Subscriber entity instance</td><td></td></tr><tr><td>Input</td><td>no</td><td>topic</td><td>DDS Topic entity instance</td><td></td></tr><tr><td>Output</td><td>yes</td><td>status</td><td>0 for successful reader creation</td><td></td></tr><tr><td>Output</td><td>no</td><td>data</td><td>BUS</td><td>user</td></tr><tr><td>Output</td><td>yes</td><td>info</td><td>BUS</td><td>user</td></tr><tr><td>Output</td><td>yes</td><td>samples read</td><td>Number of samples read</td><td>user</td></tr></table>

# 11.1 Reader Block Parameters

![Block Parameters: Reader\nReader\nParameters\nData	Ports	QoS	Filters\nBus Type: bus	)))\nMode:\n○ read\n● take\nSample Time: -1\nBus Width: 1\nWait for\n□ Historical Data	Timeout(s): 0\n□ Data Available	Timeout(s): 0\nOK	Cancel	Help	Apply](.vortex-opensplice-dds-simulink-guide/73fb34b94974c64f6260af37ce5d7d82aa38bd339f9dddf43aa342f01696c290.jpg)

# 11.1.1 Data Tab

The Data tab is used to set:

• Bus Type

The output data type (BUS) for the data output port

• Mode: take or read

Specify whether the reader block is accessing the samples using DDS take or DDS read.

• Sample Time

“The sample time of a block is a parameter that indicates when, during simulation, the block produces outputs and if appropriate, updates its internal state.” -Simulink documentation

Default is -1, meaning it will inherit the Simulink sample time from inputs or the model. Valid values: -1 and Numeric > 0

• Bus Width

The bus width is the maximum number of samples that can be read or take(n) per block step. Valid values for the bus width are: integers >= 1.

• Wait for

Checking the Historical Data field in the Wait for section specifies that the Reader will wait for historical data to arrive. The Timeout field is for setting time period (in seconds) determining how long the Reader should wait for the historical data. If the timeout is reached, then any remaining historical data may be interleaved with new data.

The Data Available field is for specifying whether the Reader should read only if the data is available. The following Timeouts field determines how long the Reader should wait for the availability of data. If the timeout is reached, then the block returns no data and the simulation continues.

# 11.1.2 Ports Tab

The Ports tab allows the user to toggle on or off optional ports.

# 11.1.3 QoS Tab

The QoS tab is used to set the QoS profile. By default, the OSPL default profile is used.

In DDS - The Data-Distribution Service (DDS) relies on the usage of QoS. A QoS (Quality of Service) is a set of characteristics that controls some aspect of the behavior of the DDS Service.

Each DDS block has an associated QoS profile. By default, the OSPL default profile is used. An XML file that specifies QoS profiles can be used to set the QoS of a DDS block.

# 11.1.4 Filters Tab

The filters tab allows for the filtering of incoming samples. The filtering can happen based on a query and/or on a sample read condition(s).

# Query

Expression: The expression is a SQL condition.

Parameters: N parameters in the format {‘a’, ‘b’} Each parameter element must be a char array (string).

Note: Query expressions are only validated at runtime.

# Read Condition

The read conditions specified will filter the samples that are read or take(n).

Example: For a reader, the Sample State has Read selected and Not Read deselected.

Only samples with a Sample State Read will be processed with read or take. Any samples with the Not Read sample state will not be read or take(n).

Note: At least one read condition must be selected for each category of Sample State, View State, or Instance State. If not, an error will be thrown when a diagram simulation is run.

![Block Parameters: Reader\nReader\nParameters\nData	Ports	QoS	Filters\nQuery\nExpression: color=%0\nParameters: {'RED'}\nRead Condition\nSample State: ✓ Read ✓ Not Read\nView State: ✓ New ✓ Not New\nInstance State: ✓ Alive ✓ Not Alive Disposed ✓ Not Alive No Writers\nOK	Cancel	Help	Apply](.vortex-opensplice-dds-simulink-guide/beebd73757de92da52ebc0762d24899ecee2d35496b8d24af361bf18c59b10ff.jpg)

# 12

# Tutorial

To demonstrate the capabilities of the DDS Simulink Integration, this tutorial will create two Simulink models. One model will write DDS samples, and the second model will read the DDS samples.

Both models will be run simultaneously, and use a DDS system for communication.

A Simulink bus named ShapeType is created as part of this tutorial. The bus can be created by either using the Simulink bus editor, or by generation from an IDL file. Both options are covered in this tutorial.

# 12.1 Create ShapeType Bus Using Simulink Bus Editor

Buses define the data which will be published and read. Both the read and write Simulink models will make use of a bus to read and write sample data.

For this tutorial, we will create a BUS named ShapeType.

# 12.1.1 Open the bus editor from the MATLAB command window

![Command Window\n)) buseditor\nfx ))\nWorkspace\nName L Value\nBus Editor - Manage Bus Objects in the Base Workspace\nFile Edit View Options Help\nFilter: by Bus Name Clear Filter\nBase Workspace\nName DataScope HeaderFile Alignment Description\nBase Workspace\nThe Simulink Bus Editor provides a graphical interface for managing bus objects. A bus object is an instance of the class Simulink.Bus. You can use a bus object to specify the properties of a bus signal.](.vortex-opensplice-dds-simulink-guide/8851677c4ce94e6b27e4815c5db867173d95e8ff09528ce11cacc9e83743b98d.jpg)

# 12.1.2 Add a new BUS named ShapeType

# 12.1.2.1 Select Add Bus button

![Bus Editor - Manage Bus Objects in the Base Workspace\nFile Edit View Options Help\nFilter: by Bus Name\nBase Workspace\nName DataScope Head](.vortex-opensplice-dds-simulink-guide/aeeae35935bb3677eba8d5626623fab536c90d05cb712c0ffbf28a8091af3179.jpg)

# 12.1.2.2 Set Bus name and Key

• Set the new bus name to: ShapeType.
• Set Description to: @Key(color). This sets the Topic key.
• Select Apply button to save.

![Bus Editor - Manage Bus Objects in the Base Workspace\nFile Edit View Options Help\nFilter: by Bus Name\nClear Filter\nBase Workspace\nBusObject\nName DataType Complexity Dimensions Di\nSimulink.Bus: BusObject\nProperties\nName: ShapeType\nCode generation options\nData scope: Auto\nHeader file:\nAlignment: -1\nDescription:\n@Key(color)\nRevert Help Apply](.vortex-opensplice-dds-simulink-guide/41849f385c9b498aa35f5261d33892166547f07f89a65d820a2680d71331fe1e.jpg)

Note: If the Key is not set, the topic block’s Key annotation in the model will be shown empty and it will result in a keyless topic. Keyless topics have only one instance.

# 12.1.3 Add BusElements

The ShapeType bus will have 4 bus elements: color, x, y and shapesize.

A BusElement can be added to the ShapeType bus by selecting the Add/Insert BusElement button.

![Bu Editor - Manage Bus Objed\nFile Edit View Options Help\nBase Workspace\nShapeType\nName](.vortex-opensplice-dds-simulink-guide/df979bd7f37addb92a30204552aa0478a657752548a264a5f3ec65a6d8ee2bb7.jpg)

A BusElement can be moved up or down using the Move Element Up and Move Element Down buttons.

![Bus Editor - Manage Bus Obj\nFile Edit View Options Help\n↑ ↓\nBase Workspace\nShapeType\nName](.vortex-opensplice-dds-simulink-guide/87516c455777b9b1bc2c21aa95ccd242b670f3741ac6e233683343dbc2007149.jpg)

# 12.1.3.1 Add color

• Select Add/Insert BusElement button
• Set name to: color
• Set DataType to: uint8
• Set Dimensions to: 10
• Set Description to: @String
• Select Apply to save

![Bus Editor - Manage Bus Objects in the Base Workspace\nFile Edit View Options Help\nFilter: by Bus Name\nClear Filter\nSimulink.BusElement: color\nProperties\nName: color\nDataType: uint8\nData Type Assistant\nMode: Built in uint8 Data type override: Inherit\nComplexity: real\nDimensions: 10 DimensionsMode: Fixed\nSampleTime: -1\nMinimum: () Maximum: ()\nUnit:\nDescription:\n@String\nRevert Help Apply](.vortex-opensplice-dds-simulink-guide/d49ea809aad51bb9ea81206ea613f028768fdf5ae24209d1236f0be601f43d7c.jpg)

Note: This creates a DDS ‘string’ type. Bus elements of type ‘int8’ or ‘uint8’ with an annotation of @String in the Description field define a DDS string. Dimension set to 10 means Simulink is going to read only the first ten bytes of the string. You can also use the ‘@BString’ annotation to define a DDS bounded string. The dimension of the field is treated as the maximum string size.

# 12.1.3.2 Add x

• Select Add/Insert BusElement button
• Set name to: x
• Set DataType to: int32
• Select Apply to save

![Bus Editor - Manage Bus Objects in the Base Workspace\nFile Edit View Options Help\nFilter: by Bus Name\nClear Filter\nBase Workspace\nShapeType\nx\ncolor\nName\nSimulink.BusElement: x\nProperties\nName: x\nDataType: int32\n((\nData Type Assistant\nMode: Built in int32 Data type override: Inherit\nComplexity: real\nDimensions: 1 DimensionsMode: Fixed\nSampleTime: -1\nMinimum: () Maximum: ()\nUnit:\nDescription:\nRevert Help Apply](.vortex-opensplice-dds-simulink-guide/352a156a9d4d599adf46a250c510968d504a48e8e969893cc1bc7934e335f3ad.jpg)

# 12.1.3.3 Add y

• Select Add/Insert BusElement button
• Set name to: y
• Set DataType to: int32
• Select Apply to save

![Bus Editor - Manage Bus Objects in the Base Workspace\nFile Edit View Options Help\nFilter: by Bus Name\nClear Filter\nBase Workspace\nShapeType\ny\nx\ncolor\nName\nSimulink.BusElement: y\nProperties\nName: y\nDataType: int32\nData Type Assistant\nMode: Built in int32 Data type override: Inherit\nComplexity: real\nDimensions: 1 DimensionsMode: Fixed\nRevert Help Apply](.vortex-opensplice-dds-simulink-guide/e625738247ec53d5f9084588c095ee621bc595b19a447709ba4e5d82ab50ab32.jpg)

# 12.1.3.4 Add shapesize

• Select Add/Insert BusElement button
• Set name to: shapesize
• Set DataType to: int32
• Select Apply to save

![Bus Editor - Manage Bus Objects in the Base Workspace\nFile Edit View Options Help\nFilter: by Bus Name\nClear Filter\nBase Workspace\nShapeType\ncolor\nx\ny\nshapesize\nName\nSimulink.BusElement: shapesize\nProperties\nName: shapesize\nDataType: int32\nData Type Assistant\nMode: Built in int32 Data type override: Inherit\nComplexity: real\nDimensions: 1 DimensionsMode: Fixed\nRevert Help Apply](.vortex-opensplice-dds-simulink-guide/fbe29a82f1b778c4ace9ebc1556a18e5dd7bed4476c480e1d0f4b837220d1460.jpg)

# 12.1.4 Export BUS objects

When bus objects are added to the MATLAB workspace, they will be lost on MATLAB close or workspace clear. To persist the bus objects, they can be exported.

A quick way to export the ShapeType bus using the bus editor, is to right click on the bus and select Export ShapeType to File. . .

![Bus Editor - Manage Bus Objects in the Base Workspace\nFile Edit View Options Help\nFilter: by Bus Name\nName DataType Complexity D\ncolor uint8 real 1\nSimulink.Bus: ShapeType\nProperties\nExport ShapeType to File...\nCreate/Edit a Simulink.Parameter object... Ctrl+P\nCreate a MATLAB Structure... Ctrl+M\nCut Ctrl+X\nCopy Ctrl+C\nPaste Ctrl+V\nDelete Del\nDescription:](.vortex-opensplice-dds-simulink-guide/ef69812ae8e615b04fa6d062bcfa6407f3810c065f1c2edf62dbc504ebc7e9b4.jpg)

The ShapeType bus is complete.

# 12.2 Create ShapeType Using IDL

The public Vortex.idlImportSl function can be called to generate Simulink bus definitions from an IDL file. The generated bus definitions are inserted into the ‘Design Data’ section of a data dictionary.

From the Simulink documentation - “A data dictionary is a persistent repository of data that are relevant to your model. You can also use the base workspace to store design data that are used by your model during simulation.”

The data dictionary can then be referenced from your models.

# 12.2.1 Create IDL File

Create an IDL file to define your ShapeType topic structure. For this tutorial we will name the file ShapeType.idl.

```objectivec
struct ShapeType {
    string color; // @Key
    long x;
    long y;
    long shapesize;
};
#pragma keylist ShapeType color
```

IMPORTANT NOTE: The IDL file has to have a blank line after the pragma keylist declaration. (known bug)

# 12.2.2 Generate Simulink bus definitions from an IDL file

# Steps:

1. In MATLAB, navigate to the directory that contains the ShapeType.idl file. Set this directory to be the MATLAB Current Folder.
2. Call the idlImportSl function in the MATLAB command window.

>> Vortex.idlImportSl(‘ShapeType.idl’, ‘shape.sldd’)

where:

‘ShapeType.idl’ is the name of the IDL file

‘shape.sldd’ is the name of the target data dictionary for the generated bus definitions

# 12.2.3 Model Explorer

To make use of the bus definitions generated into the data dictionary, Simulink models can specify design data using the Model Explorer.

![Model Explorer\nFile Edit View Tools Add Help\nSearch: by Name Name: Search\nModel Hierarchy\nSimulink Root\nBase Workspace\nuntitled\nContents of: untitled (only) Filter Contents\nColumn View: Block Data Types Show Details 3 object(s)\nName BlockType OutDataTypeStr OutMin OutMa\nModel Workspace\nConfiguration (Active)\nAdvice for untitled\nModel Properties: untitled\nMain Callbacks History Description Data\nDesign Data\nDesign data are variables defined outside the model that model and its blocks and signals.\nDefined in:\nBase Workspace\nData Dictionary:\nBrowse... New...\nRevert Help Apply\nContents Search Results](.vortex-opensplice-dds-simulink-guide/7b04d4b5e9aba4241e0c3fa8d367f0d03d75f33f53a0ae73eefba7db23bb5af3.jpg)

# 12.3 Shapes Write Model

This section outlines how to create a new DDS Simulink model that will write sample data for the topic type ShapeType.

Although not necessary, this model will use the optional Domain and Publisher blocks.

# 12.3.1 Create a new Simulink model

# 12.3.1.1 Start Simulink

![MATLAB R2016b\nHOME\nPLOTS\nAPPS\nNew Script\nNew\nOpen\nFind Files\nCompare\nImport Data\nSave Workspace\nNew Variable\nOpen Variable\nClear Workspace\nAnalyze Code\nRun and Time\nClear Commands\nSimulink\nStart Simulink\nLayout\nSet Path\nAdd-Ons\nHelp\nCommunity\nRequest Support\nLearn MATLAB\nFILE\nVARIABLE\nCODE\nSIMULINK\nENVIRONMENT\nRESOURCES](.vortex-opensplice-dds-simulink-guide/70ead066cbf7aa975a913c635c3ae83528fd1f82e6f88a0915d07862346563c1.jpg)

![A solid red arrow pointing upwards.](.vortex-opensplice-dds-simulink-guide/1f06c9edd9002c268c6d045e4eb9345501881d5e8216108933777250d24bebbb.jpg)

# 12.3.1.2 Add a new blank model

![Simulink Start Page\nSIMULINK®\nOpen...\nRecent\ndds_sample_model.six\nProjects\nSource Control...\nArchive...\nNew	Examples\nSearch	All Templates\n✓ Simulink\nBlank Model	Blank Library\nBlank Project	Code Generation](.vortex-opensplice-dds-simulink-guide/7f69d713b409aede9562ed020dc8e43e9592bd62a6577a4be315aa6f92aeeff6.jpg)

# 12.3.1.3 Save As...

• Save the model as “shapes\_write\_model.slx”.

# 12.3.1.4 Model Settings

• Open Model Configuration Parameters dialog, by selecting menu Simulation / Model Configuration Parameters.
• Set the simulation stop time to 1000.0 seconds. (Note: “Simulation time is not the same as clock time. For example, running a simulation for 10 seconds usually does not take 10 seconds. Total simulation time depends on factors such as model complexity, solver step sizes, and computer speed.” Simulink Help documentation)
• Set the Solver Type to Fixed-step.

![Configuration Parameters: shapes_write_model/Configuration (Active)\n★ Commonly Used Parameters\n≡ All Parameters\nSelect:\nSolver\nData Import/Export\nOptimization\n► Diagnostics\nHardware Implementation\nModel Referencing\nSimulation Target\nSimulation time\nStart time: 0.0 Stop time: 1000\nSolver options\nType: Fixed-step Solver: auto (Automatic solver selection)\n► Additional options\nFixed-step size (fundamental sample time): auto\nTasking and sample time options\nPeriodic sample time constraint: Unconstrained\nTreat each discrete rate as a separate task\nAutomatically handle rate transition for data transfer\nHigher priority value indicates higher task priority\nOK Cancel Help Apply](.vortex-opensplice-dds-simulink-guide/f631264cbb08b4d3782f5ebe975d11321dca28b7680e32c14b10bc04ea3e04dc.jpg)

# 12.3.2 Add Simulink DDS Blocks

# 12.3.2.1 Open the Simulink Library Browser

• Open the Simulink Library Browser
• Browse to and select Vortex DDS to view DDS custom blocks

![File Edit View Display Diagram Simulation Analysis Code Tools Help](.vortex-opensplice-dds-simulink-guide/1917e1fb20afc8bcedbdc2aa5a4bb9d7cde55a6ed1078d55d177a267a31b27a2.jpg)

![The image displays a solid red arrow pointing upward, centered against a plain white background.](.vortex-opensplice-dds-simulink-guide/1e9ee057f973ad353f6c45c3d8c9e4cbd6c1d0fb8b89e2f98043b20056952efc.jpg)

![Based on the provided image from the Simulink Library Browser under the 'Vortex DDS' library, here are the labeled blocks and their respective input/output connections:\n\n**Domain**\n*   **Output:** `pp`\n\n**Publisher**\n*   **Input:** `pp`\n*   **Output:** `ppub`\n\n**Reader**\n*   **Inputs:** `psub`, `topic`\n*   **Outputs:** `status`, `data`, `info`, `samples read`\n\n**Subscriber**\n*   **Input:** `pp`\n*   **Output:** `psub`\n\n**Topic**\n*   **Input:** `pp`\n*   **Output:** `topic`\n\n**Writer**\n*   **Inputs:** `ppub`, `topic`, `data`, `action`\n*   **Outputs:** `status`, `samples written`](.vortex-opensplice-dds-simulink-guide/c8e5f7e397fd8115ef64460686034258b9f7a217564f579af4a8c5d8fb60f3c9.jpg)

# 12.3.2.2 Add a Domain block

• Drag a Domain participant block from the Simulink Library Browser onto the Simulink model diagram.

# 12.3.2.3 Set domain block properties

• To set a block’s parameters, double click on the block to bring up the Block Parameters dialog.
• The domain id is read only and set to DDS\_DOMAIN\_DEFAULT. This default is specified in the OSPL configuration file.
• The QoS tab defaults to the OSPL defaults.
• For this tutorial example, we are going to use the defaults, therefore no block parameters need to be specified.

![shapes_write_model * - Simulink\nFile Edit View Display Diagram Simulation Analysis Code Tools Help\n1000\nshapes_write_model\nBlock Parameters: Domain\nDomain\nParameters\nDomain QoS\nDomain Id:\nDDS_DOMAIN_DEFAULT\nQoS File = None\nQoS Profile = Default\nOK Cancel Help Apply](.vortex-opensplice-dds-simulink-guide/f5fc0d7509d7c090ee7cb92cfb3521ca2e30374782ed530c95c5ff16d4b4ca41.jpg)

# 12.3.2.4 Add blocks (Topic, Publisher, and Writer)

Using the Simulink Library Browser drag the following block types onto your diagram:

• 1 Topic
• 1 Publisher
• 1 Writer

# 12.3.2.5 Connect Domain to Topic and Publisher

• Connect the Domain pp output to Topic pp input.
• Connect the Domain pp output to Publisher pp input.

![The diagram displays a Simulink model named 'shapes_write_model' containing four main blocks connected by signal lines.\n\n**1. Domain Block**\n*   **Location:** Left side.\n*   **Label:** 'Domain'\n*   **Ports:** A 'pp' port on the right side and a small downward arrow on the bottom left.\n*   **Text:** 'Domain Id = DDS_DOMAIN_DEFAULT', 'QoS File = None', 'QoS Profile = Default'\n*   **Connection:** A line originates from the 'pp' port and splits into two paths.\n\n**2. Topic Block**\n*   **Location:** Top right.\n*   **Label:** 'Topic'\n*   **Ports:** An input 'pp' port on the left (connected to the split line from the Domain block) and an output 'topic' port on the right. A small downward arrow is on the bottom left.\n*   **Text:** 'Topic', 'Bus Name =', 'Data Type = bus', 'QoS File = None', 'QoS Profile = Default', 'Key =', 'Topic Name ='\n*   **Connection:** The 'topic' port connects to the 'topic' port of the Writer block.\n\n**3. Publisher Block**\n*   **Location:** Bottom middle.\n*   **Label:** 'Publisher'\n*   **Ports:** An input 'pp' port on the left (connected to the split line from the Domain block) and an output 'ppub' port on the right. A small downward arrow is on the bottom left.\n*   **Text:** 'Publisher', 'QoS File = None', 'QoS Profile = Default'\n*   **Connection:** The 'ppub' port connects to the 'ppub' port of the Writer block.\n\n**4. Writer Block**\n*   **Location:** Far right.\n*   **Label:** 'Writer'\n*   **Ports:** Inputs on the left labeled 'ppub' (connected from Publisher), 'topic' (connected from Topic), 'data', and 'action'. Outputs on the right labeled 'status' and 'samples written'.\n*   **Text:** 'Writer', 'Bus Name =', 'Input Data Type = bus', 'QoS File = None', 'QoS Profile = Default', 'Bus Width = 1'](.vortex-opensplice-dds-simulink-guide/b38d1c7c285798dd3d175c7070cc4371be8f12983cb096c530c2f6f36703c26c.jpg)

# 12.3.2.6 Set Topic Block Parameters

• Double click on the Topic to bring up the Block Parameters dialog.
• In the Topic tab:

– Set Bus Type to: ShapeType

– Set Topic Name to: Circle

• The Ports tab allows for the setting of optional ports. For this model, we will not change the defaults.
• Select the QoS tab.
• Set the QoS file to: Shapes\_Demo\_QoS.xml.

/INSTALLDIR/ADLINK/Vortex\_v2/Device/VortexOpenSplice/6.8.x/HDE/x86\_64.linux/tools/matlab/ /examples/simulink/dds\_reader\_writer\_model/Shapes\_Demo\_QoS.xml

![**Labeled Blocks:**\n\n*   **Domain Block:** Located on the left. Inside is a blue circle icon. To the right of the icon is the label 'pp'. Below the block, the text reads:\n    *   'Domain'\n    *   'Domain Id = DDS_DOMAIN_DEFAULT'\n    *   'QoS File = None'\n    *   'QoS Profile = Default'\n*   **Topic Block:** Located in the upper right. It has an input port labeled 'pp' on the left and an output port labeled 'topic' on the right. Inside is a green list-like icon. Below the block, the text reads:\n    *   'Topic'\n    *   'Bus Name = ShapeType'\n    *   'Data Type = Bus: ShapeType'\n    *   'QoS File = None'\n    *   'QoS Profile = Default'\n    *   'Key = color'\n    *   'Topic Name = Circle'\n*   **Publisher Block:** Located in the lower right. It has an input port labeled 'pp' on the left and an output port labeled 'ppub' on the right. Inside is a blue arrow icon. Below the block, the text reads:\n    *   'Publisher'\n    *   'QoS File = None'\n    *   'QoS Profile = Default'\n\n**Connections:**\n\n*   A black line originates from the 'pp' port of the **Domain** block.\n*   The line splits into two branches:\n    *   One branch connects to the 'pp' input port of the **Topic** block.\n    *   The other branch connects to the 'pp' input port of the **Publisher** block.\n\n**Dialog Box Text:**\n\n*   **Window Title:** 'Block Parameters: Topic'\n*   **Header:** 'Topic'\n*   **Group:** 'Parameters'\n*   **Tabs:** 'Topic', 'Ports', 'QoS'\n*   **Fields:**\n    *   'Bus Type:', 'Bus: ShapeType', '))'\n    *   'Topic Name:', 'Circle'\n*   **Buttons:** 'OK', 'Cancel', 'Help', 'Apply'](.vortex-opensplice-dds-simulink-guide/93f2fa002591e1dbd77aec116fc30be4b13e5f2048f5341a7c72ae3a7db263a1.jpg)

# 12.3.2.7 Connect Topic, Publisher and Writer Blocks & Set Writer Block Parameters

• Connect the Topic topic output to the Writer topic input.
• Connect the Publisher ppub output to the Writer ppub input.
• Double click on the Writer block to edit the Block Parameters. Set the Input Data Type to the bus: ShapeType.
• Select the Writer QoS tab.
• Set the QoS file to: Shapes\_Demo\_QoS.xml.

– /INSTALLDIR/ADLINK/Vortex\_v2/Device/VortexOpenSplice/6.8.x/HDE/x86\_64.linux/tools/matlab/ /examples/simulink/dds\_reader\_writer\_model/Shapes\_Demo\_QoS.xml

![The flowchart displays a Simulink model with four main blocks connected by signal lines.\n\n**Blocks and Properties:**\n\n1.  **Domain** (Leftmost block)\n    *   **Port:** pp\n    *   **Properties:**\n        *   Domain Id = DDS_DOMAIN_DEFAULT\n        *   QoS File = None\n        *   QoS Profile = Default\n\n2.  **Topic** (Top middle block)\n    *   **Ports:** pp (input), topic (output)\n    *   **Properties:**\n        *   Bus Name = ShapeType\n        *   Data Type = Bus: ShapeType\n        *   QoS File = Shapes_Demo_QoS.xml\n        *   QoS Profile = DDS Shapes_Demo_Profile\n        *   Key = color\n        *   Topic Name = Circle\n\n3.  **Publisher** (Bottom middle block)\n    *   **Ports:** pp (input), ppub (output)\n    *   **Properties:**\n        *   QoS File = None\n        *   QoS Profile = Default\n\n4.  **Writer** (Rightmost block)\n    *   **Inputs:** ppub, topic, data, action\n    *   **Outputs:** status, samples written\n    *   **Properties:**\n        *   Bus Name = ShapeType\n        *   Input Data Type = Bus: ShapeType\n        *   QoS File = Shapes_Demo_QoS.xml\n        *   QoS Profile = DDS Shapes_Demo_Profile\n        *   Bus Width = 1\n\n**Connections:**\n\n*   A line originates from the **Domain** block port `pp`, splitting into two branches:\n    *   One branch connects to the **Topic** block port `pp`.\n    *   The other branch connects to the **Publisher** block port `pp`.\n*   A line connects the **Topic** block port `topic` to the **Writer** block port `topic`.\n*   A line connects the **Publisher** block port `ppub` to the **Writer** block port `ppub`.](.vortex-opensplice-dds-simulink-guide/e61b226b3f310eb4bee275d165f502ae5191c776bb9d75625abf4e294a7e45a8.jpg)

# 12.3.2.8 Add a Bus Creator to Set Sample Data

To generate sample data, we will add a Simulink / Signal Routing / BusCreator block to our diagram.

![**Dialog Box: Block Parameters: Bus Creator**\n\n*   **Title:** Block Parameters: Bus Creator\n*   **Block Name:** BusCreator\n*   **Description:** This block creates a bus signal from its inputs.\n*   **Parameters Section:**\n    *   **Number of inputs:** 4\n    *   **Filter by name:** (Text Field)\n    *   **Find:** (Button)\n    *   **Signals in the bus:**\n        *   signal1\n        *   signal2\n        *   signal3\n        *   signal4\n    *   **Right-side buttons:** Refresh, Up, Down, Add, Remove\n    *   **Output data type:** Bus: ShapeType\n    *   **))** (Button)\n    *   **Override bus signal names from inputs:** (Unchecked Checkbox)\n    *   **Require input signal names to match signals above:** (Unchecked Checkbox)\n    *   **Output as nonvirtual bus:** (Checked Checkbox)\n*   **Bottom Buttons:** OK, Cancel, Help, Apply\n\n**Diagram Blocks and Connections**\n\n*   **Block 1 (Left):**\n    *   **Label:** Domain\n    *   **Properties:**\n        *   Domain Id = DDS_DOMAIN_DEFAULT\n        *   QoS File = None\n        *   QoS Profile = Default\n    *   **Output Port:** pp\n*   **Block 2 (Top Right, partially obscured):**\n    *   **Input Port:** pp\n    *   **Properties:**\n        *   Bus N...\n        *   Data Typ...\n        *   QoS File = S...\n        *   QoS Profile = D...\n        *   Topic...\n*   **Block 3 (Bottom Right, partially obscured):**\n    *   **Input Port:** pp\n    *   **Properties:**\n        *   QoS...\n\n**Connections:**\n*   A signal line originates from the **pp** output port of the **Domain** block.\n*   This line splits into two branches.\n*   One branch connects to the **pp** input port of the **Top Right** block.\n*   The other branch connects to the **pp** input port of the **Bottom Right** block.](.vortex-opensplice-dds-simulink-guide/05fd9b241e4738056c1ed540f2ef4e5ba4af213838b5bb76dbbbf968ad77212f.jpg)

# 12.3.2.9 Add Bus Creator Inputs

For demonstration purposes, we will input to the BusCreator signals using Constant, Clock and Sine Wave blocks.

Note: To change the positioning of block ports, you can use the Rotate & Flip block menu item, accessible by right clicking on a block.

• Drag 2 Simulink / Sources / Constant blocks onto the diagram
• Connect one Constant block to color input signal
• Connect one Constant block to shapesize input signal

![Based on the provided image, here is the description of the flowchart:\n\n**Labeled Blocks:**\n*   **Constant:** A square box containing the number '1' with the text 'Constant' below it.\n*   **Constant1:** A square box containing the number '1' with the text 'Constant1' below it.\n*   **Vertical Bar:** A tall, thick black vertical rectangle on the right side.\n\n**Connections:**\n*   **color:** A horizontal arrow connects the 'Constant' block to the upper portion of the vertical black bar. The text 'color' is positioned above this arrow.\n*   **shapesize:** A horizontal arrow connects the 'Constant1' block to the lower portion of the vertical black bar. The text 'shapesize' is positioned above this arrow.\n*   There is a thin line extending from the right side of the vertical black bar, moving to the far right edge, going upwards, and looping back into the vertical bar.\n*   Two ')' symbols are visible on the right face of the vertical black bar.](.vortex-opensplice-dds-simulink-guide/3ff465e5fcb585eb7d601f7ae41e7a468ed37f95e68983bd04e07872d21e8564.jpg)

• Set the Block Parameters for color signal Constant block
• Set Constant value to: uint8(pad(‘GREEN’,10,’right’, char( 0 ) ))
• Select OK

![Block Parameters: Constant\nConstant\nOutput the constant specified by the 'Constant value' parameter. If\n'Constant value' is a vector and 'Interpret vector parameters as 1-D' is\non, treat the constant value as a 1-D array. Otherwise, output a matrix\nwith the same dimensions as the constant value.\nMain Signal Attributes\nConstant value:\nuint8(pad('GREEN',10,'right', char( 0 ) ))\n✓ Interpret vector parameters as 1-D\nSample time:\ninf\nOK Cancel Help Apply](.vortex-opensplice-dds-simulink-guide/f9ed29ceac4ea3152ae8332ad1844adc0054df94604504c9f392f0296c006ec5.jpg)

• Set the Block Parameters for shapesize signal Constant block
• Set Constant value to: 25
• Set Output data type to: int32

![Block Parameters: Constant1\nConstant\nOutput the constant specified by the 'Constant value' parameter. If\n'Constant value' is a vector and 'Interpret vector parameters as 1-D' is\non, treat the constant value as a 1-D array. Otherwise, output a matrix\nwith the same dimensions as the constant value.\nMain Signal Attributes\nConstant value:\n25\n✓ Interpret vector parameters as 1-D\nSample time:\ninf\nOK Cancel Help Apply](.vortex-opensplice-dds-simulink-guide/15e5f868d5b7222b53b39b021b72c9a0eb8f6ca8358540098c8e820b4420fa11.jpg)

![Block Parameters: Constant1\nConstant\nOutput the constant specified by the 'Constant value' parameter. If\n'Constant value' is a vector and 'Interpret vector parameters as 1-D' is\non, treat the constant value as a 1-D array. Otherwise, output a matrix\nwith the same dimensions as the constant value.\nMain Signal Attributes\nOutput minimum:\n() Output maximum:\n()\nOutput data type: int32 ))\nLock output data type setting against changes by the fixed-point tools\nOK Cancel Help Apply](.vortex-opensplice-dds-simulink-guide/0704eeba811a13e38f058601581b7d61f43145826af9ff7fcd091d1e4cda7fa4.jpg)

• Drag a Simulink / Sources / Sine Wave block onto diagram
• Connect Sine Wave block to y input signal
• Drag a Simulink / Signal Attributes / Data Type Conversion block onto Sine Wave connector.
• Set Output data type to: int32

![The flowchart depicts a data flow diagram with the following labeled blocks and connections:\n\n**Blocks:**\n*   **Top Left:** A square block labeled **'-C-'** with the text **'Constant'** underneath.\n*   **Middle Left:** A square block containing a wave symbol, labeled **'Sine Wave'**.\n*   **Middle Center:** A rectangular block with a blue border labeled **'int32'** with the text **'Data Type Conversion'** underneath.\n*   **Bottom Left:** A square block labeled **'25'** with the text **'Constant1'** underneath.\n*   **Right:** A thick vertical black bar (representing a merge block) with a downward arrow at its base.\n\n**Connections:**\n*   An arrow labeled **'color'** connects the **Constant** block to the top input of the vertical black bar.\n*   An arrow connects the **Sine Wave** block to the **Data Type Conversion** block.\n*   An arrow connects the **Data Type Conversion** block to the middle input of the vertical black bar.\n*   An arrow labeled **'shapesize'** connects the **Constant1** block to the bottom input of the vertical black bar.\n*   A single line exits the right side of the vertical black bar.](.vortex-opensplice-dds-simulink-guide/7548ea5b4fcebcd65ff0faf7c68cf26f27923d897f613c3ccb112e75dd7aad89.jpg)

• Set Block Parameters for Sine Wave block.
• Set Amplitude to: 150
• Set Bias to: 175
• Set Sample time to: 0.5

![The image displays a close-up of a circular orange button featuring a black 'X' in the center, set against a dark vertical background.](.vortex-opensplice-dds-simulink-guide/bff49d5676a73adfa42ed154823078aaae3cd17453ddd98ee4656661323d0544.jpg)

![The image displays three identical icons arranged in a horizontal row. Each icon is a light gray circle containing a square frame, which consists of an outer square outline and a smaller, concentric square outline inside it. The icons are rendered in grayscale.](.vortex-opensplice-dds-simulink-guide/a6be224be737bd30106c70bdc192fd2ff412805e5ad5b6d6b7a01e2fc31ff378.jpg)

# Block Parameters: Sine Wave

Sine Wave

Output a sine wave:

O(t) = Amp\*Sin(Freq\*t+Phase) + Bias

Sine type determines the computational technique used. The parametersinthe twotypesarerelated through:

Samples per period = 2\*pi /(Frequency \* Sample time)

Number of offset samples = Phase \* Samples per period/(2\*pi)

Use the sample-based sine type if numerical problems due to running forlarge times(e.g.overflowinabsolutetime)occur.

Parameters

Sine type:Time based

Time (t):Use simulation time

Amplitude:

150

![The image displays a large, bright red arrow pointing to the left, centered against a white background. Faint, thin grey horizontal lines are visible at the very top and bottom edges of the frame.](.vortex-opensplice-dds-simulink-guide/94ae0226b28b207181acea3753e2dd160ae44158938e425d1f0f39e61500627c.jpg)

Bias:

175

![The image displays a large, red arrow pointing to the left. It is centered on a white background that features thin, horizontal gray lines running across the top and bottom edges.](.vortex-opensplice-dds-simulink-guide/545884fd36f605b0a383c8b486bac5f33a63d6a1cd8d32494f6ce4606cb887b0.jpg)

Frequency (rad/sec):

1

Phase (rad):

0

Sample time:

0.5

![The image displays a large, red arrow pointing to the left, centered within a white rectangular area bordered by thin grey horizontal lines.](.vortex-opensplice-dds-simulink-guide/26545759c7198443f357a5434d3ca2c6ad03740170b6b65357e74588df29dc42.jpg)

√Interpret vector parameters as1-D

![The image features two light blue circular icons, each displaying a white question mark in the center. The left icon is smaller, while the right icon is larger and surrounded by a white ring.](.vortex-opensplice-dds-simulink-guide/ed01f1f128fcae70abcb08d2f4dd1f92b5ffb5cf7c6e3603cd9c1adec1845e51.jpg)

OK

Cancel

Help

• For the x input signal, drag 3 new blocks onto diagram:

– Simulink / Sources / Constant
– Simulink / Sources / Clock
– Simulink / Math Operations / Math Function

• Set Block Parameters for Math Function block.

• Set Function to: mod

• Set Output signal type to: real

![**Dialog Box: Block Parameters: Math Function**\n*   **Header:** Math\n*   **Description:** Mathematical functions including logarithmic, exponential, power, and modulus functions. When the function has more than one argument, the first argument corresponds to the top (or left) input port.\n*   **Tabs:** Main, Signal Attributes\n*   **Fields:**\n    *   Function: mod (indicated by a red arrow)\n    *   Output signal type: real (indicated by a red arrow)\n*   **Buttons:** OK, Cancel, Help, Apply\n\n**Background Blocks and Labels**\n*   pp\n*   -C-, Constant\n*   mod, Math Function\n*   Sine Wave\n*   Data Typ\n*   1, Constant2\n*   Clock\n*   25, Constant1\n*   shapesize (label on the wire)](.vortex-opensplice-dds-simulink-guide/6a2dc3fe254ceb190b487e085a850583cb4a43863e0c6104eb82ab70c7e1123a.jpg)

• Set Block Parameters for Constant block.
• Set Constant value to: 350

![Block Parameters: Constant2\nConstant\nOutput the constant specified by the 'Constant value' parameter. If 'Constant value' is a vector and 'Interpret vector parameters as 1-D' is on, treat the constant value as a 1-D array. Otherwise, output a matrix with the same dimensions as the constant value.\nMain Signal Attributes\nConstant value:\n350\n✓ Interpret vector parameters as 1-D\nSample time:\ninf\n25\nConstant1\n1\nConstant2\nClock](.vortex-opensplice-dds-simulink-guide/96a00a4d2b855148587a1efc599a2cd387dbfff430ce6e31ba1e6088e8b77128.jpg)

• Connect the Clock and Constant blocks to the mod Math Function
• Connect the mod Math Function to the BusCreator x input signal

![**Blocks:**\n*   '-C-' (Constant)\n*   'Clock'\n*   '350' (Constant2)\n*   'mod' (Math Function)\n*   'Sine Wave'\n*   'int32' (Data Type Conversion)\n*   '25' (Constant1)\n*   A tall vertical black bar (acting as a multiplexer or bus)\n\n**Connections:**\n*   The 'Clock' and '350' (Constant2) blocks both connect to the inputs of the 'mod' (Math Function) block. The output of 'mod' connects to the second input of the vertical bar.\n*   The '-C-' (Constant) block connects to the top input of the vertical bar; the wire is labeled 'color'.\n*   The 'Sine Wave' block connects to the input of the 'int32' (Data Type Conversion) block, which then connects to the third input of the vertical bar.\n*   The '25' (Constant1) block connects to the bottom input of the vertical bar; the wire is labeled 'shapesize'.\n*   A single line exits the bottom of the vertical bar and extends to the right.](.vortex-opensplice-dds-simulink-guide/69d8361c9beb42db0f7e063e88a1338a05fb3dbd4fe85331084ff92737d07ca6.jpg)

• Drag a Simulink / Signal Attributes / Data Type Conversion block onto Math Function connector.
• Set Output data type to: int32

![Based on the provided image, here is the accurate description of the flowchart:\n\n**Labeled Blocks:**\n*   **Clock** (symbol of a clock)\n*   **Constant2** (contains value '350')\n*   **Constant** (contains value '-C-')\n*   **Math Function** (contains value 'mod')\n*   **Data Type Conversion1** (contains value 'int32', highlighted with a blue box and red arrow)\n*   **Data Type Conversion** (contains value 'int32')\n*   **Sine Wave** (symbol of a wave)\n*   **Constant1** (contains value '25')\n*   A thick **vertical black bar** on the far right acting as a terminal or bus.\n\n**Connections:**\n*   **Clock** and **Constant2** both connect to **Math Function**.\n*   **Math Function** connects to **Data Type Conversion1**.\n*   **Data Type Conversion1** connects to the vertical black bar.\n*   **Constant** connects to the vertical black bar (associated with the label 'color').\n*   **Sine Wave** connects to **Data Type Conversion**.\n*   **Data Type Conversion** connects to the vertical black bar.\n*   **Constant1** connects to the vertical black bar (associated with the label 'shapesize').](.vortex-opensplice-dds-simulink-guide/243681564a7f73b9307914b5fb2d9342072e71cb6b50308a6350ca4e35374f75.jpg)

Save your model. Your model is now complete!

# 12.4 Shapes Read Model

# 12.4.1 Create a new Simulink model

This section outlines how to create a new DDS Simulink model that will read and display sample data for the topic type ShapeType.

In this model example, we will be making use of many of the defaults, so the optional blocks will not be included in this model.

# 12.4.1.1 Start Simulink

![MATLAB R2016b\nHOME\nPLOTS\nAPPS\nNew\nScript\nNew\nOpen\nFind Files\nCompare\nImport\nData\nSave\nWorkspace\nNew Variable\nOpen Variable\nClear Workspace\nAnalyze Code\nRun and Time\nClear Commands\nSimulink\nStart Simulink\nLayout\nSet Path\nAdd-Ons\nHelp\nCommunity\nRequest Support\nLearn MATLAB\nFILE\nVARIABLE\nCODE\nSIMULINK\nENVIRONMENT\nRESOURCES](.vortex-opensplice-dds-simulink-guide/66d78e7d6edb8e12e570b7881c33bec614d2a7066d39ebead3900827fec5e20f.jpg)

# 12.4.1.2 Add a new blank model

![Simulink Start Page\nSIMULINK®\nOpen...\nRecent\ndds_sample_model.six\nProjects\nSource Control...\nArchive...\nNew	Examples\nSearch	All Templates\n✓ Simulink\nBlank Model	Blank Library\nBlank Project	Code Generation](.vortex-opensplice-dds-simulink-guide/53e15b358ef271f4732258fd95327eb54230f07dbd848c5d147d67cf87e58b3e.jpg)

# 12.4.1.3 Save As...

• Save the model as “shapes\_read\_model.slx”.

# 12.4.1.4 Model Settings

• Open Model Configuration Parameters dialog, by selecting menu Simulation / Model Configuration Parameters.
• Set the simulation stop time to inf. (Note: “Specify inf to run a simulation or generated program until you explicitly pause or stop it.” Simulink Help documentation)
• Set the Solver Type to Fixed-step.

![Configuration Parameters: shapes_read_model/Configuration (Active)\n★ Commonly Used Parameters\nAll Parameters\nSelect:\nSolver\nData Import/Export\nOptimization\n► Diagnostics\nHardware Implementation\nModel Referencing\nSimulation Target\nSimulation time\nStart time: 0.0 Stop time: inf\nSolver options\nType: Fixed-step Solver: auto (Automatic solver selection)\n► Additional options\nOK Cancel Help Apply](.vortex-opensplice-dds-simulink-guide/835709ce47a6a8e17c70c05f1e54db6fca8a51f8ca4dd7407f4c68aac900abda.jpg)

# 12.4.2 Add Simulink DDS Blocks

# 12.4.2.1 Open the Simulink Library Browser

# 12.4.2.2 Add all required blocks (Topic and Reader)

Using the Simulink Library Browser drag the following block types onto your diagram:

• 1 Topic
• 1 Reader

Note: For this example model, we will be using the block defaults for the Domain and Subscriber, therefore they will not be included on the model.

To set a block’s parameters, double click on the block to bring up the Block Parameters dialog.

# 12.4.2.3 Toggle off optional ports

• Double click on the Topic to bring up the Block Parameters dialog.
• In the Topic Ports tab deselect the Participant port.
• Double click on the Reader to bring up the Block Parameters dialog.
• In the Reader Ports tab deselect the Subscriber, Reader, Status, Info and Samples Read ports.

# Simulink Library Browser

![A blue arrow pointing to the left.](.vortex-opensplice-dds-simulink-guide/67c7ee147c6ee0ecc3b20a24a54334a18f1f2d2cb6c79fec45f6e2055e7341f0.jpg)

![The image displays a horizontal row of three identical arrows pointing to the right. The arrows are rendered in a light grey or beige color with a slightly darker outline and are evenly spaced against a plain, light-colored background. There is no legible text visible.](.vortex-opensplice-dds-simulink-guide/5e8fc213813e0af4a2bce9d5e3191146fcddb577c05c4cb60338e661f3350679.jpg)

![A black downward-pointing triangle on a white background.](.vortex-opensplice-dds-simulink-guide/e5db81e34858d22476a3515e8f7dcc92d86b2cd0beba8347a3caae9238d921a0.jpg)

![The image displays a section of a digital interface. On the far left is a large, black, uppercase letter 'A'. Partially overlapping the letter to its right is a blue magnifying glass icon. To the right of the magnifying glass is a black downward-pointing triangle.](.vortex-opensplice-dds-simulink-guide/9c37e5eba6d63debfcc3196a9280c9e912bc517551e6f1b8a4e077b1c4ef93e1.jpg)

![This image is a close-up view of a digital interface, likely a software toolbar, featuring square buttons with directional arrows. On the left side, there are two square buttons stacked vertically, each displaying a blue arrow pointing to the left. To the right of the top button is another square button containing a red arrow pointing to the left. A hand is reaching into the frame from the right side, with a finger pressing or pointing at the button with the red arrow. There is no text in the image.](.vortex-opensplice-dds-simulink-guide/a3f72b14abab3d9af3849871ac50a4e317d0a7e678924d669a85a3f4f33f10aa.jpg)

![The image displays a horizontal row of three icons on a white background. On the left and right sides are black, downward-pointing triangles (arrows). In the center is a yellow folder icon.](.vortex-opensplice-dds-simulink-guide/4a254ee768ab1fa78e906611699c4ff2975edbea25d0d60fcdf88e53e69e77c8.jpg)

![The image displays a small, dark, and blurry icon centered on a white background. The icon resembles a stylized container, such as a bucket or a trash bin. It consists of a vertical rectangular body with a horizontal line across the top, creating the appearance of a lid or rim. The image is pixelated, suggesting it is a low-resolution graphic.](.vortex-opensplice-dds-simulink-guide/9bf4a994c9e3a3ab9e446c836d1531cc87fbda65c5c3f65b38724502a20a0c04.jpg)

![A circular icon featuring a light blue gradient background with a black question mark centered within it.](.vortex-opensplice-dds-simulink-guide/1b157363de44497868b39a5280132ab81da368cd69773628daa9c95802e029de.jpg)

# Vortex DDS

# Simulink

Commonly Used Blocks

Continuous

Dashboard

Discontinuities

Discrete

Logic and Bit Operations

Lookup Tables

Math Operations

ModelVerification

Model-Wide Utilities

Ports&Subsystems

Signal Attributes

Signal Routing

Sinks

Sources

User-Defined Functions

Additional Math& Discrete

HDL Coder
Simulink 3D Animation
Simulink Coder
Simulink Extras

Stateflow

# VortexDDS

Recently Used

![Simple blue circular shape inside a rectangular frame with no text or symbols](.vortex-opensplice-dds-simulink-guide/eb13c502f5dc839619908562b942240334ddfc04d6a7b0e380f0801be451289b.jpg)

Domain

![Based on the provided image, here is the accurate description of the flowchart:\n\n*   **Input:** An arrow pointing into the left side of a rectangular box, labeled **'pp'**.\n*   **Process:** Inside the box, there is a blue arrow pointing to the right.\n*   **Output:** An arrow pointing out of the right side of the box, labeled **'ppub'**.](.vortex-opensplice-dds-simulink-guide/bbddeb837c9da2410d54070d5560eea5c9f8addbea01dba3b6b7d66be9ca6ba2.jpg)

Publisher
![The image displays a single rectangular block diagram representing a process or node.\n\n**Labeled Blocks/Inputs/Outputs:**\n*   **Inputs (Left side):**\n    *   'psub'\n    *   'topic'\n*   **Outputs (Right side):**\n    *   'status'\n    *   'data'\n    *   'info'\n    *   'samples read'\n\n**Connections:**\n*   Arrows labeled **'psub'** and **'topic'** point into the left side of the box.\n*   Arrows labeled **'status'**, **'data'**, **'info'**, and **'samples read'** point out from the right side of the box.\n*   Inside the box, there is a blue symbol resembling a pair of glasses.](.vortex-opensplice-dds-simulink-guide/8979ac3dd5a8097a42d4a1328bf75f9079367311e1004224df087234143b0209.jpg)

Reader

![The image displays a rectangular block diagram containing the following elements arranged horizontally from left to right:\n\n*   A right-pointing arrowhead.\n*   The text **pp**.\n*   A large blue arrow pointing to the left.\n*   The text **psub**.\n*   A right-pointing arrowhead.](.vortex-opensplice-dds-simulink-guide/2971a0782f0fae8967fb3bd12e1a99e7cf8b59ebc097a9b5b7b66c332b6bbba5.jpg)

Subscriber

![The diagram depicts a single central processing block with inputs and outputs.\n\n*   **Central Block:** A large rectangular box containing a centered icon of a notepad with a checklist (green circles).\n*   **Left Connection:** An arrow pointing into the left side of the box, labeled **pp**.\n*   **Right Connection:** An arrow pointing out of the right side of the box, labeled **topic**.](.vortex-opensplice-dds-simulink-guide/0c626f864dcdbec4a1a93f7fa6657cab89cab2f76d1ddd2901b5a99c4ea89233.jpg)

Topic

![ppub\ntopic\ndata\naction\nstatus\nsamples written](.vortex-opensplice-dds-simulink-guide/d739c93875ad82f653ab257bc19eb2c94a0e87f07da30662c5bfd7b8d7f75064.jpg)

Writer

![The image displays a Simulink model with two main blocks connected by a signal line.\n\n**Left Block:**\n*   **Label:** Topic\n*   **Ports:**\n    *   Left side: 'pp'\n    *   Right side: 'topic'\n*   **Properties listed below:**\n    *   Bus Name =\n    *   Data Type = bus\n    *   QoS File = None\n    *   QoS Profile = Default\n    *   Key =\n    *   Topic Name =\n\n**Right Block:**\n*   **Label:** Reader\n*   **Ports:**\n    *   Left side: 'psub' (top), 'topic' (bottom)\n    *   Right side: 'status' (top), 'data' (middle), 'info' (middle), 'samples read' (bottom)\n*   **Properties listed below:**\n    *   Bus Name =\n    *   Output Data Type = bus\n    *   QoS File = None\n    *   QoS Profile = Default\n    *   Read Mode = take\n    *   Ts = -1\n    *   Bus Width = 1\n\n**Connections:**\n*   A line connects the 'topic' output port of the **Topic** block to the 'topic' input port of the **Reader** block.](.vortex-opensplice-dds-simulink-guide/99ee725d73ac8a3d2bc2c0c39d4491edef33481876eac8f75df846ed14b5e11e.jpg)

# 12.4.2.4 Set Topic Block Parameters

• Double click on the Topic to bring up the Block Parameters dialog, select Topic tab.
• Set the Bus Type: ShapeType bus Note: If the ShapeType bus is not displayed, select Refresh data types from dropdown list.
• Set the Topic Name to: Circle.

![shapes_read_model * - Simulink\nFile Edit View Display Diagram Simulation Analysis Code Tools Help\nshapes_read_model\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\nTopic\n topic\nPorts QoS\nBus Type: Bus: ShapeType )))\nTopic Name:\nCircle\nOK Cancel Help Apply\nReady 100% FixedStepAuto](.vortex-opensplice-dds-simulink-guide/9ce6dc8c53441c8aa2c4d13080684cec1b0118b44de32cf3d346b0ef08295889.jpg)

• Select the QoS tab.
• Set the QoS file to [Shapes\_Demo\_QoS.xml.]

INSTALLDIR/ADLINK/Vortex\_v2/Device/VortexOpenSplice/6.8.x/HDE/x86\_64.linux/tools/matlab/

# 12.4. Shapes Read Model

examples/simulink/dds\_reader\_writer\_model/Shapes\_Demo\_QoS.xml

# 12.4.2.5 Set Reader Block Parameters

• Double click on the Reader block to edit the Block Parameters. Set the Input Data Type to the bus: ShapeType.
• Select the QoS tab.
• Set the QoS file to [Shapes\_Demo\_QoS.xml.]

INSTALLDIR/ADLINK/Vortex\_v2/Device/VortexOpenSplice/6.8.x/HDE/x86\_64.linux/tools/matlab/ examples/simulink/dds\_reader\_writer\_model/Shapes\_Demo\_QoS.xml

# 12.4.2.6 Connect Topic and Reader

• Connect the Topic block topic output to the Reader block topic input.

![This Simulink model, titled 'shapes_read_model', features two main blocks connected by a signal line:\n\n**1. Topic Block (Left)**\n*   **Label:** Topic\n*   **Properties:**\n    *   Bus Name = ShapeType\n    *   Data Type = Bus: ShapeType\n    *   QoS File = Shapes_Demo_QoS.xml\n    *   QoS Profile = DDS Shapes_Demo_Profile\n    *   Key = color\n    *   Topic Name = Circle\n*   **Ports:** It has a downward-pointing arrow port at the bottom left and an output port on the right labeled **topic**.\n\n**2. Reader Block (Right)**\n*   **Label:** Reader\n*   **Properties:**\n    *   Bus Name = ShapeType\n    *   Output Data Type = Bus: ShapeType\n    *   QoS File = Shapes_Demo_QoS.xml\n    *   QoS Profile = DDS Shapes_Demo_Profile\n    *   Read Mode = take\n    *   Ts = -1\n    *   Bus Width = 1\n*   **Ports:** It has an input port on the left labeled **topic**, an output port on the right labeled **data**, and a downward-pointing arrow port at the bottom left.\n\n**Connection:**\nA single line connects the **topic** output port of the 'Topic' block to the **topic** input port of the 'Reader' block.](.vortex-opensplice-dds-simulink-guide/015a8da3e2e04d095d3f59a2b8340189a7d4b8466c25e85ead3bb009cf77be18.jpg)

# 12.4.2.7 Add a Bus Selector to read and display sample data

To read and display sample data, we will add a Simulink / Signal Routing / Bus Selector block to our diagram.

# 12.4.2.8 Set Bus Selector Block Parameters

Specify the output signals we would like to display in our simulation. For this example, we will display all the ShapeType BUS signals in the running simulation.

• Connect the Reader data output to the Bus Selector.
• Double click on the Bus Selector block to edit the Block Parameters.
• Add all the signals in the bus to the Selected signals.

![The image shows a block diagram on the left and a 'Block Parameters: Bus Selector' dialog window on the right.\n\n**Diagram Blocks and Connections:**\n*   **Topic Block:** Labeled 'Topic'. It has an output port labeled 'topic'. Below it, the text reads:\n    *   Bus Name = ShapeType\n    *   Data Type = Bus: ShapeType\n    *   QoS File = Shapes_Demo_QoS.xml\n    *   QoS Profile = DDS_Shapes_Demo_Profile\n    *   Key = color\n    *   Topic Name = Circle\n*   **Reader Block:** Labeled 'Reader'. It has an input port labeled 'topic' and an output port labeled 'data'. Below it, the text reads:\n    *   Bus Name = ShapeType\n    *   Output Data Type = Bus: ShapeType\n    *   QoS File = Shapes_Demo_QoS.xml\n    *   QoS Profile = DDS_Shapes_Demo_Profile\n    *   Read Mode = take\n    *   Ts = -1\n    *   Bus Width = 1\n*   **Connection:** An arrow connects the 'topic' output port of the 'Topic' block to the 'topic' input port of the 'Reader' block.\n*   **Bus Line:** A thick vertical black line (bus) runs down the right side of the diagram area. A small block is attached to it, corresponding to the dialog box.\n\n**Dialog Box ('Block Parameters: Bus Selector'):**\n*   **Description:** 'This block accepts a bus as input which can be created from a Bus Creator, Bus Selector or a block that defines its output using a bus object. The left listbox shows the signals in the input bus. Use the Select button to select the output signals. The right listbox shows the selections. Use the Up, Down, or Remove button to reorder the selections. Check 'Output as bus' to output a single bus signal.'\n*   **Parameters Section:**\n    *   **Filter by name:** (Text field is empty)\n    *   **Left Listbox ('Signals in the bus'):** Contains 'color', 'x', 'y', 'shapesize' (with 'shapesize' highlighted in blue).\n    *   **Middle Buttons:** 'Select))', 'Refresh'.\n    *   **Right Listbox ('Selected signals'):** Contains 'color', 'x', 'y', 'shapesize'.\n    *   **Right Buttons:** 'Up', 'Down', 'Remove'.\n    *   **Checkbox:** 'Output as bus' (Unchecked).\n*   **Bottom Buttons:** 'OK', 'Cancel', 'Help', 'Apply'.](.vortex-opensplice-dds-simulink-guide/4991f80cb4f27eaea7f3cd1fcdbe2be5a6222b5676b85b1d27005c6ecf576124.jpg)

# 12.4.2.9 Add Bus Selector outputs

For demonstration purposes, we will output the bus signals using 2 Simulink Display blocks and an XY Graph.

Note: To change the positioning of block ports, you can use the Rotate & Flip block menu item, accessible by right clicking on a block.

• Drag 2 Simulink / Sinks / Display blocks onto the diagram.
• Connect the Display blocks to the Bus Selector output signals.

– Connect the Bus Selector color output signal to a Display block.
– Connect the Bus Selector shapesize output signal to a Display block.

Note: Default Display block settings used.

![The diagram consists of two rectangular blocks on the left side and a thick vertical black line on the right side.\n\n**Labeled Blocks:**\n*   **Display:** A rectangle located at the top left, containing a smaller inner rectangle.\n*   **Display1:** A rectangle located at the bottom left (outlined in blue), containing a smaller inner rectangle.\n\n**Connections:**\n*   An arrow originates from the vertical black line and points left to the **Display** block. The text label above this arrow is **(color)**.\n*   An arrow originates from the vertical black line and points left to the **Display1** block. The text label above this arrow is **(shapesize)**.](.vortex-opensplice-dds-simulink-guide/9f0019993cf97303b383f04dd9900bb7594e2cae1f2fc2ec892adaef68890df2.jpg)

• Drag Simulink / Sinks / XY Graph block onto diagram
• Connect the BusSelector x and y outputs to the XY Graph block.
• Set the Block Parameters on the XY Graph: X-min: 0 X-max: 400 Y-min: 0 Y-max: 400

![This block diagram illustrates a data flow from a data source (Topic) to a consumer (Reader), which then distributes data to three visualization components.\n\n**Top Section: Topic and Reader**\n*   **Topic Block (Left):**\n    *   **Label:** Topic\n    *   **Description:** Below the box, the text reads:\n        *   Bus Name = ShapeType\n        *   Data Type = Bus: ShapeType\n        *   QoS File = Shapes_Demo_QoS.xml\n        *   QoS Profile = DDS Shapes_Demo_Profile\n        *   Key = color\n        *   Topic Name = Circle\n    *   **Connection:** An arrow labeled 'topic' points from the right side of this block to the left side of the Reader block.\n\n*   **Reader Block (Right):**\n    *   **Label:** Reader\n    *   **Description:** Below the box, the text reads:\n        *   Bus Name = ShapeType\n        *   Output Data Type = Bus: ShapeType\n        *   QoS File = Shapes_Demo_QoS.xml\n        *   QoS Profile = DDS Shapes_Demo_Profile\n        *   Read Mode = take\n        *   Ts = -1\n        *   Bus Width = 1\n    *   **Connection:** The left side has an input port labeled 'topic'. The right side has an output port labeled 'data'. A line extends downward from the 'data' port, connecting to a vertical bus line.\n\n**Bottom Section: Visualization Blocks**\nA thick vertical black line acts as a bus connecting the Reader's output to three blocks below. Arrows point left from this bus into the blocks.\n\n*   **Display Block (Top):**\n    *   **Label:** Display (inside the box)\n    *   **Connection:** A horizontal arrow connects the vertical bus to the left side of the box. The connection label above the line is `(color)`.\n\n*   **XY Graph Block (Middle):**\n    *   **Label:** XY Graph (inside the box)\n    *   **Connection:** Two horizontal arrows connect the vertical bus to the right side of the box.\n        *   The top connection label is `(x)`.\n        *   The bottom connection label is `(y)`.\n\n*   **Display1 Block (Bottom):**\n    *   **Label:** Display1 (inside the box)\n    *   **Connection:** A horizontal arrow connects the vertical bus to the left side of the box. The connection label above the line is `(shapesize)`.](.vortex-opensplice-dds-simulink-guide/ab5a539850e0a4dd29557f3997af4fc76f4fe5c1004d0d943dabd28a3e20f5ef.jpg)

![Block Parameters: XY Graph\nXY scope. (mask) (link)\nPlots second input (Y) against first input (X) at each time step to\ncreate an X-Y plot. Ignores data outside the ranges specified by x-\nmin, x-max, y-min, y-max.\nParameters\nX-min:\n0\nX-max:\n400\nY-min:\n0\nY-max:\n400\nSample time:\n-1\nOK Cancel Help Apply](.vortex-opensplice-dds-simulink-guide/c1c4b2fccfb5cb19ad21a8300284e39926b9907e202d9f07fe3acbfaa03beb7d.jpg)

Save your model!!! The model is now complete!

# 12.5 Running Simulations

We now have two Simulink models. We will run both models and see that data samples are being written by one model and read be the second model.

# 12.5.1 Setup Write Model

1. Open shapes\_write\_model.slx.
2. Select menu item Simulation / Update Diagram to diagnose any possible model problems.
3. Fix any issues.

# 12.5.2 Setup Read Model

1. Open shapes\_read\_model.slx.
2. Select menu item Simulation / Update Diagram to diagnose any possible model problems.
3. Fix any issues.

# 12.5.3 Run Simulations

1. Position models side by side.
2. Start the read model simulation.
3. Start the write model simulation.
4. Expected: The write model will write samples, that are received by the read model and displayed in that model’s XY Graph and Display blocks.
5. The write model will run to completion. The read model needs to be stopped manually.

![Based on the provided image, here is the description of the two Simulink models:\n\n**Left Model: `shapes_write_model`**\n\n*   **Blocks:**\n    *   **Domain:** Labeled 'Domain'. Text: 'Domain Id = DDS_DOMAIN_DEFAULT', 'QoS File = None', 'QoS Profile = Default'. Output port 'pp'.\n    *   **Topic (Top):** Labeled 'topic' (top right corner). Text: 'Topic', 'Bus Name = ShapeType', 'Data Type = Bus: ShapeType', 'QoS File = Shapes_Demo_QoS.xml', 'QoS Profile = DDS Shapes_Demo_Profile', 'Key = color', 'Topic Name = Circle'. Input port 'pp'.\n    *   **Publisher:** Labeled 'Publisher'. Text: 'topic' (near blue arrow icon), 'QoS File = None', 'QoS Profile = Default'. Input port 'pp'. Output port 'ppub'.\n    *   **Writer:** Labeled 'Writer'. Text: 'Writer', 'Bus Name = ShapeType', 'Input Data Type = Bus: ShapeType', 'QoS File = Shapes_Demo_QoS.xml', 'QoS Profile = DDS Shapes_Demo_Profile', 'Bus Width = 1'. Inputs: 'ppub', 'topic', 'data', 'option'. Output: 'status' (pencil icon with text 'samples written').\n    *   **Clock:** Connects to 'mod'.\n    *   **Constant2:** Value '350'. Connects to 'mod'.\n    *   **mod:** Label 'Math Function'. Output 'color'. Connects to 'int32' (Data Type Conversion1).\n    *   **Sine Wave:** Connects to 'int32' (Data Type Conversion).\n    *   **Constant1:** Value '25'. Connects to 'Sine Wave'. Output 'shapesize'.\n    *   **int32 (Data Type Conversion1):** Output merges into bus.\n    *   **int32 (Data Type Conversion):** Output merges into bus.\n\n*   **Connections:**\n    *   'Domain' 'pp' output splits to 'Topic' 'pp' input and 'Publisher' 'pp' input.\n    *   'Publisher' 'ppub' output connects to 'Writer' 'ppub' input.\n    *   'Topic' (top) connects to 'Writer' 'topic' input.\n    *   The merged signals from the bottom 'int32' blocks connect to 'Writer' 'data' input.\n\n**Right Model: `shapes_read_model`**\n\n*   **Blocks:**\n    *   **Topic:** Labeled 'topic'. Text: 'Topic', 'Bus Name = ShapeType', 'Data Type = Bus: ShapeType', 'QoS File = Shapes_Demo_QoS.xml', 'QoS Profile = DDS Shapes_Demo_Profile', 'Key = color', 'Topic Name = Circle'. Output port 'topic'.\n    *   **Reader:** Labeled 'Reader'. Text: 'Reader', 'Bus Name = ShapeType', 'Output Data Type = Bus: ShapeType', 'QoS File = Shapes_Demo_QoS.xml', 'QoS Profile = DDS Shapes_Demo_Profile', 'Read Mode = take', 'Ts = -1', 'Bus Width = 1'. Input port 'topic'. Output port 'data'.\n    *   **Display:** Input '(color)'.\n    *   **XY Graph:** Inputs '(x)' and '(y)'.\n    *   **Display1:** Input '(shapesize)'.\n\n*   **Connections:**\n    *   'Topic' 'topic' output connects to 'Reader' 'topic' input.\n    *   'Reader' 'data' output splits into three lines:\n        *   '(color)' connects to 'Display'.\n        *   '(x)' and '(y)' connect to 'XY Graph'.\n        *   '(shapesize)' connects to 'Display1'.](.vortex-opensplice-dds-simulink-guide/e16d2bd03d9d96bad117e065120c2742e1c5133e3b86c61b085c47448e35a266.jpg)

# Run Results

![Based on the provided image, here is a description of the two Simulink models:\n\n**Left Model: `shapes_write_model`**\n\n*   **Blocks and Text:**\n    *   **Domain:** Contains text 'Domain Id = DDS_DOMAIN_DEFAULT', 'QoS File = None', 'QoS Profile = Default'.\n    *   **Topic:** Contains text 'Bus Name = ShapeType', 'Data Type = Bus: ShapeType', 'QoS File = Shapes_Demo_QoS.xml', 'QoS Profile = DDS Shapes_Demo_Profile', 'Key = color', 'Topic Name = Circle'.\n    *   **Publisher:** Contains text 'QoS File = None', 'QoS Profile = Default'.\n    *   **Writer:** Contains text 'Bus Name = ShapeType', 'Input Data Type = Bus: ShapeType', 'QoS File = Shapes_Demo_QoS.xml', 'QoS Profile = DDS Shapes_Demo_Profile', 'Bus Width = 1'.\n    *   **Math Function:** Labeled with 'Math Function' and 'sin'.\n    *   **int32 (Data Type Conversion1):** Labeled 'Data Type Conversion1'.\n    *   **int32 (Data Type Conversion2):** Labeled 'Data Type Conversion2'.\n    *   **Constant:** Labeled '-C'.\n    *   **Constant2:** Labeled '350'.\n    *   **Constant1:** Labeled '25'.\n    *   **Sine Wave:** Labeled 'Sine Wave'.\n    *   **Clock:** Labeled 'Clock'.\n\n*   **Connections:**\n    *   **DDS Section:** The `Domain` block's `pp` port connects to the `Topic` block's `pp` port and the `Publisher` block's `pp` port. The `Publisher` block's `ppub` port connects to the `Writer` block's `ppub` port. The `Topic` block's `topic` port connects to the `Writer` block's `topic` port. The `Writer` block has outputs labeled `status` and `samples written`.\n    *   **Signal Generation:** The `Clock`, `Constant` ('-C'), and `Constant2` ('350') blocks all connect to the `Math Function` block. The output of the `Math Function` block connects to the `int32` (Data Type Conversion1) block. The output of this `int32` block connects to a vertical bus line labeled `color`. The `Constant1` ('25') block connects to the same bus line labeled `shapesize`. These bus signals (`color` and `shapesize`) connect to the `Writer` block's `data` port.\n    *   **Action Signal:** The `Sine Wave` block connects to the `int32` (Data Type Conversion2) block, which connects to the `Writer` block's `action` port.\n\n**Right Model: `shapes_read_model`**\n\n*   **Blocks and Text:**\n    *   **Topic:** Contains text 'Bus Name = ShapeType', 'Data Type = Bus: ShapeType', 'QoS File = Shapes_Demo_QoS.xml', 'QoS Profile = DDS Shapes_Demo_Profile', 'Key = color', 'Topic Name = Circle'.\n    *   **Display:** Labeled 'Display'.\n    *   **XY Graph:** Labeled 'XY Graph'.\n    *   **Display1:** Labeled 'Display1'.\n    *   There is a block with a glasses icon (top right) with ports `topic` and `data`.\n\n*   **Connections:**\n    *   **DDS Section:** The `Topic` block's `topic` port connects to the glasses-icon block's `topic` port. The glasses-icon block's `data` port connects to a vertical bus line.\n    *   **Display Section:** The vertical bus line splits. One signal, labeled `(shapesize)`, connects to the `Display` and `Display1` blocks. Other signals from the bus connect to the `XY Graph` block inputs (X Axis and Y Axis).\n    *   **XY Graph Window:** An overlay window titled 'XY Plot' shows a graph with Y Axis ranging from 0 to 400 and X Axis ranging from 0 to 400, displaying a dense blue plot.](.vortex-opensplice-dds-simulink-guide/5f5085e0e318673e67dc874258da1f6cb89fccc09fb21d697e093f9c7043fed8.jpg)

# 13

# Generating C code with Simulink Coder

The Vortex DDS Blockset for Simulink supports Simulink Coder generation of C code, if you have a Simulink Coder license from MathWorks.

# 13.1 Prerequisites for C generation

In order to generate and compile C code containing DDS blocks, you must:

• Have Simulink Coder and MATLAB Coder installed and licensed from MathWorks.
• You have an appropriate C compile installed, as described by the MATLAB documentation.
• Vortex OpenSplice must be installed, and the appropriate release.com (Linux) or release.bat (Windows) script must have been executed in a command window.
• MATLAB must have been started from the same command window. You can check this by running the MATLAB command getenv(’OSPL\_HOME’). It should return a non-empty value.
• Your Simulink mode should execute correctly in simulation mode.

# 13.2 Preparing for C generation

Once your model has been validated via simulation mode, you are ready to generate and compile code. Because of an issue with the OpenSplice C99 language headers, you must manualy change the code generation options for your model. Follow these steps:

• From the model’s menu, choose Code > C/C++ Code > Code Generation Options.
• Click on the Code Generation tab in the left-hand pane.
• In the Build Configurations drop-down, choose Specify.
• In the table that appears below this, edit the Options value in the C Compiler row to remove the text \$(ANSI\_OPTS).
• Click OK or Apply to save your changes, then close the Code Generation Options dialog.

See the image, below, for an example of the code generation dialog.

# 13.3 Generating code

At least from the Vortex DDS Blockset point of view, you are ready to generate code. Follow these steps:

• From the model’s menu, choose Code > C/C++ Code > Build Model.
• Simulink will get busy. You may see the following warnings in the Diagnostic View. These are OK, but are explained below.

![Configuration Parameters: SimpleDomain/Configuration (Active)\n★ Commonly Used Parameters\nSelect:\nSolver\nData Import/Export\nOptimization\nDiagnostics\nHardware Implementation\nModel Referencing\nSimulation Target\nCode Generation\nReport\nComments\nSymbols\nCustom Code\nInterface\nAll Parameters\nTarget selection\nSystem target file: grt.tlc\nBrowse...\nLanguage: C\nBuild process\nGenerate code only\nPackage code and artifacts\nZip file name: SimpleDomain.zip\nToolchain settings\nToolchain: GNU gcc/g++ v4.4.x | gmake (64-bit Linux)\nBuild configuration: Specify\nTool	Options\nC Compiler	-c \$(ANSI_OPTS) -fPIC -O0\nLinker	-Wl,-rpath, '\$(MATLAB_ARCH_BIN)',-L'\$(MATLAB_ARCH_BIN)'\nShared Library Linker	-shared -Wl,-rpath, '\$(MATLAB_ARCH_BIN)',-L'\$(MATLAB_ARCH_BIN)' -Wl,--no-undefined\nC++ Compiler	-c \$(CPP_ANSI_OPTS) -fPIC -O0\nC++ Linker	-Wl,-rpath, '\$(MATLAB_ARCH_BIN)',-L'\$(MATLAB_ARCH_BIN)'\nC++ Shared Library ...	-shared -Wl,-rpath, '\$(MATLAB_ARCH_BIN)',-L'\$(MATLAB_ARCH_BIN)' -Wl,--no-undefined\nArchiver	ruvs\nDownload\nExecute\nMake Tool	-f \$(MAKEFILE)\nCode generation objectives\nSelect objective: Execution efficiency\nCheck model before generating code: Off	Check Model...\nOK	Cancel	Help	Apply](.vortex-opensplice-dds-simulink-guide/f9449b69ec3a289ec24d332c2accb8f9d55d76c9d0d3c176b1b488d30a8e1675.jpg)

Figure 13.1: C/C++ Code Generation Options. Remove the text \$(ANSI\_OPTS) for C Compiler to avoid compile errors.

# Domain Participant Warning

A warning may appear about the domain participant block:

```txt
Source 'SimpleDomain/Domain/Participant_Entity' specifies that its sample time (-1) is back-inherited. You should explicitly specify the sample time of sources. You can disable this diagnostic by setting the 'Source block specifies -1 sample time' diagnostic to 'none' in the Sample Time group on the Diagnostics pane of the Configuration Parameters dialog box.
```

```txt
Component: Simulink | Category: Blockwarning
```

As the message states, this is because the block specifies a sample time of -1. The block only creates meaningful output on initialization (it connects to DDS), so any inherited sample time is sufficient. Specifying a sample time of -1 allows the block to be place into a function-call subblock.

# Full header search warning

The following warning about reverting to full header searches may appear:

```txt
The following error occurred while attempting to run the preprocessor to find the minimum needed set of include files:
```

```txt
While parsing the source file '&lt;path-to&gt;/source/debug_utils.c' the following error occurred
```

```txt
&lt;path-to&gt;/source/debug_utils.c:14: cannot open source file "os_stdlib.h"
| #include "os_stdlib.h"
| ^
```

```txt
Reverting to full header search.
```

This may occur as you are trying to package code from compilation on another platform. The referenced header file is part of the OpenSplice distrubution. When you compile on another platform, you will need to have that platform’s OpenSplice distribution installed, and release variables set. The warning may be ignored.

# Copy File information messages

If you are creating a source distrubution, you may see information messages such as the following:

```txt
cp: cannot stat '/libdcpsc99': No such file or directory
```

The build is attempting to copy OpenSplice shared libraries (which are refered to via environment variables). These should not be copied by the build. Instead, when you compile the source on a target platform, these libraries will be found in the local OpenSplice installation.

# 13.4 Cross-compilation of models

If you are using Simulink Coder to cross-compile a model using the VortexDDS Block Set to a target other than environment in which you are running MATLAB, then the cross compilation needs access to:

• the OpenSplice HDE environment on the host, in order to obtain include files as well as libraries and executables required to run the VortexDDS block set. This is specified by the OSPL\_HOME environment variable.
• the OpenSplice RTS environment for the target environment, in order to obtain libraries necessary to link your executables. This is specified by the LINK\_OSPL\_HOME environment variable.

During a Simulink Coder build, the VortexDDS Block Set will print a warning if the LINK\_OSPL\_HOME environment variable is set, indicating that it is appropriate only for cross-compilation. If you are performing both cross-compilations and host compilations, you must take care to set LINK\_OSPL\_HOME appropriately. For host compilations, you should clear LINK\_OSPL\_HOME.

# 13.5 Running built models

When you run a compiled Simulink executable, you will need:

• An appropriate OpenSplice runtime installation on the machine executing the model
• The correct OpenSplice environment variables, which are set by the release script in the installation root directory.

# 14 二

# Troubleshooting

When double clicking on a DDS block to view the block parameters, an error dialog is shown with the message: Error evaluating ‘MaskDialog’ callback of SubSystem block (mask).

Cause: The OSPL environment variables have not been setup correctly.

Solution: Open a command shell and run the script to setup OSPL environment variables.

# Linux

• Open a Linux terminal.
• Navigate to directory containing release.com file.
/INSTALLDIR/ADLINK/Vortex\_v2/Device/VortexOpenSplice/6.8.x/HDE/x86\_64.linux
• Run release.com. (Type in “. release.com” at command line.)

# Windows

• Open a command prompt.
• Navigate to directory containing release.bat file.
INSTALLDIR/ADLINK/Vortex\_v2/Device/VortexOpenSplice/6.8.x/HDE/x86\_64.win64
• Run release.bat. (Type in “release.bat” at command line.)

# 15

# Appendix A

Appendix A provides a description of the Simulink Bus to DDS Mapping implementation.

# 15.1 Simulink Bus to DDS Mapping

Simulink data is represented in buses whose types are not compatable with DDS types. Therfore sending Simulink data to DDS requires a conversion from Simulink types to DDS types. Conversly sending DDS data to Simulink requires a conversion from DDS types to Simulink types. This document describes the mapping between these types, the type descriptors generated for Topic registration and any annotations needed to describe keys, namespaces, ... for two different workflows.

# 15.1.1 Workflow 1: Using idlpp to Generate Simulink Bus and Type Descriptor

DDS Topic Types are described in IDL. To be compatible with DDS, these types must be represented in Sumlink as Bus Types. On writes, these Simulink Bus types are converted to DDS types and on read DDS types are converted to Simulink Bus types.

IDL can be defined in an IDL file and the corresponding Simulink Bus Types can be created by Vortex.idlImportSl at the MATLAB command line. This will create the necessary Simulink Bus Types and Elements in a Simulink dictionary. It also creates the XML type descriptor for the Simulink Bus types that is used to create the Topic. The type descriptor is a Simulink variable of the form &lt;bus-name&gt;TypeDescriptor. The type descriptor is necessary for the block set to work correctly, but you will not directly address this when creating Simulink blocks.

# DDS IDL to Simulink Bus Mapping

The table below describes the generated Simulink artifacts when Vortex.idlImportSl is invoked from MAT-LAB.

<table><tr><td>DDS IDL</td><td>Simulink Type</td><td>Annotation</td><td>Comments</td></tr><tr><td>struct B</td><td>Simulink.Bus B</td><td></td><td>Creates Simulink Bus</td></tr><tr><td>enum E</td><td>Simulink Enum E</td><td></td><td>Creates Simulink Enum type</td></tr><tr><td>module A</td><td></td><td>@Scope(A)</td><td>Added to each enum or struct contained in the module.</td></tr><tr><td>#pragma keylist</td><td></td><td>@Key</td><td>Every topic bus has @Key in its description.</td></tr><tr><td>boolean</td><td>boolean</td><td></td><td></td></tr><tr><td>char</td><td>int8</td><td></td><td></td></tr><tr><td>octet</td><td>uint8</td><td></td><td></td></tr><tr><td>short</td><td>int16</td><td></td><td></td></tr><tr><td>unsigned short</td><td>uint16</td><td></td><td></td></tr><tr><td>long</td><td>int32</td><td></td><td></td></tr><tr><td>unsigned long</td><td>uint32</td><td></td><td></td></tr><tr><td>long long</td><td>double</td><td></td><td>No int64 in Simulink. Copied into the memory allocated for a double.</td></tr><tr><td>unsigned long long</td><td>double</td><td></td><td>No int64 in Simulink. Copied into the memory allocated for a double.</td></tr><tr><td>float</td><td>single</td><td></td><td></td></tr><tr><td>double</td><td>double</td><td></td><td></td></tr><tr><td>string</td><td>int8</td><td>@String</td><td>Default dimension is 256</td></tr><tr><td>string</td><td>int8 Dimension N</td><td>@BString</td><td></td></tr><tr><td>T field[N]</td><td>Mapped type for T. Dimension N</td><td></td><td>Multidimensional arrays are supported.</td></tr><tr><td>sequence</td><td>Bus: seqN_T. Dimension: N</td><td></td><td>E.g. sequencebecomes “Bus: seq3_int32”</td></tr><tr><td>sequence</td><td>Bus: seq_T Dimension: 16</td><td></td><td>E.g. sequencebecomes “Bus: seq_int32” with default dimension of 16</td></tr><tr><td>typedef</td><td></td><td></td><td>expanded in place</td></tr><tr><td colspan="4">Unsupported DDS data types</td></tr><tr><td>wchar</td><td>not supported</td><td></td><td></td></tr><tr><td>wstring</td><td>not supported</td><td></td><td></td></tr><tr><td>any</td><td>not supported</td><td></td><td></td></tr><tr><td>long double</td><td>not supported</td><td></td><td></td></tr><tr><td>union</td><td>not supported</td><td></td><td></td></tr><tr><td>inheritance</td><td>not supported</td><td></td><td></td></tr></table>

# 15.1.2 Workflow 2: Manually Modeling DDS data in the Simulink Bus Editor

DDS IDL is not necessary to interact with DDS applicatoins. You can also model the Simulink buses directly. In this case, the block set will infer the DDS data types from the Simulink types.

Defining Simulink busses without first defining the IDL is not recommended; it has the following limitations:

• fewer IDL concepts are supported. In particular, sequences are unsupported.
• it will be difficult for your Simulink application to interact with applications written in other languages, as those languages will required IDL to define the topic data.

# IDL-less mapping of Simulink bus IDL concepts

The table below describes how a Simulink bus that was not created from an IDL file is mapped to IDL concepts.

# 15.1. Simulink Bus to DDS Mapping

<table><tr><td>Simulink Type</td><td>IDL equivalent</td><td>Description</td></tr><tr><td>Simulink.Bus B</td><td>struct B</td><td>Defines DDS topic type B</td></tr><tr><td>bus annotation: @Scope(A::B)</td><td>module</td><td>Creates DDS namespace for struct</td></tr><tr><td>bus annotation: @Key(f1,f2)</td><td>#pragma keylist</td><td>Defines topic key field(s)</td></tr><tr><td>boolean</td><td>boolean</td><td>IDL array if Dimensions &gt; 1</td></tr><tr><td>int8</td><td>char</td><td>IDL array if Dimensions &gt; 1</td></tr><tr><td>uint8</td><td>octet</td><td>IDL array if Dimensions &gt; 1</td></tr><tr><td>int16</td><td>short</td><td>IDL array if Dimensions &gt; 1</td></tr><tr><td>uint16</td><td>unsigned short</td><td>IDL array if Dimensions &gt; 1</td></tr><tr><td>int32</td><td>long</td><td>IDL array if Dimensions &gt; 1</td></tr><tr><td>uint32</td><td>unsigned long</td><td>IDL array if Dimensions &gt; 1</td></tr><tr><td>single</td><td>float</td><td>IDL array if Dimensions &gt; 1</td></tr><tr><td>double</td><td>double</td><td>IDL array if Dimensions &gt; 1</td></tr><tr><td>int8, annotated @String</td><td rowspan="2">string</td><td rowspan="2">max length of read strings is determined by field dimension</td></tr><tr><td>uint8, annotated @String</td></tr><tr><td>int8, annotated @BString</td><td rowspan="3">string</td><td rowspan="3"></td></tr><tr><td>uint8, annotated @BString</td></tr><tr><td>Dimension N</td></tr><tr><td>Simulink enumeration, E</td><td>enum E</td><td>IDL array if Dimensions &gt; 1</td></tr></table>

# 16

# Contacts & Notices

# 16.1 Contacts

# ADLINK Technology Corporation

400 TradeCenter

Suite 5900

Woburn, MA

01801

USA

Tel: +1 781 569 5819

# ADLINK Technology Limited

The Edge

5th Avenue

Team Valley

Gateshead

NE11 0XA

UK

Tel: +44 (0)191 497 9900

# ADLINK Technology SARL

28 rue Jean Rostand

91400 Orsay

France

Tel: +33 (1) 69 015354

Web: http://ist.adlinktech.com/

Contact: http://ist.adlinktech.com

E-mail: ist\_info@adlinktech.com

LinkedIn: https://www.linkedin.com/company/79111/

Twitter: https://twitter.com/ADLINKTech\_usa

Facebook: https://www.facebook.com/ADLINKTECH

# 16.2 Notices

Copyright © 2018 ADLINK Technology Limited. All rights reserved.

This document may be reproduced in whole but not in part. The information contained in this document is subject to change without notice and is made available in good faith without liability on the part of ADLINK Technology Limited. All trademarks acknowledged.
[🔗 Link to the original document](.vortex-opensplice-dds-simulink-guide/vortex-opensplice-dds-simulink-guide.pdf)
