如何在.Net C#上获取OPC UA服务器列表?

时间:2014-12-05 12:03:57

标签: list proxy server client opc-ua

我正在用C#编写OPC代理程序。我想获取localhost或机器远程的所有OPC-Server列表。我正在使用OPC基础V1.26的OPC UA .NET

我从Softing的“sampleDiscovery-Programm”中启发了我,现在我的服务器列表为ApplicationDescription

现在我想查看指定服务器的已连接客户端。使用Softing的示例“servers_control-Programm”,我可以看到服务器的所有客户端。但是这个类的构造函数需要服务器为StandardServerApplicationConfiguration

    public ServerForm(StandardServer server, ApplicationConfiguration configuration)
    {
        InitializeComponent();

        m_server = server;

        m_configuration = configuration;
        this.ServerDiagnosticsCTRL.Initialize(m_server, m_configuration);

        TrayIcon.Text = this.Text = m_configuration.ApplicationName;
        this.Icon = TrayIcon.Icon = ConfigUtils.GetAppIcon();
    }

如何将服务器的主服务器ApplicationDescription用作StandardServer?

1 个答案:

答案 0 :(得分:1)

您可以使用OPC Labs Quick OPC Calssic获取OPC UA serversC#列表的列表。

http://opclabs.com/products/quickopc/downloads

下载并安装QuickOPC 5.23(.NET Framework 3.5 or 4.0)QuickOPC 5.31(.NET Framework 4.5)

C#代码:

' Instantiate the client object
 Dim easyUAClient = New EasyUAClient()

' Obtain collection of server elements
Dim applicationElementCollection As UAApplicationElementCollection = easyUAClient.DiscoverServers()

' Display results
For Each applicationElement As UAApplicationElement In applicationElementCollection
    Console.WriteLine("applicationElementCollection[""{0}""].ApplicationUriString: {1}", _
                                  applicationElement.DiscoveryUriString, applicationElement.ApplicationUriString)
Next applicationElement

enter image description here