Disabled tag breaking Expression tag expression

I have an expression tag that ORs together the values of a bunch of alarm tags in a UDT so that I have a single tag to tell me if there is an active alarm within the folder.

Firstly, can I do this a better way?

Secondly, some instances of the UDT don’t have a couple of the alarms, so I simply disable these non-required tags, but this then breaks the expression tag’s value and throws a REFERENCE_NOT_FOUND error. Shouldn’t this tag simply be ignored if it’s disabled?

I am not sure of a better way to do it but you can workaround it by using the runScript function with something like this

def activeAlarms(*tags):
	
	tagValues = system.tag.readAll(tags)
	
	for value in tagValues:
		if value.value == True:
			return True
			
	return False

And then in the expression

runScript("shared.alarm.activeAlarms", 0, 
		"[default]test 1.alertActive",
		"[default]test 2.alertActive", 
		"[default]test 3.alertActive")
1 Like

Hmm, I didn’t think about doing it that way, I like it. I may even be able to make it a little smarter by just passing in the parent folder name and extracting the tags in the folder so it’s less of a manual process per udt.
I’m interested though in how using this will affect the system performance, as it will run this script for a large number of UDTs.
It would be nice if folders had properties in Ignition, such as the alarm state of tags within it, the count of alarms active, etc. ClearSCADA does this well and it’s quite useful to use on overview symbols.

You can do that with the system.tag.browseTags like this

def activeAlarms(path, recursive):
	
	tags = system.tag.browseTags(parentPath=path, recursive=recursive)
	tags = [x.fullPath + '.AlertActive' for x in tags]
	
	tagValues = system.tag.readAll(tags)
	
	for value in tagValues:
		if value.quality.isGood():
			if value.value == True:
				return True
	
	return False

It would be nice if folders/udts had that feature built in but in the meantime you can get similar behavior if you use the system.alarm.queryStatus() function and filter to the folder you want.

Careful with this approach. system.tag.browseTags is a performance killer and pretty much always hits the internal DB, which cannot be accessed concurrently. Too many scripts/events in the system invoking browseTags can make access to the internal DB highly contested and bring down a bunch of other parts of the system.

1 Like

Our project was built before the SQL-Lite DB update and now internal DB access is killing our system, both in terms of performance and also making it unstable. What do you recommend in place of using system.tag.browseTags()? Is there any alternative that will perform better?

There’s an advanced property on the realtime tag providers (in the gateway Config > Tags > Realtime) called “Memory Resident Tag Properties” since ~7.9.1. You could try enabling this. As you can imagine given the name, there’s a tradeoff in that it uses more memory.

Other than that… reduce your dependency on browseTags. Call it less often, don’t call it at high levels in the tag structure where it has to do a lot of recursion, cache results when applicable, hard code lists of tags instead of relying on tricky dynamic generation.

In turning this option on, can we then use browseTags without heavy performance consequences?