2014-12-05 97 views
0

我正在用C#編寫一個OPC代理程序。我想獲得所有OPC-Server的列表,或localhost或機器的遠端。我使用OPC基礎版的OPC UA .NET V1.26如何獲得.Net C#上的OPC UA服務器列表?

我從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

你有沒有嘗試過這麼遠嗎?請包括你有什麼和你面臨的問題 – fejese 2014-12-05 12:05:25

+0

爲什麼我可以從類型爲ApplicationDescription的服務器獲得currentInstance? – Brigitte 2014-12-05 14:57:53

回答

1

您可以使用OPC Labs Quick OPC Calssic獲取C#列表中的od OPC UA servers列表。

下載並安裝QuickOPC 5.23(.NET Framework 3.5 or 4.0)QuickOPC 5.31(.NET Framework 4.5)http://opclabs.com/products/quickopc/downloads

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