// Attempts to parse an absolute OPC-UA browse path and displays its starting node and elements.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
using System;
using OpcLabs.BaseLib;
using OpcLabs.EasyOpc.UA.Navigation;
using OpcLabs.EasyOpc.UA.Navigation.Parsing;
namespace UADocExamples._UABrowsePathParser
{
class TryParse
{
public static void Main1()
{
var browsePathParser = new UABrowsePathParser();
IStringParsingError stringParsingError = browsePathParser.TryParse(
"[ObjectsFolder]/Data/Static/UserScalar",
out UABrowsePath browsePath);
// Display results
if (!(stringParsingError is null))
{
Console.WriteLine("*** Error: {0}", stringParsingError);
return;
}
Console.WriteLine("StartingNodeId: {0}", browsePath.StartingNodeId);
foreach (UABrowsePathElement browsePathElement in browsePath.Elements)
Console.WriteLine(browsePathElement);
// Example output:
// StartingNodeId: ObjectsFolder
// /Data
// /Static
// /UserScalar
}
}
}
# Attempts to parse an absolute OPC-UA browse path and displays its starting node and elements.
#
# 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.EasyOpc.UA import *
from OpcLabs.EasyOpc.UA.Navigation import *
from OpcLabs.EasyOpc.UA.Navigation.Parsing import *
browsePathParser = UABrowsePathParser()
stringParsingError, browsePath = browsePathParser.TryParse('[ObjectsFolder]/Data/Static/UserScalar', None)
# Display results.
if stringParsingError is not None:
print('*** Error: ', stringParsingError, sep='')
exit()
print('StartingNodeId: ', browsePath.StartingNodeId, sep='')
print()
for browsePathElement in browsePath.Elements:
print(browsePathElement)
print()
print('Finished.')
' Attempts to parses an absolute OPC-UA browse path and displays its starting node and elements.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
Imports System
Imports OpcLabs.BaseLib
Imports OpcLabs.EasyOpc.UA.Navigation
Imports OpcLabs.EasyOpc.UA.Navigation.Parsing
Namespace _UABrowsePathParser
Friend Class TryParse
Public Shared Sub Main1()
Dim browsePathParser = New UABrowsePathParser()
Dim browsePath As UABrowsePath = Nothing
Dim stringParsingError As IStringParsingError = browsePathParser.TryParse("[ObjectsFolder]/Data/Static/UserScalar", browsePath)
' Display results
If Not stringParsingError Is Nothing Then
Console.WriteLine("*** Error: {0}", stringParsingError)
Exit Sub
End If
Console.WriteLine("StartingNodeId: {0}", browsePath.StartingNodeId)
For Each browsePathElement As UABrowsePathElement In browsePath.Elements
Console.WriteLine(browsePathElement)
Next browsePathElement
' Example output:
' StartingNodeId: ObjectsFolder
' /Data
' /Static
' /UserScalar
End Sub
End Class
End Namespace