OPC Studio User's Guide and Reference
UAHostAndEndpointDialog Class
Members  Example 



View with Navigation Tools
OpcLabs.EasyOpcForms Assembly > OpcLabs.EasyOpc.UA.Forms.Browsing Namespace : UAHostAndEndpointDialog Class
Displays a dialog box from which the user can select a host (computer) and an endpoint of an OPC-UA server residing on it.
Object Model
UAHostAndEndpointDialog ClassEasyUAClientSelector ClassUADiscoveryElement ClassUAEndpointDescriptor ClassHostElement Class
Syntax
'Declaration
 
<CLSCompliantAttribute(True)>
<ComDefaultInterfaceAttribute(OpcLabs.EasyOpc.UA.Forms.Browsing.ComTypes._UAHostAndEndpointDialog)>
<ComVisibleAttribute(True)>
<GuidAttribute("0612DEF8-C143-45F4-A58F-C9C6A2B4AAA6")>
<TypeConverterAttribute(System.ComponentModel.ExpandableObjectConverter)>
<DesignerCategoryAttribute("Component")>
<SerializableAttribute()>
Public NotInheritable Class UAHostAndEndpointDialog 
   Inherits UADialog
   Implements OpcLabs.BaseLib.Forms.ComTypes._FormCommonDialog, OpcLabs.BaseLib.Forms.ComTypes._SizableCommonDialog, OpcLabs.BaseLib.Licensing.ILicensingContextHolder, OpcLabs.EasyOpc.UA.Forms.Browsing.ComTypes._UADialog, OpcLabs.EasyOpc.UA.Forms.Browsing.ComTypes._UAHostAndEndpointDialog, System.ComponentModel.IComponent, System.IDisposable 
 
'Usage
 
Dim instance As UAHostAndEndpointDialog
Remarks

This is a modal dialog box; therefore, when shown, it blocks the rest of the application until the user has made a selection. When a dialog box is displayed modally, no input (keyboard or mouse click) can occur except to objects on the dialog box. The program must hide or close the dialog box (usually in response to some user action) before input to the calling program can occur.

 

General

Icon:

With UAHostAndEndpointDialog, your application can integrate a dialog box from which the user can select a host (computer) and an endpoint of OPC-UA server residing on it. This dialog box combines functions of the Computer Browser Dialog and OPC-UA Endpoint Dialog -  into a single dialog.

In addition, the user can add Host nodes in case the particular computer is not visible on the network, or add OPC-UA Endpoint nodes in case the OPC-UA Server is known to exist but is not returned by OPC-UA discovery feature.

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

.NET

// This example shows how to let the user browse for a host (computer) and an endpoint of an OPC-UA server residing on it.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

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

namespace UAFormsDocExamples._UAHostAndEndpointDialog
{
    static class ShowDialog
    {
        public static void Main1(IWin32Window owner)
        {
            var hostAndEndpointDialog = new UAHostAndEndpointDialog
            {
                EndpointDescriptor = {Host = "opcua.demo-this.com"}
            };

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

            // Display results
            MessageBox.Show(owner, 
                $"HostElement: {hostAndEndpointDialog.HostElement}\r\n" +
                $"DiscoveryElement: {hostAndEndpointDialog.DiscoveryElement}");
        }
    }
}

COM

// This example shows how to let the user browse for a host (computer) and an endpoint of an OPC-UA server residing on it.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

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

namespace _UAHostAndEndpointDialog
{
    void ShowDialog::Main()
    {
        // Initialize the COM library
        CoInitializeEx(NULL, COINIT_MULTITHREADED);
        {
            // 
            _UAHostAndEndpointDialogPtr HostAndEndpointDialogPtr(__uuidof(UAHostAndEndpointDialog));

            //
            HostAndEndpointDialogPtr->EndpointDescriptor->Host = L"opcua.demo-this.com";

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

            if (dialogResult == 1/*OK*/)
            {
                // Display results
                _HostElementPtr hostElementPtr = HostAndEndpointDialogPtr->HostElement;
                _tprintf(_T("HostElement: %s\n"), (hostElementPtr == NULL) ? _T("") : (LPCTSTR)CW2CT(hostElementPtr->ToString));
                _UADiscoveryElementPtr discoveryElementPtr = HostAndEndpointDialogPtr->DiscoveryElement;
                _tprintf(_T("DiscoveryElement: %s\n"), (discoveryElementPtr == NULL) ? _T("") : (LPCTSTR)CW2CT(discoveryElementPtr->ToString));
            }
        }
         // Release all interface pointers BEFORE calling CoUninitialize()
        CoUninitialize();
    }
}

Python

# This example shows how to let the user browse for a host (computer) and an endpoint of an OPC-UA server residing on it.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
# a commercial license in order to use Online Forums, and we reply to every post.
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from System.Windows.Forms import *
from OpcLabs.EasyOpc.UA.Forms.Browsing import *


hostAndEndpointDialog = UAHostAndEndpointDialog()
hostAndEndpointDialog.EndpointDescriptor.Host = 'opcua.demo-this.com'

dialogResult = hostAndEndpointDialog.ShowDialog()
print(dialogResult)
if dialogResult != DialogResult.OK:
    exit()

# Display results.
print('HostElement: ', hostAndEndpointDialog.HostElement, sep='')
print('DiscoveryElement: ', hostAndEndpointDialog.DiscoveryElement, sep='')

print('Finished.')

 

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.

 

 

Example
// This example shows how to let the user browse for a host (computer) and an endpoint of an OPC-UA server residing on it.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

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

namespace UAFormsDocExamples._UAHostAndEndpointDialog
{
    static class ShowDialog
    {
        public static void Main1(IWin32Window owner)
        {
            var hostAndEndpointDialog = new UAHostAndEndpointDialog
            {
                EndpointDescriptor = {Host = "opcua.demo-this.com"}
            };

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

            // Display results
            MessageBox.Show(owner, 
                $"HostElement: {hostAndEndpointDialog.HostElement}\r\n" +
                $"DiscoveryElement: {hostAndEndpointDialog.DiscoveryElement}");
        }
    }
}
Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         System.Windows.Forms.CommonDialog
            OpcLabs.BaseLib.Forms.ConcreteCommonDialog
               OpcLabs.BaseLib.Forms.FormCommonDialog
                  OpcLabs.BaseLib.Forms.SizableCommonDialog
                     OpcLabs.EasyOpc.UA.Forms.Browsing.UADialog
                        OpcLabs.EasyOpc.UA.Forms.Browsing.UAHostAndEndpointDialog

Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows

See Also