QuickOPC User's Guide and Reference
OpcLabs.EasyOpc.UA.PubSub.Configuration Namespace
Inheritance Hierarchy
OpcLabs.EasyOpcUA Assembly : OpcLabs.EasyOpc.UA.PubSub.Configuration Namespace
This namespace contains classes that facilitate easy work with OPC UA PubSub configuration.
Classes
 ClassDescription
ClassRepresents the broker specific transport mapping parameters for the PubSub connection.
ClassRepresents the broker specific transport mapping parameters for dataset writers.
ClassRepresents the broker specific transport mapping parameters for dataset writers.
ClassRepresent the broker specific transport mapping parameters for writer groups.
ClassIndicates configuration changes in the information published for a dataset.
ClassAn abstract base type for transport mapping specific PubSub connection parameters.
ClassRepresents the configuration parameters for the datagram transport protocol specific settings of PubSub connections.
ClassRepresents the datagram specific transport mapping parameters for writer groups.
ClassUsed to organize the published datasets in a tree of folders.
ClassA collection of OPC-UA dataset folders.
ClassDescribes the content and semantic of a dataset.
ClassAn abstract base type for message mapping specific dataset reader parameters.
ClassAn abstract base type for transport specific dataset reader parameters.
ClassRepresents the dataset writer parameters.
ClassA collection of OPC-UA dataset writers.
ClassRepresents a dataset writer element in the PubSub configuration.
ClassContains names of objects that specify the location of the dataset in the PubSub configuration.
ClassAn abstract base type for message mapping specific dataset writer parameters.
ClassAn abstract base type for transport mapping specific dataset writer parameters.
ClassContains qualified names of well-known OPC UA PubSub extension fields.
ClassProvide the metadata for a field in a dataset.
ClassA collection of OPC-UA field metadata.
ClassRepresents JSON message mapping specific dataset reader parameters.
ClassRepresents JSON dataset message mapping specific dataset writer parameters.
ClassRepresents the JSON network message mapping specific writer group parameters.
ClassRepresents published data items element in the PubSub configuration.
ClassRepresents a published dataset in the PubSub configuration.
ClassA collection of OPC-UA published datasets.
ClassRepresents a published dataset element in the PubSub configuration.
ClassRepresents a published dataset source element in the PubSub configuration.
ClassRepresents a published events element in the PubSub configuration.
ClassRepresents the configuration information for one variable.
ClassA collection of OPC-UA published variable configuration information.
ClassRepresents a PubSub component element in the PubSub configuration.
ClassRepresents the PubSub configuration.
ClassAn element that represents the PubSub configuration.
ClassRepresents a PubSub connection in the PubSub configuration.
ClassA collection of OPC-UA PubSub connections.
ClassRepresents a PubSub connection element in the PubSub configuration.
ClassRepresents a PubSub group element in the PubSub configuration.
ClassRepresents a PubSub object element in the PubSub configuration.
ClassAn abstract base type for message mapping specific reader group parameters.
ClassAn abstract base type for transport mapping specific reader group parameters.
ClassRepresents UADP message mapping specific dataset reader parameters.
ClassRepresents UADP dataset message mapping specific dataset writer parameters.
ClassRepresents the UADP network message mapping specific writer group parameters.
ClassRepresents a writer group in the PubSub configuration.
ClassA collection of OPC-UA writer groups.
ClassRepresents a writer group element in the PubSub configuration.
ClassA semi-abstract base type for message mapping specific writer group parameters.
ClassA semi-abstract base type for transport mapping specific writer group parameters.
Interfaces
 InterfaceDescription
InterfaceProvides read-only access to OPC UA PubSub configuration.
Enumerations
 EnumerationDescription
EnumerationDefines the quality of service for broker transport.
EnumerationDefines flags to include dataset field related information like status and timestamp in addition to the field value in the dataset message.
EnumerationDefines flags for DataSet fields.
EnumerationSpecifies the possible options for the ordering of dataset messages inside network messages.
EnumerationJSON message mapping specific flags for content of the dataset message header.
EnumerationJSON message mapping specific flags for content of the network message header.
EnumerationThe UADP message mapping specific flags for the content of the dataset message header.
EnumerationUADP message mapping specific flags for content of the network message header.
Remarks

 

Introduction

PubSub configuration describes the parameters of an OPC UA publisher and/or subscriber. It can be stored in a file, or it can be accessed through an information model in a "normal" OPC UA server.

Note that the use of PubSub configuration model is entirely optional. The model is standardized in OPC UA specifications, and when used, it must be used "as is". But, OPC UA publishers and subscribers may not use the configuration model at all, or they may choose to expose their configuration is some different way. 

If your intent is to use the PubSub configuration 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, QuickOPC only provides a read-only view of the PubSub configuration. That is, you cannot use QuickOPC to change anything in the PubSub configuration.

You can obtain the IUAReadOnlyPubSubConfiguration Interface by calling appropriate methods on the OPC UA Publish-Subscribe Client

