Top  | Previous | Next

Troubleshooting Gateway Scripts

Writing an event script that runs on a client (through a client event Script or on a component) allows for easy debugging because a red error message pops up when something goes wrong. In a Gateway Event Script the errors still appear, but because there is no GUI associated with it, they don't show up for the user to see.  One might think that these errors would be generated and logged in the Ignition Gateway Console utility, but unfortunately due to how logging works internally this is not the case. These errors are indeed logged and there are a couple places where you can go to find inspect these error messages.

 

Ignition's wrapper.log

All of the error messages from your Gateway Event Scripts are logged to one file: wrapper.log. You can find this file in the install directory under

Version 7.3+ <INSTALL DIR>\Inductive Automation\Ignition\logs\wrapper.log

Version 7.2- <INSTALL DIR>\Inductive Automation\Ignition\wrapper.log

When you open this file, scroll to the bottom to see the newest messages. If you have just started Ignition for the first time you will see something like this:

 

STATUS | wrapper | 2011/11/23 10:47:09 | --> Wrapper Started as Service

STATUS | wrapper | 2011/11/23 10:47:09 | Java Service Wrapper Standard Edition 

     32-bit 3.5.4

STATUS | wrapper | 2011/11/23 10:47:09 |   Copyright (C) 1999-2010 Tanuki Software,

     Ltd. All Rights Reserved.

STATUS | wrapper | 2011/11/23 10:47:09 |     http://wrapper.tanukisoftware.com

STATUS | wrapper | 2011/11/23 10:47:09 |   Licensed to Inductive Automation for

     Ignition Gateway

STATUS | wrapper | 2011/11/23 10:47:09 | 

STATUS | wrapper | 2011/11/23 10:47:09 | Launching a JVM...

INFO | jvm 1 | 2011/11/23 10:47:09 | WrapperManager: Initializing...

INFO | jvm 1 | 2011/11/23 10:47:10 | Nov 23, 2011 10:47:10 AM org.apache.catalina.

     startup.Embedded start

INFO | jvm 1 | 2011/11/23 10:47:10 | INFO: Starting tomcat server

INFO | jvm 1 | 2011/11/23 10:47:10 | Nov 23, 2011 10:47:10 AM org.apache.catalina.

     core.StandardEngine start

INFO | jvm 1 | 2011/11/23 10:47:10 | INFO: Starting Servlet Engine: Apache Tomcat/

     6.0.18

 

This file is in constant use by the Ignition system and is being modified in realtime.  It is recommended that you download a tool like Wintail that will allow you to view the tail-end (hence the name) of the changing wrapper.log without having to constantly reopen the file.

 

Output to the wrapper.log file

Gateway Event Script errors are not the only handy bits of information logged to the wrapper file.  Print statements that you add to your Gateway Event Scripts are also output to the wrapper.log file.  Print statements can be extremely helpful in troubleshooting tricky pieces of scripting.  Adding a few simple print statements can help you see values of variables as a script is being executed, or even allow you to see how far your script is getting if it is seeming to merely stop with out throwing an error.

 

1.In the designer go to the Gateway Event Scripts found under Projects > Event Scripts (Gateway)
2.Click on the Timer option and add a new timer script with the default settings.
3.Add this code to you Timer Script:

print "Hello World"

4.Click OK and then save your project.

 

Your script will now be running every second and you will begin to see messages appear in the wrapper.log file similar to the following:

INFO | jvm 1 | 2012/8/23 11:12:56 | INFO [Project[IADemo] ] [11:12:56,044]: 

     Restarting gateway scripts...

INFO | jvm 1 | 2012/8/23 11:12:57 | Hello World

INFO | jvm 1 | 2012/8/23 11:12:58 | Hello World

INFO | jvm 1 | 2012/8/23 11:12:59 | Hello World

INFO | jvm 1 | 2012/8/23 11:13:00 | Hello World

 

If an error is generated in your script is will show up in the wrapper looking something like:

INFO | jvm 1 | 2011/11/23 11:20:36 | ERROR [TimerScriptTask ] [11:20:36,310]: Error

     executing global timer script: test (1000) [Delay, Shared]. Repeat errors of 

     this type will be logged as 'debug' messages.

