Im using system.tag.getConfiguration(tag)[0][‘opcItemPath’]
We are using a lot of UDT instances with UDT parameter bindings. When I get the configuration for the opc item path, it returns these bindings in this format:
{bindType=parameter, binding={myParam}.“the Rest of the path defined in UDT definition”}
when I try to pull out the value of the binding by using something like print config[‘opcItemPath’][‘binding’], I am met with this error:
Traceback (most recent call last):
File “”, line 11, in
TypeError: ‘com.inductiveautomation.ignition.common.config.BoundValue’ object is unsubscriptable
So, i’m resorting to using string splits to access the bound value which feels like such a workaround. Isn’t there a better way?
Still finding the object to be unsubscriptable when I try and get to the value of some binding of a udt instance.
cfg = system.tag.getConfiguration(tag)[0]
print cfg['parameters']['Comm_name']
print cfg['parameters']['Comm_name']['value']
Printed results are:
>>>
{datatype=String, value=ACOSTA1_RTU}
Traceback (most recent call last):
File "<input>", line 8, in <module>
TypeError: 'com.inductiveautomation.ignition.common.tags.config.properties.ParameterValue' object is unsubscriptable
>>>
I’ve got exactly the same problem today. Did you ever find a better solution than parsing the string?
Unfortunately it’s been crickets. Kind of a hassle to get a simple tag config parameter. Hopefully someone chimes in here and shows us the way!
print config['opcItemPath'].getBinding()
or print config['opcItemPath'].binding
should work - the latter is Jython syntactic sugar for the former.
I was recently trying to search for answer to this same question. I reached out to support and they gave me some info from the SDK documentation which provides the answer.
tags = system.tag.getConfiguration("[default]_types_/", True)
#print tags
for tag in tags:
tagConfigs = tag
#print tagConfigs
for key,value in tagConfigs.iteritems():
#This is all of the tags in the _types_ folder
#More specifically, this is a list of configurations for each of the tags in this folder
if key == 'tags':
tagConfigList = value
#print type(tagConfigList)
#Becuase it's a list we must loop for each item in the list
for tag in tagConfigList:
tagConfig = tag
#Now, we get an actual dictionary of configurations for each tag
print "UDT Configs:"
for key,value in tagConfig.iteritems():
#These are all the properties (or keys) for the UDT
print "KEY:",key,"| VALUE:",value
#Parameters seems to have another dictionary for its value
if key == 'parameters':
parameterValueDict = value
print "--------------------------------------------"
print "Parameter Value Dictionary = ",parameterValueDict
#This is a dictionary type so I will get the key,value pair again
for key,value in parameterValueDict.iteritems():
print key,value
#This seems to have another dictionary as its value
print type(value)
#But it's not a dict type
#It's a com.inductiveautomation.ignition.common.tags.config.properties.ParameterValue type!
#So we cannot use iteritems again
parameterValue = value
#But we can use this method from the java docs to easily get the type of the parameter
print "This Parameter is a:", parameterValue.getDatatype()
print "This Parameter's value is: ", parameterValue.getValue()
Also if value is of the type <type ‘com.inductiveautomation.ignition.common.config.BoundValue’>
e.g. value={bindType=parameter, binding={InstanceName}}
then you can use
value.getValue().getBinding()
value.getValue().getBindType()
Summary
This text will be hidden
2 Likes