OPC-UA Method Calls

Nothing like that is available.

OPC UA does have a service called TranslateBrowsePathsToNodeIds, which if you know the full browse path to the Node in question, can be used to get the NodeId, but there’s no way to get the NodeId from just a Node’s name on its own.

There’s no way for you to call this service from scripting right now though, we’d have to add support for it like we did with callMethod.

1 Like

@Kevin.Herron
Using a service such as TranslateBrowsePathsToNodeIds would help Ignition be more elegant in its scripting to access methods. Hard-coding the NodeId, which includes the namespace id is clunky, and won’t be feasible when trying to access gateway-type devices that aggregate multiple address spaces and assign whatever namespace id it chooses.

What are the next features to be added to the system.opcua family of scripting functions?

Thanks!

It's only a marginal win because browse names are QualifiedNames, which also require a namespace index. So it would end up looking something like this:

result = system.opcua.callMethod(
    "Ignition OPC UA Server",
    "Obects/3:Path/3:To/3:Node",
    "Obects/3:Path/3:To/3:Node/3:MethodName",
    [1]
)

where you'd still be required to know the correct namespace indices of each component in the path...

Nothing solid planned... anything in particular you had in mind?

Would it be possible to parse the source of an existing Ignition OPC tag to obtain what the namespace index is? The tag I would poll would be within the same address space as the method.

The OPC Item Path of an OPC Tag from an OPC UA server is a parseable string representation of a NodeId. The “ns=N;” prefix is specifying the namespace index (N).

@Kevin.Herron Thanks.

For those interested, here’s some code that I used to achieve what Kevin suggested:

tagPath = "path-to-ignition-tag-in-same-address-space-as-method"
tagConfig = system.tag.getConfiguration(tagPath, False)
server = tagConfig[0]['opcServer']
opcPath = tagConfig[0]['opcItemPath']
#opcValue = system.opc.readValue(server, opcPath).getValue()

namespaceID = opcPath[3:str(opcPath).find(";")]
objectId = 'ns='+namespaceID+';s=id-of-object-containing-the-method'
methodId = 'ns='+namespaceID+';s=id-of-method'
system.opcua.callMethod(server, objectId, methodId,[])
1 Like

I am using Ignition Edge, and when I attempt to test the system.opcua.callMethod(), I get a message saying that “com.inductiveautomation.ignition.designer.gui.tool’ object has no attribute ‘opcua’.”

Is there a separate library I need to install to use this function?

system.opcua.callMethod() is scoped for scripting from the Gateway and Perspective Session contexts.

image

https://docs.inductiveautomation.com/display/DOC81/system.opcua.callMethod

That means you’ll need to run this either from inside Perspective (as a script on a button click, for example), on a tag script (tag change, for example), or other Gateway scripting places. It’s not designed to run from the Designer scope. (The error indicates you’re trying to run it from the designer.)