EventData object access

Hi all,

I’m working with some alarms that I got with system.alarm.queryJournal()

The docs say that this returns a list of AlarmEvent objects. Are there any docs on this object? I found a blurb about some of the access functions on the queryJournal page, but a search of the docs yields no more information. In any case, I managed to figure out most of what I needed with the information on that page, with the exception of getting any data from the events that are part of the alarms.

From the alarms I can get EventData objects, which should contain some sort of ‘eventTime’ attribute. How do I access this? And where is there documentation on these objects? Searches of the docs and forums yielded disappointing results.

With ignition I’ve been able to figure the not-so-awesomely-documented parts with trial and error, but this time I haven’t been able to get to the results. Here are a few of the things I’ve tried:
activeData[‘eventTime’] <- EventObject is not subscriptable
activeData.getEventTime(), .getTime() <- No attribute
activeData.get(‘eventTime’) <- can’t coerce to property
alarm.getActiveEventTime() <- No attribute

As an aside - how do alerts and alarms fit together? I’ve poured over the user manual extensively and cannot figure out how they are different or how they are related. I haven’t been able to get anything with alerts to work - it just keeps saying that the journal doesn’t exist, but the journal works for the alarms…

Finally - it looks like queryJournal returns a semi-unique alarm for each event, where semi-unique means that it is a new object, but the alarm UUID is the same. Is there a way to ‘squash’ all alarms with the same UUID into the same alarm object? What I’d like to be able to do is get the cleared and active times from a single alarm object, instead of going through a list and pulling all the ones with the same UUID out and then merging it all manually.

Looking forwards to great success,
Charles

A few updates to help some others out:

  • Alerts and alarms seem to be distinct systems. It looks like the system.alert is deprecated and system.alarm is what should be used moving forwards. I might be wrong…

  • The queryJournal function looks practical, but it seems in practice the queryStatus is really the function you’re looking for. It will logically squash the journalled events which is what I was looking for above. I can only think of very few specialized cases where someone would want the raw journalled alarms from queryJournal.

I still haven’t found out how to access any of the members of the EventData objects, however.

I did find the dir() python function which is pretty neat - it will enumerate the members/attributes of an object. For the EventData object I get:

['__class__', '__copy__', '__deepcopy__', '__delattr__', '__doc__', '__eq__', '__getattribute__', '__hash__', '__init__', '__iter__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__unicode__', 'addPropertyChangeListener', 'class', 'contains', 'count', 'equals', 'get', 'getClass', 'getCount', 'getOrDefault', 'getOrElse', 'getProperties', 'getRawValueMap', 'getTimestamp', 'getValues', 'hashCode', 'isExtended', 'isInherited', 'iterator', 'merge', 'notify', 'notifyAll', 'of', 'properties', 'propertyChange', 'propertyChangeListener', 'rawValueMap', 'remove', 'removePropertyChangeListener', 'set', 'setDirect', 'setRawValueMap', 'timestamp', 'toString', 'values', 'wait']

I was able to find a bit of love through the raw value map, but I doubt that’s how the IA folks want me to access the EventData attributes.

Given an alarm, does anyone know how to determine when it became active (ie: the eventTime of the Active Data attribute)?

Charles

I still haven’t found a reasonable way of accessing the EventData object members. When converting the object to a string it looks like there is interesting data - but how do I access it?

Active Data: {eventTime=Mon May 05 10:22:41 PDT 2014, timestampSource=System, priority=Diagnostic, name=, setpointA=1.0, ackMode=Manual, eventValue=true, notes=null, deadband=0.0, mode=Equal}

Ack Data: {ackUser=usr-prov:pmcs:/usr:chache, eventTime=Tue May 06 15:01:56 PDT 2014}

Clear Data: {eventTime=Mon May 05 10:52:41 PDT 2014, timestampSource=System, priority=Diagnostic, name=, setpointA=1.0, ackMode=Manual, eventValue=false, notes=null, deadband=0.0, mode=Equal}

