How to read values from Extended Alarm Configuration

HI,
I am trying to read the alarm setpoint, enabled, displaypath etc… from a tag.
I am using the getConfiguration to find which tags have alarms then doing a tag read on the tapath.alarms.
it returns an ExtendedAlarmConfiguration object. Is this the right way to go about reading the alarm properties.

nodes = system.tag.getConfiguration(folder, True)

# Iterate over the results
for item in nodes:
     
    # Through the results, search each dictionary
    for key, value in item.iteritems():
         
        # ...looking for a 'tags' key
        if key == 'tags':
            # iterate over the tag configurations we found
            for tagConfig in value:
				for conf in tagConfig:
					if conf == "alarms": 
						filter = []
						path = folder+"/" + tagConfig["name"] + "." + conf
						p = system.tag.read(path)
						print p

It’s all in the config.

nodes = system.tag.getConfiguration(folder, 1)

# Iterate over the results
for item in nodes:

	# Through the results, search each dictionary
	for key, value in item.iteritems():
	
		# ...looking for a 'tags' key
		if key == 'tags':
			# iterate over the tag configurations we found
			for tagConfig in value:
				# ...looking for a 'alarms' key
				if 'alarms' in tagConfig.keys():
					
					print tagConfig['name']			
					for alarm in tagConfig['alarms']:
						for alarmKey in alarm.keys():
							print '   ', alarmKey, ':', alarm[alarmKey]
						# print alarm listing sparator
						print '   ------------------'
					# print tag listing separator'
					print '______________________'

Note: This only shows configured items. If there is no displayPath key, there isn’t one set up. If there is no enabled key, it’s enabled.

with this solution it seems that this only returns the tag on the lowest level.
So I have a UDT with over 40 tags with 15 of them having alarms configured.
The UDT also has 4 folders with tags inside with alarms configured on a few.
The only tag that are returned are the ones in the folders.

This will recurse through the config

def iterTagConfig(dictIn, tab=0, folderIn = ''):
	keys = dictIn.keys()
	if 'tags' in keys:
		keys.append(keys.pop(keys.index('tags')))
	if 'alarms' in keys:
		keys.append(keys.pop(keys.index('alarms')))
	for key in keys:
		if isinstance(dictIn[key], dict):
			iterTagConfig(dictIn[key])
		elif key == 'tags':
			for tag in dictIn[key]:
				print '    ' * tab,'tag'
				iterTagConfig(tag, tab + 1, folderIn = folderIn + str(dictIn['path']) + '/')      
		elif key == 'alarms':
			print '    ' * tab, 'alarms'
			for tag in dictIn[key]:
				print '    ' * (tab+1),'alarm'
				iterTagConfig(tag, tab + 2)      
		else:
			if key == 'path':
				fullPath = folderIn + str(dictIn['path'])
				print '    ' * tab, key,":",dictIn[key],'   fullPath =', fullPath
			else:
				print '    ' * tab, key,":",dictIn[key]


nodes = system.tag.getConfiguration(folder, 1)

for item in nodes:
	iterTagConfig(item)
1 Like

Hi Jordan,

What should be in the itertag function on line 9 instead of v?

Never mind got it working.

Thanks for the catch! Example updated.