DataWriter
When you use RTI Connext DDS publish-subscribe middleware to send and receive data between applications, you must create one or more DataWriter objects, and call write() to send your data.
DataWriter objects are responsible for sending type-specific data to one or more DataReaders.
A DataWriter is created with a Topic, which gives a name to the data stream and associates the DataWriter with a data type. A DataWriter sends data to one or more DataReaders if the DataWriter and DataReader(s):
- have Topics with the same name
- have data types that are assignable to each other (not necessarily identical)
- are within the same domain
- have compatible QoS
- can be discovered and communicate with each other over one or more transports
The behavior of a DataWriter is controlled by QoS. For example, a DataWriter can be made reliable by configuring its RELIABILITY QoS. A DataWriter provides asynchronous notifications in the form of Status Changes.
There are two types of objects that can be referred to as DataWriters: DDS DataWriter objects and type-specific DataWriter objects (usually called FooDataWriter to indicate a user data type “Foo”).
The DDS::DataWriter object is used for actions that are not specific to a single data type, such as configuring QoS or installing listeners. The type-specific FooDataWriter object is used for actions that involve the specific data type, such as writing data or unregistering/disposing of an instance.
For example, when writing data, you must use a type-specific DataWriter, rather than the generic DataWriter class:
// Create the DDS::DataWriter. This object can be used for configuring QoS, // asserting liveliness, or other non-type specific actions. DDS::DataWriter *ddsWriter = publisher->create_datawriter(medicalDataTopic, qos, listener, DDS_STATUS_MASK_ALL); // Create the type-specific DataWriter. This object can be used for writing data, // disposing a data-instance, or other actions that are specific to a data type MedicalDeviceDataWriter *medicalDataWriter = MedicalDeviceDataWriter::narrow(ddsWriter); medicalDataWriter->write(deviceData, ...);
Comments
lucas17
Fri, 11/01/2019 - 02:21
Permalink
Now I got to know what I was
Now I got to know what I was doing wrong. Thanks for saving me.