OPC Studio User's Guide and Reference
OPC-UA Endpoint Dialog
View with Navigation Tools
Client and Subscriber Development > Features > User Interface > OPC Common Dialogs > OPC-UA Common Dialogs > OPC-UA Endpoint Dialog
In This Topic

General

Icon:

If you do not know upfront which OPC-UA server and its endpoint to connect to, and do not have this information from any other source, your application will need to allow the user select the OPC server(s) to work with. The OPC-UA Endpoint Dialog (UAEndpointDialog class) allows the user to select the OPC server and its endpoint interactively from the list of OPC Unified Architecture servers provided by a LDS (Local Discovery Server) installed on a machine.

Here is an example of OPC-UA Endpoint dialog in action:

To run the dialog, call the ShowDialog method. If the result is equal to DialogResult.OK, the user has selected the OPC UA server, and information about it can be retrieved from the DiscoveryElement property.

Currently, the dialog shows endpoint provided by a LDS (Local Discovery Server) that you set by a static property on the EasyUAClient object. This approach may change in future.

.NET

// This example shows how to let the user browse for an OPC-UA server endpoint.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

using System.Windows.Forms;
using OpcLabs.EasyOpc.UA.Forms.Browsing;

namespace UAFormsDocExamples._UAEndpointDialog
{
    static class ShowDialog
    {
        public static void Main1(IWin32Window owner)
        {
            var endpointDialog = new UAEndpointDialog
            {
                DiscoveryHost = "opcua.demo-this.com"
            };

            DialogResult dialogResult = endpointDialog.ShowDialog(owner);
            if (dialogResult != DialogResult.OK)
                return;

            // Display results
            MessageBox.Show(owner, endpointDialog.DiscoveryElement.ToString());
        }
    }
}

COM

// This example shows how to let the user browse for an OPC-UA server endpoint.
//
// Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

#include "stdafx.h"    // Includes "QuickOpc.h", and other commonly used files
#include "ShowDialog.h"

namespace _UAEndpointDialog
{
    void ShowDialog1::Main()
    {
        // Initialize the COM library
        CoInitializeEx(NULL, COINIT_MULTITHREADED);
        {
            // 
            _UAEndpointDialogPtr EndpointDialogPtr(__uuidof(UAEndpointDialog));

            //
            EndpointDialogPtr->DiscoveryHost = L"opcua.demo-this.com";

            // 
            DialogResult dialogResult = EndpointDialogPtr->ShowDialog(NULL);
            _tprintf(_T("%d\n"), dialogResult);

            if (dialogResult == 1/*OK*/)
            {
                // Display results
                _tprintf(_T("%s\n"), (LPCTSTR)CW2CT(EndpointDialogPtr->DiscoveryElement->ToString));
            }
        }
         // Release all interface pointers BEFORE calling CoUninitialize()
        CoUninitialize();
    }
}

 

Advanced

If you want to change the parameters of the client object the component uses to perform its OPC operations, you can use the ClientSelector Property.

 

See Also