Example Project: Alarm Label on Left Bar problem

The dynamic property for this label tries to run an app and I get a null exception error but I cannot figure out what is wrong. If there is a better way for the label to show when I have an alarm active I am game to try something else.

Dynamic Property Expression:
runScript(“app.alert.activeAlerts()”, 1000)

APP defined as:
def activeAlerts():
import system
return system.alert.queryAlertStatus(activeAndUnacked=1).rowCount

Error as follows:
Exception: Error executing expression binding on
Temporary.Root Container.AlarmLabel.NumAlarms
caused by ExpressionException: Error executing script for runScript() expression:app.alert.activeAlerts()
caused by Traceback (innermost last):
File “expression:runScript”, line 1, in ?
File “module:alert”, line 3, in activeAlerts
java.lang.NullPointerException

I think the system.alert.queryAlertStatus(activeAndUnacked=1) is returning null. You may want to do the following for you activeAlerts function:def activeAlerts(): import system ds = system.alert.queryAlertStatus(activeAndUnacked=1) if ds == None: return 0 else: return ds.rowCountTry that out and let us know.

Sadly the same result. Would you rather have the error copy?

Exception: Error executing expression binding on
Temporary.Root Container.AlarmLabel.NumAlarms
caused by ExpressionException: Error executing script for runScript() expression:app.alert.activeAlerts()
caused by Traceback (innermost last):
File “expression:runScript”, line 1, in ?
File “module:alert”, line 3, in activeAlerts
java.lang.NullPointerException
java.lang.NullPointerException: java.lang.NullPointerException

Ignition v7.1.6 (b5739)
Java: Sun Microsystems Inc. 1.6.0_22

Well it must be getting an error in our function. I will check it out. In the meantime you can wrap all of the code in your function into a try…except block like the following:def activeAlerts(): import system try: return system.alert.queryAlertStatus(activeAndUnacked=1).rowCount except: return 0

Here are the details from the error:

#def activeAlerts():

import system

try:

ds = system.alert.queryAlertStatus(activeAndUnacked=1)

if ds == None:

return 0

else:

return ds.rowCount

except:

return 0

def activeAlerts():
import system
return system.alert.queryAlertStatus(activeAndUnacked=1).rowCount

java.lang.Exception: Error executing expression binding on
Temporary.Root Container.AlarmLabel.NumAlarms
at com.inductiveautomation.factorypmi.application.binding.ExpressionPropertyAdapter.runExpression(ExpressionPropertyAdapter.java:56)
at com.inductiveautomation.factorypmi.application.binding.ExpressionPropertyAdapter.childInteractionUpdated(ExpressionPropertyAdapter.java:31)
at com.inductiveautomation.ignition.common.expressions.functions.AbstractPollingFunction.actionPerformed(AbstractPollingFunction.java:80)
at javax.swing.Timer.fireActionPerformed(Unknown Source)
at javax.swing.Timer$DoPostEvent.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(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)
Caused by: com.inductiveautomation.ignition.common.expressions.ExpressionException: Error executing script for runScript() expression:app.alert.activeAlerts()
at com.inductiveautomation.ignition.common.expressions.functions.ScriptFunction.execute(ScriptFunction.java:57)
at com.inductiveautomation.ignition.common.expressions.FunctionExpression.execute(FunctionExpression.java:69)
at com.inductiveautomation.factorypmi.application.binding.ExpressionPropertyAdapter.runExpression(ExpressionPropertyAdapter.java:50)
… 12 more
Caused by: Traceback (innermost last):
File “expression:runScript”, line 1, in ?
File “module:alert”, line 13, in activeAlerts
java.lang.NullPointerException

at com.inductiveautomation.ignition.common.script.builtin.AbstractAlertUtilities.toDataset(AbstractAlertUtilities.java:106)

at com.inductiveautomation.ignition.common.script.builtin.AbstractAlertUtilities.queryAlertStatus(AbstractAlertUtilities.java:40)

at sun.reflect.GeneratedMethodAccessor67.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)

at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction.__call__(ScriptManager.java:310)

at org.python.pycode._pyx4.activeAlerts$1(<module:alert>:13)

at org.python.pycode._pyx4.call_function(<module:alert>)

at org.python.core.PyTableCode.call(PyTableCode.java)

at org.python.core.PyTableCode.call(PyTableCode.java)

at org.python.core.PyFunction.__call__(PyFunction.java)

at org.python.core.PyObject.invoke(PyObject.java)

at org.python.pycode._pyx1.f$0(<expression:runScript>:1)

at org.python.pycode._pyx1.call_function(<expression:runScript>)

at org.python.core.PyTableCode.call(PyTableCode.java)

at org.python.core.PyCode.call(PyCode.java)

at org.python.core.Py.runCode(Py.java)

at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:391)

at com.inductiveautomation.ignition.common.expressions.functions.ScriptFunction.execute(ScriptFunction.java:54)

