// This example shows how to obtain nodes under a given node of the OPC-UA address space.
// For each node, it displays its browse name and node ID.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.
#include "stdafx.h" // Includes "QuickOpc.h", and other commonly used files
#include "Browse.h"
namespace _EasyUAClient
{
void Browse::Main()
{
// Initialize the COM library
CoInitializeEx(nullptr, COINIT_MULTITHREADED);
{
_UAEndpointDescriptorPtr EndpointDescriptorPtr(__uuidof(UAEndpointDescriptor));
EndpointDescriptorPtr->UrlString =
//L"http://opcua.demo-this.com:51211/UA/SampleServer";
L"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer";
_UANodeDescriptorPtr NodeDescriptorPtr(__uuidof(UANodeDescriptor));
_UABrowsePathParserPtr BrowsePathParserPtr(__uuidof(UABrowsePathParser));
BrowsePathParserPtr->DefaultNamespaceUriString = L"http://test.org/UA/Data/";
NodeDescriptorPtr->BrowsePath = BrowsePathParserPtr->Parse(L"[ObjectsFolder]/Data/Static/UserScalar");
_UABrowseParametersPtr BrowseParametersPtr(__uuidof(UABrowseParameters));
BrowseParametersPtr->StandardName = L"AllForwardReferences";
// Instantiate the client object
_EasyUAClientPtr ClientPtr(__uuidof(EasyUAClient));
// Perform the operation
_UANodeElementCollectionPtr NodeElementsPtr = ClientPtr->Browse(
static_cast<IDispatch*>(EndpointDescriptorPtr),
static_cast<IDispatch*>(NodeDescriptorPtr),
static_cast<IDispatch*>(BrowseParametersPtr));
// Display results
IEnumVARIANTPtr EnumNodeElementPtr = NodeElementsPtr->GetEnumerator();
_variant_t vNodeElement;
while (EnumNodeElementPtr->Next(1, &vNodeElement, nullptr) == S_OK)
{
const _UANodeElementPtr NodeElementPtr(vNodeElement);
_tprintf(_T("%s: "), (LPCTSTR)CW2CT(NodeElementPtr->BrowseName->ToString));
_tprintf(_T("%s\n"), (LPCTSTR)CW2CT(NodeElementPtr->NodeId->ToString));
vNodeElement.Clear();
}
}
// Release all interface pointers BEFORE calling CoUninitialize()
CoUninitialize();
}
}
// This example shows how to obtain nodes under a given node of the OPC-UA
// address space. For each node, it displays its browse name and node ID.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.
class procedure Browse.Main;
var
BrowseParameters: _UABrowseParameters;
BrowsePathParser: _UABrowsePathParser;
Client: EasyUAClient;
Count: Cardinal;
Element: OleVariant;
EndpointDescriptor: _UAEndpointDescriptor;
NodeDescriptor: _UANodeDescriptor;
NodeElement: _UANodeElement;
NodeElementEnumerator: IEnumVariant;
NodeElements: _UANodeElementCollection;
begin
EndpointDescriptor := CoUAEndpointDescriptor.Create;
EndpointDescriptor.UrlString :=
//'http://opcua.demo-this.com:51211/UA/SampleServer';
'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer';
NodeDescriptor := CoUANodeDescriptor.Create;
BrowsePathParser := CoUABrowsePathParser.Create;
BrowsePathParser.DefaultNamespaceUriString := 'http://test.org/UA/Data/';
NodeDescriptor.BrowsePath := BrowsePathParser.Parse('[ObjectsFolder]/Data/Static/UserScalar');
BrowseParameters := CoUABrowseParameters.Create;
BrowseParameters.StandardName := 'AllForwardReferences';
// Instantiate the client object
Client := CoEasyUAClient.Create;
NodeElements := Client.Browse(
EndpointDescriptor,
NodeDescriptor,
BrowseParameters);
NodeElementEnumerator := NodeElements.GetEnumerator;
while (NodeElementEnumerator.Next(1, Element, Count) = S_OK) do
begin
NodeElement := IUnknown(Element) as _UANodeElement;
WriteLn(NodeElement.BrowseName.ToString, ': ', NodeElement.NodeId.ToString);
end;
end;
// This example shows how to obtain nodes under a given node of the OPC-UA
// address space. For each node, it displays its browse name and node ID.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in Object Pascal (Delphi) on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-OP .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.
class procedure Browse.Main;
var
BrowseParameters: _UABrowseParameters;
BrowsePathParser: _UABrowsePathParser;
Client: OpcLabs_EasyOpcUA_TLB._EasyUAClient;
Count: Cardinal;
Element: OleVariant;
EndpointDescriptor: _UAEndpointDescriptor;
NodeDescriptor: _UANodeDescriptor;
NodeElement: _UANodeElement;
NodeElementEnumerator: IEnumVariant;
NodeElements: _UANodeElementCollection;
begin
EndpointDescriptor := CoUAEndpointDescriptor.Create;
EndpointDescriptor.UrlString :=
//'http://opcua.demo-this.com:51211/UA/SampleServer';
//'https://opcua.demo-this.com:51212/UA/SampleServer/';
'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer';
NodeDescriptor := CoUANodeDescriptor.Create;
BrowsePathParser := CoUABrowsePathParser.Create;
BrowsePathParser.DefaultNamespaceUriString := 'http://test.org/UA/Data/';
NodeDescriptor.BrowsePath := BrowsePathParser.Parse('[ObjectsFolder]/Data/Static/UserScalar');
BrowseParameters := CoUABrowseParameters.Create;
BrowseParameters.StandardName := 'AllForwardReferences';
// Instantiate the client object
Client := CoEasyUAClient.Create;
try
NodeElements := Client.Browse(
EndpointDescriptor,
NodeDescriptor,
BrowseParameters);
except
on E: EOleException do
begin
WriteLn(Format('*** Failure: %s', [E.GetBaseException.Message]));
Exit;
end;
end;
NodeElementEnumerator := NodeElements.GetEnumerator;
while (NodeElementEnumerator.Next(1, Element, Count) = S_OK) do
begin
NodeElement := IUnknown(Element) as _UANodeElement;
WriteLn(NodeElement.BrowseName.ToString, ': ', NodeElement.NodeId.ToString);
end;
end;
// This example shows how to obtain nodes under a given node of the OPC-UA address space.
// For each node, it displays its browse name and node ID.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in PHP on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-PHP .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.
$EndpointDescriptor = new COM("OpcLabs.EasyOpc.UA.UAEndpointDescriptor");
$EndpointDescriptor->UrlString =
//"http://opcua.demo-this.com:51211/UA/SampleServer";
//"https://opcua.demo-this.com:51212/UA/SampleServer/";
"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer";
$NodeDescriptor = new COM("OpcLabs.EasyOpc.UA.UANodeDescriptor");
$BrowsePathParser = new COM("OpcLabs.EasyOpc.UA.Navigation.Parsing.UABrowsePathParser");
$BrowsePathParser->DefaultNamespaceUriString = "http://test.org/UA/Data/";
$NodeDescriptor->BrowsePath = $BrowsePathParser->Parse("[ObjectsFolder]/Data/Static/UserScalar");
$BrowseParameters = new COM("OpcLabs.EasyOpc.UA.UABrowseParameters");
$BrowseParameters->StandardName = "AllForwardReferences";
// Instantiate the client object
$Client = new COM("OpcLabs.EasyOpc.UA.EasyUAClient");
// Perform the operation
try
{
$NodeElements = $Client->Browse($EndpointDescriptor, $NodeDescriptor, $BrowseParameters);
}
catch (com_exception $e)
{
printf("*** Failure: %s\n", $e->getMessage());
exit();
}
// Display results
foreach ($NodeElements as $NodeElement)
{
printf(" s\n", $NodeElement->BrowseName, $NodeElement->NodeId);
}
# This example shows how to obtain nodes under a given node of the OPC-UA address space.
# For each node, it displays its browse name and node ID.
#
# The Python for Windows (pywin32) extensions package is needed. Install it using "pip install pypiwin32".
# CAUTION: We now recommend using Python.NET package instead. Full set of examples with Python.NET is available!
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
import win32com.client
from pywintypes import com_error
endpointDescriptor = win32com.client.Dispatch('OpcLabs.EasyOpc.UA.UAEndpointDescriptor')
#endpointDescriptor.UrlString = 'http://opcua.demo-this.com:51211/UA/SampleServer'
endpointDescriptor.UrlString = 'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer'
nodeDescriptor = win32com.client.Dispatch('OpcLabs.EasyOpc.UA.UANodeDescriptor')
browsePathParser = win32com.client.Dispatch('OpcLabs.EasyOpc.UA.Navigation.Parsing.UABrowsePathParser')
browsePathParser.DefaultNamespaceUriString = 'http://test.org/UA/Data/'
nodeDescriptor.BrowsePath = browsePathParser.Parse('[ObjectsFolder]/Data/Static/UserScalar')
browseParameters = win32com.client.Dispatch('OpcLabs.EasyOpc.UA.UABrowseParameters')
browseParameters.StandardName = 'AllForwardReferences'
# Instantiate the client object
client = win32com.client.Dispatch('OpcLabs.EasyOpc.UA.EasyUAClient')
# Perform the operation
try:
nodeElements = client.Browse(endpointDescriptor, nodeDescriptor, browseParameters)
except com_error as e:
print('*** Failure: ' + e.args[2][1] + ': ' + e.args[2][2])
exit()
# Display results
for nodeElement in nodeElements:
print(nodeElement.BrowseName, ': ', nodeElement.NodeId)
REM This example shows how to obtain nodes under a given node of the OPC-UA address space.
REM For each node, it displays its browse name and node ID.
REM
REM Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
REM OPC client and subscriber examples in Visual Basic on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VB .
REM Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
REM a commercial license in order to use Online Forums, and we reply to every post.
Public Sub Browse_Main_Command_Click()
OutputText = ""
Dim endpointDescriptor As New UAEndpointDescriptor
endpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
Dim nodeDescriptor As New UANodeDescriptor
Dim BrowsePathParser As New UABrowsePathParser
BrowsePathParser.DefaultNamespaceUriString = "http://test.org/UA/Data/"
Set nodeDescriptor.browsePath = BrowsePathParser.Parse("[ObjectsFolder]/Data/Static/UserScalar")
Dim browseParameters As New UABrowseParameters
browseParameters.StandardName = "AllForwardReferences"
' Instantiate the client object
Dim Client As New EasyUAClient
' Perform the operation
On Error Resume Next
Dim NodeElements As UANodeElementCollection
Set NodeElements = Client.Browse(endpointDescriptor, nodeDescriptor, browseParameters)
If Err.Number <> 0 Then
OutputText = OutputText & "*** Failure: " & Err.Source & ": " & Err.Description & vbCrLf
Exit Sub
End If
On Error GoTo 0
' Display results
Dim NodeElement: For Each NodeElement In NodeElements
OutputText = OutputText & NodeElement.BrowseName & ": " & NodeElement.NodeId & vbCrLf
Next
End Sub
Rem This example shows how to obtain nodes under a given node of the OPC-UA address space.
Rem For each node, it displays its browse name and node ID.
Rem
Rem Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript .
Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
Rem a commercial license in order to use Online Forums, and we reply to every post.
Option Explicit
Dim EndpointDescriptor: Set EndpointDescriptor = CreateObject("OpcLabs.EasyOpc.UA.UAEndpointDescriptor")
EndpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
Dim NodeDescriptor: Set NodeDescriptor = CreateObject("OpcLabs.EasyOpc.UA.UANodeDescriptor")
Dim BrowsePathParser: Set BrowsePathParser = CreateObject("OpcLabs.EasyOpc.UA.Navigation.Parsing.UABrowsePathParser")
BrowsePathParser.DefaultNamespaceUriString = "http://test.org/UA/Data/"
NodeDescriptor.BrowsePath = BrowsePathParser.Parse("[ObjectsFolder]/Data/Static/UserScalar")
Dim BrowseParameters: Set BrowseParameters = CreateObject("OpcLabs.EasyOpc.UA.UABrowseParameters")
BrowseParameters.StandardName = "AllForwardReferences"
' Instantiate the client object
Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.UA.EasyUAClient")
' Perform the operation
On Error Resume Next
Dim NodeElements: Set NodeElements = Client.Browse(EndpointDescriptor, NodeDescriptor, BrowseParameters)
If Err.Number <> 0 Then
WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
WScript.Quit
End If
On Error Goto 0
' Display results
Dim NodeElement: For Each NodeElement In NodeElements
WScript.Echo NodeElement.BrowseName & ": " & NodeElement.NodeId
Next