Browsing
Home Product
Details Free 
Demo Pricing &
Ordering Related
Products Support About Us

Please use our Code Center to obtain source-code and example projects/solutions:

http://codecenter.softwaretoolbox.com

 

OPC Browsing

Be sure to check out the OPC Browser Tutorial.

This page shows you how to:

  • Browse available PC's
  • Browse available OPC Servers (using the dialog and via code)
  • Browse available OPC Groups/Branches (via code)
  • Browse available OPC Tags (using the dialog and via code)

Browsing available PCs

'define our object browser
Dim o As New OPCUserObjects.OPCUserBrowseMachine

'call the dialog
o.RunMe

'display the output from the dialog
MsgBox o.MachineName

Browsing Available OPC Servers

    Via Dialog Browser

    'define the object browser
    Dim o As
    OPCUserObjects.OPCUserBrowseMachine

    'specify the computer to browse servers on
    o.MachineName = ""

    'call the dialog to screen
    o
    .RunMe

    'display the dialog output
    MsgBox o.MachineName & "\" & o.ServerClass

    Via Code

    The following code assumes that an empty for exists with a single listbox control in it. Place the following code in the Form_load event:
    'create the web client object
       Dim objOWC As New EasyDA3

    'define the object to receive the servers listing
       Dim ServerElements

    'specify the computer to go browsing on
       Dim strMachineName As String
       strMachineName = "127.0.0.1"

    'get the server listing into our collection
       Set ServerElements = objOWC.BrowseServers(strMachineName)
      
    'now iterate thru collection
       Dim key
       For Each key In ServerElements.Keys

           'get the collection item into a usable object
           Dim server
           Set server = ServerElements.Item(key)
          
           'add the server details to the list
           List1.AddItem server.ProgID
       Next

Browsing Available OPC Groups/Branches

    The following code assumes that an empty form exists with a single listbox control in it. Place the following code in the Form_load event:

    'define the opc web client object
    Dim EasyDA As New EasyDA3

    'define a variable to act as a collection of groups
    Dim BranchElements

    'specify the name of the computer to browse on
    Dim strMachineName
    strMachineName = ""

    'get the groups into the collection
    Set BranchElements = EasyDA.BrowseBranches(strMachineName, "OPCLabs.KitServer.2", "")

    'now iterate thru the collection
    Dim Key
    For Each Key In BranchElements.Keys

           'get the collection item into an object
           Dim BranchElement
           Set BranchElement = BranchElements.Item(Key)
      
           'add the group (if it is a group) to the list
           If BranchElement.IsBranch Then
               List1.AddItem BranchElement.ItemID
           End If
    Next

Browsing Available Tags

    Via Dialog Browser

    'define the object browser
    Dim o As New OPCUserObjects.OPCUserBrowseItem

    'set the server we want to browse
    o.MachineName = "127.0.0.1"
    o.ServerClass = "OPCLabs.KitServer.2 "

    'call the dialog
    o.RunMe

    'display the dialog result to screen
    MsgBox "Tag selected: " & o.ItemID

    Via Code

      The following code assumes that an empty for exists with a single listbox control in it. Place the following code in the Form_load event:

      'define the opc web client object
      Dim EasyDA As New EasyDA3

      'define a variable, which will act as a collection
      Dim LeafElements

      'specify the name of the computer
      Dim strMachineName
      strMachineName
      = "127.0.0.1"

      'get the tags into the collection
      Set LeafElements = EasyDA.BrowseLeafs(strMachineName, "OPCLabs.KitServer.2", "Simulation")

      'now to iterate thru collection
      Dim Key
         For Each Key In LeafElements.Keys

             'get the collection item into a usable object
             Dim LeafElement
             Set LeafElement = LeafElements.Item(Key)
        
             'add the item to the list
             If (Not LeafElement.IsBranch) Then
                 List1.AddItem (LeafElement.ItemID)
             End If
      Next

Copyright Software Toolbox, Inc., 1996-2004, All Rights Reserved Worldwide.
148A East Charles Street, Matthews, North Carolina, USA 28105
Phone: 704-849-2773 or 1-888-665-3678 (US), Fax: 704-849-6388
sales@softwaretoolbox.com | support@softwaretoolbox.com