using System; using System.Collections; using Opc.Ua; using Opc.Ua.Client; namespace Siemens.OpcUA { public class Discovery { #region Construction public Discovery() { } #endregion #region Public Interfaces /// /// Returns a list of OPC UA servers. /// /// The discovery URL. /// The servers being found. public void FindServers(Uri discoveryUrl, ref ApplicationDescriptionCollection servers) { try { // Create Discovery Client. DiscoveryClient client = DiscoveryClient.Create(discoveryUrl); // Look for servers. servers = client.FindServers(null); } catch (Exception e) { throw e; } } /// /// Returns a list of endpoints for a server. /// /// The discovery URL. /// The according endpoints. public string GetEndpoints(Uri discoveryUrl, ref EndpointDescriptionCollection endpoints) { int i = 0; try { // Create Discovery Client. DiscoveryClient client = DiscoveryClient.Create(discoveryUrl); i++; // Get endpoints. endpoints = client.GetEndpoints(null); i++; return ""; } catch (Exception e) { return e.StackTrace+e.Message+","+i.ToString(); throw e; } } #endregion } }