Browser

Browser is returned by ua.Model:browse() method. 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 can be a string, table wirh parameters. You can mix strings and tables in the path.

  • for strings and QualifiedName it will browsed hierarhical references

  • for tables it will browsed references by the ReferenceTypeId

Parameters for table path element:

  • TargetName - (required, string or QualifiedName) browse name of a node

  • ReferenceTypeId (optional, NodeID, Hierarchical References by default) - type of references to follow.

  • IsInverse (optional, boolean, false by default) - Direction to follow: forward or inverse

  • IncludeSubtypes (optional, boolean, true by default) - Include subtypes of the ReferenceTypeId or not

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 an node under which all the objects are placed.

NodeId:

Node identifier.

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 an node under which all the types are placed.

NodeId:

Node identifier.

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