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