Charles

AlarmEvent has getActiveData(), getClearedData(), and getAckData() on it. These each return an EventData object, which is just a PropertySet.

PropertySets are a little awkward to work with in Jython, but the data is there.

I think generally you’ll have to access them like this, for example:

from com.inductiveautomation.ignition.common.alarming.config import CommonAlarmProperties
ack_time = alarmEvent.getAckData().get(CommonAlarmProperties.AckTime)

You can also create your own BasicProperty to pass to get() instead of using the ones defined in CommonAlarmProperties, since those aren’t really documented for use.

Excellent!

It’s a tiny bit clumsy but not nearly as sketchy as me calling toString and then parsing what I wanted out of there!

Thanks for the help, Kevin
Charles

For everyone’s reference, the members of CommonAlarmProperties are:

['AckDuration', 'AckMode', 'AckNotes', 'AckNotesReqd', 'AckTime', 'AckUser', 'ActiveDuration', 'ActivePipeline', 'ActiveTime', 'BASIC_BINDABLE_PROPS', 'BranchDepth', 'CONFIG_PROPS', 'ClearPipeline', 'ClearTime', 'Deadband', 'DeadbandEvalMode', 'DisplayPath', 'DisplayPathOrSource', 'Enabled', 'EventCanceled', 'EventId', 'EventState', 'EventTime', 'EventValue', 'Filter', 'FullItemPath', 'INFO_PROPERTIES', 'IsAcked', 'IsActive', 'IsClear', 'IsInitialEvent', 'IsShelved', 'IsSystemEvent', 'ItemName', 'ItemPath', 'LegacySendClear', 'Name', 'Notes', 'PipelineTransitionCount', 'Priority', 'ShelfExpiration', 'ShelvingAllowed', 'Source', 'State', 'SystemAck', 'TimeOffDelaySeconds', 'TimeOnDelaySeconds', 'TimestampSource', '__class__', '__copy__', '__deepcopy__', '__delattr__', '__doc__', '__eq__', '__getattribute__', '__hash__', '__init__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__unicode__', 'advanced', 'bindable', 'category', 'categoryKey', 'class', 'defaultValue', 'description', 'displayName', 'equals', 'getCategory', 'getCategoryKey', 'getClass', 'getDefaultValue', 'getDescription', 'getDisplayName', 'getName', 'getType', 'hashCode', 'isAdvanced', 'isBindable', 'name', 'notify', 'notifyAll', 'toString', 'type', 'values', 'wait']

Also, for a slight reduction in code, you can use the get through the EventObject directly with the alarm properties:

alarms = system.alarm.queryStatus(state=["ClearAcked"]) print alarms[0].get(CommonAlarmProperties.ActiveTime)
Yields:

Fri May 02 10:12:43 PDT 2014

1 Like

Thank you for the reference, it helped.

Not sure though to understand how to access custom associated data.

I have an alarm with a custom associated data named ‘customProperty’ for example. Its value is set to ‘Custom Value’.
When my alarm becomes active, I use getActiveData() and gets the active Data in a propertySet.

[{Source: 'prov:default:/tag:Pressure:/alm:Alarm', Display Path: '', UUID: 'dce1f2ed-d74a-4778-9a19-e1d777709036', Current State: 'Active, Unacknowledged', Priority: 'Low', Active Data: {mode=Above Setpoint, setpointA=30.0, eventValue=75, name=Alarm, customProperty=Custom Value, eventTime=Mon Dec 22 16:02:43 CET 2014}, Clear Data: null, Ack Data: null, Runtime Data: {}}]

I tried several unsuccesful ways to get the value of ‘customProperty’, including getActiveData().get(‘customProperty’).

I read that there is an option with using toString() and split() in order to parse and extract the wanted property but is there any other more elegant way to do so ?

Thank you.

@Amarth
Associated data are captured whenever the alarm event occurs. Hence

event.get("customProperty")

will do the trick.

