How to pull Associated Alarm Data from the alarm event list generated with system.alarm.queryStatus?

I am using system.alarm.queryStatus(state=[“ActiveUnacked”]) to poll the Gateway for any Active Unacked alarms. It returns a list of alarm events. I would like to pull out associated alarm data from the alarm event for each alarm event in the list.

Here is an example alarm event:
{Source: ‘prov:*****wwtp1:/tag:Digesters/Digester_1_DO/Value:/alm:High Alarm’, Display Path: ‘Digester 1 Dissolved Oxygen’, UUID: ‘e53a939d-a2c7-485e-adc1-5095d710c462’, Current State: ‘Active, Unacknowledged’, Priority: ‘High’, Active Data: {mode=Above Setpoint, setpointA=21.0, eventValue=21.05, com.inductiveautomation.ignition.common.alarming.config.AssociatedData@1c1f3=Digester 1 Dissolved Oxygen High Alarm, name=High Alarm, eventTime=Fri Aug 16 13:51:54 EDT 2019, priority=High, displayPath=Digester 1 Dissolved Oxygen, enabled=true}, Clear Data: null, Ack Data: null, Runtime Data: {}}

The data I need is in the AssociatedData@1c1f3=Digester 1 Dissolved Oxygen High Alarm

is there a clean way to extract this information.
Im working with Ignition 8.0.3

Not sure if this is the cleanest way of doing so but it seems to be working. I was able to use getActiveData().getProperties() and printed the list of properties

results = system.alarm.queryStatus(state=["ActiveUnacked"])
for Alarms in results:
	for Properties in Alarms.getActiveData().getProperties():
		print Properties

this gave me the following properties to choose from:
mode
setpointA
eventValue
com.inductiveautomation.ignition.common.alarming.config.AssociatedData@1c1f3
name
eventTime
priority
displayPath
enabled
I then used the com.inductiveautomation.ignition.common.alarming.config.AssociatedData@1c1f3
as a key to pull out the associated data. And since I wanted it in a long string I used this code

results = system.alarm.queryStatus(state=["ActiveUnacked"])
ConcatenatedPropertyString=''
PropertyName = "com.inductiveautomation.ignition.common.alarming.config.AssociatedData@1c1f3"
for Alarms in results:
	for Properties in Alarms.getActiveData().getProperties():
		if str(Properties) == PropertyName:
			ConcatenatedPropertyString += str(Alarms.get(Properties))

it would be nice how the property name had settled on ‘com.inductiveautomation.ignition.common.alarming.config.AssociatedData@1c1f3’
from an associated alarm property called TTS.

also note to all do not use the same parameters names as associative alarm property names, it really confuses the system.

That identifier will not be the same once you restart your gateway. The @1c1f3 is the object’s hashcode in Java, identifying where it sits in the JVM’s memory allocation (basically). The safer check is to use isinstance(), like this:

from com.inductiveautomation.ignition.common.alarming.config import AssociatedData

results = system.alarm.queryStatus(state=["ActiveUnacked"])
ConcatenatedPropertyString=''
for alarms in results:
	for prop in alarms.getActiveData().getProperties():
		if isinstance(prop, AssociatedData):
			ConcatenatedPropertyString += str(alarms.get(prop))
1 Like

I appreciate you pointing out that the identifier will change on reboot. I have been working with a stable server that hasn’t needed restarting so I missed the trouble that that would cause.

I would like to fix my scripts so they will continue working if the gateway gets reset and am working with your code alteration. However, the isinstance(prop, AssociatedData) never returns true.

I did a print type() on AssociatedData and return <type ‘java.lang.Class’>

I did print type() on the prop in the for loop and it returns <type ‘com.inductiveautomation.ignition.common.alarming.evaluation.EventProperty’>
for the property that I need, as well as every other property.

I don’t see how this will identify the needed associated data if all the properties are the same type. Am I missing something?

Hmm, maybe try isinstance(prop.getType(), AssociatedData) - the EventProperty wrapper should have an internal property with a type associated with it, which should be an instance of that AssociatedData class.

The isinstance() still never returns true. The type that gets returned from type(AssociatedData) is <type ‘java.lang.Class’> and doesn’t match any of the property types that gets spit out of the prop.getType().
I ran:
for alarms in results:
for prop in alarms.getActiveData().getProperties():
print str(prop)
print str(prop.getType())
print ‘+++++++++++++++++++++++++++++++++++++++++’
to be able to see all the properties type that exist beneath the EventProperty wrapper.

I get:
mode
<type ‘com.inductiveautomation.ignition.common.alarming.config.AlarmMode’>
+++++++++++++++++++++++++++++++++++++++++
setpointA
<type ‘java.lang.Double’>
+++++++++++++++++++++++++++++++++++++++++
eventValue
<type ‘java.io.Serializable’>
+++++++++++++++++++++++++++++++++++++++++
com.inductiveautomation.ignition.common.alarming.config.AssociatedData@1c1f3
<type ‘java.lang.String’>
+++++++++++++++++++++++++++++++++++++++++
name
<type ‘java.lang.String’>
+++++++++++++++++++++++++++++++++++++++++
com.inductiveautomation.ignition.common.alarming.config.AssociatedData@9cb7c09e
<type ‘java.lang.Object’>
+++++++++++++++++++++++++++++++++++++++++
eventTime
<type ‘java.util.Date’>
+++++++++++++++++++++++++++++++++++++++++
priority
<type ‘com.inductiveautomation.ignition.common.alarming.AlarmPriority’>
+++++++++++++++++++++++++++++++++++++++++
displayPath
<type ‘java.lang.String’>
+++++++++++++++++++++++++++++++++++++++++
enabled
<type ‘java.lang.Boolean’>
+++++++++++++++++++++++++++++++++++++++++

<type ‘java.lang.String’> is used for the display path, and name property as well as the associated data I am trying to get data from so I don’t know if this would be a good unique identifier. It also doesn’t match the type from AssociatedData.

After restarting my gateway a few times I am now getting the name of the associated alarm data as I titled it.
so when I run:

results = system.alarm.queryStatus(state=["ActiveUnacked"])
for Alarms in results:
	for Properties in Alarms.getActiveData().getProperties():
		print Properties

I now am getting:
mode
setpointA
eventValue
TTS
name
AreaDesc
eventTime
priority
displayPath
enabled

Very confusing that it wasn’t returning as TTS initially, but now it does so I can grab the data I need. Hopefully it doesn’t decide to switch back.