Ignition OPC UA to Cognex not able to write

I am working with a Cognex D905 using the Cognex Program "In-Sight Vision Suite". I have the camera hooked up to our Ignition Gateway through OPC UA connection. We are able to read and write to certain tags on the device except for the one we are trying to use. We are trying to use the default "LoadJob" tag provided within the Cognex camera, which says it can be read/wrote too

But when I try to write to it in Ignition I get this error:

The tag came populated with this string:
image

And I am not sure if it is something on Ignitions end or something on Cognex's end.

We have also looked into using the system.opc.callMethod but we can't seem to figure out exactly what this function needs to work (Where would we find the methodID, objectID, how to call a method with a specific name at connection name, etc.).

We are also working with Cognex to see if it is something on there end. Any information would be helpful, thanks!

LoadJob is a Method, not a Variable Node you can subscribe to.

You'll need to use system.opcua.callMethod from a script to call it.

edit: err, missed that you figured some of that out.

The objectId will be the NodeId of whatever the parent Node you found that Method underneath is. The methodId is the NodeId of that Method Node itself. It helps to connect to the server with something like UaExpert to get a look at the overall structure and the attributes of these Nodes.

The existing OPC browser in the Designer doesn't really let you see any of this as its very outdated and functionally the lowest common denominator of OPC UA + OPC Classic.

Is there a verified free version of this software that you could recommend? I looked it up and see some downloads but not sure exactly what to trust.

1 Like

Finally got IT to download the program. How do I use this program now? I can't seem to find where I would add the camera or where I would go to find the different methodsIDs/objectIds.

Once you add a connection to this server there is a browser component on the left that is much like the OPC Browser in Ignition. You just need to navigate the address space to the same places you did in the Ignition OPC Browser. Then click on the Method Node and its parent Node and the attributes pane on the right will have a bunch of information in it, including a NodeId.

So I connected to the camera and I was able to find this information for the method I am trying to work with,

But when I try and write this script on a tags value changed event, nothing seems to happen...

Still having a hard time understanding exactly what to be filling in for the system.opcua.callMethod , but I tried to follow the example in the manual as closely as I could.

Add print statements to verify you're even making the call and to print the results. These will end up in the wrapper.log files. Alternatively you can use system.util.getLogger: system.util.getLogger | Ignition User Manual

Your comparison to a string value of "10" is immediately suspicious.

My thought behind this was so that I can control when I want this script to activate. I have this script running and a value changed event on a tag, so when I manually flip the tag value to 10 it would (hopefully) change the cameras job. I just chose 10 as an arbitrary number. If that's not how you would recommend doing this, I can change it up. This is all just for testing currently.

I also tried to switch the "system.tag.writeBlocking" part of my previous script to:print results[0] but I am not getting anymore information in our Logs

A numeric tag will never be equal to the string "10".

It is a Memory tag looking for a string, I just randomly picked 10.

I did notice that I am getting this error in our logs when testing it:

Can you copy/paste that whole error here? Click the "+" and copy any stack trace available as well.

I think I see the issue, but just to be sure...

You may end up needing to upgrade your Ignition Gateway.

([default]E405/TestJobSwitch, valueChanged) Error executing tag event script: Traceback (most recent call last): File "<tagevent:valueChanged>", line 3, in valueChanged at com.inductiveautomation.ignition.gateway.opcua.scripting.CallMethodKt.readMethodArguments(callMethod.kt:119) at com.inductiveautomation.ignition.gateway.opcua.scripting.CallMethodKt.access$readMethodArguments(callMethod.kt:1) at com.inductiveautomation.ignition.gateway.opcua.scripting.CallMethodKt$readMethodArguments$1.invokeSuspend(callMethod.kt) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:274) at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85) at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59) at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source) at com.inductiveautomation.ignition.gateway.opcua.scripting.OpcUaGatewayScriptingFunctions.callMethod(OpcUaGatewayScriptingFunctions.kt:72) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) java.lang.ClassCastException: java.lang.ClassCastException: class org.eclipse.milo.opcua.sdk.client.model.nodes.variables.PropertyTypeNode cannot be cast to class org.eclipse.milo.opcua.sdk.client.nodes.UaMethodNode (org.eclipse.milo.opcua.sdk.client.model.nodes.variables.PropertyTypeNode and org.eclipse.milo.opcua.sdk.client.nodes.UaMethodNode are in unnamed module of loader com.inductiveautomation.ignition.gateway.modules.ModuleClassLoader @60c44b44)
com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File "", line 3, in valueChanged at com.inductiveautomation.ignition.gateway.opcua.scripting.CallMethodKt.readMethodArguments(callMethod.kt:119) at com.inductiveautomation.ignition.gateway.opcua.scripting.CallMethodKt.access$readMethodArguments(callMethod.kt:1) at com.inductiveautomation.ignition.gateway.opcua.scripting.CallMethodKt$readMethodArguments$1.invokeSuspend(callMethod.kt) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:274) at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85) at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59) at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source) at com.inductiveautomation.ignition.gateway.opcua.scripting.OpcUaGatewayScriptingFunctions.callMethod(OpcUaGatewayScriptingFunctions.kt:72) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) java.lang.ClassCastException: java.lang.ClassCastException: class org.eclipse.milo.opcua.sdk.client.model.nodes.variables.PropertyTypeNode cannot be cast to class org.eclipse.milo.opcua.sdk.client.nodes.UaMethodNode (org.eclipse.milo.opcua.sdk.client.model.nodes.variables.PropertyTypeNode and org.eclipse.milo.opcua.sdk.client.nodes.UaMethodNode are in unnamed module of loader com.inductiveautomation.ignition.gateway.modules.ModuleClassLoader @60c44b44)

