OPC Studio User's Guide and Reference
BrowseProperties Method (IEasyDAClientExtension)
Example 



OpcLabs.EasyOpcClassicCore Assembly > OpcLabs.EasyOpc.DataAccess Namespace > IEasyDAClientExtension Class : BrowseProperties Method
The client object that will perform the operation.

This is typically the EasyDAClient object.

The value of this parameter cannot be null (Nothing in Visual Basic).

Name of the machine (empty string for local computer).

The value represents a UNC or DNS computer name. Any string can be passed to this parameter (i.e. will not cause System.ArgumentException), but not all values make sense and will work when an operation using them is attempted. IPv6 addresses are normally enclosed between '[' and ']'.

The value of this parameter cannot be null (Nothing in Visual Basic).

Contains ProgID of the OPC server to browse.

The value of this parameter cannot be null (Nothing in Visual Basic).

ID of the item for which the properties will be browsed.

The value of this parameter cannot be null (Nothing in Visual Basic).

Browses the available properties of a specified OPC item.

Browse for available item properties. Specify machine name, server class, and item ID.

Syntax
'Declaration
 
<ExtensionAttribute()>
<NotNullAttribute()>
Public Shared Function BrowseProperties( _
   ByVal client As IEasyDAClient, _
   ByVal machineName As String, _
   ByVal serverClass As String, _
   ByVal itemId As String _
) As DAPropertyElementCollection
'Usage
 
Dim client As IEasyDAClient
Dim machineName As String
Dim serverClass As String
Dim itemId As String
Dim value As DAPropertyElementCollection
 
value = IEasyDAClientExtension.BrowseProperties(client, machineName, serverClass, itemId)

Parameters

client
The client object that will perform the operation.

This is typically the EasyDAClient object.

The value of this parameter cannot be null (Nothing in Visual Basic).

machineName
Name of the machine (empty string for local computer).

The value represents a UNC or DNS computer name. Any string can be passed to this parameter (i.e. will not cause System.ArgumentException), but not all values make sense and will work when an operation using them is attempted. IPv6 addresses are normally enclosed between '[' and ']'.

The value of this parameter cannot be null (Nothing in Visual Basic).

serverClass
Contains ProgID of the OPC server to browse.

The value of this parameter cannot be null (Nothing in Visual Basic).

itemId
ID of the item for which the properties will be browsed.

The value of this parameter cannot be null (Nothing in Visual Basic).

Return Value

The method returns a keyed collection of OpcLabs.EasyOpc.DataAccess.AddressSpace.DAPropertyElement values, each containing information about a particular property found. The keys of the keyed collection are the IDs of the properties.

This method never returns null (Nothing in Visual Basic).

The individual elements of the returned value are never null (Nothing in Visual Basic).

Exceptions
ExceptionDescription

A null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.

This is a usage error, i.e. it will never occur (the exception will not be thrown) in a correctly written program. Your code should not catch this exception.

The OPC "Classic" (or OPC XML-DA) operation has failed. This operation exception in uniformly used to allow common handling of various kinds of errors. The System.Exception.InnerException always contains information about the actual error cause.

This is an operation error that depends on factors external to your program, and thus cannot be always avoided. Your code must handle it appropriately.

Remarks

The server(s) can be local or can be remotely accessed via DCOM.

