cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Subscribe to a ValueStream update

SOLVED
Highlighted
Garnet

Subscribe to a ValueStream update

Are you able to subscribe to the update of a ValueStream that is assigned to a Thing to store the information of logged properties? The DataTable entity has 4 additional events that monitor for updates, deletions, etc. However the ValueStream does not have anything similar.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Subscribe to a ValueStream update

I had the same problem, and what I did it's the subscription to DataChange event check if an event on the same timestamp as been raised, on that case I've ignore the second event.

5 REPLIES 5

Re: Subscribe to a ValueStream update

Can you describe the use case? I believe that there will be some easier way to resolve your problem.

Re: Subscribe to a ValueStream update

Effectively, I need to mimic a subscription to a data change event. The problem with subscribing to the data change event now is that there is an issue with the remote binding which causes the data change event to fire twice for the exact same value and timestamp. This issue has been raised to PTC as an open support ticket and in the meantime I am looking for a workaround.

Re: Subscribe to a ValueStream update

I had the same problem, and what I did it's the subscription to DataChange event check if an event on the same timestamp as been raised, on that case I've ignore the second event.

Re: Subscribe to a ValueStream update

Interesting approach, thanks Carles. Where is the log of events that has been fired? IE: How would I monitor for another event with the same time stamp?

Re: Subscribe to a ValueStream update

I've aggregated a JSON property as a Cache of last property values:

 

{

 "propertyName1": timestamp,

 "propertyName2": timestamp,

 ...

}

 

And just checked in front of if ( I just did this code on the fly on the forum, check it...):

 

var process = true;

if (me.myCacheJson[propertyName]==undefined) {
 me.myCacheJson[propertyName] = timestamp;
} else {
   if (dateDifference(me.myCacheJson[propertyName],timestamp)==0) {
     process = false;
    } else {
     me.myCacheJson[propertyName] = timestamp;
    }
}
if (process) {
 // do whatever
}