at org.python.core.Py.JavaError(Py.java:545)

at org.python.core.Py.JavaError(Py.java:536)

at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:192)

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

at org.python.core.PyObject.__call__(PyObject.java:512)

at org.python.core.PyObject.__call__(PyObject.java:517)

at org.python.pycode._pyx2008344.valueChanged$1(:7)

at org.python.pycode._pyx2008344.call_function()

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

at org.python.core.PyBaseCode.call(PyBaseCode.java:306)

at org.python.core.PyFunction.function___call__(PyFunction.java:474)

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

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

at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:847)

at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:829)

at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$TrackingProjectScriptManager.runFunction(ProjectScriptLifecycle.java:868)

at com.inductiveautomation.ignition.gateway.tags.scripting.TagScriptManagerImpl$FunctionInvokerImpl.run(TagScriptManagerImpl.java:550)

at com.inductiveautomation.ignition.gateway.tags.scripting.events.AbstractTagScript.invoke(AbstractTagScript.java:34)

at com.inductiveautomation.ignition.gateway.tags.scripting.TagScriptManagerImpl$Task.invoke(TagScriptManagerImpl.java:498)

at com.inductiveautomation.ignition.gateway.tags.scripting.TagScriptManagerImpl$TagScriptDispatcher.run(TagScriptManagerImpl.java:458)

at com.inductiveautomation.ignition.common.execution.impl.BasicExecutionEngine$ThrowableCatchingRunnable.run(BasicExecutionEngine.java:544)

at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)

at java.base/java.util.concurrent.FutureTask.run(Unknown Source)

at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.base/java.lang.Thread.run(Unknown Source)

Caused by: org.python.core.PyException: java.lang.ClassCastException: java.lang.ClassCastException: class org.eclipse.milo.opcua.sdk.client.model.nodes.variables.PropertyTypeNode cannot be cast to class org.eclipse.milo.opcua.sdk.client.nodes.UaMethodNode (org.eclipse.milo.opcua.sdk.client.model.nodes.variables.PropertyTypeNode and org.eclipse.milo.opcua.sdk.client.nodes.UaMethodNode are in unnamed module of loader com.inductiveautomation.ignition.gateway.modules.ModuleClassLoader @60c44b44)

... 27 common frames omitted

Caused by: java.lang.ClassCastException: class org.eclipse.milo.opcua.sdk.client.model.nodes.variables.PropertyTypeNode cannot be cast to class org.eclipse.milo.opcua.sdk.client.nodes.UaMethodNode (org.eclipse.milo.opcua.sdk.client.model.nodes.variables.PropertyTypeNode and org.eclipse.milo.opcua.sdk.client.nodes.UaMethodNode are in unnamed module of loader com.inductiveautomation.ignition.gateway.modules.ModuleClassLoader @60c44b44)

at com.inductiveautomation.ignition.gateway.opcua.scripting.CallMethodKt.readMethodArguments(callMethod.kt:119)

at com.inductiveautomation.ignition.gateway.opcua.scripting.CallMethodKt.access$readMethodArguments(callMethod.kt:1)

at com.inductiveautomation.ignition.gateway.opcua.scripting.CallMethodKt$readMethodArguments$1.invokeSuspend(callMethod.kt)

at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)

at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)

at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:274)

at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)

at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)

at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)

at com.inductiveautomation.ignition.gateway.opcua.scripting.OpcUaGatewayScriptingFunctions.callMethod(OpcUaGatewayScriptingFunctions.kt:72)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.base/java.lang.reflect.Method.invoke(Unknown Source)

at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:190)


Let me know if that works or if you would like it in a different format

Yeah, same error has over here basically: Error calling OPC UA method - #2 by Kevin.Herron

This server has a buggy OPC UA implementation. I reworked our OPC UA method call logic to avoid triggering that path in servers that use this implementation and it got released with Ignition 8.1.43.

Sounds good. So you think if we were to upgrade our server it would fix this issue?

It should. Unless you're already on 8.1.43 or newer.

Sounds good. I will work with IT on making that happen and get back to you if I have anymore questions.