This is an extension method (info: C#, VB.NET). In languages that have support for extensions methods (such as C# and VB.NET), you can use the extension method as if it were a regular method on the object that is its first parameter. In other languages (such as with Python.NET), you will call the extension as a static method, and pass it the object on which it acts as its first parameter.

Example
// This example shows how to enumerate all properties of an OPC item. For each property, it displays its Id and description.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

using System;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.DataAccess.AddressSpace;
using OpcLabs.EasyOpc.OperationModel;

namespace DocExamples.DataAccess._EasyDAClient
{
    class BrowseProperties
    {
        public static void Main1()
        {
            // Instantiate the client object.
            var client = new EasyDAClient();
            DAPropertyElementCollection propertyElements;
            try
            {
                propertyElements = client.BrowseProperties("OPCLabs.KitServer.2", "Simulation.Random");
            }
            catch (OpcException opcException)
            {
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
                return;
            }

            foreach (DAPropertyElement propertyElement in propertyElements)
                Console.WriteLine($"PropertyElements(\"{propertyElement.PropertyId.NumericalValue}\").Description: {propertyElement.Description}");
        }


        // Example output:
        //
        //PropertyElements("15008").Description: Visible
        //PropertyElements("5").Description: Item Access Rights
        //PropertyElements("2").Description: Item Value
        //PropertyElements("7").Description: Item EU Type
        //PropertyElements("15001").Description: Item Name
        //PropertyElements("4").Description: Item Timestamp
        //PropertyElements("1").Description: Item Canonical Data Type
        //PropertyElements("103").Description: Low EU
        //PropertyElements("15009").Description: Addable
        //PropertyElements("6").Description: Server Scan Rate
        //PropertyElements("15000").Description: Item ID
        //PropertyElements("3").Description: Item Quality
    }
}
# This example shows how to enumerate all properties of an OPC item. For each property, it displays its Id and description.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in PowerShell on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-PowerShell .
# Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
# a commercial license in order to use Online Forums, and we reply to every post.

#requires -Version 5.1
using namespace OpcLabs.EasyOpc.OperationModel
using namespace OpcLabs.EasyOpc.DataAccess

# The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows .
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassicCore.dll"
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassic.dll"
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassicComponents.dll"

# Instantiate the client object.
$client = New-Object EasyDAClient

try {
    $propertyElements = $client.BrowseProperties("OPCLabs.KitServer.2", "Simulation.Random")
}
catch [OpcException] {
    Write-Host "*** Failure: $($PSItem.Exception.GetBaseException().Message)"
    return
}

Foreach ($propertyElement in $propertyElements) {
    Write-Host "PropertyElements(`"$($propertyElement.PropertyId.NumericalValue)`").Description: $($propertyElement.Description)"
}


# Example output:
#
#PropertyElements("15008").Description: Visible
#PropertyElements("5").Description: Item Access Rights
#PropertyElements("2").Description: Item Value
#PropertyElements("7").Description: Item EU Type
#PropertyElements("15001").Description: Item Name
#PropertyElements("4").Description: Item Timestamp
#PropertyElements("1").Description: Item Canonical Data Type
#PropertyElements("103").Description: Low EU
#PropertyElements("15009").Description: Addable
#PropertyElements("6").Description: Server Scan Rate
#PropertyElements("15000").Description: Item ID
#PropertyElements("3").Description: Item Quality
' This example shows how to enumerate all properties of an OPC item. For each property, it displays its Id and description.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET .
' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
' a commercial license in order to use Online Forums, and we reply to every post.

Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.DataAccess.AddressSpace
Imports OpcLabs.EasyOpc.OperationModel

Namespace DataAccess._EasyDAClient
    Partial Friend Class BrowseProperties
        Shared Sub Main1()
            Dim client = New EasyDAClient()

            Dim propertyElements As DAPropertyElementCollection
            Try
                propertyElements = client.BrowseProperties("OPCLabs.KitServer.2", "Simulation.Random")
            Catch opcException As OpcException
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message)
                Exit Sub
            End Try

            For Each propertyElement In propertyElements
                Console.WriteLine($"PropertyElements(""{propertyElement.PropertyId.NumericalValue}"").Description: {propertyElement.Description}")
            Next propertyElement

        End Sub

        ' Example output
        '
        'PropertyElements("15008").Description: Visible
        'PropertyElements("5").Description: Item Access Rights
        'PropertyElements("2").Description: Item Value
        'PropertyElements("7").Description: Item EU Type
        'PropertyElements("15001").Description: Item Name
        'PropertyElements("4").Description: Item Timestamp
        'PropertyElements("1").Description: Item Canonical Data Type
        'PropertyElements("103").Description: Low EU
        'PropertyElements("15009").Description: Addable
        'PropertyElements("6").Description: Server Scan Rate
        'PropertyElements("15000").Description: Item ID
        'PropertyElements("3").Description: Item Quality
    End Class
End Namespace
// This example shows how to enumerate all properties of an OPC item. For each property, it displays its Id and description.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in Object Pascal (Delphi) on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-OP .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

class procedure BrowseProperties.Main;
var
  Client: OpcLabs_EasyOpcClassic_TLB._EasyDAClient;
  Count: Cardinal;
  Element: OleVariant;
  ServerDescriptor: _ServerDescriptor;
  NodeDescriptor: _DANodeDescriptor;
  PropertyElement: _DAPropertyElement;
  PropertyElementEnumerator: IEnumVariant;
  PropertyElements: _DAPropertyElementCollection;
begin
  ServerDescriptor := CoServerDescriptor.Create;
  ServerDescriptor.ServerClass := 'OPCLabs.KitServer.2';

  NodeDescriptor := CoDANodeDescriptor.Create;
  NodeDescriptor.ItemId := 'Simulation.Random';

  // Instantiate the client object
  Client := CoEasyDAClient.Create;

  try
    PropertyElements := Client.BrowseProperties(
      ServerDescriptor,
      NodeDescriptor);
  except
    on E: EOleException do
    begin
      WriteLn(Format('*** Failure: %s', [E.GetBaseException.Message]));
      Exit;
    end;
  end;

  PropertyElementEnumerator := PropertyElements.GetEnumerator;
  while (PropertyElementEnumerator.Next(1, Element, Count) = S_OK) do
  begin
    PropertyElement := IUnknown(Element) as _DAPropertyElement;
    WriteLn('PropertyElements("', PropertyElement.PropertyId.NumericalValue, '").Description: ', PropertyElement.Description);
  end;
end;
// This example shows how to enumerate all properties of an OPC item. For each property, it displays its Id and description.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in PHP on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-PHP .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

$ServerDescriptor = new COM("OpcLabs.EasyOpc.ServerDescriptor");
$ServerDescriptor->ServerClass = "OPCLabs.KitServer.2";

$NodeDescriptor = new COM("OpcLabs.EasyOpc.DataAccess.DANodeDescriptor");
$NodeDescriptor->ItemID = "Simulation.Random";

$Client = new COM("OpcLabs.EasyOpc.DataAccess.EasyDAClient");

try
{
    $PropertyElements = $Client->BrowseProperties($ServerDescriptor, $NodeDescriptor);
}
catch (com_exception $e)
{
    printf("*** Failure: %s\n", $e->getMessage());
    Exit();
}

foreach ($PropertyElements as $PropertyElement)
{
    printf("PropertyElements(\"s\").Descriptions\n", $PropertyElement->PropertyID->NumericalValue, $PropertyElement->Description);
}
REM This example shows how to enumerate all properties of an OPC item. For each property, it displays its Id and description.
REM
REM Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
REM OPC client and subscriber examples in Visual Basic on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VB .
REM Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
REM a commercial license in order to use Online Forums, and we reply to every post.

Private Sub BrowseProperties_Main_Command_Click()
    OutputText = ""
    
    Dim serverDescriptor As New serverDescriptor
    serverDescriptor.ServerClass = "OPCLabs.KitServer.2"
    
    Dim nodeDescriptor As New DANodeDescriptor
    nodeDescriptor.itemId = "Simulation.Random"
    
    ' Instantiate the client object
    Dim client As New EasyDAClient

    On Error Resume Next
    Dim propertyElements As DAPropertyElementCollection
    Set propertyElements = client.BrowseProperties(serverDescriptor, nodeDescriptor)
    If Err.Number <> 0 Then
        OutputText = OutputText & "*** Failure: " & Err.Source & ": " & Err.Description & vbCrLf
        Exit Sub
    End If
    On Error GoTo 0

    Dim propertyElement: For Each propertyElement In propertyElements
        OutputText = OutputText & "propertyElements(""" & propertyElement.propertyId.NumericalValue & """).Description: " & propertyElement.Description & vbCrLf
    Next
End Sub
Rem This example shows how to enumerate all properties of an OPC item. For each property, it displays its Id and description.
Rem
Rem Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript .
Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
Rem a commercial license in order to use Online Forums, and we reply to every post.

Option Explicit

Dim ServerDescriptor: Set ServerDescriptor = CreateObject("OpcLabs.EasyOpc.ServerDescriptor")
ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"

Dim NodeDescriptor: Set NodeDescriptor = CreateObject("OpcLabs.EasyOpc.DataAccess.DANodeDescriptor")
NodeDescriptor.ItemID = "Simulation.Random"

Dim EasyDAClient: Set EasyDAClient = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient")
On Error Resume Next
Dim PropertyElements: Set PropertyElements = EasyDAClient.BrowseProperties(ServerDescriptor, NodeDescriptor)
If Err.Number <> 0 Then
    WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
    WScript.Quit
End If
On Error Goto 0

Dim PropertyElement: For Each PropertyElement In PropertyElements
    WScript.Echo "PropertyElements(""" & PropertyElement.PropertyID.NumericalValue & """).Description: " & PropertyElement.Description
Next
# This example shows how to enumerate all properties of an OPC item. For each property, it displays its Id and
# description.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
# a commercial license in order to use Online Forums, and we reply to every post.
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.OperationModel import *


# Instantiate the client object.
client = EasyDAClient()

# Perform the operation.
try:
    propertyElements = IEasyDAClientExtension.BrowseProperties(client, '', 'OPCLabs.KitServer.2', 'Simulation.Random')
except OpcException as opcException:
    print('*** Failure: ' + opcException.GetBaseException().Message)
    exit()

# Display results.
for propertyElement in propertyElements:
    print('PropertyElements[', propertyElement.PropertyId.NumericalValue, '].Description: ', propertyElement.Description,
          sep='')
// This example shows how to enumerate all properties of an OPC XML-DA item. For each property, it displays its Id and description.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

using System;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.DataAccess.AddressSpace;
using OpcLabs.EasyOpc.OperationModel;

namespace DocExamples.DataAccess.Xml
{
    class BrowseProperties
    {
        public static void Main1Xml()
        {
            // Instantiate the client object.
            var client = new EasyDAClient();
            DAPropertyElementCollection propertyElements;
            try
            {
                propertyElements = client.BrowseProperties("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx", "Dynamic/Analog Types/Int");
            }
            catch (OpcException opcException)
            {
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
                return;
            }

            foreach (DAPropertyElement propertyElement in propertyElements)
                Console.WriteLine($"PropertyElements(\"{propertyElement.PropertyId.NumericalValue}\").Description: {propertyElement.Description}");
        }


        // Example output:
        //
        //PropertyElements("1").Description: Item Canonical DataType
        //PropertyElements("2").Description: Item Value
        //PropertyElements("3").Description: Item Quality
        //PropertyElements("4").Description: Item Timestamp
        //PropertyElements("5").Description: Item Access Rights
        //PropertyElements("6").Description: Server Scan Rate
        //PropertyElements("7").Description: Item EU Type
        //PropertyElements("8").Description: Item EU Info
        //PropertyElements("102").Description: High EU
        //PropertyElements("103").Description: Low EU
    }
}
' This example shows how to enumerate all properties of an OPC XML-DA item. For each property, it displays its Id and description.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET .
' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
' a commercial license in order to use Online Forums, and we reply to every post.

Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.DataAccess.AddressSpace
Imports OpcLabs.EasyOpc.OperationModel

Namespace DataAccess.Xml
    Partial Friend Class BrowseProperties
        Shared Sub Main1Xml()
            Dim client = New EasyDAClient()

            Dim propertyElements As DAPropertyElementCollection
            Try
                propertyElements = client.BrowseProperties("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx", "Dynamic/Analog Types/Int")
            Catch opcException As OpcException
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message)
                Exit Sub
            End Try

            For Each propertyElement In propertyElements
                Console.WriteLine($"PropertyElements(""{propertyElement.PropertyId.NumericalValue}"").Description: {propertyElement.Description}")
            Next propertyElement

        End Sub

        ' Example output
        '
        'PropertyElements("1").Description: Item Canonical DataType
        'PropertyElements("2").Description: Item Value
        'PropertyElements("3").Description: Item Quality
        'PropertyElements("4").Description: Item Timestamp
        'PropertyElements("5").Description: Item Access Rights
        'PropertyElements("6").Description: Server Scan Rate
        'PropertyElements("7").Description: Item EU Type
        'PropertyElements("8").Description: Item EU Info
        'PropertyElements("102").Description: High EU
        'PropertyElements("103").Description: Low EU
    End Class
End Namespace
# This example shows how to enumerate all properties of an OPC XML-DA item. For each property, it displays its Id and description.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
# a commercial license in order to use Online Forums, and we reply to every post.
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from OpcLabs.EasyOpc import *
from OpcLabs.EasyOpc.DataAccess import *

# Instantiate the client object.
client = EasyDAClient()

try:
    propertyElements = client.BrowseProperties(ServerDescriptor('http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx'), DANodeDescriptor('Dynamic/Analog Types/Int'))
except OpcException as opcException:
    print('*** Failure: ' + opcException.GetBaseException().Message, sep='')
    exit()

for propertyElement in propertyElements:
    print('PropertyElements("', propertyElement.PropertyId.NumericalValue, '").Description: ', propertyElement.Description, sep='')

# Example output:
#
#PropertyElements("1").Description: Item Canonical DataType
#PropertyElements("2").Description: Item Value
#PropertyElements("3").Description: Item Quality
#PropertyElements("4").Description: Item Timestamp
#PropertyElements("5").Description: Item Access Rights
#PropertyElements("6").Description: Server Scan Rate
#PropertyElements("7").Description: Item EU Type
#PropertyElements("8").Description: Item EU Info
#PropertyElements("102").Description: High EU
#PropertyElements("103").Description: Low EU
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