Search code examples
listproxyserverclientopc-ua

How can I get the list of OPC UA servers on .Net C#?


I'm writing a OPC proxy program in C#. I want to get the list of all OPC-Server on localhost or remote of the machine. I'm using OPC UA .NET from OPC foundation V1.26

I inspired me from the "sampleDiscovery-Programm" of Softing and I have now my list of servers as ApplicationDescription.

Now I want to see the connected client of a specified server. With the sample "servers_control-Programm" from Softing, I can see all client of a server. But the constructor of this class need servers as StandardServer and the ApplicationConfiguration

    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();
    }

How can I use main servers as ApplicationDescription for a servers as StandardServer?


Solution

  • You can use OPC Labs Quick OPC Calssic to get the list od OPC UA servers list in VB.NET.

    Download and install QuickOPC 5.23(.NET Framework 3.5 or 4.0) or QuickOPC 5.31(.NET Framework 4.5) from http://opclabs.com/products/quickopc/downloads

    VB.NET Code:

    ' 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