Hi all.
I'm trying to write a module component which reads all tag configurations in ignition on module start (TODO: have it periodically rescan) in order to look for custom configuration attributes and act on them.
I'm encountering something odd; the java API isn't returning all of the tags I expect.
Using a python gateway event, I'm able to run:
def browse(prefix, node, next):
if node is None:
return
prefix = prefix + "/" + (node.get("name") or "aryastark") # A node has no name
if "tags" not in node:
print "Tagchange script:", prefix, "=", {k:v for k,v in node.items() if k != "tags"}
return
for child in node["tags"]:
next(prefix, child, next)
root = "[default]/Software/LatencyTest" # Or whatever. Can also be emptystring.
print "Begin Tagchange script!", root
for node in system.tag.getConfiguration(root, True):
print "Tagchange script: Toplevel", (node.get("name") or "aryastark")
browse(root, node, browse)
print "End Tagchange script!"
(the combinator is because recursion didn't work without it).
However, when I run equivalent code (kotlin; it runs from my module's startup hook: )
fun fetchAll(
tagManager:GatewayTagManager,
sink: (TagPath) -> Unit
) {
fun browseNode(prefix: TagPath, tagConfig: TagConfigurationModel) {
val fullPath = prefix.getChildPath(tagConfig.path.toStringPartial()) // For some reason the tagConfig.path is a partial path, not a FQPath -- bug? Misnamed field? Needs doc either way.
when (tagConfig.type) {
TagObjectType.Folder, TagObjectType.Provider -> for (child in tagConfig.children) browseNode(fullPath, child)
TagObjectType.AtomicTag -> sink(BaseTag(service, tagConfig.path))
else -> logger.error("Unrecognized type $fullPath!")
}
}
val root = TagPathParser.parse("") // I know that this is different, but it is a prefix of the python code...
runBlocking {
for (provider in tagManager.tagProviders) {
for (firstGeneration in provider.getTagConfigsAsync(listOf(root), true, false).get(30, TimeUnit.SECONDS)) {
browseNode(root, firstGeneration)
}
}
}
}
Python has all of the tags I can see in the ignition designer.
However, java (kotlin...) is missing several random tags, with no apparent pattern between them!
From a spot check, this java code has e.g. [default]Software/LatencyTest/read/887/Data
, but not [default]Software/LatencyTest/read/0/Data
or [default]Software/LatencyTest/read/1/Data
(which are afaik identical tags). It doesn't matter if they are initialized; they're all readonly, memory, etc.
At this point I guess I assume startup order: perhaps ignition doesn't load the full set of tags before loading modules or something, so that my late-running python code can see more than my (relatively) early-running java code.
Is this documented? Is there a method to call (or point during execution?) where I can get the same snapshot the designer & python code has of tags in my java module?
Thank you!