.. _`QoS Provider`: ######################## Quality of Service (QoS) ######################## The following section explains how to set the Quality of Service (QoS) for a DDS entity. Users have two options available to set the QoS for an entity or entities. They can define the QoS settings using an XML file, or they can use the Node.js DCPS APIs. Both of these options are explained. If a QoS setting for an entity is not set using an xml file or the Node.js DCPS APIs, the defaults will be used. This allows a user the ability to override only those settings that require non-default values. Setting QoS Using QoS Provider XML File *************************************** QoS for DDS entities can be set using XML files based on the XML schema file QoSProfile.xsd_. These XML files contain one or more QoS profiles for DDS entities. OSPL includes an XSD (XML schema), that is located in $OSPL_HOME/etc/DDS_QoSProfile.xml. This can be used with XML schema core editors to help create valid XML files. Sample QoS Profile XML files can be found in the examples directory. Typically you will place the qos files in a subdirectory of your Node.js application. .. _QoSProfile: QoS Profile =========== A QoS profile consists of a name and optionally a base_name attribute. The base_name attribute allows a QoS or a profile to inherit values from another QoS or profile in the same file. The file contains QoS elements for one or more DDS entities. A skeleton file without any QoS values is displayed below to show the structure of the file. .. code-block:: xml **Example: Persistent QoS XML file** .. code-block:: xml true INSTANCE_PRESENTATION_QOS true true partition1 true INSTANCE_PRESENTATION_QOS false false true INSTANCE_PRESENTATION_QOS true true partition1 true PERSISTENT_DURABILITY_QOS DURATION_INFINITE_SEC DURATION_INFINITE_NSEC 0 0 AUTOMATIC_LIVELINESS_QOS DURATION_INFINITE_SEC DURATION_INFINITE_NSEC RELIABLE_RELIABILITY_QOS 0 100000000 BY_RECEPTION_TIMESTAMP_DESTINATIONORDER_QOS KEEP_LAST_HISTORY_QOS 100 LENGTH_UNLIMITED LENGTH_UNLIMITED LENGTH_UNLIMITED 0 DURATION_INFINITE_SEC DURATION_INFINITE_NSEC SHARED_OWNERSHIP_QOS 0 true PERSISTENT_DURABILITY_QOS DURATION_INFINITE_SEC DURATION_INFINITE_NSEC 0 0 AUTOMATIC_LIVELINESS_QOS DURATION_INFINITE_SEC DURATION_INFINITE_NSEC BEST_EFFORT_RELIABILITY_QOS 0 100000000 BY_RECEPTION_TIMESTAMP_DESTINATIONORDER_QOS KEEP_ALL_HISTORY_QOS LENGTH_UNLIMITED LENGTH_UNLIMITED LENGTH_UNLIMITED SHARED_OWNERSHIP_QOS 0 0 DURATION_INFINITE_SEC DURATION_INFINITE_NSEC DURATION_INFINITE_SEC DURATION_INFINITE_NSEC PERSISTENT_DURABILITY_QOS 3600 0 KEEP_LAST_HISTORY_QOS 100 8192 4196 8192 DURATION_INFINITE_SEC DURATION_INFINITE_NSEC 0 0 AUTOMATIC_LIVELINESS_QOS DURATION_INFINITE_SEC DURATION_INFINITE_NSEC BEST_EFFORT_RELIABILITY_QOS 0 100000000 BY_RECEPTION_TIMESTAMP_DESTINATIONORDER_QOS KEEP_LAST_HISTORY_QOS 1 LENGTH_UNLIMITED LENGTH_UNLIMITED LENGTH_UNLIMITED 0 DURATION_INFINITE_SEC DURATION_INFINITE_NSEC SHARED_OWNERSHIP_QOS Applying QoS Profile ==================== To set the QoS profile for a DDS entity using the Node.js DCPS API and an XML file, the user specifies the qos file URI or file path and the QoS profile name as parameters. **Example: Using QoSProvider** .. code-block:: javascript const dds = require('vortexdds'); const path = require('path'); const QOS_XML_PATH = __dirname + path.sep + 'DDS_Get_Set_QoS.xml'; const QOS_PROFILE = 'DDS GetSetQosProfile'; const DOMAIN_ID = dds.DDS_DOMAIN_DEFAULT; //... async function setup(){ let participant = null; let qp = null; try { // create a qos provider using qos xml file qp = new dds.QoSProvider(QOS_XML_PATH, QOS_PROFILE); // get participant qos from qos provider and create a participant const pqos = qp.getParticipantQos(); participant = new dds.Participant(DOMAIN_ID, pqos); // get publisher qos from qos provider const pubqos = qp.getPublisherQos(); // get publisher qos policies const pubScope = pubqos.presentation; const publisher = participant.createPublisher(pubqos); //... } finally { console.log('=== Cleanup resources'); if (qp !== null){ qp.delete(); } if (participant !== null){ participant.delete().catch((error) => { console.log('Error cleaning up resources: ' + error.message); }); } } } .. raw:: latex \newpage Setting QoS Using Node.js DCPS API Classes ****************************************** QoS settings can also be set by using the Node.js classes alone. (No XML files required.) **Example: Create Reader Using QoS APIS** .. code-block:: javascript const dds = require('vortexdds'); //... function createReader(subscriber, topic){ // get the default reader qos const rqos = dds.QoS.readerDefault(); // modify the reader qos policies rqos.partition = {names: 'partition1'}; rqos.timebasedFilter = {minimumSeparation: 60000}; rqos.readerDataLifecycle = { autopurgeNoWriterSamples: 100, autopurgeDisposedSamplesDelay: 500, }; // create a reader with qos const reader = subscriber.createReader(topic, rqos); //... } .. external links .. _QoSProfile.xsd: http://www.omg.org/spec/dds4ccm/20110201/DDS_QoSProfile.xsd .. _DDS_DefaultQoS.xml: http://www.omg.org/spec/dds4ccm/20110201/DDS_DefaultQoS.xml