OPC Studio User's Guide and Reference
IEasyUAPublishSubscribeClient Interface
Members  Example 



OpcLabs.EasyOpcUA Assembly > OpcLabs.EasyOpc.UA.PubSub.InformationModel Namespace : IEasyUAPublishSubscribeClient Interface
Provides client access to OPC UA PubSub information model.
Syntax
'Declaration
 
<ComVisibleAttribute(False)>
<ExceptionContractVerificationAttribute(True)>
Public Interface IEasyUAPublishSubscribeClient 
   Inherits OpcLabs.EasyOpc.UA.IEasyUASpecializedClient, System.IServiceProvider 
'Usage
 
Dim instance As IEasyUAPublishSubscribeClient
[ComVisible(false)]
[ExceptionContractVerification(true)]
public interface IEasyUAPublishSubscribeClient : OpcLabs.EasyOpc.UA.IEasyUASpecializedClient, System.IServiceProvider  
[ComVisible(false)]
[ExceptionContractVerification(true)]
public interface class IEasyUAPublishSubscribeClient : public OpcLabs.EasyOpc.UA.IEasyUASpecializedClient, System.IServiceProvider  
Remarks

The PubSub information model consists of the PubSub security key service model, and the PubSub configuration model.

 

Introduction

The OPC UA Publish-Subscribe Client is a specialized client object providing access to PubSub information model in OPC UA.

Note that although the OPC UA PubSub exchanges the data using its own protocols and can stay on its own, the information model provides additional useful integration with OPC UA infrastructure. The information model for OPC UA PubSub is accessed using "normal" OPC UA Client-Server technologies. This means that the OPC UA Publish-Subscribe Client accesses data in some "live" OPC UA server that must be available at the time your program makes the operations. Additionally,  the OPC UA Publish-Subscribe Client gives you access to OPC UA PubSub configuration data stored in files.

This specialized client object can be derived from IEasyUAClient Interface using the AsPublishSubscribeClient Extension Method, or it can be created standalone as EasyUAPublishSubscribeClient Component.

The EasyUAPublishSubscribeClient Class class does not have OPC UA Subscriber functionality; if you need that, see EasyUASubscriber Class instead.
If your intent is to use the PubSub configuration stored in the OPC UA information model to find data that would allow you to set up a PubSub subscription, you can use the built-in OPC UA PubSub logical resolution mechanism instead. This will save you lots of work.
Currently, the OPC UA Publish-Subscribe Client only provides a read-only view of the information model. That is, you cannot use it to change anything. In addition, only the parts relevant to OPC UA PubSub logical resolution are available (this means that the parts related to reader group and dataset reader configuration are left out).

Functionality

In order to access the PublishSubscribe element, which is at the top of the PubSub information model, use the GetPublishSubscribeElement Method. The PublishSubscribe element allows you to find out which transport profiles are supported by the publisher or subscriber associated with the server, using the SupportedTransportProfileUriStringSet Property.

The HasConfigurationModel Method determines whether the specified OPC UA server provides a PubSub configuration model. This allows you to make such test cleanly, without possibly causing an error (exception being thrown).

The "main" method of the OPC UA Publish-Subscribe client is the AccessReadOnlyConfiguration Method returns the IUAReadOnlyPubSubConfiguration Interface which provides read-only access to PubSub configuration provided by the specified server. If, instead of accessing the "live" configuration in the OPC server, you want to load the PubSub configuration from a specified file (in UABinary format), use the LoadReadOnlyConfiguration Method. The PubSub configuration interface then provides members described in Accessing OPC UA PubSub Configuration Model.

If your PubSub configuration is in the UABinary format, but not stored in a file, you can use the UAEncodedReadOnlyConfigurationLoader Property. It returns an instance of StreamLoader<TValue> Class which you can use to load the configuration from an array of bytes, a Stream, a managed resource, and so on.

For more functionality, and detailed information, see the Reference: IEasyUAPublishSubscribeClient InterfaceEasyUAPublishSubscribeClient Class and IEasyUAPublishSubscribeClientExtension Class.

Advanced: Loading PubSub configuration from a file node

Some OPC UA servers offer the PubSub configuration in form of a node representing the OPC UA file object. The file contains the PubSub configuration in the UABinary file, same as it would appear in a regular file (file on disk). This can be the only way the OPC UA server offers the PubSub configuration (possibly because the server is a small embedded server), or it can be in addition to the standard way of providing the PubSub configuration (which involves many related OPC UA nodes in a complex mesh). Representing the PubSub configuration in this way is practical for many uses cases practical. It was a non-standard practice in OPC UA 1.04 (and appeared mainly in servers built with Unified Automation toolkits). It has been standardized in OPC UA 1.05, albeit with a different node used for the PubSub configuration file. QuickOPC recognized both the standard node, and the node specific to Unified Automation toolkits.

QuickOPC has ability to load such PubSub configuration and work with it. If you know that the PubSub configuration is stored in this way in the server, you can use the LoadReadOnlyConfigurationFromFileNode Method to load it. There is also the HasConfigurationFileNode Method to test whether the "well-known" node with PubSub configuration is present in the server.

