Model methods

ua.emptyModel(config)

Create empty model. To use it, you need to load specification from XML files (including NS0) and create NS1.

ua.baseModel(config)

Create model with NS0 and NS1 initialized. Built-in NS0 contains a minimal set of nodes required for operating. To get the full standard nodeset NS0, you can load it from XML file: nodes will be merged. To create a full nodeset from the beginning, you can use ua.emptyModel() and then load the required models.

model.newNodeId()

Generates a NodeId. This method is used to generate new node identifiers for all new nodes created in the model. If you want to generate your own node identifiers, you can replace this method with your own implementation.

Returns:

NodeId with new node identifier.

model.createNamespace(namespaceUri)

Create a new namespace. If a namespace with the same URI already exists, an error will be thrown. Return index of the new namespace. For every new namespace, the index will be incremented by 1. Namespace index 0 is reserved for the default namespace ‘http://opcfoundation.org/UA/’ and index 1 is reserved for the namespace reserved for the current server. All newly created namespaces will be mapped to namespaces with indexes starting from 2.

NamespaceUri:

URI of the namespace.

Throws:

Error if namespace with same URI already exists.

Returns:

index of the new namespace.

model.validate(callback)

Validate the model for errors: Missing references, unreferenced nodes, etc.

Callback:

Function callback(error) to be called when the validation is done. Error is string with error message.

Returns:

nil

Throws:

Error if there are errors in the model.

model.commit()
Returns:

nil

Throws:

Error if there are errors in the model.

Commit the model changes. This method should be called after all changes are made to the model. It validates changes, fills internal structures and makes the model ready for use.

model.browse()

Browse the address space.

Returns:

Browser object.

model.edit()

Create editor to edit the address space. Every editor stores new nodes that are not yet committed to the model. To commit changes to the model you should call editor.save() method.

Returns:

Editor object.