Main Content

Code Mappings Editor

Configure DDS application inports and outports as DataReaders and DataWriters

Since R2021a

Description

The Code Mappings editor is a graphical interface where you can configure inports and outports as DataReaders and DataWriters in a DDS application.

To configure the inports and outports, use the Code Mappings editor panes:

  • Inports

  • Outports

The Code Mappings for the Shapes Demo model shows the Inport tab open and the Square topic mapped to the import.

Open the Code Mappings Editor

  • Open a model in the DDS Blockset app. On the DDS tab, click Code Interface and select Individual Element Code Mappings.

  • Open a model in the DDS Blockset app. The Code Mappings editor appears as a minimized tab directly below the model canvas. Click the tab to expand the editor.

Examples

Configure DataReaders and DataWriters by Using Default Behavior

This example uses the Shapes Demo example model to show how to configure the DataReaders and DataWriters for a DDS application by using default behavior.

Create a DDS application
  1. Open the Shapes Demo example model, shapesdemo.

    openExample('shapesdemo');

  2. Create DDS definitions. In the DDS Application Quick Start, on the second page, select Create and use default dictionary.

Configure the DDS Interface
  1. Open the Code Mappings editor. On the DDS tab, click Code Interface and select Individual Element Code Mappings.

    The Code Mappings for the Shapes Demo model shows the Inport tab open and the Square topic mapped to the import.

  2. Configure the inports. The inports represent DataReaders in a DDS application.

    • Select the Topic. Set the Topic to the Square Topic specified in the drop-down options by its path (ShapesDomainLibrary/ShapesDomain/Square).

    • Select the DataReader. Set the Reader XML Path to Auto to have DDS Blockset automatically generate a reader for the application.

    • Select the Quality of Service (QoS). Set the Reader QoS to Default to have the reader use the vendor provided QoS.

  3. Configure the outports. The outports represent DataWriters in a DDS application.

    • Select the Topic. Set the Topic to the Circle Topic specified in the drop-down options by its path (ShapesDomainLibrary/ShapesDomain/Circle).

    • Select the DataWriter. Set the Writer XML Path to Auto to have DDS Blockset automatically generate a reader for the application.

    • Select the Quality of Service (QoS). Set the Writer QoS to Default to have the reader use the vendor provided QoS.

Deploy the DDS application
  1. Set up the build environment for your target vendor.

  2. On the DDS tab, click Build.

  3. Deploy the application executable on DDS.

Configure DataReaders and DataWriters by Using XML Definitions

This example uses the Shapes Demo example model to show how to configure the DataReaders and DataWriters for a DDS application by using definitions previously specified in imported XML definitions.

Create a DDS application
  1. Open the Shapes Demo example model, shapesdemo.

    openExample('shapesdemo');

  2. Create DDS definitions. In the DDS Application Quick Start, select Import from XML, and select the shapesexample_qos XML file. When you close the Quick Start, the DDS DataReader and DataWriter definitions from the shapesexample_qos XML file become available in the DDS Dictionary for the example application.

Configure the DDS Interface
  1. Open the Code Mappings editor. On the DDS tab, click Code Interface and select Individual Element Code Mappings.

    The Code Mappings for the Shapes Demo model shows the Inport tab open and the Square topic mapped to the import.

  2. Configure the inports. The inports represent DataReaders in a DDS application. The Topic, DataReader, and QoS for each inport appears in the editor based on the imported XML definitions.

    • Verify the Topic. For the Topic, verify that the Square Topic specified in the drop-down options by its path (ShapesDomainLibrary/ShapesDomain/Circle) is shown in the editor.

    • Verify the DataReader. For the Reader XML Path, verify that the DataReader, MySquareRdr, specified by its path (myParticipant/MySubscriber/MySquareRdr).

    • Configure the Quality of Service (QoS). Set the Reader QoS to Default to have the reader use the vendor provided QoS.

  3. Configure the outports. The outports represent DataWriters in a DDS application. The Topic, DataWriter, and QoS for each outport appears in the editor based on the imported XML definitions.

    • Verify the Topic. For the Topic, verify that the Circle Topic is specified in the drop-down options by its path (ShapesDomainLibrary/ShapesDomain/Circle).

    • Verify the DataWriter. For the Writer XML Path, verify that the DataWriter, MyCircleWtr, specified by its path (myParticipant/MySubscriber/MyCircleWtr).

    • Configure the Quality of Service (QoS). Set the Writer QoS to Default to have the writer use the vendor provided QoS.

Deploy the DDS application
  1. Set up the build environment for your target vendor.

  2. On the DDS tab, click Build.

  3. Deploy the application executable on DDS.

Related Examples

Parameters

expand all

Inports

Identifies a root-level Inport block or an element of an In Bus Element block in the model. Inports map to DataReaders in DDS applications.

Select a Topic for each DataReader.

Select or generate a DataReader for each inport.

Select the QoS for the DataReader for each inport.

Outports

Identifies a root-level DDS Outport block or an element of an Out Bus Element block in the model. Outports map to DataWriters in DDS applications.

Select a Topic for each DataWriter.

Select or generate a DataWriter for each outport.

Select the QoS for the DataWriter for each outport.

Version History

Introduced in R2021a