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:
The model has inports and outports that are set to DDS data types.
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.
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:
Double-click the inport and view its DDS data type (
Double-click the Take DDS Sample block that converts the DDS data type to the Simulink data type to see its description.
Examine the logic component of the application model. The logic component uses the Simulink data types to compute the logic of the DDS application.
Double-click the Write DDS Sample block that converts Simulink data types to a DDS data type to see its description.
Double-click the outport and view the DDS data type (
Bus: ShapeType) on the port that sends the data to the DDS network.