at com.inductiveautomation.ignition.common.expressions.FunctionExpression.execute(FunctionExpression.java:69)

at com.inductiveautomation.factorypmi.application.binding.ExpressionPropertyAdapter.runExpression(ExpressionPropertyAdapter.java:50)

at com.inductiveautomation.factorypmi.application.binding.ExpressionPropertyAdapter.childInteractionUpdated(ExpressionPropertyAdapter.java:31)

at com.inductiveautomation.ignition.common.expressions.functions.AbstractPollingFunction.actionPerformed(AbstractPollingFunction.java:80)

at javax.swing.Timer.fireActionPerformed(Unknown Source)

at javax.swing.Timer$DoPostEvent.run(Unknown Source)

at java.awt.event.InvocationEvent.dispatch(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)

java.lang.NullPointerException: java.lang.NullPointerException

at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:394)
at com.inductiveautomation.ignition.common.expressions.functions.ScriptFunction.execute(ScriptFunction.java:54)
... 14 more

Caused by: Traceback (innermost last):
File “expression:runScript”, line 1, in ?
File “module:alert”, line 13, in activeAlerts
java.lang.NullPointerException

at com.inductiveautomation.ignition.common.script.builtin.AbstractAlertUtilities.toDataset(AbstractAlertUtilities.java:106)

at com.inductiveautomation.ignition.common.script.builtin.AbstractAlertUtilities.queryAlertStatus(AbstractAlertUtilities.java:40)

at sun.reflect.GeneratedMethodAccessor67.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)

at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction.__call__(ScriptManager.java:310)

at org.python.pycode._pyx4.activeAlerts$1(<module:alert>:13)

at org.python.pycode._pyx4.call_function(<module:alert>)

at org.python.core.PyTableCode.call(PyTableCode.java)

at org.python.core.PyTableCode.call(PyTableCode.java)

at org.python.core.PyFunction.__call__(PyFunction.java)

at org.python.core.PyObject.invoke(PyObject.java)

at org.python.pycode._pyx1.f$0(<expression:runScript>:1)

at org.python.pycode._pyx1.call_function(<expression:runScript>)

at org.python.core.PyTableCode.call(PyTableCode.java)

at org.python.core.PyCode.call(PyCode.java)

at org.python.core.Py.runCode(Py.java)

at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:391)

at com.inductiveautomation.ignition.common.expressions.functions.ScriptFunction.execute(ScriptFunction.java:54)

at com.inductiveautomation.ignition.common.expressions.FunctionExpression.execute(FunctionExpression.java:69)

at com.inductiveautomation.factorypmi.application.binding.ExpressionPropertyAdapter.runExpression(ExpressionPropertyAdapter.java:50)

at com.inductiveautomation.factorypmi.application.binding.ExpressionPropertyAdapter.childInteractionUpdated(ExpressionPropertyAdapter.java:31)

at com.inductiveautomation.ignition.common.expressions.functions.AbstractPollingFunction.actionPerformed(AbstractPollingFunction.java:80)

at javax.swing.Timer.fireActionPerformed(Unknown Source)

at javax.swing.Timer$DoPostEvent.run(Unknown Source)

at java.awt.event.InvocationEvent.dispatch(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)

java.lang.NullPointerException: java.lang.NullPointerException

at org.python.core.Py.JavaError(Py.java)
at com.inductiveautomation.ignition.common.script.builtin.AbstractAlertUtilities.queryAlertStatus(AbstractAlertUtilities.java:42)
at sun.reflect.GeneratedMethodAccessor67.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)
at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction.__call__(ScriptManager.java:310)
at org.python.pycode._pyx4.activeAlerts$1(<module:alert>:13)
at org.python.pycode._pyx4.call_function(<module:alert>)
at org.python.core.PyTableCode.call(PyTableCode.java)
at org.python.core.PyTableCode.call(PyTableCode.java)
at org.python.core.PyFunction.__call__(PyFunction.java)
at org.python.core.PyObject.invoke(PyObject.java)
at org.python.pycode._pyx1.f$0(<expression:runScript>:1)
at org.python.pycode._pyx1.call_function(<expression:runScript>)
at org.python.core.PyTableCode.call(PyTableCode.java)
at org.python.core.PyCode.call(PyCode.java)
at org.python.core.Py.runCode(Py.java)
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:391)
... 15 more

Ignition v7.1.6 (b5739)
Java: Sun Microsystems Inc. 1.6.0_22

It looks like this is a bug that we have fixed in version 7.1.7. This issue is caused by calling system.alert.acknowledgeAlert() with empty string parameters. Once you do that, a null state gets introduced into memory and you start getting this error.

To fix this: stop the Ignition service, remove the .alerts file (C:\Program Files\Inductive Automation\Ignition\contexts\main.alerts), and then restart the service.