Modifying the parameters of a nested UDT with system.tag.configure

Does anyone know how I would go about modifying the parameters of a nested UDT. For Example, Let’s say I have a UDT with the following layers.

Discrete (UDT)
—{Parameter:motorNum}
—OpcTag
—OpcTag
—OpcTag
—DiscreteAlarm (NestedUDT)
------{Parameter:someParameter}
------OpcTag
------OpcTag

In this example, I am trying to create the parent tag while also modifying the parameter of the nested UDT “DiscreteAlarm” titled “someParameter”. The example code below is straight from the manual and works just fine for creating the parentUDT.

Any help would be much appriciated.

Thanks!


  
# The provider and folder the tag will be placed at.
baseTagPath = "[SWRF]aaSCRATCHPAD"
  
# Properties that will be configured on that tag.
tagName = "Test"
typeId = "Alarm/Discrete"
tagType = "UdtInstance"
# Parameters to pass in.
motorNum = "C1245"
  
# Configure the tag.
tag = {
            "name": tagName,         
            "typeId" : typeId,
            "tagType" : tagType,
            "parameters" : {
              "tag_Alarm" : motorNum
              }
       }

collisionPolicy = "a"
  
# Create the tag.
system.tag.configure(baseTagPath, [tag], collisionPolicy)

tag = system.tag.getConfiguration("[SWRF]_types_/Alarm/DiscreteAlarm")
print tag

I was able to solve this (probably not the cleanest solution) by first creating the parent udt and then modifying the UDT by configuring the nested udt. I didn’t want someone to waste time responding as I have a ‘quick workaround’. I will continue on my own to come up with an optimized way of performing this.

Thanks to all who viewed the post.

tag[0]['parameters']['someParameter'] = '235'
 
# Overwrite the existing configuration
collisionPolicy = "o"

system.tag.configure("[SWRF]aaSCRATCHPAD/Test", tag, collisionPolicy)

You can also literally just write to the parameter itself with system.tag.writeBlocking/Async. You can actually do this in the tag browser as well if you expand the Parameters folder, fwiw.

E.g.
system.tag.writeBlocking(['tag/path/udt_instance/Parameter.ParamName'], ['newValue'])

In 8.1.7 and perhaps in the past too it’s not:

system.tag.writeBlocking(['tag/path/udt_instance/Parameter.ParamName'], ['newValue'])

it is:

system.tag.writeBlocking([‘tag/path/udt_instance/Parameters.ParamName’], [‘newValue’])

1 Like

Whoops! you’re correct