Lesson 18: Add quality of service elements

In this lesson, you add quality of service elements to the Data Distribution Service for Real-Time Systems (DDS) application.

About this task

In this final lesson, you learn about quality of service elements. Rhapsody® Developer for C++ supports modeling quality of services to all DDS entities except for DomainParticipantFactory, which is not part of the DDS profile. You can set the quality of service to DomainParticipantFactory by applying user source code into Rhapsody Developer for C++ models.

In this lesson, you apply the deadline quality of service to MyDataReader and MyDataWriter.

Procedure

  1. Open the SubscriberDiagram diagram.
    Note: Alternatively, you can use the Subscriber_Synchronous_Model diagram if you would like to try quality of service elements in a waitset-based scenario.
  2. On the Diagram toolbar, click the deadlineQosPolicy icon deadlineQosPolicy icon, and then click the diagram. Name the element MyDeadlineQos.
  3. Click the qualityOfService icon qualityOfService icon and draw a dependency line from the MyDataReader element to the MyDeadlineQos element, as shown in the following figure.
    MyDeadlineQos element
    Note: If you are using the waitset scenario, the dependency line should be drawn from the MyDataReader element on the subscriber, not from the MyDataReader element on the object that is based on the subscriber.
  4. Open the Features window for the MyDeadlineQos element. On the Tags tab, set the Period field to 2000, and then click OK.
    This value indicates an interval of 2 seconds (2000 milliseconds).
  5. Right-click the MyDeadlineQos element and select Copy.
  6. Paste the MyDeadlineQos element in the PublisherDiagram diagram.
  7. Create a qualityOfService dependency between the MyDataWriter element and the MyDeadlineQos element.
  8. If not already set, switch the active configuration to the MyPublishingApplication domain participant and regenerate it.
  9. Look at the code of MyPublisher: Right-click MyPublisher and select Edit Code. Look at the MyPublisher::initPublisher() function in the .cpp file. The source code for setting the deadline quality of service for MyDataWriter was added.
  10. Switch the active configuration to the MySubscribingApplication domain participant (or to the MySubscribingApplication_WaitSet domain participant if you are using waitsets) and regenerate it.
  11. Look at the code for MySubscriber (or MySubscriber_Synchronous if you are using waitsets). In the MySubscriber::initSubscriber function in the .cpp file, the source code for setting the deadline quality of service for MyDataWriter was added.
  12. Build MySubscribingApplication (or MySubscribingApplication_WaitSet if you are using waitsets) and run it. Then, switch to MyPublishingApplication, build it and run it. The expected output for MySubscribingApplication is the same as the output in Lesson 12: Add code to receive updates about your topic. The output is similar because both dataWriter and dataReader elements agree on a deadline quality of service of 2 seconds, and according to the source code, the publisher updates MyTopic topic every 1 second (it calls the OMDelay constructor with a 1-second argument).
    Note: If you are doing this lesson after doing the lesson on content-filtering, the output will be filtered. To see the full output, switch from the MyContentFilteredTopic topic back to the MyTopic topic.

Lesson checkpoint

In this lesson, you learned how to add quality of service elements to the DDS application.