Before they added
'recursive':True
functionality to tag browsing in scripting, you had to program your own recursive function to even browse tags recursively. But they realized that was rather inconvenient so they added the built-in option. But once you have your conveniently generated recursive tag structure, it's impossible to do anything on the entire set without writing another recursive function.
Currently system.tag.getConfiguration returns a list (always of size 1, as far as I can tell) of tag dictionaries. What if instead it returned an object that could act like the tag dictionaries, but also had a method
.modify(config, filters={})
that would search through the configuration and overwrite with the specified config, applying the specified filters?
alarms = [{"name":"Alarm", "mode":"Equality", "setpointA":1}]
config = system.tag.getConfiguration("[default]", True)
config.modify({"alarms":alarms}, {"tagType":"AtomicTag"})
system.tag.configure("[default]", config, "o")
instead of...
def make_alarms(tagdict):
if "value" in tagdict.keys():
tagdict['alarms'] = [{"name":"Alarm", "mode":"Equality", "setpointA":1}]
return tagdict
if "tags" in tagdict.keys():
for tag in tagdict['tags']:
tag = make_alarms(tag)
return tagdict
alarms = [{"name":"Alarm", "mode":"Equality", "setpointA":1}]
config = system.tag.getConfiguration("[default]", True)
config = make_alarms(config[0])
system.tag.configure("[default]", config)