Main Content

Construct Simulink Model as Publisher and Subscriber

To publish and subscribe to the DDS network, the application model for the Shapes Demo has already been configured as a top model that meets the necessary modeling aspects:

  1. The model has inports and outports that are set to DDS data types.

  2. The model has message blocks, specifically the Write DDS Sample and Take DDS Sample blocks, that send and receive messages from the DDS network. These blocks convert between DDS and Simulink® data types to enable the model to publish and subscribe to the DDS network.

  3. The model itself contains the DDS application logic. The logic portion of the model is independent of the middleware. It uses the data communicated from the middleware in a Simulink compliant form to run the application algorithm.

To explore the publish and subscribe aspects of the application model:

  1. Click the inport and view its DDS data type.

  2. Click the Take DDS Sample block that converts the DDS data type to the Simulink data type.

  3. Examine the logic component of the application model. The logic component uses the Simulink data types to compute the logic of the DDS application.

  4. Click the Write DDS Sample block that converts Simulink data types to a DDS data type.

  5. Click the outport and view the DDS data type on the port that sends the data to the DDS network.

Related Topics