Subscribe tagchange with previous/current values 8.0 +

How do you get the previous/current value of a tag using context.getTagManager().subscribeAsync ?

I see com.inductiveautomation.ignition.common.util.FilteredTagChangeListener.FilteredTagChangeEvent that looks like it has what I want but haven’t been able to implement it.

What have you tried doing so far?

It looks like you can subclass FilteredTagChangeListener and provide it as your listener to subscribeAsync.

How do you pass in the 2nd parameter? java.util.EnumSet<FilteredTagChangeListener.TagChangeType> allowedChanges

Just build an EnumSet of TagChangeTypes?

e.g. EnumSet.of(TagChangeType.ValueChange)

There’s also nothing special about this listener. It’s just a listener that happens to remember the last value for any given tag path and deliver that in its own event type via the onFilteredTagChange method you override. Plus some options for suppressing initial events and filtering certain changes. It’s used by the gateway tag change scripts.

1 Like