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



View with Navigation Tools
OpcLabs.EasyOpcUAComponents Assembly > OpcLabs.EasyOpc.UA.PubSub.InformationModel Namespace : EasyUAPublishSubscribeClient Class
A specialized client object for OPC UA PubSub information model.
Object Model
EasyUAPublishSubscribeClient ClassIEasyUAClient InterfaceEasyUAClientSelector ClassIEasyUAClient InterfaceIUAReadOnlyModelProvider Interface
Syntax
'Declaration
 
<CLSCompliantAttribute(True)>
<ComDefaultInterfaceAttribute(OpcLabs.EasyOpc.UA.PubSub.InformationModel.ComTypes._EasyUAPublishSubscribeClient)>
<ComVisibleAttribute(True)>
<GuidAttribute("0CBFF3B4-A000-445F-A931-9AFAA496A234")>
<TypeConverterAttribute(System.ComponentModel.ExpandableObjectConverter)>
<DesignerCategoryAttribute("Component")>
<SerializableAttribute()>
Public NotInheritable Class EasyUAPublishSubscribeClient 
   Inherits EasyUAPublishSubscribeClientCore
   Implements OpcLabs.BaseLib.Arrangement.IQueryTraits, OpcLabs.BaseLib.IValueEquatable, OpcLabs.BaseLib.Licensing.ILicensingContextHolder, OpcLabs.BaseLib.Widgets.ComTypes._Widget, OpcLabs.BaseLib.Widgets.IWidget, OpcLabs.EasyOpc.UA.ComTypes._EasyUASpecializedClient, OpcLabs.EasyOpc.UA.IEasyUASpecializedClient, OpcLabs.EasyOpc.UA.PubSub.InformationModel.ComTypes._EasyUAPublishSubscribeClient, IEasyUAPublishSubscribeClient, System.ComponentModel.IComponent, System.ICloneable, System.IDisposable, System.IServiceProvider, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable 
 
'Usage
 
Dim instance As EasyUAPublishSubscribeClient
Remarks

This class does *not* have OPC UA Subscriber functionality; if you need that, see OpcLabs.EasyOpc.UA.PubSub.EasyUASubscriber.

Example
// This example obtains and prints out information about all published datasets in the OPC UA PubSub configuration.
//
// 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;
using OpcLabs.BaseLib.Collections.Specialized;
using OpcLabs.EasyOpc.UA.OperationModel;
using OpcLabs.EasyOpc.UA.PubSub.Configuration;
using OpcLabs.EasyOpc.UA.PubSub.Configuration.Extensions;
using OpcLabs.EasyOpc.UA.PubSub.InformationModel;
using OpcLabs.EasyOpc.UA.PubSub.InformationModel.Extensions;

namespace UASubscriberDocExamples.PubSub._IUAReadOnlyPubSubConfiguration
{
    partial class GetMethods
    {
        public static void PublishedDataSets()
        {
            // Instantiate the publish-subscribe client object.
            var publishSubscribeClient = new EasyUAPublishSubscribeClient();

            try
            {
                Console.WriteLine("Loading the configuration...");
                // Load the PubSub configuration from a file. The file itself is at the root of the project, and we have
                // specified that it has to be copied to the project's output directory.
                IUAReadOnlyPubSubConfiguration pubSubConfiguration = 
                    publishSubscribeClient.LoadReadOnlyConfiguration("UADemoPublisher-Default.uabinary");

                // Alternatively, using the statement below, you can access a live configuration residing in an OPC UA
                // Server with appropriate information model.
                //IUAReadOnlyPubSubConfiguration pubSubConfiguration =
                //    publishSubscribeClient.AccessReadOnlyConfiguration("opc.tcp://localhost:48010");

                // Get the names of all published datasets in the PubSub configuration.
                StringCollection publishedDataSetNames = pubSubConfiguration.ListAllPublishedDataSetNames();

                foreach (string publishedDataSetName in publishedDataSetNames)
                {
                    Console.WriteLine($"Published dataset: {publishedDataSetName}");

                    // You can use the statement below to obtain parameters of the published dataset.
                    //UAPublishedDataSetElement publishedDataSetElement = 
                    //    pubSubConfiguration.GetPublishedDataSetElement(publishedDataSetName);
                }
            }
            catch (UAException uaException)
            {
                Console.WriteLine($"*** Failure: {uaException.InnerException.Message}");
            }

            Console.WriteLine("Finished.");
        }

        // Example output:
        //
        //Loading the configuration...
        //Published dataset: Simple
        //Published dataset: AllTypes
        //Published dataset: MassTest
        //Published dataset: AllTypes-Dynamic
        //Finished.
    }
}
Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         OpcLabs.BaseLib.Widgets.Widget
            OpcLabs.EasyOpc.UA.EasyUASpecializedClient
               OpcLabs.EasyOpc.UA.PubSub.InformationModel.EasyUAPublishSubscribeClientCore
                  OpcLabs.EasyOpc.UA.PubSub.InformationModel.EasyUAPublishSubscribeClient

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