Reader-side 'change' filter PreviousNext
Data Distribution Service (DDS) Forum > DDS Technical Forum >
Message/Author
Next message Ulf Sjöstedt  posted on Monday, February 02, 2009 - 10:49 am
Hi!


I have a need to implement a change filter, that is, I wish to be notified only when certain fields in my Topic change.

This is somewhat different from using a ContentFilteredTopic or a ReadCondition, since those operate on what the data is, not whether it's different from the previous sample.

You could do this with a ReadCondition which you change every time you read a sample, but this feels a bit cumbersome.

Has anyone solved this problem in a more elegant way?

Cheers,


/Uffe
Next message Emiel Schuurman  posted on Monday, February 02, 2009 - 03:11 pm
Hi Ulf,

From your post it is evident that you are working on the DCPS API of DDS. However the DDS specification also defines a layer on top of DCPS, called DLRL. This DLRL, or Object Cache, gives you an Object Oriented pub/sub view and has some nice features you might find useful.

The following figure shows how this Object Cache relates to the other profiles of the DDS specification.

<img>

Within DLRL we talk about Objects and Classes instead of topic instances and topics.

Within the DLRL API there are several mechanisms available that could help you solve your specific problem nicely, allow me to elaborate.

The DLRL API offers a fine grained listener mechanism, which includes the ability to set a listener per class of objects. This listener defines several callbacks to indicate an Object is newly created, has been modified or has been deleted, you can embed your own application logic within those callbacks.

Furthermore the DLRL API defines an 'is_xxx_modified()' operation for each attribute of a class (in DCPS terms a member of a struct). And this is were we hone into solving your problem! Because with that operation you do not need to do anything fancy at all, just invoke a simple operation to determine if an attribute has changed since the last time the object was modified.

So these two things combined would lead to the following possible implementation (in java) of your problem. Assume that within class Fubar you want to check if attribute myPosition has changed in value. And if the value has changed you would call your custom application-specific operation 'processObject(...)' to your your application magic.

SomeListener.java
public class SomeListener
{
/* Each time that an Object of class
* 'Fubar' was modified, the
* following listener callback is
* triggered
*/
public boolean on_object_modified(Fubar anObject)
{
/* Now simply call the DLRL
* operation to check if the
* specified attribute was
* actually modified. And if
* so invoke the application
* operation
*/
if(anObject.is_myPosition_modified())
{
processObject(anObject);
}
}
...
}

I believe this would be a very nice and elegant solution for your problem.

OpenSpliceDDS (which has gone Open Source recently!) offers this DDS profile with implementation available for multiple languages and platforms as a commercial add-on. See www.opensplice.com for more details.

If you would like to know more about DLRL and other potential uses and which problems it solves, then just ask. That is what this forum is for.
Next message Emiel Schuurman  posted on Monday, February 02, 2009 - 03:12 pm
mmm, the image link didn't work. It was supposed to show this image:
Next message Ulf Sjöstedt  posted on Tuesday, February 03, 2009 - 08:19 am
Hi,

Sorry, should have been more clear: I need a DCPS solution. I would far prefer to use DLRL, but at the moment that's not an option.
So, in DCPS, short of changing a Condition after every read(), is there a way of achieving this?

/Uffe
Next message Reinier Torenbeek  posted on Wednesday, February 04, 2009 - 05:02 pm
Hello Uffe,
There is no standard DCPS mechanism that gives you this functionality. Using a QueryCondition and changing the query parameters after every read should work but might not be very efficient. Also, you would have to create a query that checks all attributes of your Topic, which might lead to a large query expression.
I think the best solution depends on your situation. Do you need this functionality for just one Topic or for many? Does your Topic have keys defined? Does your system follow the approach of 'one owner (dataWriter) for each instance', or can an instance be updated by several dataWriters? Answers to these questions might lead to a solution...

Reinier
Next message Philip Taylor  posted on Friday, October 23, 2009 - 10:24 am
I found this still-open topic relevant as I am considering the same issue i.e. how to handle events defined as significant changes to a subscribed topic. This might be called "monitoring" a topic.

As its a standard requirement for an event-driven control system, so I'm a bit surprised to find that DDS/DCPS doesn't seem to have a native feature that supports this (some pub/sub software does).

Without this I guess one could simply write an event handler that filters out anything except the changes of interest: not very efficient.

As regards the questions posed in the previous post, any general comments would be welcome as I have no specific application in mind at the moment but am considering the facility in the context of an event-driven system architecture i.e. is DDS/DCPS a suitable solution for this architecture?

As before, I have to use DCPS, DLRL is not an option.
Next message Hans van 't Hag  posted on Friday, October 23, 2009 - 10:43 am
Hi Philip,

As stated alreayd, the content-awareness profile of DDS/DCPS offers capabilities to do what you are asking for (at least as far as I currently understand your requirement). You can specify both filters (also known as continuous queries in other middleware) that filter out the stream of incoming data conform a SQL-like "where-clause" specified when creating a "ContentFilteredTopic" as well as use ReadConditions (on the lifecycle of the information such as read/not-read, new/not-new, disposed/non-disposed, alive/not-alive) or query-conditions (on values/ranges of any attribute in your topic-type using a SQL-like expression). The thing is that when the definition of a 'significant change' is very dynamic, you have to 'explain' your changed interest often which could be inherently inefficient (regardless of the underlying middleware). In DDS, we do have optimized this 'use-case' in so far that there is a dedicated API called "set_query_parameters()" that allows to change parameters of a QueryCondition 'at runtime' without re-defining the query. I would suspec that this feature addresses your requirement isn't it ?

So maybe you could indicate what feature/functionality you are missing and/or point-out to similar features in other middleware that would provide a better understanding of what you're exactly asking for.

Thanks,
Hans
Next message Philip Taylor  posted on Friday, October 23, 2009 - 05:33 pm
I'm sure DDS does provide this facility. Its just that its not obvious.

What I was hoping for was a simple way to specify a filter which says "Only notify me when the data item has changed by amount X since the last time you notified me". This is not filtering by value or range - it depends on the last notified value. So are you saying that I have to respecify the filtered value range every time I receive a new value?
Next message Hans van 't Hag  posted on Monday, October 26, 2009 - 12:59 pm
Yes I'm afraid that with the current API thats the only option. Yet as said updating a paramter (i.e. range) in an existing query is faster than creating a new query...
Next message Philip Taylor  posted on Wednesday, October 28, 2009 - 09:37 am
> Yes I'm afraid that with the current
> API thats the only option.

Which is why I expressed surprise that such a commonly used feature is rather clumsy to implement in the DDS API. In the control systems I am involved in (EPICS-based, using Channel Access pubsub channels) the Monitor (i.e. notify when changed significantly) is the *only* filter available and those events drive almost everything in the system including GUIs and Alarm services.
Back to top
Add Your Message Here
Post:
Username: Posting Information:
This is a private posting area. Only registered users and moderators may post messages here.
Password:
Options: Post as "Anonymous"
Enable HTML code in message
Automatically activate URLs in message
Action: