OPC Studio User's Guide and Reference
Browsing for OPC Classic Access Paths
Concepts > QuickOPC Concepts > QuickOPC Development Models > Imperative Programming Model > Imperative Programming Model for OPC Data (Classic and UA) > Browsing for Information (OPC Data) > Browsing for OPC Classic Access Paths

Access paths are somewhat obsolete feature of OPC Data Access specification, and few OPC servers actually use it; but if a particular OPC server does use access paths, specifying the proper access path together with ItemID may be the only way to retrieve the data you want.

If you want to retrieve a list of possible access paths available for a specific OPC item, call the BrowseAccessPaths method, passing it the information about the OPC server, and the ItemID.  You will receive back an array of strings; each element of this array is an access path that you can use with methods such as ReadItem or SubscribeItem.

In QuickOPC.NET, you can also pass the access path to a constructor of DAItemDescriptor object and later use that descriptor with various methods.

 

.NET

// This example shows how to obtain all access paths available for an item.
//
// 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.OperationModel;

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

            for (int i = 0; i < accessPaths.Length; i++)
                Console.WriteLine($"accessPaths({i}): {accessPaths[i]}");
        }


        // Example output:
        //
        //accessPaths(0): Self
        //accessPaths(1): Other
    }
}
' This example shows how to obtain all access paths available for an item.
'
' 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.OperationModel

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

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

            For i = 0 To accessPaths.Length - 1
                Console.WriteLine($"accessPaths({i}): {accessPaths(i)}")
            Next i

        End Sub

        ' Example output
        '
        'accessPaths(0): Self
        'accessPaths(1): Other

    End Class
End Namespace

COM

Rem This example shows how to obtain all access paths available for an item.
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 Client: Set Client = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient")
On Error Resume Next
Dim accessPaths: accessPaths = Client.BrowseAccessPaths(ServerDescriptor, NodeDescriptor)
If Err.Number <> 0 Then
    WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
    WScript.Quit
End If
On Error Goto 0

Dim i: For i = LBound(accessPaths) To UBound(accessPaths)
    WScript.Echo "accessPaths(" & i & "): " & accessPaths(i)
Next

Python

# This example shows how to obtain all access paths available for an item.
#
# 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:
    accessPaths = IEasyDAClientExtension.BrowseAccessPaths(client, '', 'OPCLabs.KitServer.2', 'Simulation.Random')
except OpcException as opcException:
    print('*** Failure: ' + opcException.GetBaseException().Message)
    exit()

# Display results
for (i, accessPath) in enumerate(accessPaths):
    print('accessPaths[', i, ']: ', accessPath, sep='')

 

 

See Also