Alarm Popup

I am having a hard time figuring out how to get an event such as a new active alarm to open a popup window. So far I have a new window with a table in it that views the unacknowledged alarms, and that works great. Where the problem comes in is when I try to find a “trigger” from a newly active alarm that will automaticallly open the popup. In the Alarm_log table in the DB I can’t find a column that refers to active and unacknowledged alarms. How do you suggest is the best way to go about opening this window (and it needs to be a one-shot on opening so an operator can close it with a button, which is already present and works, but will open up again when a new alarm becomes active.
Thanks.

I like this idea.

I would create a timer that runs every 5 seconds or so. When it runs it would run something like this:

windows = system.gui.getOpenedWindowNames()
for path in windows:
    if path == "path\to\popup\alarm_window":
        exit()
if system.alert.queryAlertStatus( minSeverity=2).rowCount > 0:
    system.nav.openWindow("path\to\popup\alarm_window")

I would put the timer on the header/navigation pane that is always shown so that it will always popup regardless of what page the user may be looking at (your project may be different).

Alright, this is how I do it.

You first need to make a tag, to count the amount of alarms that are currently unacknowledged. I use a DB Tag and use the following expression script

runScript(
"system.alert.queryAlertStatus(activeAndUnacked=1,clearAndUnacked=1).rowCount",
500
)

This returns the number of unacknowledged alarms, either active or cleared.

Next, make a client scoped timer tag change script

if system.tag.getTagValue("[Client]Alarm Popup Enable"):
	tagValue = event.tag.getAttribute(event.tagProperty)
	value = tagValue.value
	if value > 0:
		system.nav.openWindow("New Alarms")
	else:
		try:
			system.nav.closeWindow("New Alarms")
		except AttributeError:
			None

I have an option for my users to enable/disable the popup, so you can modify the code to suit your needs. If you need any more help, feel free to ask.

Robert and Kyle - Thank you very much!
I will implement your ideas and let you know how it worked. :smiley:

Robert, Kyle, & IA,

Thanks for the tips. We made an expression in a DB tag that counts the rows of new and unacknowledged alarms and had a client scoped tag-change expression open an alarm pop-up window whenever that tag changes… However, as you probably already figured out, we only need it to open the window when the tag value (number of new/Unack alarms) increases, not decreases. Currently, the window opens also when an alarm goes away, too.

Our coding with other languages is great, but with Java it’s weak. Do you have a sample code that would allow us to only open the window when the tag count increases, not decreases? Any suggestions are greatly appreciated. Thanks in advance.

It’s OK. We were able to accomplish this using the transaction groups, writing one tag to another, updating the second tag with the first tags value. But first evaluating the two to see if the first tag is greater/less than the second tag. If anyone needs a pop-up screen and code that works pretty good, let me know.

Thanks.

From a script point of view, you could do something like the following in your tag change script. The piece you’re probably missing conceptually is that you can use the global keyword on variables to make them last in python, but it’s a tad tricky. Check it out:

global lastcount try: if lastcount>0: pass except NameError: lastcount=-1 currentcount=system.tag.getTagValue("AlertCount") if lastcount>0 and currentcount>lastcount: system.nav.openWindow("popup") lastcount=currentcount

Here’s how this works:

  1. Line 1 declares a global name, “lastcount”. This means it will be accessible to other scripts, but more importantly, it will live outside the current scope, so it will be available next time. The important thing here is that you’re not actually declaring a variable, you’re only making that name global, so…
  2. The first time you access the “lastcount” variable, it won’t exist, because it has never been assigned, so you would get an error (a “NameError”, as in, the name is invalid). It’s actually convenient for us, because we’ll use it to set an initial value (-1) that we can use to tell we’ve never run before- this prevents a popup when the client first launches.
  3. We get the value from the count tag.
  4. If we’re not in the first notification (lastcount is not -1), and the new count is greater than the last count we saw, open the popup.
  5. Update the “lastcount” with the most recent value.

Hope that helps,

Check out this thread for a generic popup that is always on top of all screens, even other programs.

viewtopic.php?f=81&t=5972&p=16102#p16102

An idea how to filter alarms and only show in such popup windows new alarms with CRITICAL priority?

What is the solution to this your question, if you have gotten it as it will also help me to widen my knowledge. Thank you in anticipation for your response.