Download RTI Core Libraries and Utilities Getting Started Guide

Transcript
Receiving Notifications When Data Delivery Is Late
the DataReader, you indicate whether you are interested in all samples, only those samples you’ve never seen before, or only those samples you have seen before. The most common value passed here is ANY_SAMPLE_STATE.
❏
View state: The view state indicates whether the instance to which a sample belongs has
been observed by a previous call to read or take. By passing a view state mask to the
DataReader, you can indicate whether you’re interested in all instances, only those
instances that you have never seen before (NEW instances), or only those instances that
you have seen before (NOT_NEW instances). The most common value passed here is
ANY_VIEW_STATE.
❏
Instance state: The instance state indicates whether the instance to which a sample
belongs is still alive (ALIVE), whether it has been disposed (NOT_ALIVE_DISPOSED),
or whether the DataWriter has simply gone away or stopped writing it without disposing
it (NOT_ALIVE_NO_WRITERS). The most common value passed here is
ANY_INSTANCE_STATE. For more information about the data lifecycle, consult the
RTI Core Libraries and Utilities User’s Manual and the online API documentation.
Unlike reading from a socket directly, or calling receive in JMS, a read or take is non-blocking:
the call returns immediately. If no data was available to be read, it will return (in C and C++) or
throw (in Java, .NET1, and Ada2) a NO_DATA result.
Connext also offers additional variations on the read() and take() methods to allow you to view
different “slices” of your data at a time:
❏ You can view one instance at a time with read_instance(), take_instance(),
read_next_instance(), and take_next_instance().
❏ You can view a single sample at a time with read_next_sample() and
take_next_sample().
For more information about these and other variations, see the online API documentation: open
ReadMe.html, select a language, and look under Modules, Subscription Module, DataReader
Support, FooDataReader. For Ada, open doc/html/api_ada/index.html and look under Subscription Module, DDSReaderModule, DDS.Typed_DataReader_Generic.
5.4.2
Running & Verifying
To see the difference between read() and take() semantics, replace “read” with “take” (the arguments are the same), rebuild the example, and run again. You will see that “(cached)” is never
printed, because every sample will be removed from the cache as soon as it is viewed for the
first time.
5.5
Receiving Notifications When Data Delivery Is Late
Many applications expect data to be sent and received periodically (or quasi-periodically). They
typically expect at least one data sample to arrive during each period; a failure of data to arrive
may or may not indicate a serious problem, but is probably something about which the application would like to receive notifications. For example:
❏ A vehicle may report its current position to its home base every second.
❏ Each sensor in a sensor network reports a new reading every 0.5 seconds.
1. RTI Connext .NET language binding is currently supported for C# and C++/CLI.
2. Ada support requires a separate add-on product, Ada 2005 Language Support.
5-15