Home Downloads Buy Now !

OPC Tag Browser

 

This sample uses IOServer.GetServerTree() to return a tree structure of all of the OPC server's Items. It then writes them to the console with their Name and AccessName. When you exit it calls Release() to shutdown.

 

using System;

using System.Collections;

using IDN.IO;

namespace OPCTagBrowser_Example

{  

   class Class1

   { 

      [STAThread]

      static void Main(string[] args)

      { 

         TagServer tagServer = new TagServer();

         

         IONode node = new IONode();

         node.NodeName = Environment.MachineName;

         node.Name = "MyNode";

         tagServer.AddChild(node);

            

         IOServer server = new IOServer();

         server.Guid = new Guid("f8582cf2-88fb-11d0-b850-00c0f0104305");

         server.Name = "MyServer";

         node.AddChild(server);

  

         tagServer.Connect();

         IDNBrowsable root = server.GetServerTree();

  

         DisplayItems(root);

         Console.WriteLine("Done... [Enter] to exit.");

         tagServer.Release();

         Console.ReadLine();

      }

 

      static void DisplayItems(IDNBrowsable inItem)

      {  

         if (inItem.GetType() == typeof (IOTag))

            Console.WriteLine(inItem.Name + ": \t" + ((IOTag)inItem).AccessName);

         else

            Console.WriteLine(inItem.Name);

         for (int i = 0; i < inItem.Children.Count; i++)

         {  

            DisplayItems((IDNBrowsable) inItem.Children.GetByIndex(i));

         }

      }

   }

}

    



Copyright © 2004-2017 Industrial DOT NET, Inc.