V8 What is the most efficient way to extract a complete list of configured alarms?

v8.1.5

Now that system.tag.getAlarmStates is gone, what is the most efficient way to get a complete list of alarms for a large number of tags (350k)?

My estimates using a combination of system.tag.browse, system.tag.getConfiguration, and system.tag.readBlocking puts it at ~9hrs of runtime. But I don't know if I have any other option :frowning:

I suppose you execute your code in the gateway scope, not in the vision client scope ?

1 Like

You’re right, I need to run it on the gateway instead. I’ll try it later on today and check the performance then. Cheers!

I’ve found a way that worked for me. Alarm evaluation must be disabled for those tags that do not have alarms (which could be feasible to do for a large amount of tags if UDTs have been used).

tags = system.tag.browse("[default]SCP", {"recursive":True}).getResults()
 
for tag in tags:

    stringPath = str(tag['fullPath'])
    if system.tag.readBlocking(stringPath+".AlarmEvalEnabled")[0].value:
    	if system.tag.readBlocking(stringPath+".OpcItemPath")[0].value != "":
    		print  system.tag.readBlocking(stringPath+".OpcItemPath")[0].value

Actually, you can just check the attributes key values for alarms directly from the browse results. You also don’t need to call getResult; you get the same results from the return ofthe browse function. Also reading one tag at a time will be extremely slow especially for large numbers of tags. You should always bulk read and write tags

Good to know. I was just using this as a one-time script in the console to get a list, so the run time is not a big deal in this case.

have you solved it?

Use the tag report tool that was recently released, use traits, alarms configured. You can also use in a script as well.

https://docs.inductiveautomation.com/display/DOC81/Tag+Report+Tool

2 Likes

I need to show the alarm configuration in a window for the user

Save as script then and run in a window,
https://docs.inductiveautomation.com/display/DOC81/system.tag.query