Alert Summary Expression set pathFilter by Client IP

Using the Alert Summary Table I am trying to run an IF or Case statement to examine client IP address and then set the Alert Summary Tables Filter to pathFilter=“WorkArea/tags%”.

psuedo expression:
if({[System]Client/Network/IPAddress}=“xxx.xxx.xxx.xxx”,pathFilter=“SomeWorkArea/Global%”,pathFilter=“OtherArea/Global%”)

I am having issues with syntax and not sure it recognizes pathFilter as a property I can set because I can’t find it under tables properties, but I see in in the link below, this is an available filter:

inductiveautomation.com/supp … status.htm

As evident by the example script but I can’t seem to figure out how to use this in an expression with logic based parameters I need:

results = system.alert.queryAlertStatus(flatten=1,activeAndUnacked=1, activeAndAcked=1)
event.source.parent.getComponent(“Table”).data=results

Any pointers is greatly appreciated. Open to feedback on whether this is the best approach in the expression.

Thanks

I am assuming you made a Custom Property
pathFilter with this code:

if({[System]Client/Network/IPAddress}="xxx.xxx.xxx.xxx",pathFilter="SomeWorkArea/Global%",pathFilter="OtherArea/Global%")

If you are using the Alarm Summary Table, you should just link the pathFilter to Item Path Filter.

If you are using a regular table, the easiest way would be to use Functions.
Bind Function = Alert Status
Path Filter would like to Custom Property pathFilter

If you want to run a script"

runScript("scriptname('"
+ {Root Container.pathFilter} +
"')" , 5000)

Script code:

def scriptname(filter):
	import system
	return system.alert.queryAlertStatus(flatten=1, path=filter, activeAndUnacked=1, activeAndAcked=1)

Or guessing this is a pushbutton or timer?
results = system.alert.queryAlertStatus(flatten=1, path=pathFilter , activeAndUnacked=1, activeAndAcked=1)
event.source.parent.getComponent(“Table”).data=results

Hope that helps.

Cheers,
Chris

Hey Chris, thanks for the reply.

I am using the AlertSummaryTable table and the pathFilter is actually a built in filter for that table native to the control. thats what I am trying to set programatically using the expression.

what I want to do is create the script as so:

results = system.alert.queryAlertStatus(flatten=1, path=pathFilter , activeAndUnacked=1, activeAndAcked=1, pathFilter="WorkArea/Tags")
event.source.parent.getComponent("Table").data=results

my problem is understanding how to create the right syntax to run this script in the expression. Thats why I was hoping I could set the AlertSummaryTables filter (pathFilter) in the IF condition so that the controls query would auto update based upon the expression’s IF condition. But since the filter does not show up as a property, I can’t set it as property to set.

The script above should work, I was hoping to just change the filter property and allow the default query to respond accordingly. In short, hoping to keep it simple at the expression level. :slight_smile:

Something like this then?

if "[System]Client/Network/IPAddress" == xxx.xxx.xxx.xxx:
	pathFilter="SomeWorkArea/Global%"
else:
	pathFilter="OtherArea/Global%"

results = system.alert.queryAlertStatus(flatten=1, path=pathFilter , activeAndUnacked=1, activeAndAcked=1)
event.source.parent.getComponent("Table").data=results

Chris

Thats exactly what I am trying to do. Thanks, testing now! Sorry still getting used to this scripting environment. :smiley:

so the expression did not work because I needed to make some syntax changes, got worked out… kinda, but I am changing my approach a bit and trying to put the condition in a script vs expression so when the main naviation window shows it write to a tag which is bound to the Item Path filter in the AlertSummaryTable.

I created a new memory tag called it app_dynamic_alert_path. I bound the filter property of the alert table control to the tag and changed it several times and it worked fine. Got the expected change in the tables results.

So then I created the script in the vision window open to see what to set the new tag to when the window opens.

The script below compiles ok, but when the window opens I get a pop error window:

