Good morning guys,
actually I have an Alarm Status Table where I show all the alarms filtered by the property “Display Path Filter” that is binded with a string variable; this variable is something like Mac1,Mac2,Mac3
I have also the alarm count in a numeric label, and to calculate the count I’m using this:
filter = ["Mac1", "Mac2", "Mac3"]
count = len(system.alarm.queryStatus(state = ["ActiveAcked", "ActiveUnacked"], priority = ["4"], displaypath = filter ))
event.source.value = count
As you see I have inserted manually the display path filter.
Now I’m trying to give the display path in a custom property of the numeric label, so that I don’t have to insert manually it every time that a specific display path is disabled.
I’ve tried to do something like this but it’s not working
In the custom property called “customFilter” I have
Mac1
The script to count the alarm is this:
filter = event.source.customFilter
filter = '"' + filter + '"'
filter = '[' + filter + ']'
count = len(system.alarm.queryStatus(state = ["ActiveAcked", "ActiveUnacked"], priority = ["4"], displaypath = filter ))
event.source.value = count
Could you help me to explain where is the mistake?
Thanks a lot
You just need to supply it with a list like you did in the first example. Eg
filterStr =...
filter = [filterStr]
Or if the filter string could be a csv:
filter = filterStr.split(',')
Question: where are you using this? And how many components on the page will run the queryStatus function? You really shouldn’t ever call this in Vision from the gui as it’ll destroy your client performance
1 Like
nminchin, thanks for the reply, as you suggest if I just split it works correctly.
I’m using this is a top docked that is always in the foreground. Could you explain me why is not raccomanded using the queryStatus? How could I change it to make it works better?
Thanks a lot!
It’s a very expensive function to run. It has to ask the gateway for the info, wait for the gateway to run the query and then deliver it. In the time it takes to run all of that, the client will stop responding. It might only be for a few hundred ms, but a frequent periodic task like this can definitely be noticed.
FWIW, calling any script from the GUI will lock up a Vision client for the time it takes to run the script, unless you pass it off to run in a new thread using system.util.invokeAsynchronous
- but you cannot interact with the GUI from this new thread. You need to ensure that all scripts you need to run periodically in the GUI are extremely fast to execute in order to keep client lockups unnoticeable.
For button actions, if it locks up the GUI for a couple seconds, it is acceptable as the operator initiated it, however if the GUI is locking up periodically then that’s when you have issues as it interferes with the operator’s ability to use the interface without losing hair in the process (and probably forking out $$ to replace broken screens due to frustration).
With all that said, you may not notice much of an impact with just one call to queryStatus, but it’s certainly good practice to avoid it.
It’s a tough pill to swallow, but as for the resolution, you’re far better off moving this functionality into the gateway global scope. I store the info in tags with 2 UDTs:
A “master” UDT that has a Summary tag which calls a library function periodically that itself calls the queryStatus function to return a list of all alarms which it then stores in a library variable.


The second UDT is just the first without the Summary tag and I put this in any folder where I want to get a summary of the alarms active within it. Then I use the Active Unack tag in the GUI to show if there are alarms in that area or not.

nminchin,thank a lot for your explanations, you have been very accurate but I’m struggling to understand exactly how to use your method in my project.
I have created the UDT, but I don’t know how to create the library function that call the queryStatus . May I ask if you have an example from which start to figure out how to implement this function in the project?
Thank you very much!
I’ll pm you in an hr or so