// This example shows how to obtain information about OPC UA servers from the Global Discovery Server (GDS).
// The result is hierarchical, i.e. each server is returned in one element, and the element contains all its discovery URLs.
using System;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.Discovery;
using OpcLabs.EasyOpc.UA.OperationModel;
namespace UADocExamples._EasyUAClient
{
partial class DiscoverGlobalServers
{
public static void Hierarchical()
{
// Instantiate the client object
var client = new EasyUAClient();
// Obtain collection of application elements
UADiscoveryElementCollection discoveryElementCollection;
try
{
discoveryElementCollection = client.DiscoverGlobalServers(
"opc.tcp://opcua.demo-this.com:58810/GlobalDiscoveryServer",
flat:false);
}
catch (UAException uaException)
{
Console.WriteLine("*** Failure: {0}", uaException.GetBaseException().Message);
return;
}
// Display results
foreach (UADiscoveryElement discoveryElement in discoveryElementCollection)
{
Console.WriteLine();
Console.WriteLine("Server name: {0}", discoveryElement.ServerName);
Console.WriteLine("Discovery URI strings:");
foreach (string discoveryUriString in discoveryElement.DiscoveryUriStrings)
Console.WriteLine(" {0}", discoveryUriString);
Console.WriteLine("Server capabilities: {0}", discoveryElement.ServerCapabilities);
Console.WriteLine("Application URI string: {0}", discoveryElement.ApplicationUriString);
Console.WriteLine("Product URI string: {0}", discoveryElement.ProductUriString);
}
}
}
}
' This example shows how to obtain information about OPC UA servers from the Global Discovery Server (GDS).
' The result is hierarchical, i.e. each server is returned in one element, and the element contains all its discovery URLs.
Imports OpcLabs.EasyOpc.UA
Imports OpcLabs.EasyOpc.UA.Discovery
Imports OpcLabs.EasyOpc.UA.OperationModel
Namespace _EasyUAClient
Partial Friend Class DiscoverGlobalServers
Public Shared Sub Hierarchical()
' Instantiate the client object
Dim client = New EasyUAClient()
' Obtain collection of application elements
Dim discoveryElementCollection As UADiscoveryElementCollection
Try
discoveryElementCollection = client.DiscoverGlobalServers( _
"opc.tcp://opcua.demo-this.com:58810/GlobalDiscoveryServer",
flat:=False)
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 strings:")
For Each discoveryUriString As String In discoveryElement.DiscoveryUriStrings
Console.WriteLine(" {0}", discoveryUriString)
Next 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