Hello everyone,
I am trying to show the most recent alarms during the past 8 hours in the Alarm status table. Tried to find a way to do this but could not find any answer. Currently, I am seeing all the alarms but I want to limit this information to only the past 8 hours of alarm data. Appreciate any information/reference you could share.
Thank you!
Entirely within the Alarm Status Table, you could also use the filterAlarm
extension function to hide alarms outside your time window.
I have some reservations about the idea of hiding alarms purely based on time, but presumably you’ve got other ways to identify or deal with long-running alarm conditions…
1 Like
Thank you for your response!
I have tried to use the link you provided but could not find a way to do this. How can I use [system.alarm.queryStatus] to filter for the last 8 hours alarm?
Could not find any example in the manual or within this forum. Would you please provide an example of how this can be done using filterAlarm component scripting? Or is it possible to filter based on the Active time column?
alarmEvent.get('ActiveTime')
will give you the time of the column
1 Like
I have tried that but not sure how can I use this information to filter the last 8 hours alarm.
The information I get from " alarmEvent.get('ActiveTime')
" is:
Tue Oct 12 11:09:58 EDT 2021
How can I filter just the time to 8 hours? I am not able to find any example so that I can build mine based on that.
filterAlarm
is fired once per alarm event and is required to return a boolean (in Java’s pseudo-functional parlance, a predicate).
So your implementation of filterAlarm
simply needs to check whether the alarm’s ActiveTime
is outside of your window.
You can use system.date.now
to retrieve the current time during script execution.
You can use system.date.addHours
to subtract eight hours from a given date.
You can use alarmEvent.get("ActiveTime")
to get the time of your event.
You can use system.date.isAfter
to compare two different dates and return a boolean (true/false).
Between those functions, you should be able to do what you want.
2 Likes
Thank you very much, Paul. Appreciate the information.
there should be a training module to help wit this and we should not have to hunt everywhere to get a simple filtering example. There not a example in user manual. Powerful software for Scada but most plant personnel with not be able to support project moving forward.
There actually is an example in the documentation, though its not for this exact scenario. I don’t know what type of positions plant personnel referrers to, but i wouldn’t expect end users to know how to do this, i would build it in for them.
1 Like
I don't think that would work. Datediff is from expression language. System is used in scripting.
I tried this:
if system.date.hoursBetween(alarmEvent.get('LastActiveTime'),system.date.now())==4:
value='true'
else:
value='false'
return true
and I tried this
return 'true' if system.date.hoursBetween(alarmEvent.get('LastActiveTime'),system.date.now())==4 else 'false'
I don't know what the property is that I need to look at, or how to find the properties.
When I look at alarms in the tags, they have this LastActiveTime property.
When I look at the page Vision - Alarm Status Table - Ignition User Manual 8.1 - Ignition Documentation
I don't see a property that I can use for this.
I don't think this will work.
It checks when a new alarm populates I think.
So it will always be recent. Or I need to find the way to make the table call all the events up again.
Either way, I don't know where to find properties accessible with alarmEvent.get()
I encounter this scenario every now and then, and my approach generally starts with directly testing properties that look useful for the problem I am trying to solve.
Here is what I believe to be the current list:
https://docs.inductiveautomation.com/display/DOC81/Tag+Alarm+Properties
How do you do your testing?
LastActiveTime is listed in the runtime metric properties.
I generally just print the results to the diagnostic console and see what is returned by my test script