For generic case (when you do not know how the PubSub configuration is stored in the server), we recommend using the AccessOrLoadReadOnlyConfiguration Method. This method can decide dynamically, based on the actual OPC UA server contents, which approach to use to provide the PubSub configuration interface to you. The method has an otional argument which you can use to control which method of accessing the PubSub configuration will be used. Note the possible differences in behavior between the PubSub configuration interfaces returned in each case, described further in this article.

Differences between "live" and loaded PubSub configurations

Accessing a PubSub configuration that is "live" in the OPC UA server always gives you the current status of the configuration, at every moment you call some operation on the PubSub configuration interface. This may be a good thing (if you are interested in up-to-date state), but also a bad thing (because OPC UA does not provide transactional access to the PubSub configuration, the information may change while you are working with different parts of it, and your code needs to be able to deal with it). Accessing a "live" PubSub configuration is generally slow (each operation requires one or more OPC UA service calls), and it may fail at any time (any operation may return an error caused by inability to perform the intended OPC UA service on the server).

In contrast, when you load the PubSub configuration from a file (or OPC UA file node in the server), it represents a one-time snapshot that does not change by itself. It resides in memory, and accessing it is fast. If used correctly, it also generally does not return any errors.

Examples

For easy set up, the examples provided here access OPC UA PubSub configuration data stored in a pre-made binary configuration file. The same principle can, however, be used to access configuration data provided by an OPC server. There are commented statements in the examples that show how to do it.

The example below starts at the "root" of the PubSub configuration, and first obtains names of all PubSub connections available (they are at the 1st level). For each PubSub connection, given its name, it obtains names of writer groups configured on that PubSub connection (they are at the 2nd level). And, for each such writer group, given its name, it obtains names of all dataset writers configured on that writer group (they are at the 3rd level). Besides the PubSub object names, the commented parts also show how to obtain more detailed information about each PubSub object.

.NET

// This example obtains and prints out information about PubSub connections, writer groups, and dataset writers in the
// OPC UA PubSub configuration.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

using System;
using OpcLabs.BaseLib.Collections.Specialized;
using OpcLabs.EasyOpc.UA.OperationModel;
using OpcLabs.EasyOpc.UA.PubSub.Configuration;
using OpcLabs.EasyOpc.UA.PubSub.InformationModel;
using OpcLabs.EasyOpc.UA.PubSub.InformationModel.Extensions;

namespace UADocExamples.PubSub._IUAReadOnlyPubSubConfiguration
{
    partial class GetMethods
    {
        public static void PubSubComponents()
        {
            // 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 PubSub connections in the configuration, regardless of the folder they reside in.
                StringCollection pubSubConnectionNames = pubSubConfiguration.ListConnectionNames();
                foreach (string pubSubConnectionName in pubSubConnectionNames)
                {
                    Console.WriteLine($"PubSub connection: {pubSubConnectionName}");

                    // You can use the statement below to obtain parameters of the PubSub connection.
                    //UAPubSubConnectionElement connectionElement = 
                    //    pubSubConfiguration.GetConnectionElement(pubSubConnectionName);

                    // Get names of the writer groups on this PubSub connection.
                    StringCollection writerGroupNames = pubSubConfiguration.ListWriterGroupNames(pubSubConnectionName);
                    foreach (string writerGroupName in writerGroupNames)
                    {
                        Console.WriteLine($"  Writer group: {writerGroupName}");

                        // You can use the statement below to obtain parameters of the writer group.
                        //UAWriterGroupElement writerGroupElement = 
                        //    pubSubConfiguration.GetWriterGroupElement(pubSubConnectionName, writerGroupName);

                        // Get names of the dataset writers on this writer group.
                        StringCollection dataSetWriterNames =
                            pubSubConfiguration.ListDataSetWriterNames(pubSubConnectionName, writerGroupName);
                        foreach (string dataSetWriterName in dataSetWriterNames)
                        {
                            Console.WriteLine($"    Dataset writer: {dataSetWriterName}");

                            // You can use the statement below to obtain parameters of the dataset writer.
                            //UADataSetWriterElement dataSetWriterElement = pubSubConfiguration.GetDataSetWriterElement(
                            //    pubSubConnectionName, writerGroupName, dataSetWriterName);
                        }
                    }
                }
            }
            catch (UAException uaException)
            {
                Console.WriteLine($"*** Failure: {uaException.InnerException.Message}");
            }

            Console.WriteLine("Finished.");
        }

        // Example output:
        //
        //Loading the configuration...
        //PubSub connection: FixedLayoutConnection
        //  Writer group: FixedLayoutGroup
        //    Dataset writer: SimpleWriter
        //    Dataset writer: AllTypesWriter
        //    Dataset writer: MassTestWriter
        //PubSub connection: DynamicLayoutConnection
        //  Writer group: DynamicLayoutGroup
        //    Dataset writer: SimpleWriter
        //    Dataset writer: MassTestWriter
        //    Dataset writer: AllTypes-DynamicWriter
        //    Dataset writer: EventSimpleWriter
        //PubSub connection: FlexibleLayoutConnection
        //  Writer group: FlexibleLayoutGroup
        //    Dataset writer: SimpleWriter
        //    Dataset writer: MassTestWriter
        //    Dataset writer: AllTypes-DynamicWriter
        //Finished.
    }
}
# This example obtains and prints out information about PubSub connections, writer groups, and dataset writers 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 Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from OpcLabs.BaseLib import *
#from OpcLabs.EasyOpc.UA import *
#from OpcLabs.EasyOpc.UA.PubSub.Configuration.Extensions import *
from OpcLabs.EasyOpc.UA.OperationModel import *
from OpcLabs.EasyOpc.UA.PubSub.InformationModel import *
from OpcLabs.EasyOpc.UA.PubSub.InformationModel.Extensions import *
from OpcLabs.EasyOpc.UA.PubSub.OperationModel import *


