Hi everyone,
I am still fairly new to Ignition and I was writing a very basic component property script when I came across this issue:
On the Vision Client the Template I use works well, but usually (not always) gives an error. Looking into the details, and reading various forum topics here, it seems to me that it is a problem that occurs when the script runs before the template parameter has evaluated its binding to the tag (memory or OPC tag). I tried to resolve the problem by utilizing system.util.invokeLater, but it does not solve the problem. I even tried adding a manual delay using the system.util.invokeLater, but it doesn’t always solve the problem (I tried 500mSec which is already a substantial delay, I believe).
First, here is the script:
For reference: ALM_Box_One (TESTING2) --> template, Alarm1_Value --> template parameter bound to a Tag name inside the main window, Alarm1 --> label component
print event.source
print event.propertyName
if event.propertyName in ['Alarm1_Value']:
print 'correct event type'
def Alarm_Box():
# Choice of text and value for "Alarm 1"
if '_50' in event.source.Alarm1_TagName:
event.source.getComponent('Alarm1').text='SHORT CIRCUIT'
elif '_51' in event.source.Alarm1_TagName:
event.source.getComponent('Alarm1').text='OVERCURRENT'
elif '_NA' in event.source.Alarm1_TagName:
event.source.getComponent('Alarm1').text='UNAVAILABLE'
elif '_27' in event.source.Alarm1_TagName:
event.source.getComponent('Alarm1').text='UNDERVOLTAGE'
else:
event.source.getComponent('Alarm1').text='TYPE MISMATCH'
if event.source.Alarm1_Value:
event.source.getComponent('Alarm1').foreground=(255,0,0)
else:
event.source.getComponent('Alarm1').foreground=(255,255,255)
system.util.invokeLater(Alarm_Box)
print 'elaborated if condition'
I will copy here the Vision console. Note that after I launched the project in the Vision Client, it didn’t give any errors. Then when I switched the window and came back, it gave an error almost immediately.
17:55:41.075 [Thread-0] INFO com.inductiveautomation.ignition.client.gateway_interface.GatewayConnectionManager - Updated login state. Logged in? true, Username: TTC, Roles: [Administrator], Security Zones: null
17:55:41.381 [Thread-4] INFO tags.manager.gwinterface - Tag poll rate changed to 250 ms
17:55:41.480 [ClientExecEngine-2] INFO tags.subscriptions - Changing connected quality to 'Good'
17:55:43.273 [Thread-4] INFO com.inductiveautomation.reporting.client.ReportingClientHook - Starting up Reporting Module. Mode: Trial
17:55:43.512 [Thread-4] ERROR Scripting.ScriptManager.OBOB_PMS - Warning: collision at system.util.initialize
17:55:43.904 [AWT-EventQueue-0] INFO vision.App - Starting Up...
ALM_Box_One (TESTING2)
Alarm1_TagName
ALM_Box_One (TESTING2)
Alarm1_Value
correct event type
elaborated if condition
ALM_Box_One (TESTING2)
componentRunning
ALM_Box_One (TESTING2)
instanceName
ALM_Box_One (TESTING2)
vision.bounds2d
ALM_Box_One (TESTING2)
componentRunning
ALM_Box_One (TESTING2)
ancestor
ALM_Box_One (TESTING2)
graphicsConfiguration
ALM_Box_One (TESTING2)
graphicsConfiguration
ALM_Box_One (TESTING2)
ancestor
ALM_Box_One (TESTING2)
componentRunning
ALM_Box_One (TESTING2)
Alarm1_Value
correct event type
elaborated if condition
ALM_Box_One (TESTING2)
Alarm1_TagName
17:56:28.823 [AWT-EventQueue-0] ERROR com.inductiveautomation.factorypmi.application.script.builtin.ClientSystemUtilities - <HTML>Error running function from <code>fpmi.system.invokeLater</code>
com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last):
File "<event:propertyChange>", line 16, in Alarm_Box
TypeError: 'NoneType' object is not iterable
at org.python.core.Py.TypeError(Py.java:265)
at org.python.core.PyObject.__iter__(PyObject.java:900)
at org.python.core.PyObject$1.iterator(PyObject.java:912)
at org.python.core.PyObject.object___contains__(PyObject.java:1786)
at org.python.core.PyObject.__contains__(PyObject.java:1782)
at org.python.core.PyObject._in(PyObject.java:1762)
at org.python.pycode._pyx0.Alarm_Box$1(<event:propertyChange>:30)
at org.python.pycode._pyx0.call_function(<event:propertyChange>)
at org.python.core.PyTableCode.call(PyTableCode.java:171)
at org.python.core.PyBaseCode.call(PyBaseCode.java:308)
at org.python.core.PyFunction.function___call__(PyFunction.java:471)
at org.python.core.PyFunction.__call__(PyFunction.java:466)
at org.python.core.PyFunction.__call__(PyFunction.java:456)
at org.python.core.PyFunction.__call__(PyFunction.java:451)
at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:788)
at com.inductiveautomation.factorypmi.application.script.builtin.ClientSystemUtilities.lambda$invokeLater$1(ClientSystemUtilities.java:276)
at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
Caused by: org.python.core.PyException: Traceback (most recent call last):
File "<event:propertyChange>", line 16, in Alarm_Box
TypeError: 'NoneType' object is not iterable
... 29 common frames omitted
ALM_Box_One (TESTING2)
Alarm1_Value
correct event type
elaborated if condition
ALM_Box_One (TESTING2)
Alarm1_TagName