INFO | jvm 1 | 2011/11/23 11:20:36 | Traceback (innermost last):

INFO | jvm 1 | 2011/11/23 11:20:36 |   File "<TimerScript:IADemo/test (1000) [Delay,

     Shared]>", line 1, in ?

INFO | jvm 1 | 2011/11/23 11:20:36 | TypeError: write(): expected 2-3 args; got 1

INFO | jvm 1 | 2011/11/23 11:20:36 | 

INFO | jvm 1 | 2011/11/23 11:20:36 |     at org.python.core.Py.TypeError(Py.java)

INFO | jvm 1 | 2011/11/23 11:20:36 |     at org.python.core.PyReflectedFunction.

     throwError(PyReflectedFunction.java)

INFO | jvm 1 | 2011/11/23 11:20:36 |     at org.python.core.PyReflectedFunction.

     throwArgCountError(PyReflectedFunction.java)

INFO | jvm 1 | 2011/11/23 11:20:36 |     at org.python.core.PyReflectedFunction.

     throwError(PyReflectedFunction.java)

INFO | jvm 1 | 2011/11/23 11:20:36 |     at org.python.core.PyReflectedFunction.

     __call__(PyReflectedFunction.java)

INFO | jvm 1 | 2011/11/23 11:20:36 |     at com.inductiveautomation.ignition.common.

     script.ScriptManager$ReflectedInstanceFunction.__call__(ScriptManager.java:314)

INFO | jvm 1 | 2011/11/23 11:20:36 |     at org.python.core.PyObject.

     __call__(PyObject.java)

INFO | jvm 1 | 2011/11/23 11:20:36 |     at org.python.core.PyObject.

     invoke(PyObject.java)

INFO | jvm 1 | 2011/11/23 11:20:36 |     at org.python.pycode._pyx1.f$0

     (<TimerScript:IADemo/test (1000) [Delay, Shared]>:1)

INFO | jvm 1 | 2011/11/23 11:20:36 |     at org.python.pycode._pyx1.call_function

     (<TimerScript:IADemo/test (1000) [Delay, Shared]>)

INFO | jvm 1 | 2011/11/23 11:20:36 |     at org.python.core.PyTableCode.call

     (PyTableCode.java)

INFO | jvm 1 | 2011/11/23 11:20:36 |     at org.python.core.PyCode.call(PyCode.java)

INFO | jvm 1 | 2011/11/23 11:20:36 |     at org.python.core.Py.runCode(Py.java)

INFO | jvm 1 | 2011/11/23 11:20:36 |     at com.inductiveautomation.ignition.common.

     script.ScriptManager.runCode(ScriptManager.java:395)

INFO | jvm 1 | 2011/11/23 11:20:36 |     at com.inductiveautomation.ignition.common.

     script.TimerScriptTask.run(TimerScriptTask.java:76)

INFO | jvm 1 | 2011/11/23 11:20:36 |     at java.util.TimerThread.mainLoop

     (Unknown Source)

INFO | jvm 1 | 2011/11/23 11:20:36 |     at java.util.TimerThread.run(Unknown Source)

 

 

Here the error message is split over two lines:

 

File "<TimerScript:IADemo/test (1000) [Delay, Shared]>", line 1, in ?

and

TypeError: write(): expected 2-3 args; got 1

 

There was no code snippet here but there should be enough information presented to get a pretty good idea of what went wrong.

The first part of the error gives the type of script, project name, and script name in which the error occurred.  The line number of the script on which the error occurred is also presented.

 

Part two of the error is a little more cryptic but still decipherable if you are familiar with some of Ignition's built in scripting functions.  One of the built in functions is system.tag.write(), this function takes 2 - 3 arguments as per its documentation in the user manual under Appendix C.  This error message is reporting that only one argument was received.  With this information one should be able to locate the script that's causing the error and make the appropriate edits to resolve the issue.

 

Gateway Script Status Page

The Gateway Script Status Page is exactly what it sounds like.  The status' of all different gateway scripts homed in the different projects located on the gateway are displayed for easy viewing on this page.  They are grouped by the project that they reside in and display any errors that may have occurred during the last execution of the script.  This status page does not show things like print statements.  The only place to view those is in the wrapper.log file as described above.

 

gateway_script_status