# Instantiate the publish-subscribe client object.
publishSubscribeClient = EasyUAPublishSubscribeClient()

try:
    print('Loading the configuration...')
    # Load the PubSub configuration from a file. The file itself is in this script's directory.
    pubSubConfiguration = IEasyUAPublishSubscribeClientExtension.LoadReadOnlyConfiguration(publishSubscribeClient,
        'UADemoPublisher-Default.uabinary')

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

    # Get the names of PubSub connections in the configuration, regardless of the folder they reside in.
    pubSubConnectionNames = pubSubConfiguration.ListConnectionNames()
    for pubSubConnectionName in pubSubConnectionNames:
        print('PubSub connection: ', pubSubConnectionName, sep='')

        # You can use the statement below to obtain parameters of the PubSub connection.
        #connectionElement = IUAReadOnlyPubSubConfigurationExtension.GetConnectionElement(pubSubConfiguration,
        #    pubSubConnectionName)

        # Get names of the writer groups on this PubSub connection.
        writerGroupNames = pubSubConfiguration.ListWriterGroupNames(pubSubConnectionName)
        for writerGroupName in writerGroupNames:
            print('  Writer group: ', writerGroupName, sep='')

            # You can use the statement below to obtain parameters of the writer group.
            #writerGroupElement = IUAReadOnlyPubSubConfigurationExtension.GetWriterGroupElement(pubSubConfiguration,
            #    pubSubConnectionName, writerGroupName)

            # Get names of the dataset writers on this writer group.
            dataSetWriterNames = pubSubConfiguration.ListDataSetWriterNames(pubSubConnectionName, writerGroupName)
            for dataSetWriterName in dataSetWriterNames:
                print('    Dataset writer: ', dataSetWriterName, sep='')

                # You can use the statement below to obtain parameters of the dataset writer.
                #dataSetWriterElement = IUAReadOnlyPubSubConfigurationExtension.GetDataSetWriterElement(pubSubConfiguration,
                #    pubSubConnectionName, writerGroupName, dataSetWriterName)

except UAException as uaException:
    print('*** Failure: ' + uaException.GetBaseException().Message)
    exit()

print('Finished.')
' This example obtains and prints out information about PubSub connections, writer groups, and dataset writers in the
' OPC UA PubSub configuration.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Imports OpcLabs.EasyOpc.UA.OperationModel
Imports OpcLabs.EasyOpc.UA.PubSub.Configuration
'Imports OpcLabs.EasyOpc.UA.PubSub.Configuration.Extensions
Imports OpcLabs.EasyOpc.UA.PubSub.InformationModel
Imports OpcLabs.EasyOpc.UA.PubSub.InformationModel.Extensions

Namespace PubSub._IUAReadOnlyPubSubConfiguration
    Partial Friend Class GetMethods
        Public Shared Sub PubSubComponents()

            ' Instantiate the publish-subscribe client object.
            Dim 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.
                Dim pubSubConfiguration As IUAReadOnlyPubSubConfiguration =
                    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.
                'Dim pubSubConfiguration As IUAReadOnlyPubSubConfiguration =
                '    publishSubscribeClient.AccessReadOnlyConfiguration("opc.tcp://localhost:48010")

                ' Get the names of PubSub connections in the configuration, regardless of the folder they reside in.
                Dim pubSubConnectionNames = pubSubConfiguration.ListConnectionNames()
                For Each pubSubConnectionName As String In pubSubConnectionNames
                    Console.WriteLine($"PubSub connection: {pubSubConnectionName}")

                    ' You can use the statement below to obtain parameters of the PubSub connection.
                    'Dim connectionElement As UAPubSubConnectionElement =
                    '    pubSubConfiguration.GetConnectionElement(pubSubConnectionName)

                    ' Get names of the writer groups on this PubSub connection.
                    Dim writerGroupNames = pubSubConfiguration.ListWriterGroupNames(pubSubConnectionName)
                    For Each writerGroupName As String In writerGroupNames
                        Console.WriteLine($"  Writer group: {writerGroupName}")

                        ' You can use the statement below to obtain parameters of the writer group.
                        'Dim writerGroupElement As UAWriterGroupElement =
                        '    pubSubConfiguration.GetWriterGroupElement(pubSubConnectionName, writerGroupName)

                        ' Get names of the dataset writers on this writer group.
                        Dim dataSetWriterNames =
                            pubSubConfiguration.ListDataSetWriterNames(pubSubConnectionName, writerGroupName)
                        For Each dataSetWriterName As String In dataSetWriterNames
                            Console.WriteLine($"    Dataset writer: {dataSetWriterName}")

                            ' You can use the statement below to obtain parameters of the dataset writer.
                            'Dim dataSetWriterElement As UADataSetWriterElement = pubSubConfiguration.GetDataSetWriterElement(
                            '    pubSubConnectionName, writerGroupName, dataSetWriterName)
                        Next dataSetWriterName
                    Next writerGroupName
                Next pubSubConnectionName
            Catch uaException As UAException
                Console.WriteLine($"*** Failure: {uaException.InnerException.Message}")
            End Try

            Console.WriteLine("Finished...")
        End Sub
    End Class

    ' Example output
    '
    'Loading the configuration...
    'PubSub connection FixedLayoutConnection
    '  Writer group: FixedLayoutGroup
    '    Dataset writer: SimpleWriter
    '    Dataset writer: AllTypesWriter
    '    Dataset writer: MassTestWriter
    'PubSub connection: DynamicLayoutConnection
    '  Writer group: DynamicLayoutGroup
    '    Dataset writer: SimpleWriter
    '    Dataset writer: MassTestWriter
    '    Dataset writer: AllTypes-DynamicWriter
    '    Dataset writer: EventSimpleWriter
    'PubSub connection: FlexibleLayoutConnection
    '  Writer group: FlexibleLayoutGroup
    '    Dataset writer: SimpleWriter
    '    Dataset writer: MassTestWriter
    '    Dataset writer: AllTypes-DynamicWriter
    'Finished.

