Professional OPC
Development Tools

logos

Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

Are the browseXXX methods recursive?

More
02 Oct 2014 16:42 #2371 by support
I will answer in more detail in your related post from today. The short answer is that the "Flat" browsing is not something that is implemented in the EasyDAClient object, but has to be supported by the server, which is extremely rare case.

Please Log in or Create an account to join the conversation.

More
02 Oct 2014 16:24 #2370 by OndrejBlazek
When using BrowseNodes() a NodeFilter can be applied.

One of the options for NodeFilters is "DABrowseFilter.Flat" which supposedly returns all Leaves nodes from a flattened version of the AddressSpace.

This should have a similar effect to a recursive browse but I was not able to get it to work correctly. When I try browsing with the "DABrowseFilter.Flat" option, the result is always empty.

Please Log in or Create an account to join the conversation.

More
20 Oct 2013 14:46 #1497 by support
No. If you need to recurse into the sub-branches, you need to code it yourself. It is quite easy. There are some examples available already, e.g. in the QuickOpcCSharpExamples (or QuickOpcVBNETExamples) solution, under Console/BrowseAndReadValues, you will find:
// BrowseAndReadValues: Console application that recursively browses and displays the nodes in the OPC address space, and 
// attempts to read and display values of all OPC items it finds.
 
using System.Diagnostics;
using JetBrains.Annotations;
using OpcLabs.EasyOpc;
using OpcLabs.EasyOpc.DataAccess;
using System;
 
namespace BrowseAndReadValues
{
    class Program
    {
        const string ServerClass = "OPCLabs.KitServer.2";
 
        [NotNull]
        static readonly EasyDAClient Client = new EasyDAClient();
 
        static void BrowseAndReadFromNode([NotNull] string parentItemId)
        {
            // Obtain all node elements under parentItemId
            var nodeFilter = new DANodeFilter();    // no filtering whatsoever
            DANodeElementCollection nodeElementCollection = Client.BrowseNodes("", ServerClass, parentItemId, nodeFilter);
            // Remark: that BrowseNodes(...) may also throw OpcException; a production code should contain handling for it, here 
            // omitted for brevity.
 
            foreach (DANodeElement nodeElement in nodeElementCollection)
            {
                Debug.Assert(nodeElement != null);
 
                // If the node is a leaf, it might be possible to read from it
                if (nodeElement.IsLeaf)
                {
                    // Determine what the display - either the value read, or exception message in case of failure.
                    string display;
                    try
                    {
                        object value = Client.ReadItemValue("", ServerClass, nodeElement);
                        display = String.Format("{0}", value);
                    }
                    catch (OpcException exception)
                    {
                        display = String.Format("** {0} **", exception.GetBaseException().Message);
                    }
 
                    Console.WriteLine("{0} -> {1}", nodeElement.ItemId, display);
                }
                // If the node is not a leaf, just display its itemId
                else
                    Console.WriteLine("{0}", nodeElement.ItemId);
 
                // If the node is a branch, browse recursively into it.
                if (nodeElement.IsBranch &&
                    (nodeElement.ItemId != "SimulateEvents") /* this branch is too big for the purpose of this example */)
                    BrowseAndReadFromNode(nodeElement);
            }
        }
 
        static void Main()
        {
            Console.WriteLine("Browsing and reading values...");
            // Set timeout to only wait 1 second - default would be 1 minute to wait for good quality that may never come.
            Client.InstanceParameters.Timeouts.ReadItem = 1000;
 
            // Do the actual browsing and reading, starting from root of OPC address space (denoted by empty string for itemId)
            BrowseAndReadFromNode("");
 
            Console.WriteLine("Press Enter to continue...");
            Console.ReadLine();
        }
    }
}
Best regards
The following user(s) said Thank You: byteslash

Please Log in or Create an account to join the conversation.

More
18 Oct 2013 12:01 #1495 by byteslash
Hello,
suppose i have a structure like:

Greenhouse
-var1
-var2
-Elements
-var3
-var4

will BrowseXXXX return (var1, var2, var3, var4) or (var1, var2,Elements) ? meaning, will these extend automatically all nodes or not?

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.083 seconds