Finding what UDT Data-Type an instance of that type is

What sciript can we use to figure out what parent data type?

The system.tag.getConfiguration() doesn’t seem to give me that information for this specific instance of a UDT:


# This example will get the configuration of a single tag
 
# Update the path here with the tag path you're trying to reach
path = '[UGC_Upstream]Emerson Series 107 Program 2/FCB 7403/2ND AFTERFLOW'
 
# Get the configurations
tags = system.tag.getConfiguration(path)
 
for tagDict in tags:
     
    # Iterate over the dictionary with the iteritems function
    for key, value in tagDict.iteritems():
         
        # Do something with the keys and values
        print key, ' : ', value

historyEnabled : True
dataType : Float4
historyProvider : Ignition_Utah_Oil_and_Gas_Corp_DB
path : [UGC_Upstream]Emerson Series 107 Program 2/FCB 7403/2ND AFTERFLOW
opcItemPath : {bindType=parameter, binding={Meter_Name}.SOFT_POINT.DATA_17:4}
tagType : AtomicTag
name : 2ND AFTERFLOW
opcServer : UGC_RRG_AUTOSOL_DB
engUnit : psi
valueSource : opc

Can you add a property to the UDT and put the name into that? Then read that out?

Sure. But I’m just wondering if there is a specific function that I’m missing that actually returns that

system.tag.readBlocking(["[default]path/to/tag.typeId"])

4 Likes

If you read the Tag + ‘.UDTParentType’ it will return the UDT Type.

#Tagpath must be the main UDT TagPath
system.tag.readBlocking([tagPath+ '.UDTParentType'])

1 Like

Here is how I did it if anyone need a quick full code. When I tried calling the system.tag.readBlocking function, using the UDT path does not work and I get a null. The full tag path is needed for this type of code:

def runAction(self, event):
	system.perspective.print("Process Started")
	
	path = "You tag/ UDT path"
	browse = system.tag.browse(path, filter={"recursive":True})
	
	for tagBrowse in browse:
		fullPath = tagBrowse['fullPath']
		configs = system.tag.getConfiguration(fullPath, False)
		for config in configs:
			try:
				system.perspective.print(tagBrowse)
				system.perspective.print("------------------------------------------------------------------------------------------------")
				system.perspective.print(system.tag.readBlocking(str(fullPath) + ".typeId")[0].value)
			except:
				pass
			break
		break
#				system.perspective.print(system.tag.readBlocking("[Maverick]STX/CGF/CARLA_CGFB/COMPRESSORS/COMPRESSOR_02/CAE_5020_COMP/DIGITAL_VALUE.LongID"))

	system.perspective.print("Process Finished")
			

I put the broad try/except there due to how something are set up in the system we have but you may not need that. Also the breaks are there so I did not have to see multiple UDTs/tags. It is not needed.

Also, you may not need even need the configs function now that I am looking at this again. This is a basic set up for me to get into the configs based on what I need i can put more logic...I hope its helpful as well.

Edit and Update:
I had to change up the code a bit in the program I made. Its a CSV file tag or UDT parameter file creator. In short It is similar to the Tag report tool, but as of now the Ignition report tool outputs a CSV file of tag that has missing tags path and info.

That said, on this properties function for tags I had to use the UDT's path and not the tag path. Here is how I got it to work in the function:

		elif parameter == "typeId":
			TypeIDPath = str(browse['fullPath']).rsplit("/",1)[0] + "." + parameter
			typeID = system.tag.readBlocking(TypeIDPath)[0].value
			RowDataToAdd.append(str(typeID))