End Namespace

COM

// This example obtains and prints out information about PubSub connections, writer groups, and dataset writers in the
// OPC UA PubSub configuration.
//
// Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

class procedure GetMethods.PubSubComponents;
var
  //DataSetWriterElement: _UADataSetWriterElement;
  DataSetWriterName: string;
  DataSetWriterNames: _StringCollection;
  //EndpointDescriptor: _UAEndpointDescriptor;
  I, J, K: Integer;
  //PubSubConnectionElement: _UAPubSubConnectionElement;
  PubSubConnectionName: string;
  ConnectionNames: _StringCollection;
  PublishSubscribeClient: _EasyUAPublishSubscribeClient;
  PubSubConfiguration: _UAReadOnlyPubSubConfiguration;
  //WriterGroupElement: _UAWriterGroupElement;
  WriterGroupName: string;
  WriterGroupNames: _StringCollection;
begin
  // Instantiate the publish-subscribe client object.
  PublishSubscribeClient := CoEasyUAPublishSubscribeClient.Create;

  try
    WriteLn('Loading the configuration...');
    // Load the PubSub configuration from a file. The file itself is included alongside the script.
    PubSubConfiguration := PublishSubscribeClient.LoadReadOnlyConfiguration('UADemoPublisher-Default.uabinary');

    // Alternatively, using the statements below, you can access a live configuration residing in an OPC UA Server
    // with appropriate information model.
    //EndpointDescriptor := CoUAEndpointDescriptor.Create;
    //EndpointDescriptor.UrlString := 'opc.tcp://localhost:48010';
    //PubSubConfiguration := PublishSubscribeClient.AccessReadOnlyConfiguration(EndpointDescriptor);

    // Get the names of PubSub connections in the configuration.
    ConnectionNames := PubSubConfiguration.ListConnectionNames;

    for I := 0 to ConnectionNames.Count-1 do
    begin
      PubSubConnectionName := ConnectionNames[I];
      WriteLn('PubSub connection: ', PubSubConnectionName);

      // You can use the statement below to obtain parameters of the PubSub connection.
      //PubSubConnectionElement := PubSubConfiguration.GetConnectionElement(PubSubConnectionName);

      // Get names of the writer groups on this PubSub connection.
      WriterGroupNames := PubSubConfiguration.ListWriterGroupNames(PubSubConnectionName);
      for J := 0 to WriterGroupNames.Count-1 do
      begin
        WriterGroupName := WriterGroupNames[J];
        WriteLn('  Writer group: ', WriterGroupName);

        // You can use the statement below to obtain parameters of the writer group.
        //WriterGroupElement := PubSubConfiguration.GetWriterGroupElement(PubSubConnectionName, WriterGroupName);

        // Get names of the dataset writers on this writer group.
        DataSetWriterNames := PubSubConfiguration.ListDataSetWriterNames(PubSubConnectionName, WriterGroupName);
        for K := 0 to DataSetWriterNames.Count-1 do
        begin
          DataSetWriterName := DataSetWriterNames[K];
          WriteLn('    Dataset writer: ', DataSetWriterName);

          // You can use the statement below to obtain parameters of the dataset writer.
          //DataSetWriterElement := PubSubConfiguration.GetDataSetWriterElement(PubSubConnectionName, WriterGroupName, DataSetWriterName);
        end;
      end;
    end;
  except
    on E: EOleException do
    begin
      WriteLn(Format('*** Failure: %s', [E.GetBaseException.Message]));
    end;
  end;

  WriteLn('Finished.');
end;

// Example output:
//
//Loading the configuration...
//PubSub connection: FixedLayoutConnection
//  Writer group: FixedLayoutGroup
//    Dataset writer: SimpleWriter
//    Dataset writer: AllTypesWriter
//    Dataset writer: MassTestWriter
//PubSub connection: DynamicLayoutConnection
//  Writer group: DynamicLayoutGroup
//    Dataset writer: SimpleWriter
//    Dataset writer: MassTestWriter
//    Dataset writer: AllTypes-DynamicWriter
//    Dataset writer: EventSimpleWriter
//PubSub connection: FlexibleLayoutConnection
//  Writer group: FlexibleLayoutGroup
//    Dataset writer: SimpleWriter
//    Dataset writer: MassTestWriter
//    Dataset writer: AllTypes-DynamicWriter
//Finished.
Rem This example obtains and prints out information about PubSub connections, writer groups, and dataset writers in the
Rem OPC UA PubSub configuration.
Rem
Rem Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Option Explicit

