EDIT: This is on the Root Node and not the members. My alarm part was for the members only. I think due to this I am missing something when I pass my new parameters to the the UDT.
Coming back to this. In my past case I got this to work for the alarms based on the documentation - system.tag.configure
I was able to add new alarms to to the UDT definitions, and by using "m" it only changed premade alarms if they were different or if it was not there it would add the a new alarm to the UDT.
That said. I can not replicate this on parameters for some reason. I make a dicts with keys = to a word and the value equal to "". I tried to copy the format in the documentation and even tried to copy json download file's format. In both case the UDT definition does not update at all.
Any insight would be greatly appricated
Here are the variable values in my code:
UDTDefinitionPath = component value of the folder teh user wants to start in
basePath = [default]_types_/folder
UDTName = the Name of theUDT
UDTconfigs = all the configs of that UDT
collisionPolicy = "m"
# this next var gets made based on a comma seperated list provide by user. E.G:
parms = {'SAP ID': {'dataType': 'String', 'value': ''}, 'Equip Type': {'dataType': 'String', 'value': ''}, 'EDM Key': {'dataType': 'String', 'value': ''}}
With that here is the code, which mimics my alarm update code that works, but for some reason I feel like I am missing something. Or this just can not be done like alarms can:
def runAction(self, event):
def updateTagParms(basePath, UDTName, UDTconfigs, collisionPolicy, newParmsmap):
"""Add new perameters to UDT definitions"""
parms = {}
for key in newParmsmap:
parms[key] = {
"dataType": "String",
"value": ""
}
system.perspective.print(parms)
# Configure the list of Tags. Need to pass a list as an argument.
tagList = [
{
"parameters":parms,
"name":UDTName
}
]
system.tag.configure(basePath, tagList, collisionPolicy)
# Variables
# merge, modifying values that are specified in the definition, without impacting values that aren't defined in the definition. Use this when you want to apply a slight change to tags, without having to build a complete configuration object.
collisionPolicy = "m"
# Parameters to add: TODO: need to take oput spaces in entries to be sure there are no duplicate add ons.
newParms = str(self.getSibling("ParmsToAdd").props.text).split(",")
newParmsmap = map(str.strip, newParms)
# #grab MAin Folder path to UDT Instances
UDTDefinitionPath = self.getSibling("DefinitionPath").props.text
# had to use broswe due to getting configs from a folder path will not give us a fullpath but instead just teh 'path' that is the UDT name only
UDTFolderBrowse = system.tag.browse(UDTDefinitionPath, filter = {"tagType": "UdtType", "recursive":False})
for udtDefinition in UDTFolderBrowse:
# grab the UDT path from teh broswe so we can feed it into the get configure function - This is so we can acess teh parameters
UDTBrowsePath = udtDefinition['fullPath']
# get more proprties/parameters for each UDT to be updated
UDTconfigs = system.tag.getConfiguration(UDTBrowsePath, False)
# itterate through each UDT configs
for udt in UDTconfigs:
# grab our UDTPath and UDTName from teh configs - To be sure Ignition doesn not get confused on what we are trying to do: update parameters
basePath = str(udt['path']).replace("/"+str(udt['name']),"")
UDTName = udt['name']
updateTagParms(basePath, UDTName, UDTconfigs, collisionPolicy, newParmsmap)