Write to system alert properties

from time import localtime, strftime
curTime = strftime("%H:%M:%S", localtime())
print curTime

if curTime == “16:09:30”:
system.tag.writeToTags(“system.alert.AlertExecEnabled”, 0)
if curTime == “16:09:45”:
system.tag.writeToTags(“system.alert.AlertExecEnabled”, 1)

The above is what i want to do how can i make this script work

The system.tag.writeToTags function takes in two python lists as an argument, a list of tag paths and a list of corresponding values. For writing to multiple tags you’d do something like this:

tagPaths=["path/to/tag1.alertExecEnabled", "path/to/tag2.alertExecEnabled"] values=[0,0] #this must match the number of tag paths in the previous list system.tag.writeTagValues(tagPaths, values)

In Ignition 7.5.x the function name has changed to system.tag.writeAll, though the old version will still work. The user manual entry is here, though it has pretty much the same example I’ve made here.

Aside from that, you’ll need to indent the block of code under each ‘if’, as python uses white space to parse the language.

So what you are saying is i have to address each and every tag that i have an alarm for with that script?

That is not efficient, and if I was going to do something like that it would be easier to do that through; Project > Client Event Script > Tag Change > and then select all the AlertExecEnabled properties for all these tags. Which is basically the script you just wrote for me.

What happens when i have 400 alerts that i want to do this for, it is not feasible to do it with the method you suggest or the one I suggested.

How can i address the system alert properties period, is what I’m asking, I don’t want to do it through a table like script bellow shows.

data = event.source.parent.getComponent(“Alert Summary Table”) .alerts

for row in range(data.rowCount):

tagstring = data.getValueAt(row,1) + ".AlertExecEnabled"

system.tag.write(tagstring,0)

I don’t want to do it one tag at a time, I want to address the AlertExecEnabled for all tags all at once.

Is there a way to do this system wide not tag by tag or through a table?

Thanks
Titus

In your case, you want to get access to all of the tags whose current alert status is activeAndAcked. To do this, you will need to use system.alert.queryAlertStatus(). So the script is somewhat similar to what you posted, but needs to iterate a dataset to get a list of the tag paths to change, and puts them in a python list datatype. Once you have a list of all the paths in a list, you can pass that using system.tag.writeAll()*, which passes the tag paths and values that need to be changed.

*Note that I used system.tag.writeAll(), if you’re using a version of Ignition lower than 7.5, you will have to use system.tag.writeTagValues().

You can put this on a timer script that runs every minute. If you need to run this script at exactly 6:00:00, then you can change the strftime to make the string have seconds, and the timer script will have to run every second.

from time import localtime, strftime
curTime = strftime("%H:%M", localtime())
print curTime

if curTime == "06:00":
	data = system.alert.queryAlertStatus(activeAndUnacked=0,activeAndAcked=1)
	tag_list = []
	values_list_zeros = [0]*data.rowCount
	values_list_ones = [1]*data.rowCount

	for row in range(data.rowCount):
		tagstring = data.getValueAt(row,1) + ".AlertExecEnabled"
		tag_list.append(tagstring)

	system.tag.writeAll(tag_list,values_list_zeros)
	system.tag.writeAll(tag_list,values_list_ones)	

Wow yeah that’s what i needed to bad it’s not something that is very intuitive to figure out on ones own.

Thanks

I would agree that the part about resetting the alert table to “reset” alarms by flipping the “AlertExecEnabled” to 0, then back to 1 is not intuitive, and kind of “hacky”. We are working on rebuilding the alarm/alert portion of Ignition to add features and make it easier to use.

The other parts of the script just come from experience with using Ignition scripts and some Python tricks. Glad to hear you got it working.