# Alarm Popup

**URL:** <https://forum.inductiveautomation.com/t/alarm-popup/2182>\
**Category:** Ignition\
**Created:** [September 10, 2010, 2:30pm UTC](https://forum.inductiveautomation.com/t/alarm-popup/2182 "2010-09-10T14:30:33Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![scott\_stc](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@scott\_stc](https://forum.inductiveautomation.com/u/scott_stc)\
**Post date:** [September 10, 2010, 2:30pm UTC](https://forum.inductiveautomation.com/t/alarm-popup/2182/1 "2010-09-10T14:30:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://forum.inductiveautomation.com/u/Robert)\
**Post date:** [September 10, 2010, 5:05pm UTC](https://forum.inductiveautomation.com/t/alarm-popup/2182/2 "2010-09-10T17:05:50Z")

</div>

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:

```auto
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).

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [September 10, 2010, 5:11pm UTC](https://forum.inductiveautomation.com/t/alarm-popup/2182/3 "2010-09-10T17:11:43Z")

</div>

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

```auto
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

```auto
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.

---

<div class="post-metadata">

**Author:** ![scott\_stc](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@scott\_stc](https://forum.inductiveautomation.com/u/scott_stc)\
**Post date:** [September 10, 2010, 5:38pm UTC](https://forum.inductiveautomation.com/t/alarm-popup/2182/4 "2010-09-10T17:38:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![scott\_stc](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@scott\_stc](https://forum.inductiveautomation.com/u/scott_stc)\
**Post date:** [January 4, 2011, 4:39pm UTC](https://forum.inductiveautomation.com/t/alarm-popup/2182/5 "2011-01-04T16:39:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![scott\_stc](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@scott\_stc](https://forum.inductiveautomation.com/u/scott_stc)\
**Post date:** [January 4, 2011, 5:56pm UTC](https://forum.inductiveautomation.com/t/alarm-popup/2182/6 "2011-01-04T17:56:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Colby.Clegg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/colby.clegg/32/3282_2.png) [@Colby.Clegg](https://forum.inductiveautomation.com/u/Colby.Clegg)\
**Post date:** [January 5, 2011, 12:56am UTC](https://forum.inductiveautomation.com/t/alarm-popup/2182/7 "2011-01-05T00:56:26Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [January 23, 2011, 1:07pm UTC](https://forum.inductiveautomation.com/t/alarm-popup/2182/8 "2011-01-23T13:07:02Z")

</div>

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](http://www.inductiveautomation.com/forum/viewtopic.php?f=81&t=5972&p=16102#p16102)

---

<div class="post-metadata">

**Author:** ![aramirez](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/aramirez/32/5283_2.png) [@aramirez](https://forum.inductiveautomation.com/u/aramirez)\
**Post date:** [August 16, 2018, 11:02pm UTC](https://forum.inductiveautomation.com/t/alarm-popup/2182/9 "2018-08-16T23:02:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![R.Alamsha](https://avatars.discourse-cdn.com/v4/letter/r/e5b9ba/32.png) [@R.Alamsha](https://forum.inductiveautomation.com/u/R.Alamsha)\
**Post date:** [August 17, 2018, 5:32am UTC](https://forum.inductiveautomation.com/t/alarm-popup/2182/10 "2018-08-17T05:32:37Z")

</div>

> [@Displaying Alarm Count](http://forum.inductiveautomation.com/t/displaying-alarm-count/15443/4):
>
> Download, restore and play with this IA official demo project. You will find almost every Ignition feature and functionality implemented here. Ignition Demo Project Gateway Backup - 34 MB. [https://inductiveautomation.com/downloads/extra-material](https://inductiveautomation.com/downloads/extra-material) The best tools to master Ignition are: Demo project IA University User manual Cloud template browser in designer under tools menu Forum search. Ignition SDK.

---

<div class="post-metadata">

**Author:** ![Abiodun.Martins](https://avatars.discourse-cdn.com/v4/letter/a/bc79bd/32.png) [@Abiodun.Martins](https://forum.inductiveautomation.com/u/Abiodun.Martins)\
**Post date:** [May 8, 2020, 2:49pm UTC](https://forum.inductiveautomation.com/t/alarm-popup/2182/11 "2020-05-08T14:49:33Z")

</div>

> [@Colby.Clegg](#):
>
> 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

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.
