// This example shows how to obtain information about OPC UA servers available on the network.
// The result is flat, i.e. each discovery URL is returned in separate element, with possible repetition of the servers.
//
// 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.Discovery;
using OpcLabs.EasyOpc.UA.OperationModel;
namespace UADocExamples._EasyUAClient
{
partial class DiscoverNetworkServers
{
public static void Main1()
{
// Instantiate the client object.
var client = new EasyUAClient();
// Obtain collection of application elements.
UADiscoveryElementCollection discoveryElementCollection;
try
{
discoveryElementCollection = client.DiscoverNetworkServers("opcua.demo-this.com");
}
catch (UAException uaException)
{
Console.WriteLine($"*** Failure: {uaException.GetBaseException().Message}");
return;
}
// Display results.
foreach (UADiscoveryElement discoveryElement in discoveryElementCollection)
{
Console.WriteLine();
Console.WriteLine($"Server name: {discoveryElement.ServerName}");
Console.WriteLine($"Discovery URI string: {discoveryElement.DiscoveryUriString}");
Console.WriteLine($"Server capabilities: {discoveryElement.ServerCapabilities}");
Console.WriteLine($"Application URI string: {discoveryElement.ApplicationUriString}");
Console.WriteLine($"Product URI string: {discoveryElement.ProductUriString}");
}
}
}
}
# This example shows how to obtain information about OPC UA servers available on the network.
# The result is flat, i.e. each discovery URL is returned in separate element, with possible repetition of the servers.
#
# 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.Discovery
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"
# Instantiate the client object.
$client = New-Object EasyUAClient
# Obtain collection of application elements.
try {
$discoveryElementCollection = [IEasyUAClientExtension]::DiscoverNetworkServers($client, "opcua.demo-this.com")
}
catch [UAException] {
Write-Host "*** Failure: $($PSItem.Exception.GetBaseException().Message)"
return
}
# Display results.
foreach ($discoveryElement in $discoveryElementCollection) {
Write-Host
Write-Host "Server name: $($discoveryElement.ServerName)"
Write-Host "Discovery URI string: $($discoveryElement.DiscoveryUriString)"
Write-Host "Server capabilities: $($discoveryElement.ServerCapabilities)"
Write-Host "Application URI string: $($discoveryElement.ApplicationUriString)"
Write-Host "Product URI string: $($discoveryElement.ProductUriString)"
}
# This example shows how to obtain information about OPC UA servers available on the network.
# The result is flat, i.e. each discovery URL is returned in separate element, with possible repetition of the servers.
#
# 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.Discovery import *
from OpcLabs.EasyOpc.UA.OperationModel import *
# Instantiate the client object.
client = EasyUAClient()
# Obtain collection of application elements.
try:
discoveryElementCollection = IEasyUAClientExtension.DiscoverNetworkServers(client, 'opcua.demo-this.com')
except UAException as uaException:
print('*** Failure: ' + uaException.GetBaseException().Message)
exit()
# Display results.
for discoveryElement in discoveryElementCollection:
print()
print('Server name: ', discoveryElement.ServerName, sep='')
print('Discovery URI string: ', discoveryElement.DiscoveryUriString, sep='')
print('Server capabilities: ', discoveryElement.ServerCapabilities, sep='')
print('Application URI string: ', discoveryElement.ApplicationUriString, sep='')
print('Product URI string: ', discoveryElement.ProductUriString, sep='')
print()
print('Finished.')
' This example shows how to obtain information about OPC UA servers available on the network.
' The result is flat, i.e. each discovery URL is returned in separate element, with possible repetition of the servers.
'
' 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.Discovery
Imports OpcLabs.EasyOpc.UA.OperationModel
Namespace _EasyUAClient
Partial Friend Class DiscoverNetworkServers
Public Shared Sub Main1()
' Instantiate the client object
Dim client = New EasyUAClient()
' Obtain collection of application elements
Dim discoveryElementCollection As UADiscoveryElementCollection
Try
discoveryElementCollection = client.DiscoverNetworkServers("opcua.demo-this.com")
Catch uaException As UAException
Console.WriteLine("*** Failure: {0}", uaException.GetBaseException.Message)
Exit Sub
End Try
' Display results
For Each discoveryElement As UADiscoveryElement In discoveryElementCollection
Console.WriteLine()
Console.WriteLine("Server name: {0}", discoveryElement.ServerName)
Console.WriteLine("Discovery URI string: {0}", discoveryElement.DiscoveryUriString)
Console.WriteLine("Server capabilities: {0}", discoveryElement.ServerCapabilities)
Console.WriteLine("Application URI string: {0}", discoveryElement.ApplicationUriString)
Console.WriteLine("Product URI string: {0}", discoveryElement.ProductUriString)
Next discoveryElement
End Sub
End Class
End Namespace