' Instantiate the publish-subscribe client object.
Dim PublishSubscribeClient: Set PublishSubscribeClient = CreateObject("OpcLabs.EasyOpc.UA.PubSub.InformationModel.EasyUAPublishSubscribeClient")

On Error Resume Next
DumpPubSubComponents
If Err.Number <> 0 Then
    WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
    WScript.Quit
End If
On Error Goto 0

WScript.Echo "Finished."



Sub DumpPubSubComponents()
    WScript.Echo "Loading the configuration..."
    ' Load the PubSub configuration from a file. The file itself is included alongside the script.
    Dim PubSubConfiguration: Set PubSubConfiguration = PublishSubscribeClient.LoadReadOnlyConfiguration("UADemoPublisher-Default.uabinary")

    ' Alternatively, using the statements below, you can access a live configuration residing in an OPC UA Server
    ' with appropriate information model.
    'Dim EndpointDescriptor: Set EndpointDescriptor = CreateObject("OpcLabs.EasyOpc.UA.UAEndpointDescriptor")
    'EndpointDescriptor.UrlString = "opc.tcp://localhost:48010"
    'Dim PubSubConfiguration: Set PubSubConfiguration = PublishSubscribeClient.AccessReadOnlyConfiguration(EndpointDescriptor)

    ' Get the names of PubSub connections in the configuration.
    Dim ConnectionNames: Set ConnectionNames = PubSubConfiguration.ListConnectionNames
    Dim pubSubConnectionName: For Each pubSubConnectionName In ConnectionNames
        WScript.Echo "PubSub connection: " & pubSubConnectionName

        ' You can use the statement below to obtain parameters of the PubSub connection.
        'Dim PubSubConnectionElement: Set PubSubConnectionElement = PubSubConfiguration.GetConnectionElement(pubSubConnectionName)

        ' Get names of the writer groups on this PubSub connection.
        Dim WriterGroupNames: Set WriterGroupNames = PubSubConfiguration.ListWriterGroupNames(pubSubConnectionName)
        Dim writerGroupName: For Each writerGroupName In WriterGroupNames
            WScript.Echo "  Writer group: " & writerGroupName

            ' You can use the statement below to obtain parameters of the writer group.
            'Dim WriterGroupElement: Set WriterGroupElement = PubSubConfiguration.GetWriterGroupElement(pubSubConnectionName, writerGroupName)

            ' Get names of the dataset writers on this writer group.
            Dim DataSetWriterNames: Set DataSetWriterNames = PubSubConfiguration.ListDataSetWriterNames(pubSubConnectionName, writerGroupName)
            Dim dataSetWriterName: For Each dataSetWriterName In DataSetWriterNames
                WScript.Echo "    Dataset writer: " & dataSetWriterName

                ' You can use the statement below to obtain parameters of the dataset writer.
                'Dim DataSetWriterElement: Set DataSetWriterElement = _
                '    PubSubConfiguration.GetDataSetWriterElement(pubSubConnectionName, writerGroupName, dataSetWriterName)
            Next
        Next
    Next
End Sub



' Example output:
'
'Loading the configuration...
'PubSub connection: FixedLayoutConnection
'  Writer group: FixedLayoutGroup
'    Dataset writer: SimpleWriter
'    Dataset writer: AllTypesWriter
'    Dataset writer: MassTestWriter
'PubSub connection: DynamicLayoutConnection
'  Writer group: DynamicLayoutGroup
'    Dataset writer: SimpleWriter
'    Dataset writer: MassTestWriter
'    Dataset writer: AllTypes-DynamicWriter
'    Dataset writer: EventSimpleWriter
'PubSub connection: FlexibleLayoutConnection
'  Writer group: FlexibleLayoutGroup
'    Dataset writer: SimpleWriter
'    Dataset writer: MassTestWriter
'    Dataset writer: AllTypes-DynamicWriter
'Finished.

 

The example below uses the ListAllPublishedDataSetNames Method to retrieve all published dataset from the PubSub configuration. The published datasets are actually organized in the PubSub configuration using a hierarchical structure of dataset folders. The word "all" in the method name denotes that the method will truly return all published datasets in the configuration, not just those at the "root" of the dataset folder structure, or in any specified dataset folder. The method will act recursively in the dataset folder structure, if needed. There are also methods that allow you to work with contents of individual dataset folders. Note that the published dataset names are unique across the PubSub configuration as a whole (regardless of their location in the dataset folder structure), and therefore a published dataset name is sufficient to identify the published dataset, and the dataset folder path is not strictly necessary.

.NET

// 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 .

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 UADocExamples.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.
    }
}
# 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 Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from OpcLabs.BaseLib import *
#from OpcLabs.EasyOpc.UA import *
from OpcLabs.EasyOpc.UA.OperationModel import *
from OpcLabs.EasyOpc.UA.PubSub.Configuration.Extensions import *
from OpcLabs.EasyOpc.UA.PubSub.InformationModel import *
from OpcLabs.EasyOpc.UA.PubSub.InformationModel.Extensions import *
from OpcLabs.EasyOpc.UA.PubSub.OperationModel import *


