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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Subscribe to a ValueStream update

agondek
11-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.

ACCEPTED SOLUTION

Accepted Solutions

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.

View solution in original post

5 REPLIES 5
A_Macierzynski
14-Alexandrite
(To:agondek)

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

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.

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.

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?

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
}

 

Announcements


Top Tags