Temporarily disable alarms without shelving

Our system started out with FPMI/FSQL, and then we migrated to 7.3.3. We use external providers for our SQLTags so that we can manipulate certain aspects of tags on our own programmatically.

One of the actions we performed was to disable an alarm, but to still keep all of the threshold information (“maintenance mode” as we call it). This would involve us grabbing the alertmode from the sqlt_meta table (intval of 1 for digital, 2 for analog), and storing this information in a separate table. We then set the intval to 0, reload the tag, and acknowledge/clear any active alerts.

Since our upgrade to version 7.6, this is no longer working for us. If we place an active alert into maintenance mode, the alert clears as expected, is acknowledged, and disappears from our alert table, but shortly returns again.

It seems as if this functionality is somewhat mimicked through the shelving functions, but we would like to indefinitely disable an alarm without losing the threshold info until any work being performed is completed, during which we would re-enable the alarm. Is there a scripting function I can use to do this work for me?

Is the sqlt_as table no longer used? Can I replicate this functionality through the new sqlt_alarm and sqlt_alarm_meta tables which were created in the upgrade?

Thank you

Hi,

Yes, unfortunately the AlertMode property isn’t used any more, though it’s probably a bit of an oversight that it doesn’t work in a backwards compatible way (with 0=off, 1 or 2=on).

The most direct way that you could transition this to the new system would be to modify the “enabled” property of each alarm, under “sqlt_alarm_meta”. You would need to make sure there was a row for each alarm you were interested in, and use the following settings:
name= enabled
intvalue= 0 (off), 1 (on)
bindtype= -1

Once you modify the value, you need to update configchange on the owning tag, as before.

Hope this helps,

This looks like it will work out great for us, and the code should actually be a little bit cleaner in the end over our previous method.

I’m in the middle of implementing this now, however, I ran into a bit of an issue. The only alarms which have an “enabled” entry are the two I just created for testing this functionality. What would be the quickest and/or safest way to get an enabled entry for all of our alarmed tags without having to manually disable/re-enable every tag?

Hi,

I suppose the easiest way is to delete the existing entries, and then add an entry for each alarm:

delete from sqlt_alarm_meta where name='enabled'
insert into sqlt_alarm_meta (alarmid, name, intvalue, bindtype) select id, 'enabled', 1, -1 from sqlt_alarm

Regards,

Thanks! Just finished implementing and testing this last night and this worked out great for us!

Here’s the SQL statement I used to disable alarms based on a given SQLTag name. If anybody else has a use for functionality similar to ours, I can post the whole package module.

###############################################################################
# Change enabled value for ALL alarms for given SQLTag in sqlt_alarm_meta.    #
#                                                                             # 
# Param:    tagName - string - sqlt_core name of SQLTag to have alarm state   #
#                              changed.                                       #
#           value   - int    - Changes the state of an alarm by changing the  #
#                              intval column for 'enabled' entry in           #
#                              sqlt_alarm_meta.   0=Alarm Off, 1= Alarm On    # 
# Returns:  int - number of affected rows                                     #
###############################################################################
def changeAlarmState(tagName, value):
	import system
	
	SQL = """UPDATE `sqlt_alarm_meta`
                 SET `intvalue`='%i'
                 WHERE `alarmid` in ( SELECT id 
                                      FROM  `sqlt_alarm` 
                                      WHERE tagid in ( SELECT id
                                                       FROM sqlt_core
                                                       WHERE name='%s'
                                                       AND deleted='0')
			            )
                 AND `name`='enabled'"""

	return system.db.runUpdateQuery(SQL %(value, tagName))