# Instantiate the publish-subscribe client object.
publishSubscribeClient = EasyUAPublishSubscribeClient()

try:
    print('Loading the configuration...')
    # Load the PubSub configuration from a file. The file itself is in this script's directory.
    pubSubConfiguration = IEasyUAPublishSubscribeClientExtension.LoadReadOnlyConfiguration(publishSubscribeClient,
        'UADemoPublisher-Default.uabinary')

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

    # Get the names of all published datasets in the PubSub configuration.
    publishedDataSetNames = IUAReadOnlyPubSubConfigurationExtension.ListAllPublishedDataSetNames(pubSubConfiguration)

    for publishedDataSetName in publishedDataSetNames:
        print('Published dataset: ', publishedDataSetName, sep='')

        # You can use the statement below to obtain parameters of the published dataset.
        #publishedDataSetElement = IUAReadOnlyPubSubConfigurationExtension.GetPublishedDataSetElement(
        #    pubSubConfiguration,
        #    publishedDataSetName)

except UAException as uaException:
    print('*** Failure: ' + uaException.GetBaseException().Message)
    exit()

print('Finished.')
' 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 .

Imports OpcLabs.EasyOpc.UA.OperationModel
Imports OpcLabs.EasyOpc.UA.PubSub.Configuration
Imports OpcLabs.EasyOpc.UA.PubSub.Configuration.Extensions
Imports OpcLabs.EasyOpc.UA.PubSub.InformationModel
Imports OpcLabs.EasyOpc.UA.PubSub.InformationModel.Extensions

Namespace PubSub._IUAReadOnlyPubSubConfiguration
    Partial Friend Class GetMethods
        Public Shared Sub PublishedDataSets()

            ' Instantiate the publish-subscribe client object.
            Dim 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.
                Dim pubSubConfiguration As IUAReadOnlyPubSubConfiguration =
                    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.
                'Dim pubSubConfiguration As IUAReadOnlyPubSubConfiguration =
                '    publishSubscribeClient.AccessReadOnlyConfiguration("opc.tcp://localhost:48010")

                ' Get the names of all published datasets in the PubSub configuration.
                Dim publishedDataSetNames = pubSubConfiguration.ListAllPublishedDataSetNames()

                For Each publishedDataSetName As String In publishedDataSetNames
                    Console.WriteLine($"Published dataset: {publishedDataSetName}")

                    ' You can use the statement below to obtain parameters of the published dataset.
                    'Dim publishedDataSetElement As UAPublishedDataSetElement =
                    '    pubSubConfiguration.GetPublishedDataSetElement(publishedDataSetName)
                Next publishedDataSetName
            Catch uaException As UAException
                Console.WriteLine($"*** Failure: {uaException.InnerException.Message}")
            End Try

            Console.WriteLine("Finished...")
        End Sub
    End Class

    ' Example output
    '
    'Loading the configuration...
    'Published dataset Simple
    'Published dataset: AllTypes
    'Published dataset: MassTest
    'Published dataset: AllTypes-Dynamic
    'Finished.

End Namespace

COM

// 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 .

class procedure GetMethods.PublishedDataSets;
var
  //EndpointDescriptor: _UAEndpointDescriptor;
  I: Integer;
  PublishedDataSetName: string;
  PublishedDataSetNames: _StringCollection;
  //PublishedDataSetElement: _UAPublishedDataSetElement;
  PublishSubscribeClient: _EasyUAPublishSubscribeClient;
  PubSubConfiguration: _UAReadOnlyPubSubConfiguration;
begin
  // Instantiate the publish-subscribe client object.
  PublishSubscribeClient := CoEasyUAPublishSubscribeClient.Create;

  try
    WriteLn('Loading the configuration...');
    // Load the PubSub configuration from a file. The file itself is included alongside the script.
    PubSubConfiguration := PublishSubscribeClient.LoadReadOnlyConfiguration('UADemoPublisher-Default.uabinary');

    // Alternatively, using the statements below, you can access a live configuration residing in an OPC UA Server
    // with appropriate information model.
    //EndpointDescriptor := CoUAEndpointDescriptor.Create;
    //EndpointDescriptor.UrlString := 'opc.tcp://localhost:48010';
    //PubSubConfiguration := PublishSubscribeClient.AccessReadOnlyConfiguration(EndpointDescriptor);

    // Get the names of PubSub connections in the configuration, regardless of the folder they reside in.
    PublishedDataSetNames := PubSubConfiguration.ListAllPublishedDataSetNames;

    for I := 0 to PublishedDataSetNames.Count-1 do
    begin
      PublishedDataSetName := PublishedDataSetNames[I];
      WriteLn('Published dataset: ', PublishedDataSetName);

      // You can use the statement below to obtain parameters of the published dataset.
      //PublishedDataSetElement := PubSubConfiguration.GetPublishedDataSetElement(Unassigned, PublishedDataSetName);
    end;
  except
    on E: EOleException do
    begin
      WriteLn(Format('*** Failure: %s', [E.GetBaseException.Message]));
    end;
  end;

  WriteLn('Finished.');
end;