I’m trying to do exactly what Amarth was trying, namely to access custom associated data for an alarm.

Can anyone see what is wrong with the following approach when trying to return the value of the associated data “Group” field for each alarm?

alarms = system.alarm.queryStatus() for alarm in alarms: print alarm.get("Group")

Looks like we need a way to get the properties of each alarm, as they are probably custom, and wont be in the class mentioned earlier (CommonAlarmProperties). I thought creating an AlarmProperty instance would work, but it doesn’t. Need some other form of accessing this, so maybe someone from IA can chime in.

I would like to add that it seems that the data you can get by using methods like getActiveData() don’t contain all the information it used to contain “before”. (Also true with getClearedData(), getAckData()…)

I currently use a 7.7.5 version and when I use this method on an alarm fetched from queryJournal(), I only retrieve the eventtime. I can’t get the information I could get in my previous post (mode, setpoint, name, value and, of course, associated Data).

I tried the exact same code on an old Gateway (7.6.6) and the getActiveData() gave me a correct result.

Has those functions been changed ?

Check and make sure you have the includeData arg set to true or specify a condition for associated data in system.alarm.queryJournal().

support.inductiveautomation.com … eryJournal

includeData set to false:

{Source: 'prov:default:/tag:Alarm Test/Realistic0:/alm:Hi Alarm', Display Path: '', UUID: '9142c56b-7929-4f47-a0af-98a03193ce30', Current State: 'Active, Unacknowledged', Priority: 'Low', Active Data: {eventTime=Thu Aug 27 08:05:34 CDT 2015}, Clear Data: null, Ack Data: null, Runtime Data: {}}

includeData set to true:

{Source: 'prov:default:/tag:Alarm Test/Realistic0:/alm:Hi Alarm', Display Path: '', UUID: '9142c56b-7929-4f47-a0af-98a03193ce30', Current State: 'Active, Unacknowledged', Priority: 'Low', Active Data: {eventValue=97.57897236938345, eventTime=Thu Aug 27 08:05:34 CDT 2015}, Clear Data: null, Ack Data: null, Runtime Data: {}}

(Ignition 7.7.5b2015071516)

facepalms

Thank you.

I’ve been playing around with querying the alarm journal. Following this post, I have been unable to extract the eventTime from the alarms. Experimenting with the script playground, I’ve been able to get other data, but the time still eludes me. I’ve tried many permutations. I would like to get the time the event became active.

results = system.alarm.queryJournal(journalName="Journal", startDate='2015-09-21 07:00:00', endDate='2015-09-21 17:00:00', includeData=True, includeSystem=False) for event in results: x = [ event.get(CommonAlarmProperties.ActiveTime), event.getState() ] print x
This returns an error that CommonAlarmProperties doesn’t exist. So does
x = event.getActiveData().get(CommonAlarmProperties.ActiveTime)

I also get errors with:
event.getActiveData().eventTime
event.getActiveData()[eventTime]
etc.

If I just print out the results from getActiveData(), I can see eventTime=XXX, but I can’t seem to access it.

I’m probably just being obtuse. Thanks for any answers.

Hello,

This should grant you access to the eventTime.

from com.inductiveautomation.ignition.common.config import BasicProperty

results = system.alarm.queryJournal(journalName="JRNL_ALARMES", 
   startDate='2015-09-22 17:30:00', 
   endDate='2015-09-22 18:00:00',
   includeData=True,
   includeSystem=False)
   
eventTime = BasicProperty("eventTime", BasicProperty().getType())

for event in results:
		activeData = event.getActiveData()
		if not(activeData is None):
			print event.getName(), activeData.get(eventTime)

It works but I am not sure that it is the right way to do it…

Here you get the data for an Active event. Similar methods exist for Clear and Ack events.

1 Like

Amarth, thanks for the help! :thumb_right:

It does seem a little convoluted, but there doesn’t seem a built-in way to access it. I was able to get this working.

IA - it would be nice to have better documentation of the AlarmEvent and how to access its properties.