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.

Modeled Subscriber and Publisher communicated through the DDS interface.

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

  1. Double-click the inport and view its DDS data type (Bus: ShapeType).

  2. Double-click the Take DDS Sample block that converts the DDS data type to the Simulink data type to see its description.

  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. Double-click the Write DDS Sample block that converts Simulink data types to a DDS data type to see its description.

  5. Double-click the outport and view the DDS data type (Bus: ShapeType) on the port that sends the data to the DDS network.

Related Topics