Monday, May 12, 2008

Displaying Alarm Activity Status

Hi, my name is Bobby and I am a part of the tech support team at Inductive Automation. I'm going to be using this blog to post some ideas and tricks for FactoryPMI and FactorySQL that you may not have thought of. If it gets the wheels spinning and you want some more info, feel free to jump into our forums (www.inductiveautomation.com/forum) or email me (rmckenzie AT inductiveautomation DOT com).

Displaying alarm activity status:

I have dealt with this problem a few time times. It's important to understand the way alerts work in FactoryPMI and FactorySQL if you want to do anything other than the basic alarm screen. It's also important to note that the Inductive Automation Demo project already contains components using this, so you can always check that out to see the finished product.

Your database will contain two tables that hold all the information about the alarms. Do not modify either of these unless you REALLY know what you are doing, but feel free to look at them to set up your select queries. These tables are usually named something like alarm_status and alarm_log, but they could be renamed to anything (to check the names, go to the FactorySQL Frontend -> Settings -> Alert Settings in the menu options). For this trick, we will just be looking at the status table, and the important column here is current_state_id. This is the column that tells you what state each alarm is in, and we want to know if there is one or more alarms that are currently active.

To write an SQL query to get this info, you use something like:
SELECT COUNT(*)
FROM alarm_status
WHERE current_state_id != 0
This will count the number of rows that contain active alarms (if current_stats_id is zero, then the alarm is not active). Just put this into a dynamic property on your text label and bind the visibility to true if this property is greater than zero.

There is a lot more you can do here, with different colors indicating more alarms or more severe alarms, display the number of active alarms, or filter out specific groups of alarms, to name a few. You can even do these on a per-project or per-area basis using the point_path or group_name and group_folder columns. Don't forget to give your label a mouseClicked event to switch to your alarm screen!


Robert McKenzie
Inductive Automation

1 comment:

Nathan said...

Awesome post Bobby - keep 'em coming!