# Any Change Digit Alert label Options

**URL:** <https://forum.inductiveautomation.com/t/any-change-digit-alert-label-options/3145>\
**Category:** Ignition\
**Created:** [August 2, 2011, 6:55am UTC](https://forum.inductiveautomation.com/t/any-change-digit-alert-label-options/3145 "2011-08-02T06:55:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![David.DeAth](https://avatars.discourse-cdn.com/v4/letter/d/49beb7/32.png) [@David.DeAth](https://forum.inductiveautomation.com/u/David.DeAth)\
**Post date:** [August 2, 2011, 6:55am UTC](https://forum.inductiveautomation.com/t/any-change-digit-alert-label-options/3145/1 "2011-08-02T06:55:00Z")

</div>

It it possible to add an extra label field to the Any Change Digital Alert configuration such we can have different messages for rising and falling edges?

Example:-  
Rising edge = Circuit Breaker Closed  
Falling edge = Circuit Breaker Open

This feature would be extremely useful to us as we monitor large power distribution schemes 😃

---

<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:** [August 3, 2011, 7:14pm UTC](https://forum.inductiveautomation.com/t/any-change-digit-alert-label-options/3145/2 "2011-08-03T19:14:19Z")

</div>

Totally from memory because I’m nowhere near those screens right now…  
but can’t you set up two alarms? (maybe I’m thinking of the analog alarm screen)

There is no real magic behind those screens. You can easily modify them to add multiple alarms for a digital point.

💡 thinking about this some more, what you are asking for is to make the point always in alarm. Given a large power distribution scheme you could have hundreds of points in alarm. This would drown out the real alarms. I’m thinking what you really want is the ability to quickly and easily change the ‘normal’ state of the Breaker so the it alarms in the ‘Off Normal’ state. Then your alarm screen will reflect only those points that are ‘off normal’ and need attention.

I have couple of ideas on how you can do this. PM me if you want to discuss this more.

---

<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:** [August 29, 2011, 6:31pm UTC](https://forum.inductiveautomation.com/t/any-change-digit-alert-label-options/3145/3 "2011-08-29T18:31:02Z")

</div>

I actually found a bit of time to look into this.

If you look behind the “Save” button (Ctrl-J in the designer) you this:

[code]alertName = event.source.parent.getComponent(‘AlertName’).text  
severity = event.source.parent.getComponent(‘Severity’).selectedValue  
equalTo = event.source.parent.getComponent(‘AlertType’).getComponent(‘EqualTo’).selected  
notEqualTo = event.source.parent.getComponent(‘AlertType’).getComponent(‘NotEqualTo’).selected  
anyChange = event.source.parent.getComponent(‘AlertType’).getComponent(‘AnyChange’).selected  
noAlert = event.source.parent.getComponent(‘AlertType’).getComponent(‘NoAlert’).selected  
value0 = event.source.parent.getComponent(‘Value0’).selected  
value1 = event.source.parent.getComponent(‘Value1’).selected  
valueOther = event.source.parent.getComponent(‘ValueOther’).selected  
otherValue = event.source.parent.getComponent(‘OtherValue’).intValue

tagID = event.source.parent.parent.getComponent(‘AvailableTags’).getComponent(‘Tags’).selectedTagID

fpmi.db.runUpdateQuery(“DELETE FROM sqlt\_as WHERE tagid = %d” % (tagID))

if not noAlert:  
query = “INSERT INTO sqlt\_as (tagid, statename, severity, low, high, flags) VALUES (?,?,?,?,?,?)”  
if anyChange:  
fpmi.db.runPrepStmt(query, [tagID, alertName, severity, 0, 1, 26])  
else:  
if value0:  
value = 0  
elif value1:  
value = 1  
else:  
value = otherValue

```
	if equalTo:
		fpmi.db.runPrepStmt(query, [tagID, alertName, severity, value, value, 0])
	else:
		fpmi.db.runPrepStmt(query, [tagID, alertName, severity, 0, value, 6])
		fpmi.db.runPrepStmt(query, [tagID, alertName, severity, value, 1, 9])

```

fpmi.db.runUpdateQuery(“UPDATE sqlt\_core SET configchange = CURRENT\_TIMESTAMP WHERE ID = %d” % tagID)[/code]

The first 10 lines are just reading the various controls in the “Digital Properties” panel.  
Line 12 gets the Digital Tag Id from the tag list  
Line 14 deletes any current alarms for this tag.

All nice and simple. Now the fun part.  
line 17 creates a SQL query. Note that the values to be inserted are all ???. This is good coding practice. By doing it this way you stop [this](http://xkcd.com/327/) from happening.

Starting at line 18 we figure out what alarms need to be added to the DB and add them. In David’s case he is adding an alarm for any change so the very first one (line 19) is what is been created. The only _magic_ here is the 26 for the flags. There is a [secret](http://files.inductiveautomation.com.s3.amazonaws.com/guides/sqltags_custom_driver_guide.pdf) document that spells out the flags as follows:

`0x01 Low Exclusive
0x02 Low Infinite
0x04 High Exclusive
0x08 High Infinite
0x10 Any Change
0x20 Low Driven
0x40 High Driven`  
Using this guide (and my trusty windows calculator) I know that 26 means Any Change (between) Low Infinite (and) High Infinite.

Now to modify this to do what David asked for, first we have to copy the Alarm name box (call it AlertName2). Then we have to copy and change line 1 above to get AlertName2.`alertName2 = event.source.parent.getComponent('AlertName2').text`  
Then change line 19 to create 2 alerts instead of one:`fpmi.db.runPrepStmt(query, [tagID, alertName, severity, 0, 0, 0])
fpmi.db.runPrepStmt(query, [tagID, alertName2, severity, 1, 1, 0])`  
So what this does is create two alarms. One for when the point is 1 and one for when the point is 0.

😈 Of course if you want to use this panel to create digital alarms for none boolean points as well you probably have more work to do 😈
