I am trying to get all the tags using my history provider and send them to my historian during startup. Is there a better way I can achieve this than the following? I am doing this for each tag provider during startup() for my Gateway module.
private void browseNode(TagProvider provider, TagPath parentPath, JSONArray tags) throws Exception {
Results<NodeDescription> results = provider.browseAsync(parentPath, BrowseFilter.NONE).get(30, TimeUnit.SECONDS);
if(results.getResultQuality().isNotGood()) {
throw new Exception("Bad quality results: "+ results.getResultQuality().toString());
}
Collection<NodeDescription> nodes = results.getResults();
assert nodes != null;
for (NodeDescription node : nodes) {
var tagPath = node.getFullPath();
// TODO get all at once?
var tagConfig = provider.getTagConfigsAsync(List.of(tagPath), true, false).get().get(0);
var historyProvider = tagConfig.getOrDefault(WellKnownTagProps.HistoryProvider);
if (historyProvider != null && historyProvider.equalsIgnoreCase(MyHistoryModule.TypeId)) {
var tagId = tagConfig.get(MyHistoryModule.TagIdProperty);
tags.put(Utility.getTagJsonObject(tagId, tagPath, node.getDataType()));
}
// Browse child nodes, but not Document nodes such as UDT parameters
if (node.hasChildren() && DataType.Document != node.getDataType()) {
TagPath childPath = parentPath.getChildPath(node.getName());
browseNode(provider, childPath, tags);
}
}
}