How to detect tag overrides in scripting?

I’ve just upgraded from 7.9 to 8.1, and one major headache is the change to how expression bindings evaluated parameters and speech marks.

In most of my UDTs there are alarmed tags which had an expression on the Display Path. This is now evaluating literally, and i need to change it to show the parameters properly.
The trouble is, a lot of these alarmed tags have been overridden, and i’m struggling to find a good way to detect that automatically…

There doesn’t seem to be anything in the JSON tag export to indicate a tag property has been overridden.
system.tag.getConfiguration also doesn’t seem to help.
Any ideas?

Overwrite shows in the exported files as “something”, I don’t have a reference now but to the remove the overwrite try to set that something to nothing.

I’m afraid I was not clear,
Can you share the file of a tag and another with no overwrites to help explain?

Hi there,

Here is a snippet of a tag that DOES have an override on the AlarmPriority expression tag:

    {
      "expression": "toInt(tag(\"[.]/In.AlertCurrentSeverity\")) + 1",
      "value": "0",
      "name": "AlarmPriority",
      "tagType": "AtomicTag"
    },

And here is an example of a similar tag that DOESN’T have the override on the same tag:

    {
      "value": "0",
      "name": "AlarmPriority",
      "tagType": "AtomicTag"
    },

So there is a difference i suppose, but it is not clear that it is an override. I’m surprised there is no flag.
How does Ignition know during an import that this differs from the original UDT structure?

I still haven’t found a good solution for this… Does anyone have any ideas?
Specifically after how to detect overrides in scripting… not via tag JSON export.

i’m going through a process of updating some UDTs, of which there are thousands of tag instances.
There may be dozens of instances which have specific attributes overridden, but there is no good way to find these via scripting.
I can search for specific properties i know been modified, but this doesn’t help identify things that might slip through the cracks.

2 Likes

The function below can be copied into the Ignition 8.1 Designer Script Console and called from there. You’ll need to provide an XML export that includes all of your deployed UDT instances. The code will recursively work through the XML export to identify overrides in atomic tags within UDT instances, printing the tag path and overridden tag property for each override found. If you would like to exclude certain tag properties, append them to the propExclustionList list. I currently have the ‘value’ tag property in that list so that overridden memory tag values don’t get printed to the console.

#Provide file path to XML export from Ignition designer. XML export must be generated by right-clicking on site folder within Ignition designer 
#and exporting to .xml file. Provide full file path to this file including .xml extension, ex. "C:\\Users\\LHammami\\Documents\\tags.xml"
#Recursively browses XML export for "Tags" elements and prints all UDT instance atomic tag overrides found in XML export to script console.
def getUdtOverrides(filePath):
	#Required libraries
	import sys
	import xml.etree.ElementTree as ET

	#Properties that will not throw an error if found overridden in UDT instance
	propExclustionList = ['value']
	
	#Check Tags structure for Tag overrides
	def checkTagsForTagOverrides(Tags, path, udtCheckCount=0, udtInstance=False):
		for child in Tags:
			if (child.tag == 'Tag') and (child.attrib != {}):
				for key in child.attrib:
					if (key == 'type') and child.attrib[key] == 'Folder':
						if path == '':
							folderPath = child.attrib['name']
						else:
							folderPath = path + '/' + child.attrib['name']
						for subchild in child:
							if (subchild.tag == 'Tags'):
								udtCheckCount = checkTagsForTagOverrides(subchild, folderPath, udtCheckCount, udtInstance)
					elif (key == 'type') and child.attrib[key] == 'UdtInstance':
						if path == '':
							udtPath = child.attrib['name']
						else:
							udtPath = path + '/' + child.attrib['name']
						for subchild in child:
							if (subchild.tag == 'Tags'):
								udtCheckCount = checkTagsForTagOverrides(subchild, udtPath, udtCheckCount + 1, True)
					elif (key == 'type') and (child.attrib[key] == 'AtomicTag') and udtInstance:
						for prop in child:
							if prop.attrib['name'] not in propExclustionList:
								tagPath = path + '/' + child.attrib['name']
								print tagPath
								print "Tag path:	", tagPath
								print "Override:	", prop.attrib['name']
								print ''
									
			elif (child.tag == 'Tags'):
				udtCheckCount = checkTagsForTagOverrides(child, path, udtCheckCount, udtInstance)
				
		return udtCheckCount
	
	#Print error to console if file doesn't exist. Else check all UDT instances for overrides. 
	if system.file.fileExists(filePath):
		print 'Checking ' + siteFolder + ' tag export file ' + filePath + ' for UDT instance overrides.'
		print ''
	
		tagXml = system.file.readFileAsString(filePath)
		element = ET.fromstring(tagXml)
		udtCheckCount = checkTagsForTagOverrides(element, '')
		
		print udtCheckCount, "UDT instances checked."
		
	else:
		print 'ERROR: FILE NOT FOUND'
1 Like

@LHammami FYI, as of 8.1.19, Ignition has a tag report tool that can be leveraged for detecting overrides, among other things. This tool can used in both designer and scripting.

2 Likes

@jlandwerlen Thank you for the heads up; I wasn’t aware that a tag report tool had been developed. We will be upgrading one of our site server Ignition deployments to 8.1.19, so I will have an opportunity to work with that tool soon. I am sure it will be more robust, intuitive, and user-friendly than the code I posted.

Thanks for the script @LHammami , I’ll be keen to try it out, as well as this new Tag Report tool in 8.1.19. Hopefully one of these tools will do what i need!

@cmason have you tried this 8.1.19 tag report tool? Might be useful to test on the recent upgrade.