Concepts

Most PubSub objects in the PubSub configuration are identified by their names. The name is usually a string, but some PubSub object are identified by an instance of UAQualifiedName Class.

Depending on the type of PubSub object and the structure of other arguments, sometimes a simple name of the PubSub object is enough to unambiguously locate it in the PubSub configuration. In other cases, the name is not sufficient, and a locator has to be used.

In this context, locator is a structure that consists of two or more names of PubSub objects. The names together unambiguously determine the location of the PubSub object in the PubSub configuration. For example, a dataset writer locator (represented by the UADataSetWriterLocator Class) contains

Published datasets are organized in a tree of dataset folders. Each published dataset has a name that must be unique not only in its dataset folder, but across the whole PubSub configuration. If a location of a published dataset in the PubSub configuration needs to be specified, a dataset folder path is used. The dataset folder path is a sequence of dataset folder names, starting from the root of the dataset folder tree.

Because published dataset names are unambiguous across the whole PubSub configuration, some methods allow you to omit the dataset folder path. In such case, you can pass a null reference in place of the dataset folder path, and the method will work on the whole tree. Note that a null reference in place of a dataset folder path is different from an empty path (a non-null, empty sequence): An empty dataset folder path denotes a "root" folder.

Some more information related to OPC UA PubSub configuration can be found in OPC UA PubSub logical identifiers.

Functionality

The methods available on the PubSub configuration allow you to look up PubSub objects using various criteria, and retrieve their data. They are grouped into several categories.

Looking up and searching for PubSub objects

PubSub objects can be looked up using their names. Methods that allow you to look up certain type of object in the PubSub configuration (sometimes given the location of their logical parent) are consistently called FindXXXX, where XXXX determines the type of PubSub object being looked up.

Attempt to look up an object that does not exist is not considered an error. When any of the FindXXXX does not find the PubSub object being looked up, it does not throw an exception. Instead, it simply returns a null reference. If the method call, however, contains argument that give location where the lookup is to be performed (e.g. the name of the PubSub connection when looking for a writer group), this location must be valid, otherwise an error occurs (UALogicalException Class).

List of the FindXXXX methods is below.

If you need to look for a published dataset (by its name) in a given dataset folder and its subfolders, use the SearchPublishedDataSet Method.

Determining PubSub object presence

In most cases, you can use one of the FindXXXX methods to determine whether a certain PubSub object is present in the PubSub configuration. The PubSub object with the given name is present if the result of the FindXXXX method is not null. Alternatively, you can use one of the ListXXXX methods, and check whether the PubSub object name is among those returned.

You can use the above described approaches, except:

The methods to determine the PubSub object presence are consistently named HasXXXX, where XXXX determines the type of PubSub object being tested for existence.

Getting PubSub object names and locators

If you do not know the names of certain PubSub objects, you can obtain the names from the PubSub configuration, usually given the location of some kind of logical parent. The methods that return the list of such names (or locators) are consistently called ListXXXX, where XXXX determines the type of PubSub object.

The methods below return names or locators of PubSub objects residing under a given parent.

There are also utility methods, built on top of others, that provide data about PubSub objects combined from multiple locations. They are briefly described below.

Retrieving PubSub objects

Methods that retrieve PubSub objects from the configuration are consistently named using the GetXXXX pattern. In most cases, a PubSub object can be retrieved by looking it up using one of the FindXXXX methods described above. For the remaining information in the PubSub configuration that cannot be accessed in this way, use one of the methods below.

The published dataset can optionally be associated with a published dataset source. The information about the published dataset source can be retrieved using the GetPublishedDataSetSourceElement Method. Because the published dataset source is optional, this method (and the methods that are derived from it - see further) returns null when the published dataset source is not configured - this is a difference from all other GetXXXX methods which never return null. The result of the GetPublishedDataSetSourceElement Method is polymorphic - its type depends on the type of the published dataset source, and it can be an instance of either UAPublishedDataItemsElement Class or UAPublishedEventsElement Class. If you know upfront which type of published dataset source you expect, you can use one of the extension methods, the GetPublishedDataItemsElement Method or GetPublishedEventsElement Method, to directly retrieve the desired type; they give an error if the actual type is not what you have coded for.

The methods below provide basically a functionality of the corresponding FindXXXX methods, with the difference that the PubSub object being looked up must exist; if not, the method gives an error. Consequently, in case of successful completion of any of these methods, the return value is never null. 

Sometimes you need to retrieve information for all child objects under certain parent. This is, in fact, a combination of a ListXXXXNames method and one of the GetXXXXElement methods above. For convenience, QuickOPC provides (extension) methods for this functionality already. The return type is always a keyed collection of elements, where the key is the name. The methods in this group are given below.

Examples

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.

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.

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

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: {0}", uaException.GetBaseException.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.

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.

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.

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.

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

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: {0}", uaException.GetBaseException.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.

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.

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.

 

 

See Also

Reference

OpcLabs.EasyOpcUA Assembly