IA Scripting to extract alarm details

Hi all

Version 7.6.3

We are currently attempting to create a table within our system which gives information and current settings of all configured alarms within the gateway, using features within the IA Labs scripting module (1.6.4) to get the attributes of the tags and using the current alarm severity to filter out non-alarm tags within the project. Here is the code we are attempting to use:

[code]system.db.runUpdateQuery(“Delete from alarms”)
tags = system.tag.browseTags(parentPath="", recursive=1)
for tag in tags:
tagDefs = system.tag.getAttribute(tag.fullPath,“AlertCurrentSeverity”)

if (tagDefs >= 0):	
	xID = system.db.beginTransaction()
	path = tag.fullPath
	name = system.tag.getAttribute(tag.fullPath,"Name")
	message = system.tag.getAttribute(tag.fullPath,"AlertMessage")
	displayP = system.tag.getAttribute(tag.fullPath,"AlertDisplayPath")
	execEn = system.tag.getAttribute(tag.fullPath,"AlertExecEnabled")
	alertMode = system.tag.getAttribute(tag.fullPath,"AlertMode")
	ackMode = system.tag.getAttribute(tag.fullPath,"AlertAckMode")
	print path
	system.db.runUpdateQuery("INSERT INTO alarms (path, severity, name, Alert_Message, Alert_DisplayPath, Alert_ExecEnabled, Alert_Mode, Alert_AckMode) VALUES ('%s','%s','%s','%s','%s',%s, %i, %i )" % (path, tagDefs,name, message, displayP, execEn, alertMode, ackMode))		


With this code we do retrieve some of the information from the tags (path,severity,name,AlertExecEnabled,AlertMode,AlertAckMode) but no results for the display path or the alert message are inserted into the database, I have tested running the .getAttribute on single tags with alarms using the script playground and am unable to get the information this way either,

We have notice that some configured alarms show a NULL or -1 property (such as “AlertCurrentSeverity”) when the alarm is not active but have the correct value when active. This has prevented us from finding all configured alarms, is there a different property we could use?

we would also like to extract the current setpoint and current notification pipeline.

We are obliged to provide a current list of configured alarms to our customer.

many thanks

1 Like

I would try using the system.tag.getAlarmStates() function from the IALabs Scripting Module. Try this to get you going:tags = system.tag.browseTags(parentPath="", recursive=1) for tag in tags: try: tagDefs = system.tag.getAlarmStates(tag.fullPath) if len(tagDefs) > 0: print "" for tagDef in tagDefs: print "Alarm Name:", tagDef.alarm print "Props:" for prop in tagDef.getAlarmProperties(): print prop.property, prop.type, prop.value except: pass

Thank you for the reply, sadly however this solution doesn’t solve the issue, when this script runs the output is [quote]displayPath Expression {[.]Board}+" “+{[.]Name}+” Tripped"
[/quote] whereas we require the output to be [quote]displayPath Expression HV1.1 Board 3 Tripped [/quote]This is the same for the Priority and the Enabled Tag, so what is required is that the values for the tags to be printed instead of the tag name.

Unfortunately there is no way to fill in that information at the moment. I will add a request to make all UDT properties evaluate for the getAlarmStates() function, but it may not be something we can implement any time soon.

Hi, I am doing a project in 7.9. I am looking to see the output of expression. But all I get is the expression tied to the alarm property. Was the request to make all UDT properties evaluate for the getAlarmStates() function completed? If not, is there any alternate way to get the output of those expressions.

I am trying to build an Alarms Screen and they want all the required info like priority, display path, etc. And all these properties are tied to some other stuff in the UDT.