Browser

Browser is returned by model:browse(). It is used to browse the address space.

browser:children()

Get the children of the parent node.

Returns:

Array of browser objects.

browser:path(pathElements)

Resolve a path in the address space starting from the root node.

PathElements:

Path elements. You can mix strings, QualifiedName values, and table elements in the same path.

Strings and QualifiedName values follow hierarchical references. Table elements can select a specific reference type.

Table path elements use these fields:

Field

Type

Description

TargetName

string or QualifiedName

Required browse name of the target node.

ReferenceTypeId

NodeId, optional

Reference type to follow. Defaults to hierarchical references.

IsInverse

boolean, optional

Follow inverse references when true. Defaults to false.

IncludeSubtypes

boolean, optional

Include subtypes of ReferenceTypeId. Defaults to true.

Returns:

Browser object.

Raises:

if the path is not found, or other error occurs.

Examples:

Get one child node by browse name:

1-- Resolve path to the objects folder node with id i=85
2local objectsFolderPath = model:browse():path("Objects")

Follow hierarchical references:

1-- Resolve path to the server object node
2local serverObject = model:browse():path({"Objects", "Server"})

Mix browse names and table parameters:

 1-- Resolve path to server object type definition node
 2-- it is possible to mix string and table in the path:
 3--   * for strings it will browsed hierarhical references
 4--   * for tables it will browsed references by the ReferenceTypeId
 5local serverObjectTypeDefinition = model:browse():path({
 6  "Objects", -- #1
 7  "Server",  -- #2
 8  {          -- #3
 9    TargetName = "ServerType", -- This is either a strinf or a QualifiedName
10    ReferenceTypeId = ua.ReferenceType.HasTypeDefinition,
11    IncludeSubtypes = false,
12    IsInverse = false,
13  }
14})
15
16print(serverObjectTypeDefinition.Attrs.BrowseName.Name) -- "ServerType"
17print(serverObjectTypeDefinition.Attrs.NodeId) -- "i=2253"

Full source

browser:getNode(nodeId)

Get the browser object by identifier. Result object will have methods according to the node class.

NodeId:

Node identifier.

Returns:

Browser object.

browser:objectsFolder()

Returns a node under which all the objects are placed.

Returns:

Browser object.

Example:

1-- Get the objects folder node with id i=85
2local objectsFolder = model:browse():objectsFolder()
3print(objectsFolder.Attrs.BrowseName.Name) -- "Objects"
4print(objectsFolder.Attrs.NodeId) -- "i=85"

Full source

browser:typesFolder()

Returns a node under which all the types are placed.

Returns:

Browser object.

Example:

1-- Resolve path to the server type node which is a type of server object instance
2local serverType = model:browse():typesFolder():path({
3  "ObjectTypes",
4  "BaseObjectType",
5  "ServerType"
6})
7print(serverType.Attrs.BrowseName.Name) -- "ServerType"
8print(serverType.Attrs.NodeId) -- "i=2253"

Full source