if "[System]Client/Network/IPAddress" == "10.10.1.100": system.Tag.writeToTag("app_dynamic_alert_path".Value,"WorkArea/Global/%") else: system.Tag.writeToTag("app_dynamic_alert_path".Value,"WorkArea/OtherTags/%")
Error:
Error executing script for event visionWindowOpened on component AlarmStatus
Details:
Traceback (most recent call last):
File “event:visionWindowOpened”, line 4, in
AttributeError: ‘com.inductiveautomation.ignition.common.script.Scr’ object has no attribute ‘Tag’

at org.python.core.PyException.fillInStackTrace(PyException.java:70)
at java.lang.Throwable.<init>(Throwable.java:181)
at java.lang.Exception.<init>(Unknown Source)
at java.lang.RuntimeException.<init>(Unknown Source)
at org.python.core.PyException.<init>(PyException.java:46)
at org.python.core.PyException.<init>(PyException.java:43)
at org.python.core.PyException.<init>(PyException.java:61)
at org.python.core.Py.AttributeError(Py.java:166)
at org.python.core.PyObject.noAttributeError(PyObject.java:930)
at org.python.core.PyObject.__getattr__(PyObject.java:925)
at org.python.pycode._pyx7.f$0(<event:visionWindowOpened>:4)
at org.python.pycode._pyx7.call_function(<event:visionWindowOpened>)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1261)
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:539)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:155)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:266)
at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:55)
at $Proxy18.visionWindowOpened(Unknown Source)
at com.inductiveautomation.factorypmi.application.FPMIWindow.fireVisionWindowOpened(FPMIWindow.java:639)
at com.inductiveautomation.factorypmi.application.FPMIApp$RuntimeWindowOpener.openWindow(FPMIApp.java:1561)
at com.inductiveautomation.factorypmi.application.FPMIApp.openWindow(FPMIApp.java:883)
at com.inductiveautomation.factorypmi.application.script.builtin.NavUtilities$5.run(NavUtilities.java:417)
at com.inductiveautomation.factorypmi.application.script.builtin.WindowUtilities.doGUIAction(WindowUtilities.java:608)
at com.inductiveautomation.factorypmi.application.script.builtin.NavUtilities.openWindowImpl(NavUtilities.java:352)
at com.inductiveautomation.factorypmi.application.script.builtin.NavUtilities.openWindow(NavUtilities.java:341)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:186)
at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction.__call__(ScriptManager.java:455)
at org.python.core.PyObject.__call__(PyObject.java:387)
at org.python.core.PyObject.__call__(PyObject.java:391)
at org.python.pycode._pyx6.f$0(<event:mouseReleased>:5)
at org.python.pycode._pyx6.call_function(<event:mouseReleased>)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1261)
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:539)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:155)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:266)
at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:55)
at $Proxy15.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$400(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Ignition v7.5.4-beta4 (b1182)
Java: Sun Microsystems Inc. 1.6.0_37

Sorry, know that alot of detail… Assuming write to tag is the issue but not sure why… Thanks for any help. :frowning:

Try system.tag.write() works the same as writeToTag
I think it maybe capitalization or import system

Chris

Thanks for the quick response. Unfortunately I get the same response:

Traceback (most recent call last):
File “event:visionWindowOpened”, line 4, in
AttributeError: ‘str’ object has no attribute ‘Value’

at org.python.core.PyException.fillInStackTrace(PyException.java:70)
at java.lang.Throwable.<init>(Throwable.java:181)
at java.lang.Exception.<init>(Unknown Source)
at java.lang.RuntimeException.<init>(Unknown Source)
at org.python.core.PyException.<init>(PyException.java:46)
at org.python.core.PyException.<init>(PyException.java:43)
at org.python.core.PyException.<init>(PyException.java:61)
at org.python.core.Py.AttributeError(Py.java:166)
at org.python.core.PyObject.noAttributeError(PyObject.java:930)
at org.python.core.PyObject.__getattr__(PyObject.java:925)
at org.python.pycode._pyx7.f$0(<event:visionWindowOpened>:4)
at org.python.pycode._pyx7.call_function(<event:visionWindowOpened>)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1261)
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:539)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:155)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:266)
at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:55)
at $Proxy18.visionWindowOpened(Unknown Source)
at com.inductiveautomation.factorypmi.application.FPMIWindow.fireVisionWindowOpened(FPMIWindow.java:639)
at com.inductiveautomation.factorypmi.application.FPMIApp$RuntimeWindowOpener.openWindow(FPMIApp.java:1561)
at com.inductiveautomation.factorypmi.application.FPMIApp.openWindow(FPMIApp.java:883)
at com.inductiveautomation.factorypmi.application.script.builtin.NavUtilities$5.run(NavUtilities.java:417)
at com.inductiveautomation.factorypmi.application.script.builtin.WindowUtilities.doGUIAction(WindowUtilities.java:608)
at com.inductiveautomation.factorypmi.application.script.builtin.NavUtilities.openWindowImpl(NavUtilities.java:352)
at com.inductiveautomation.factorypmi.application.script.builtin.NavUtilities.openWindow(NavUtilities.java:341)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:186)
at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction.__call__(ScriptManager.java:455)
at org.python.core.PyObject.__call__(PyObject.java:387)
at org.python.core.PyObject.__call__(PyObject.java:391)
at org.python.pycode._pyx6.f$0(<event:mouseReleased>:5)
at org.python.pycode._pyx6.call_function(<event:mouseReleased>)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1261)
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:539)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:155)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:266)
at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:55)
at $Proxy15.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$400(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Ignition v7.5.4-beta4 (b1182)
Java: Sun Microsystems Inc. 1.6.0_37

sorry meant to add the updated script:

if "[System]Client/Network/IPAddress" == "10.10.1.100": system.tag.write("app_dynamic_alert_path".Value,"WorkArea/Global/%") else: system.tag.write("app_dynamic_alert_path".Value,"WorkArea/NewTags/%")

It is a different error. As I always say I program to the next error…

Lose the .Value

system.tag.write(“app_dynamic_alert_path”,“WorkArea/Global/%”)

Also, are you going to be having only 1 client? :scratch:
As this code (not script) is only called when the window is opened, if another client opens the same window the tag will be overwritten. Then the table will update in 250ms (or whatever you have the update rate set for) with the new filter.

Then that client will see WorkArea/Global/% instead of WorkArea/NewTags/% and vice versa.

Cheers,
Chris

To topic one, dropping the .Value fixed the binding issue. Thank you very much!

To topic two… GREAT POINT! LOL! Need to rethink that global tag concept… LOL I think I need to get it back to the control layer so that it only impacts the local client. :slight_smile:

I will think that process this evening and post my updates in the event anyone else follows the thread later. Thanks again for you assistance.

The easiest solution would be to create a Custom Property on the Root Container named: app_dynamic_alert_path
Then write to the property vice the Global tag like this:

if "[System]Client/Network/IPAddress" == "10.10.1.100":
	system.gui.getParentWindow(event).getComponentForPath('Root Container').app_dynamic_alert_path = "WorkArea/Global/%"
else:
	system.gui.getParentWindow(event).getComponentForPath('Root Container').app_dynamic_alert_path = "WorkArea/NewTags/%"

Cheers,
Chris

ah very cool. Thanks very much for that. I gotta figure out what the if statement is returning false, but once I get that, I think it will be perfect setup. I will test that as soon I figure out why the if statement comparison does not like the string.

string tag for the system.client.network.ipaddress shows the value I have in the condition but still returns false.

Thanks again!

Because “[System]Client/Network/IPAddress” does not equal “10.10.1.100”.
It is not reading the tag.
In the script editor, you have to tell it to read the tag.

ipaddress = system.tag.read("[System]Client/Network/IPAddress")
if ipaddress.value == "10.10.1.100":
	system.gui.getParentWindow(event).getComponentForPath('Root Container').app_dynamic_alert_path = "WorkArea/Global/%"
else:
	system.gui.getParentWindow(event).getComponentForPath('Root Container').app_dynamic_alert_path = "WorkArea/NewTags/%"

Sorry, I missed that before. Forgot you moved the instruction. :slight_smile:

Cheers,
Chris

I wish you were near by to get a big hug… LOL

Worked like a champ. I apologize… I am so accustom to my C / C# world and other SCADA packages scripting environments. I am enjoying this but it is tough converting…

You Rock! Thanks again, I got the entire setup worked out! Will be posting back the final result. to close out the thread and thanks again! :smiley: