Get the list of all the tag with alarms Configured

Hello.

I am trying to get the list of all alarms configured on my Ignition project, instead of manually checking tag by tag the Alarms names. Is There any fast solution for It? I want to be able to change an alarm pipeline of any alarms throught the Scada.

A combination of system.tag.browseTags() and system.tag.getAlarmStates() should give you what you need in a script.

3 Likes

Yes thank you, that is exactly the kind of Functions I was looking for

1 Like

For the next ones:

Heere is the code to get the list of all the alarms:

        today = system.date.now()
        Author = system.tag.read("[System]Client/User/OSUsername").value
	tags = system.tag.browseTagsSimple("", "ASC")
	"""Name the column of the Dataset"""
	headers = ["Alarm_Name", "Tag_Path", "Active_Pipeline","Creation Date", "author"]
	data = []
	"""-------------------------------------------------------------------------------------------------------"""
	"""Browse tags"""
	for tag in tags:
		"""------- Verify tag currently checked contain alarm. Else, move on to the next tag ----------- """
		try:
			"""----- Get all alarm information on the tag. Can be one or many alarms condition for 1 tag ------- """
			tagDefs = system.tag.getAlarmStates(tag.fullPath)

			"""Keep only tags with alarm configured"""
			for tagDef in tagDefs:
				priority = 0
				for prop in tagDef.getAlarmProperties():
					"""Look only for alarm with medium and High severity"""
					if (prop.property == "priority" and not str(prop.value) == "Diagnostic" ):
						priority = 1
				if priority == 1:
					tagPaths = [tag.fullPath]
					""" Then Write the result in a dataset"""						
					data.append([tagDef.alarm, tag.fullPath, pipeline, system.date.format(today, "YYYY-MM-d"), Author])
		except:
			pass

4 Likes

Unfortunately, this script isn’t easily converted to v8 :frowning: The function system.tag.getAlarmStates was deprecated.

I assume that we now need to use system.tag.getConfiguration, however this only returns non-default values… so if the priority for example is set to Low, then you won’t be able to read this. I guess you could assume it’s Low if the key isn’t in the dictionary? This would require knowing the defaults of all properties though, assuming you wanted to bring back other property values as well. Also, getConfiguration eats up all available memory and subsequently kills the script for large numbers of tags…

I really don’t know the best way to approach this anymore… I can think of really dumb ways that will probably take hours to run (for a lot of tags). E.g. using system.tag.browse to find the tags, then system.tag.getConfiguration to get the configuration for each tag individually, check if it has an alarm, get the alarm names, then use system.tag.readBlocking to read the values of the alarm properties (of course I would collate a list of all tags and all properties to read, and then bulk read them)… very cumbersome to write the code and very dumb and inefficient in terms of structure… Who knows how long that will take for 350k tags. A rough estimate based on a quick simulation is >9hrs

My client wants to get a list of alarms configured. Facing the same issue now.

Is there any better ways after 3 years?

Use system.tag.browse recursively over your entire tag provider and then filter out tags from the result that have an alarms attribute key… hmm… although i’m missing how to get the alarm info from the attribute. The attributes will tell you if there is an alarm associated with the tag, but won’t tell you the details of the alarm

e.g.

tags = system.tag.browse(path='[default]', filter={'recursive':True, 'tagType': 'AtomicTag'}) # this will include UDT Types, not sure how to filter these out through this filter...
alarmed_tags = [tag['fullPath'] for tag in tags if 'attributes' in tag and any('alarm' in atr.id for atr in tag['attributes']]

Maybe @PGriffith or @ggross or @kcollins1 can assist in best way to pull the alarm details? (also how to filter out tags from within UDT definitions within the filter arg (doesn’t appear possible)? - can always filter them out in the results…)

You could loop through your alarmed_tags and do something like

def getAlarmTagInfo(tag):
	tagPath = str(tag)
	tagDefs = system.tag.getAlarmStates(tagPath)
	if len(tagDefs) > 0:
		print tagPath
		for tagDef in tagDefs:
			for prop in tagDef.getAlarmProperties():
				print prop.property,':',prop.value

ahem :slight_smile:

1 Like

Ah yes, there are so many of these forum questions :laughing:

deprecated != removed. :wink:

deprecated = will-be-removed-soon :upside_down_face:

Will it? I feel like IA keeps deprecated stuff around forever for backwards compatibility reasons lol.

FIFY

Haha, you’re all probably right. It’s hard to remove things that people might still be using :confused: Documentation for it might disappear though. I don’t see any documentation for Ignition version 7.7 as an example, unless the online manuals only started in 7.8…
Looks like there’s a PDF of it on scribd, so I guess that answers that

How about

def isAlmTag(path):
	nodes = system.tag.getConfiguration(path, False)
	for item in nodes:
		if item.has_key('alarms'):
			return True
		else:
			return False

Just grab a list of tags and then loop and call isAlmTag?

I imagine this would be pretty darn slow for 30k alarmed tags calling getConfiguration individually on each one. Calling getConfiguration to return the entire tag tree though is also slow and requires a very large amount of memory - I crashed my designer last time even with the memory boosted (might have been set to 1.5GB? or 2GB?)

Actually I just read what you’re doing in the function and it’s just checking to see if there are any alarms at all. If you just want to get a list of all tags with alarms, then system.tag.browse is by far the most efficient/fastest way to go. getConfiguration is far slower

I don’t have a good solution at this point in time other than to refer to the other post mentioned earlier. I will tease you with the fact that this will become a lot easier in the near future with a feature we are finishing up.

Garth

2 Likes

@ggross how near is the future? :slight_smile: