In Ignition 7 I was able to get the tagChanged(TagChangeEvent tagChangeEvent) by implementing the TagChangeListener class.
This is my code for Ignition 8 where I am trying to do the same thing.
My Implementation:
public class TagListener implements TagChangeListener {
String name;
GatewayContext context;
String historyProviderName;
public TagListener(String name, GatewayContext context, String historyProviderName) {
this.name = name.toLowerCase();
this.context = context;
this.historyProviderName = historyProviderName;
}
@Override
public void tagChanged(TagChangeEvent tagChangeEvent) throws InvalidListenerException {
List<TagPath> list= new ArrayList<TagPath>();//creates list with type TagPath
list.add(tagChangeEvent.getTagPath());
try {
List<QualifiedValue> tags= context.getTagManager().readAsync(list).get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
I call my implementation:
String tagPath = historicalTagValue.getSource().toStringFull();
tagPath = createFullTagPath(tagPath, systemProvider).toLowerCase();
TagPath tagPathItem = TagPathParser.parse(tagPath);
//Register a Tag Change Listener if the tag doesn't already have one
if(!tagsWithListeners.contains(tagPathItem)){
TagChangeListener tempListener = new TagListener(tagPath, context, profile.getName());
tagsWithListeners.add(tagPathItem);
tagChangeListeners.add(tempListener);
context.getTagManager().subscribeAsync(tagPathItem, tempListener).get();
}