// Example output:
//
//Loading the configuration...
//Published dataset: Simple
//Published dataset: AllTypes
//Published dataset: MassTest
//Published dataset: AllTypes-Dynamic
//Finished.
Rem This example obtains and prints out information about all published datasets in the OPC UA PubSub configuration.
Rem
Rem Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Option Explicit

' Instantiate the publish-subscribe client object.
Dim PublishSubscribeClient: Set PublishSubscribeClient = CreateObject("OpcLabs.EasyOpc.UA.PubSub.InformationModel.EasyUAPublishSubscribeClient")

On Error Resume Next
DumpPublishedDataSets
If Err.Number <> 0 Then
    WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
    WScript.Quit
End If
On Error Goto 0

WScript.Echo "Finished."



Sub DumpPublishedDataSets()
    WScript.Echo "Loading the configuration..."
    ' Load the PubSub configuration from a file. The file itself is included alongside the script.
    Dim PubSubConfiguration: Set PubSubConfiguration = PublishSubscribeClient.LoadReadOnlyConfiguration("UADemoPublisher-Default.uabinary")

    ' Alternatively, using the statements below, you can access a live configuration residing in an OPC UA Server
    ' with appropriate information model.
    'Dim EndpointDescriptor: Set EndpointDescriptor = CreateObject("OpcLabs.EasyOpc.UA.UAEndpointDescriptor")
    'EndpointDescriptor.UrlString = "opc.tcp://localhost:48010"
    'Dim PubSubConfiguration: Set PubSubConfiguration = PublishSubscribeClient.AccessReadOnlyConfiguration(EndpointDescriptor)

    ' Get the names of PubSub connections in the configuration, regardless of the folder they reside in.
    Dim PublishedDataSetNames: Set PublishedDataSetNames = PubSubConfiguration.ListAllPublishedDataSetNames

    Dim publishedDataSetName: For Each publishedDataSetName In PublishedDataSetNames
        WScript.Echo "Published dataset: " & publishedDataSetName

        ' You can use the statement below to obtain parameters of the published dataset.
        'Dim PublishedDataSetElement: Set PublishedDataSetElement = PubSubConfiguration.GetPublishedDataSetElement(Nothing, publishedDataSetName)
    Next
End Sub



' Example output:
'
'Loading the configuration...
'Published dataset: Simple
'Published dataset: AllTypes
'Published dataset: MassTest
'Published dataset: AllTypes-Dynamic
'Finished.

 

The features discussed here, or some of them, may not be available in all editions of the product. Check the Product Editions page for differences between the editions. The trial license has all features enabled (and is limited in period for which it provides valid data), but licenses for specific commercial editions may have functionality limitations.

 

Example

.NET

COM

// 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 .

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 UADocExamples.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.
    }
}
# 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 Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from OpcLabs.BaseLib import *
#from OpcLabs.EasyOpc.UA import *
from OpcLabs.EasyOpc.UA.OperationModel import *
from OpcLabs.EasyOpc.UA.PubSub.Configuration.Extensions import *
from OpcLabs.EasyOpc.UA.PubSub.InformationModel import *
from OpcLabs.EasyOpc.UA.PubSub.InformationModel.Extensions import *
from OpcLabs.EasyOpc.UA.PubSub.OperationModel import *


# Instantiate the publish-subscribe client object.
publishSubscribeClient = EasyUAPublishSubscribeClient()

try:
    print('Loading the configuration...')
    # Load the PubSub configuration from a file. The file itself is in this script's directory.
    pubSubConfiguration = IEasyUAPublishSubscribeClientExtension.LoadReadOnlyConfiguration(publishSubscribeClient,
        'UADemoPublisher-Default.uabinary')

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

    # Get the names of all published datasets in the PubSub configuration.
    publishedDataSetNames = IUAReadOnlyPubSubConfigurationExtension.ListAllPublishedDataSetNames(pubSubConfiguration)

    for publishedDataSetName in publishedDataSetNames:
        print('Published dataset: ', publishedDataSetName, sep='')

        # You can use the statement below to obtain parameters of the published dataset.
        #publishedDataSetElement = IUAReadOnlyPubSubConfigurationExtension.GetPublishedDataSetElement(
        #    pubSubConfiguration,
        #    publishedDataSetName)

except UAException as uaException:
    print('*** Failure: ' + uaException.GetBaseException().Message)
    exit()

print('Finished.')
' 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 .

Imports OpcLabs.EasyOpc.UA.OperationModel
Imports OpcLabs.EasyOpc.UA.PubSub.Configuration
Imports OpcLabs.EasyOpc.UA.PubSub.Configuration.Extensions
Imports OpcLabs.EasyOpc.UA.PubSub.InformationModel
Imports OpcLabs.EasyOpc.UA.PubSub.InformationModel.Extensions

