Beispiel #1
0
        private static void Browse(OpcNodeInfo node, int level)
        {
            //// In general attributes and children are retrieved from the server on demand. This
            //// is done to reduce the amount of traffic and to improve the preformance when
            //// searching/browsing for specific attributes or children. After attributes or
            //// children of a node were browsed they are stored internally so that subsequent
            //// attribute and children requests are processed without any interaction with the
            //// OPC UA server.

            // Browse the DisplayName attribute of the node. It is also possible to browse
            // multiple attributes at once (see the method Attributes(...)).
            var displayName = node.Attribute(OpcAttribute.DisplayName);

            Console.WriteLine(
                "{0}{1} ({2})",
                new string(' ', level * 4),
                node.NodeId.ToString(OpcNodeIdFormat.Foundation),
                displayName.Value);

            // Browse the children of the node and continue browsing in preorder.
            foreach (var childNode in node.Children())
            {
                Program.Browse(childNode, level + 1);
            }
        }
Beispiel #2
0
        private void Browse(OpcNodeInfo node, int level = 0)
        {
            Console.WriteLine("{0}{1}({2})",
                              new string('.', level * 4),
                              node.Attribute(OpcAttribute.DisplayName).Value,
                              node.NodeId);

            level++;

            foreach (var childNode in node.Children())
            {
                Browse(childNode, level);
            }
        }