// This example shows how to obtain properties under the "Server" node in the address space.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
using System;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.AddressSpace;
using OpcLabs.EasyOpc.UA.AddressSpace.Standard;
using OpcLabs.EasyOpc.UA.OperationModel;
namespace UADocExamples._EasyUAClient
{
class BrowseProperties
{
public static void Overload2()
{
UAEndpointDescriptor endpointDescriptor =
"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer";
// or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
// or "https://opcua.demo-this.com:51212/UA/SampleServer/"
// Instantiate the client object
var client = new EasyUAClient();
// Obtain properties under "Server" node.
UANodeElementCollection nodeElementCollection;
try
{
nodeElementCollection = client.BrowseProperties(endpointDescriptor, UAObjectIds.Server);
}
catch (UAException uaException)
{
Console.WriteLine($"*** Failure: {uaException.GetBaseException().Message}");
return;
}
// Display results
foreach (UANodeElement nodeElement in nodeElementCollection)
{
Console.WriteLine();
Console.WriteLine($"nodeElement.DisplayName: {nodeElement.DisplayName}");
Console.WriteLine($"nodeElement.NodeId: {nodeElement.NodeId}");
Console.WriteLine($"nodeElement.NodeId.ExpandedText: {nodeElement.NodeId.ExpandedText}");
}
}
// Example output:
//
//nodeElement.DisplayName: ServerArray
//nodeElement.NodeId: Server_ServerArray
//nodeElement.NodeId.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=2254
//
//nodeElement.DisplayName: NamespaceArray
//nodeElement.NodeId: Server_NamespaceArray
//nodeElement.NodeId.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=2255
//
//nodeElement.DisplayName: ServiceLevel
//nodeElement.NodeId: Server_ServiceLevel
//nodeElement.NodeId.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=2267
//
//nodeElement.DisplayName: Auditing
//nodeElement.NodeId: Server_Auditing
//nodeElement.NodeId.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=2994
}
}
# This example shows how to obtain properties under the "Server" node in the address space.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
#requires -Version 5.1
using namespace OpcLabs.EasyOpc.UA
using namespace OpcLabs.EasyOpc.UA.AddressSpace.Standard
using namespace OpcLabs.EasyOpc.UA.OperationModel
# The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows .
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcUA.dll"
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcUAComponents.dll"
[UAEndpointDescriptor]$endpointDescriptor =
"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
# or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
# or "https://opcua.demo-this.com:51212/UA/SampleServer/"
# Instantiate the client object.
$client = New-Object EasyUAClient
# Obtain objects under "Server" node.
try {
$nodeElementCollection = [IEasyUAClientExtension]::BrowseProperties($client,
$endpointDescriptor, [UAObjectIds]::Server)
}
catch [UAException] {
Write-Host "*** Failure: $($PSItem.Exception.GetBaseException().Message)"
return
}
# Display results
foreach ($nodeElement in $nodeElementCollection) {
Write-Host
Write-Host "nodeElement.DisplayName: $($nodeElement.DisplayName)"
Write-Host "nodeElement.NodeId: $($nodeElement.NodeId)"
Write-Host "nodeElement.NodeId.ExpandedText: $($nodeElement.NodeId.ExpandedText)"
}
# Example output:
#
#nodeElement.DisplayName: ServerArray
#nodeElement.NodeId: Server_ServerArray
#nodeElement.NodeId.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=2254
#
#nodeElement.DisplayName: NamespaceArray
#nodeElement.NodeId: Server_NamespaceArray
#nodeElement.NodeId.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=2255
#
#nodeElement.DisplayName: ServiceLevel
#nodeElement.NodeId: Server_ServiceLevel
#nodeElement.NodeId.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=2267
#
#nodeElement.DisplayName: Auditing
#nodeElement.NodeId: Server_Auditing
#nodeElement.NodeId.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=2994
# This example shows how to obtain properties under the "Server" node in the address space.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc
# Import .NET namespaces.
from OpcLabs.EasyOpc.UA import *
from OpcLabs.EasyOpc.UA.AddressSpace import *
from OpcLabs.EasyOpc.UA.AddressSpace.Standard import *
from OpcLabs.EasyOpc.UA.OperationModel import *
endpointDescriptor = UAEndpointDescriptor('opc.tcp://opcua.demo-this.com:51210/UA/SampleServer')
# or 'http://opcua.demo-this.com:51211/UA/SampleServer' (currently not supported)
# or 'https://opcua.demo-this.com:51212/UA/SampleServer/'
# Instantiate the client object.
client = EasyUAClient()
# Obtain objects under "Server" node.
try:
nodeElementCollection = IEasyUAClientExtension.BrowseProperties(client,
endpointDescriptor,
UANodeDescriptor(UAObjectIds.Server))
except UAException as uaException:
print('*** Failure: ' + uaException.GetBaseException().Message)
exit()
# Display results.
for nodeElement in nodeElementCollection:
print()
print('nodeElement.DisplayName: ', nodeElement.DisplayName, sep='')
print('nodeElement.NodeId: ', nodeElement.NodeId, sep='')
print('nodeElement.NodeId.ExpandedText: ', nodeElement.NodeId.ExpandedText, sep='')
print()
print('Finished.')
' This example shows how to obtain properties under the "Server" node in the address space.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
Imports OpcLabs.EasyOpc.UA
Imports OpcLabs.EasyOpc.UA.AddressSpace
Imports OpcLabs.EasyOpc.UA.AddressSpace.Standard
Imports OpcLabs.EasyOpc.UA.OperationModel
Namespace _EasyUAClient
Friend Class BrowseProperties
Public Shared Sub Overload2()
' Define which server we will work with.
Dim endpointDescriptor As UAEndpointDescriptor =
"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
' or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
' or "https://opcua.demo-this.com:51212/UA/SampleServer/"
' Instantiate the client object
Dim client = New EasyUAClient()
' Obtain properties under "Server" node
Dim nodeElementCollection As UANodeElementCollection
Try
nodeElementCollection = client.BrowseProperties(endpointDescriptor, UAObjectIds.Server)
Catch uaException As UAException
Console.WriteLine("*** Failure: {0}", uaException.GetBaseException.Message)
Exit Sub
End Try
' Display results
For Each nodeElement As UANodeElement In nodeElementCollection
Console.WriteLine()
Console.WriteLine("nodeElement.NodeId: {0}", nodeElement.NodeId)
Console.WriteLine("nodeElement.DisplayName: {0}", nodeElement.DisplayName)
Next nodeElement
' Example output:
'
'nodeElement.NodeId: nsu=http://opcfoundation.org/UA/;i=2254
'nodeElement.DisplayName: ServerArray
'
'nodeElement.NodeId: nsu=http://opcfoundation.org/UA/;i=2255
'nodeElement.DisplayName: NamespaceArray
'
'nodeElement.NodeId: nsu=http://opcfoundation.org/UA/;i=2267
'nodeElement.DisplayName: ServiceLevel
'
'nodeElement.NodeId: nsu=http://opcfoundation.org/UA/;i=2994
'nodeElement.DisplayName: Auditing }
End Sub
End Class
End Namespace