Address Space Browsing
Address space browsing is done with the ‘browse’ method. Both the client and server have this method.
The browse method accepts three parameter types:
String with node ID
Array of strings with Node ID
Table with detailed parameters
These parameters are described in section BrowseParameters.
Method browse returns BrowseResult
Browsing by String NodeID
To browse a single node, you need to pass a string with node ID into the browse Method:
-- Browse one node by ID.
resp, err = client:browse(RootFolder)
To browse several nodes at once, you can pass an array of nodeIDs as follows:
-- Browse array of Node IDs.
resp, err = client:browse({RootFolder, TypesFolder})
Browsing a node by ID sends a request to the server with the following parameters:
Follow Hierarchical references in forward direction
Node class mask - All node classes
Result mask - all attributes
Detailed Parameters
For special cases, you can manually set the browse parameters as shown in the following example:
local browseParams = {
NequestedMaxReferencesPerNode = 0,
NodesToBrowse = {
{
NodeId = RootFolder,
ReferenceTypeId = HierarchicalReferences,
BrowseDirection = ua.Types.BrowseDirection.Forward,
NodeClassMask = ua.Types.NodeClass.Unspecified,
ResultMask = ua.Types.BrowseResultMask.All,
IncludeSubtypes = true,
},
{
NodeId = TypesFolder,
ReferenceTypeId = HierarchicalReferences,
BrowseDirection = ua.Types.BrowseDirection.Forward,
NodeClassMask = ua.Types.NodeClass.Unspecified,
ResultMask = ua.Types.BrowseResultMask.All,
IncludeSubtypes = true,
}
},
}
local resp,err = client:browse(browseParams)
for _,res in ipairs(resp.Results) do
if res.StatusCode ~= ua.StatusCode.Good then
trace(string.format("Cannot browse node: 0x%X", res.StatusCode))
else
trace("References:")
for i,ref in ipairs(res.References) do
trace(string.format("%d: NodeId=%s Name=%s", i, ref.NodeId, ref.DisplayName.text))
end
end
end