Namespace PubSub._IUAReadOnlyPubSubConfiguration
    Partial Friend Class GetMethods
        Public Shared Sub PublishedDataSets()

            ' Instantiate the publish-subscribe client object.
            Dim 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.
                Dim pubSubConfiguration As IUAReadOnlyPubSubConfiguration =
                    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.
                'Dim pubSubConfiguration As IUAReadOnlyPubSubConfiguration =
                '    publishSubscribeClient.AccessReadOnlyConfiguration("opc.tcp://localhost:48010")

                ' Get the names of all published datasets in the PubSub configuration.
                Dim publishedDataSetNames = pubSubConfiguration.ListAllPublishedDataSetNames()

                For Each publishedDataSetName As String In publishedDataSetNames
                    Console.WriteLine($"Published dataset: {publishedDataSetName}")

                    ' You can use the statement below to obtain parameters of the published dataset.
                    'Dim publishedDataSetElement As UAPublishedDataSetElement =
                    '    pubSubConfiguration.GetPublishedDataSetElement(publishedDataSetName)
                Next publishedDataSetName
            Catch uaException As UAException
                Console.WriteLine($"*** Failure: {uaException.InnerException.Message}")
            End Try

            Console.WriteLine("Finished...")
        End Sub
    End Class

    ' Example output
    '
    'Loading the configuration...
    'Published dataset Simple
    'Published dataset: AllTypes
    'Published dataset: MassTest
    'Published dataset: AllTypes-Dynamic
    'Finished.

End Namespace
// 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 .

class procedure GetMethods.PublishedDataSets;
var
  //EndpointDescriptor: _UAEndpointDescriptor;
  I: Integer;
  PublishedDataSetName: string;
  PublishedDataSetNames: _StringCollection;
  //PublishedDataSetElement: _UAPublishedDataSetElement;
  PublishSubscribeClient: _EasyUAPublishSubscribeClient;
  PubSubConfiguration: _UAReadOnlyPubSubConfiguration;
begin
  // Instantiate the publish-subscribe client object.
  PublishSubscribeClient := CoEasyUAPublishSubscribeClient.Create;

  try
    WriteLn('Loading the configuration...');
    // Load the PubSub configuration from a file. The file itself is included alongside the script.
    PubSubConfiguration := PublishSubscribeClient.LoadReadOnlyConfiguration('UADemoPublisher-Default.uabinary');

    // Alternatively, using the statements below, you can access a live configuration residing in an OPC UA Server
    // with appropriate information model.
    //EndpointDescriptor := CoUAEndpointDescriptor.Create;
    //EndpointDescriptor.UrlString := 'opc.tcp://localhost:48010';
    //PubSubConfiguration := PublishSubscribeClient.AccessReadOnlyConfiguration(EndpointDescriptor);

    // Get the names of PubSub connections in the configuration, regardless of the folder they reside in.
    PublishedDataSetNames := PubSubConfiguration.ListAllPublishedDataSetNames;

    for I := 0 to PublishedDataSetNames.Count-1 do
    begin
      PublishedDataSetName := PublishedDataSetNames[I];
      WriteLn('Published dataset: ', PublishedDataSetName);

      // You can use the statement below to obtain parameters of the published dataset.
      //PublishedDataSetElement := PubSubConfiguration.GetPublishedDataSetElement(Unassigned, PublishedDataSetName);
    end;
  except
    on E: EOleException do
    begin
      WriteLn(Format('*** Failure: %s', [E.GetBaseException.Message]));
    end;
  end;

  WriteLn('Finished.');
end;

// Example output:
//
//Loading the configuration...
//Published dataset: Simple
//Published dataset: AllTypes
//Published dataset: MassTest
//Published dataset: AllTypes-Dynamic
//Finished.
Rem This example obtains and prints out information about all published datasets in the OPC UA PubSub configuration.
Rem
Rem Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Option Explicit

' Instantiate the publish-subscribe client object.
Dim PublishSubscribeClient: Set PublishSubscribeClient = CreateObject("OpcLabs.EasyOpc.UA.PubSub.InformationModel.EasyUAPublishSubscribeClient")

On Error Resume Next
DumpPublishedDataSets
If Err.Number <> 0 Then
    WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
    WScript.Quit
End If
On Error Goto 0

WScript.Echo "Finished."



Sub DumpPublishedDataSets()
    WScript.Echo "Loading the configuration..."
    ' Load the PubSub configuration from a file. The file itself is included alongside the script.
    Dim PubSubConfiguration: Set PubSubConfiguration = PublishSubscribeClient.LoadReadOnlyConfiguration("UADemoPublisher-Default.uabinary")

    ' Alternatively, using the statements below, you can access a live configuration residing in an OPC UA Server
    ' with appropriate information model.
    'Dim EndpointDescriptor: Set EndpointDescriptor = CreateObject("OpcLabs.EasyOpc.UA.UAEndpointDescriptor")
    'EndpointDescriptor.UrlString = "opc.tcp://localhost:48010"
    'Dim PubSubConfiguration: Set PubSubConfiguration = PublishSubscribeClient.AccessReadOnlyConfiguration(EndpointDescriptor)

    ' Get the names of PubSub connections in the configuration, regardless of the folder they reside in.
    Dim PublishedDataSetNames: Set PublishedDataSetNames = PubSubConfiguration.ListAllPublishedDataSetNames

    Dim publishedDataSetName: For Each publishedDataSetName In PublishedDataSetNames
        WScript.Echo "Published dataset: " & publishedDataSetName

        ' You can use the statement below to obtain parameters of the published dataset.
        'Dim PublishedDataSetElement: Set PublishedDataSetElement = PubSubConfiguration.GetPublishedDataSetElement(Nothing, publishedDataSetName)
    Next
End Sub



' Example output:
'
'Loading the configuration...
'Published dataset: Simple
'Published dataset: AllTypes
'Published dataset: MassTest
'Published dataset: AllTypes-Dynamic
'Finished.
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