// This example shows how to obtain all nodes under the "Simulation" branch of the address space. For each node, it displays // whether the node is a branch or a leaf. using System; using OpcLabs.EasyOpc.DataAccess; using OpcLabs.EasyOpc.DataAccess.AddressSpace; using OpcLabs.EasyOpc.OperationModel; namespace DocExamples.DataAccess._EasyDAClient { partial class BrowseNodes { public static void Main1() { // Instantiate the client object. var client = new EasyDAClient(); DANodeElementCollection nodeElements; try { nodeElements = client.BrowseNodes("", "OPCLabs.KitServer.2", "Greenhouse", DABrowseParameters.Default); } catch (OpcException opcException) { Console.WriteLine($"*** Failure: {opcException.GetBaseException().Message}"); return; } foreach (DANodeElement nodeElement in nodeElements) { Console.WriteLine($"NodeElements(\"{nodeElement.Name}\"):"); Console.WriteLine($" .IsBranch: {nodeElement.IsBranch}"); Console.WriteLine($" .IsLeaf: {nodeElement.IsLeaf}"); } } } }
# This example shows how to obtain all nodes under the "Simulation" branch of the address space. For each node, it displays # whether the node is a branch or a leaf. #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 { $nodeElements = [IEasyDAClientExtension]::BrowseNodes($client, "", "OPCLabs.KitServer.2", "Greenhouse", [DABrowseParameters]::Default) } catch [OpcException] { Write-Host "*** Failure: $($PSItem.Exception.GetBaseException().Message)" return } Foreach ($nodeElement in $nodeElements) { Write-Host "NodeElements(`"$($nodeElement.Name)`"):" Write-Host " .IsBranch: $($nodeElement.IsBranch)" Write-Host " .IsLeaf: $($nodeElement.IsLeaf)" }
# This example shows how to obtain all nodes under the "Simulation" branch of the address space. For each node, it displays # whether the node is a branch or a leaf. # 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: nodeElements = IEasyDAClientExtension.BrowseNodes(client, '', 'OPCLabs.KitServer.2', 'Greenhouse', DABrowseParameters.Default) except OpcException as opcException: print('*** Failure: ' + opcException.GetBaseException().Message) exit() # Display results for nodeElement in nodeElements: print('NodeElements("' + nodeElement.Name + '"):') print(' .IsBranch:', nodeElement.IsBranch) print(' .IsLeaf:', nodeElement.IsLeaf) # Example output: # #NodeElements("Register_ArrayOfI1"): # .IsBranch: False # .IsLeaf: True #NodeElements("Register_ArrayOfI2"): # .IsBranch: False # .IsLeaf: True #NodeElements("Register_ArrayOfI4"): # .IsBranch: False # .IsLeaf: True #NodeElements("Staircase 0:2 (10 s)"): # .IsBranch: False # .IsLeaf: True #NodeElements("Constant_VARIANT"): # .IsBranch: False # .IsLeaf: True #...
// This example shows how to obtain all nodes under the "Simulation" branch of the address space. For each node, it displays // whether the node is a branch or a leaf. class procedure BrowseNodes.Main; var BrowseParameters: _DABrowseParameters; Client: OpcLabs_EasyOpcClassic_TLB._EasyDAClient; Count: Cardinal; Element: OleVariant; ServerDescriptor: _ServerDescriptor; NodeDescriptor: _DANodeDescriptor; NodeElement: _DANodeElement; NodeElementEnumerator: IEnumVariant; NodeElements: _DANodeElementCollection; begin ServerDescriptor := CoServerDescriptor.Create; ServerDescriptor.ServerClass := 'OPCLabs.KitServer.2'; NodeDescriptor := CoDANodeDescriptor.Create; NodeDescriptor.ItemId := 'Simulation'; BrowseParameters := CoDABrowseParameters.Create; // Instantiate the client object Client := CoEasyDAClient.Create; try NodeElements := Client.BrowseNodes( ServerDescriptor, NodeDescriptor, BrowseParameters); except on E: EOleException do begin WriteLn(Format('*** Failure: %s', [E.GetBaseException.Message])); Exit; end; end; NodeElementEnumerator := NodeElements.GetEnumerator; while (NodeElementEnumerator.Next(1, Element, Count) = S_OK) do begin NodeElement := IUnknown(Element) as _DANodeElement; // WriteLn(NodeElement.Name, ': ', NodeElement.ItemId); WriteLn('BrowseElements("', NodeElement.Name, '"):'); WriteLn(' .IsBranch: ', NodeElement.IsBranch); WriteLn(' .IsLeaf: ', NodeElement.IsLeaf); end; end;
// This example shows how to obtain all nodes under the "Simulation" branch of the address space. For each node, it displays // whether the node is a branch or a leaf. $ServerDescriptor = new COM("OpcLabs.EasyOpc.ServerDescriptor"); $ServerDescriptor->ServerClass = "OPCLabs.KitServer.2"; $NodeDescriptor = new COM("OpcLabs.EasyOpc.DataAccess.DANodeDescriptor"); $NodeDescriptor->ItemID = "Simulation"; $BrowseParameters = new COM("OpcLabs.EasyOpc.DataAccess.DABrowseParameters"); $Client = new COM("OpcLabs.EasyOpc.DataAccess.EasyDAClient"); try { $NodeElements = $Client->BrowseNodes($ServerDescriptor, $NodeDescriptor, $BrowseParameters); } catch (com_exception $e) { printf("*** Failure: %s\n", $e->getMessage()); Exit(); } foreach ($NodeElements as $NodeElement) { printf("NodeElements(\"%s\"):\n", $NodeElement->Name); printf(" .IsBranch: %s\n", $NodeElement->IsBranch ? 'true' : 'false'); printf(" .IsLeaf: %s\n", $NodeElement->IsLeaf ? 'true' : 'false'); }
// This example shows how to obtain all nodes under the "Simulation" branch of the address space. For each node, it displays // whether the node is a branch or a leaf. mle_outputtext.Text = "" // Instantiate the client object OLEObject client client = CREATE OLEObject client.ConnectToNewObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient") // Prepare the arguments OLEObject serverDescriptor serverDescriptor = CREATE OLEObject serverDescriptor.ConnectToNewObject("OpcLabs.EasyOpc.ServerDescriptor") serverDescriptor.ServerClass = "OPCLabs.KitServer.2" OLEObject nodeDescriptor nodeDescriptor = CREATE OLEObject nodeDescriptor.ConnectToNewObject("OpcLabs.EasyOpc.DataAccess.DANodeDescriptor") nodeDescriptor.ItemID = "Simulation" OLEObject browseParameters browseParameters = CREATE OLEObject browseParameters.ConnectToNewObject("OpcLabs.EasyOpc.DataAccess.DABrowseParameters") // Perform the operation OLEObject nodeElements TRY nodeElements = client.BrowseNodes(serverDescriptor, nodeDescriptor, browseParameters) CATCH (OLERuntimeError oleRuntimeError) mle_outputtext.Text = mle_outputtext.Text + "*** Failure: " + oleRuntimeError.Description + "~r~n" RETURN END TRY OLEObject nodeElementList nodeElementList = nodeElements.ToList() // Display results Int i FOR i = 0 TO nodeElementList.Count - 1 OLEObject nodeElement nodeElement = nodeElementList.Item[i] mle_outputtext.Text = mle_outputtext.Text + 'NodeElements("' + nodeElement.Name + '"):' + "~r~n" mle_outputtext.Text = mle_outputtext.Text + " nodeElement.IsBranch: " + String(nodeElement.IsBranch) + "~r~n" mle_outputtext.Text = mle_outputtext.Text + " nodeElement.IsLeaf: " + String(nodeElement.IsLeaf) + "~r~n" NEXT mle_outputtext.Text = mle_outputtext.Text + "~r~n" mle_outputtext.Text = mle_outputtext.Text + "Finished." + "~r~n"
# This example shows how to obtain all nodes under the "Simulation" branch of the address space. For each node, it displays # whether the node is a branch or a leaf. # The Python for Windows (pywin32) extensions package is needed. Install it using "pip install pypiwin32". # CAUTION: We now recommend using Python.NET package instead. Full set of examples with Python.NET is available! import win32com.client from pywintypes import com_error serverDescriptor = win32com.client.Dispatch('OpcLabs.EasyOpc.ServerDescriptor') serverDescriptor.ServerClass = 'OPCLabs.KitServer.2' nodeDescriptor = win32com.client.Dispatch('OpcLabs.EasyOpc.DataAccess.DANodeDescriptor') nodeDescriptor.ItemID = 'Simulation' browseParameters = win32com.client.Dispatch('OpcLabs.EasyOpc.DataAccess.DABrowseParameters') # Instantiate the client object client = win32com.client.Dispatch('OpcLabs.EasyOpc.DataAccess.EasyDAClient') # Perform the operation try: nodeElements = client.BrowseNodes(serverDescriptor, nodeDescriptor, browseParameters) except com_error as e: print('*** Failure: ' + e.args[2][1] + ': ' + e.args[2][2]) exit() # Display results for nodeElement in nodeElements: print('NodeElements("' + nodeElement.Name + '"):') print(' .IsBranch:', nodeElement.IsBranch) print(' .IsLeaf:', nodeElement.IsLeaf) # Example output: # #NodeElements("Register_ArrayOfI1"): # .IsBranch: False # .IsLeaf: True #NodeElements("Register_ArrayOfI2"): # .IsBranch: False # .IsLeaf: True #NodeElements("Register_ArrayOfI4"): # .IsBranch: False # .IsLeaf: True #NodeElements("Staircase 0:2 (10 s)"): # .IsBranch: False # .IsLeaf: True #NodeElements("Constant_VARIANT"): # .IsBranch: False # .IsLeaf: True #...
Rem This example shows how to obtain all nodes under the "Simulation" branch of the address space. For each node, it displays Rem whether the node is a branch or a leaf. Private Sub BrowseNodes_Main_Command_Click() OutputText = "" Dim serverDescriptor As New serverDescriptor serverDescriptor.ServerClass = "OPCLabs.KitServer.2" Dim nodeDescriptor As New DANodeDescriptor nodeDescriptor.itemId = "Simulation" Dim browseParameters As New DABrowseParameters ' Instantiate the client object Dim client As New EasyDAClient On Error Resume Next Dim nodeElements As DANodeElementCollection Set nodeElements = client.BrowseNodes(serverDescriptor, nodeDescriptor, browseParameters) If Err.Number <> 0 Then OutputText = OutputText & "*** Failure: " & Err.Source & ": " & Err.Description & vbCrLf Exit Sub End If On Error GoTo 0 Dim nodeElement: For Each nodeElement In nodeElements OutputText = OutputText & "BrowseElements(""" & nodeElement.Name & """): " & nodeElement.itemId & vbCrLf OutputText = OutputText & " .IsBranch: " & nodeElement.IsBranch & vbCrLf OutputText = OutputText & " .IsLeaf: " & nodeElement.IsLeaf & vbCrLf Next End Sub
Rem This example shows how to obtain all nodes under the "Simulation" branch of the address space. For each node, it displays Rem whether the node is a branch or a leaf. 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" Dim BrowseParameters: Set BrowseParameters = CreateObject("OpcLabs.EasyOpc.DataAccess.DABrowseParameters") Dim Client: Set Client= CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient") On Error Resume Next Dim NodeElements: Set NodeElements = Client.BrowseNodes(ServerDescriptor, NodeDescriptor, BrowseParameters) If Err.Number <> 0 Then WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description WScript.Quit End If On Error Goto 0 Dim NodeElement: For Each NodeElement In NodeElements WScript.Echo "NodeElements(""" & NodeElement.Name & """):" With NodeElement WScript.Echo Space(4) & ".IsBranch: " & .IsBranch WScript.Echo Space(4) & ".IsLeaf: " & .IsLeaf End With Next
Copyright © 2004-2023 CODE Consulting and Development, s.r.o., Plzen. All rights reserved. Web page: www.opclabs.com
Send Documentation Feedback. Resources: Knowledge Base. Technical support: Online Forums, FAQ.