Script Failing Due to Trying to Add two Values

The script is failing when I try to add a value of 1 to the chart.releaseBank variable.

This is the script:

[code] value1=1
chart.releaseBank = system.tag.read(chart.tagPath+“ReleaseBank”).value
kitReleased = system.db.runScalarPrepQuery("
SELECT TOP 1
PH.PHID
FROM
PouHeader PH
LEFT JOIN JobHeader JH ON PH.JobID = JH.JobID
WHERE
PH.StatusID = 1 AND
PH.PouID = ?
ORDER BY
JH.SeqNumber ASC", [chart.pouID], chart.databaseName)

system.db.runPrepUpdate("UPDATE PouHeader SET StatusID = 8 WHERE PHID = ?", [kitReleased], chart.databaseName)
chart.releaseBank += 1
system.tag.write(chart.tagPath+"ReleaseBank", chart.releaseBank)[/code]

This is the console error:

[code] 8:30:09 AM ChartInstance Chart ‘Charlotte/EPS_R1_0_0/ScannerHUD’ aborted in ‘Script[Step:KitRelease10]’

Traceback (most recent call last):
File “”, line 25, in onStart
TypeError: unsupported operand type(s) for +: ‘NoneType’ and ‘int’

at org.python.core.Py.TypeError(Py.java:235)
at org.python.core.PyObject._basic_add(PyObject.java:2017)
at org.python.core.PyObject._basic_iadd(PyObject.java:2058)
at org.python.core.PyObject._iadd(PyObject.java:2032)
at org.python.pycode.pyx22195.onStart$1(:26)
at org.python.pycode.pyx22195.call_function()
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyBaseCode.call(PyBaseCode.java:301)
at org.python.core.PyFunction.function___call
(PyFunction.java:376)
at org.python.core.PyFunction.call(PyFunction.java:371)
at org.python.core.PyFunction.call(PyFunction.java:361)
at org.python.core.PyFunction.call(PyFunction.java:356)
at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:639)
at com.inductiveautomation.sfc.elements.steps.StepScriptRunner.invoke(StepScriptRunner.java:46)
at com.inductiveautomation.sfc.elements.steps.StepScriptRunner.invoke(StepScriptRunner.java:34)
at com.inductiveautomation.sfc.elements.steps.action.ActionStep.activateStep(ActionStep.java:48)
at com.inductiveautomation.sfc.elements.StepContainer.onActivateRequested(StepContainer.java:125)
at com.inductiveautomation.sfc.fsm.element.ElementInactive.action(ElementInactive.java:33)
at com.inductiveautomation.sfc.fsm.element.ElementInactive.action(ElementInactive.java:8)
at com.inductiveautomation.sfc.fsm.StateContext.lambda$handleEvent$0(StateContext.java:52)
at com.inductiveautomation.sfc.api.ExecutionQueue$ThrowableCatchingRunnable.run(ExecutionQueue.java:136)
at com.inductiveautomation.sfc.api.ExecutionQueue$PollAndExecute.run(ExecutionQueue.java:111)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)[/code]

Either your tag path is invalid or the path is valid and the value is None.

You can debug your tag read with print statements so that you will know when you have the path correct and/or a good value to work with.

path = chart.tagPath+"ReleaseBank"
chart.releaseBank = system.tag.read(path).value

print "Path: %s" % path
print "Path exists: %s" % system.tag.exists(path)
print "Type: %s\tValue: %s" % (type(chart.releaseBank), chart.releaseBank)
1 Like

Solved!
The tag path wasn’t correct. Thanks!