Main Content

Manage Types

The DDS middleware platform requires that applications use Data Samples, composed of DDS data types, to send and receive data on the DDS network. When you use DDS Blockset, you configure application model inports and outports as DataReaders and DataWriters that use Data Samples defined in the DDS Dictionary as DDS data types. DDS Blockset supports the DDS data types Const, Struct, and Enum. You can use the DDS Dictionary to import, create, and edit these DDS data types and their Simulink® equivalent data types to meet your application requirements.

To import and manage DDS data types for applications:

To learn how to apply these DDS data types to configure Data Samples for applications, see Configure Data Samples and Configure DataReaders and DataWriters.

Import DDS Data Types

To specify DDS definitions by using IDL or XML files, you can use the DDS Application Quick Start to import the definitions into a DDS Dictionary. If you are working in an existing DDS Dictionary, you can use the DDS Dictionary directly to import additional XML or IDL files. To import from the DDS Dictionary, on the dictionary toolstrip, click Import to select and upload XML and IDL files.

Additionally, if you would like to convert data types in a Simulink data dictionary to DDS data types, you can right-click and choose Convert to DDS Type from the context menu to add these data types to a DDS Dictionary.

View DDS Data Types

To view the DDS data types available for your application, open its associated DDS Dictionary. To open the DDS Dictionary, on the DDS tab, click Code Interface and select DDS Dictionary.

DDS dictionary with the Types tab displaying Base, Common, and Shapes modules with their respective types.

Alternatively, you can open the DDS Dictionary from a Simulink data dictionary. In a Simulink data dictionary, if DDS definitions are available, a DDS Libraries node appears in the dictionary. If you open the DDS Libraries section of the Simulink data dictionary, in the Details pane, you can click Open DDS Libraries to open the graphical interface for the DDS Dictionary.

Edit DDS and Simulink Data Types

You can use the DDS Dictionary to configure these aspects of the DDS data types available for your DDS application:

Organize DDS Data Types in the DDS Dictionary

To organize large numbers of DDS data types, you can group DDS data types into libraries and then subgroup libraries into modules.

To create a DDS data type library, on the DDS Dictionary toolstrip, click Library. To duplicate a library, select a library, and then on the toolstrip, click Duplicate. To delete a library, select a library, and then on the toolstrip, click Delete.

To add a module within a library, select a library, and then on the DDS Dictionary toolstrip, click Module. A module appears nested within the selected library. To duplicate a module, select the module, and then on the toolstrip, click Duplicate. To delete a module, select the model, on the toolstrip, click Delete.

You can use libraries and nested modules within a DDS Dictionary to organize your DDS data types.

Create New DDS Data Types

To create new DDS data types, on the DDS Dictionary toolstrip, click the icon of the data type you would like to create: Const, Struct, or Enum.

Configure DDS Data Type Names

To change the name of a DDS data type, in the Name column, click and directly edit the spreadsheet.

Configure the Values of Simulink equivalent data types

To adjust the properties of the equivalent Simulink data type that represents the DDS data type in the Simulink environment, select the DDS data type to open and view the Simulink data type in the Details pane. The equivalent Simulink data types for the supported DDS data types are the following:

DDS Data TypeSimulink Data Type
ConstNumeric MATLAB® variable
EnumEnumeration
StructSimulink.Bus object

You can configure the Simulink data type properties as available and necessary for your application.

You can view, but not edit, these Simulink equivalent data types in the Design Data section of a Simulink data dictionary with the other Simulink data objects that are not a part of the DDS specification. The types shown are kept in sync with their counterparts in the DDS Dictionary, including the renaming and deleting of DDS data types. Simulink uses Shortname for data types defined in DDS dictionaries that were created in R2022b. For DDS dictionaries created in R2022a or earlier, Simulink uses Fullname for the type.

Duplicate DDS Data Types

To duplicate DDS data types, select the data types, and then on the DDS Dictionary toolstrip, click Duplicate.

Delete DDS Data Types

To delete DDS data types, select the data types, and then on the DDS Dictionary toolstrip, click Delete.

Examples

These examples show how to configure DDS data types from a data management perspective and then how to apply these created DDS data types to configure the inports and outports of DDS application models so that applications modeled in Simulink can send and receive Data Samples from the DDS network.

Configure Data Samples

This example shows how to import, create, and configure DDS data types that represent Data Samples.

  1. (Optional) Import DDS data types. If you would like to import DDS data types, use the DDS Application Quick Start or DDS Dictionary.

  2. Open the DDS Dictionary. On the DDS tab, click Code Interface and select DDS Dictionary.

  3. Add a new library. On the DDS Dictionary toolstrip, click Library.

  4. Create new DDS data types.

    • Create and name a new DDS Struct data type. On the DDS Dictionary toolstrip, click Struct. In the Name column, rename the data type. Select the new DDS type and in the Details pane, view its Simulink equivalent data type, a Simulink.Busobject.

    • Create a DDS Const data type. On the DDS Dictionary toolstrip, click Const. In the Name column, rename the data type. Select the new DDS type and in the Details pane, view its Simulink equivalent data type, a numeric MATLAB variable.

    • Create a DDS Enum data type. On the DDS Dictionary toolstrip, click Enum. In the Name column, rename the data type. Select the new DDS type and in the Details pane, view its Simulink equivalent data type, an Enumeration.

  5. Delete a DDS data type. Select one of the DDS data types, and on the DDS Dictionary toolstrip, click Delete.

Configure DataReaders and DataWriters

This example shows at a high level how to configure a DDS application model so that the inports and outports that represent DataReaders and DataWriters are configured with DDS data types. The DDS data types enable the application to send and receive Data Samples.

  1. Open a model in the DDS Blockset app.

  2. Open the DDS Dictionary and create the necessary DDS data types.

  3. Construct or adapt the Simulink model so that it acts as a Publisher or Subscriber.

  4. Set the inports and outports to DDS data types that match the Registered Type of the Topic that the application subscribes to or publishes.

For more information about how to configure a model and its ports as a Publisher or Subscriber, see Model DDS Applications.

See Also

| |

Related Topics