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