Issue with queryAlarmStatus() and getActiveData()

I am unable to access the values returned from getActiveData().

The code below runs fine:

alarms = system.alarm.queryStatus()
print alarms[0].getActiveData()

output:

{eventTime=Mon Jul 19 10:14:49 CDT 2021, label=Emergency Stop, priority=Diagnostic, mode=Bit State, eventValue=0 bitPosition=4, AlarmClass=Event, systemAck=true, name=Emergency Stop, displayPath= Emergency Stop}

But when I try to extract a value with:

print alarms[0].getActiveData().eventTime

I get the error:

Traceback (most recent call last):
File “”, line 4, in
AttributeError: ‘com.inductiveautomation.ignition.common.alarming.E’ object has no attribute ‘eventTime’

Is this a bug or am I missing something here? Thanks!

Does alarms[0].getActiveData().getTimestamp() (alternate syntax: alarms[0].getActiveData().timestamp) have the timestamp you want?

getActiveData() returns an instance of EventData, which has a getTimestamp() method:
https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.1/com/inductiveautomation/ignition/common/alarming/EventData.html#getTimestamp()

You can also get the EventTime from the property set directly, but it’ll be a bit tricky; this might work:

from com.inductiveautomation.ignition.common.alarming.config.CommonAlarmProperties import EventTime
alarms[0].getActiveData().get(EventTime)

Thank you for the reply. What I actually need is the Associated Data we have in our alarms. Such as “AlarmClass” in the example above. I used eventTime for an example, but any value I attempt to access from getActiveData() throws the same error.

One option:

for property in alarms[0].getActiveData().properties:
    if property.name == "AlarmClass":
        print dir(property)

This should work for now thank you. Do you think the other issue is a bug that could be fixed?

The other issue being the AttributeError?

I don’t think it’s a bug, exactly - it’s just that alarm events weren’t implemented in a way that allows direct property access. Changing something like that would be ‘risky’ at this point - if we make any easier syntax work, it would likely be to allow dictionary-like subscript access, so activeData["AlarmClass"] or something like that.

2 Likes