Module opc-ua

Note: As this module was written in 100% C++ for fastest execution time, this page was not created with JSDoc and does look a bit different than the other documentation pages.

Examples which use this module:

General rule regarding errors in callback: Either the error parameter is null or the following parameters are undefined.

Note: If you cannot connect to your server, you might have restarted your program to often by pressing Stop. This way destroy() is not called and the connection is not closed gracefully. The server will need some time to timeout.

Exported constants

For UAClientNode.read/UAClientNode.write:

For UAClientNode.write:

Exported class UAClient extends events.EventEmitter

Event connect

Called when connection to the client is established and the object can be used.

Event error(err)

Called when an error happens in connecting or handling the connection. The object is no longer usable after this event happened and should be destroy()-ed by the user. This event is not called if a specific request fails and can be tried again.

Event dataChanged(node, val)

Called when the data value of a node changes which is being monitored using a subscription. node is exactly the object which was added to a subscription via subscription.add(node). val is the new value of the node.

constructor(options)

options is an object with the following properties:

root (property of type UAClientNode)

A ready to use object for the root node, which exists in every OPC-UA server.

objects (property of type UAClientNode)

A ready to use object for the objects node, which exists in every OPC-UA server.

destroy(callback)

Gracefully shuts a connection down and then destroys the object.

node(namespace, node)

Returns a UAClientNode object for the node with the given parameters.

createSubscription(callback)

Creates a subscription on the server which can be used to monitor nodes.

Class UAClientNode

namespace (integer property)

Always set

node (integer property)

Always set

browseName (string property)

Only set if the node is created by parentNode.children() or node.lookupProps() is called.

displayName (string property)

Only set if the node is created by parentNode.children() or node.lookupProps() is called.

description (string property)

Only set if node.lookupProps() is called.

lookupProps(callback)

Looks up the properties browseName, displayName and description. When sucessful, these properties are saved in the node object.

subNode(path, callback)

Allows to traverse from this node to any sub node. The path is in the format NamespaceInteger:BrowseName/NamespaceInteger:BrowseName/... and is meant to be relative to the node. Subtypes are followed.

children(callback)

Looks up all children of this node and gives them to the callback as array.

read([attribute,] callback)

Looks up an attribute of the node. If the attribute type is not given, it defaults to ATTRIBUTE_VALUE.

write([attribute,] value, type, callback)

Allows to write an attribute of the node. If the attribute type is not given, it defaults to ATTRIBUTE_VALUE. The type is the type of the value and is one of TYPE_... (see above).

call(callback)

Allows to call method nodes. Arguments and return values are not supported yet. Useful for calls to methods such as "apply".

Class UAClientSubscription

destroy(callback)

Destroys a subscription. Nodes must be removed first.

add(node, callback)

Adds a node to a subscription (creates a monitored item). After this, changes in the value of the node result into the event dataChanged of the UAClient being called.

remove(node, callback)

Removes a node from a subscription.