|
 Browsing Tags and Servers using the OPC Web Client ActiveX Controls
OPC Browsing
Take a look at the OPC Browsing Tutorial.
There are 3 browsers available:
- OPC Servers (see code for VBScript or JavaScript)
- Groups (aka BRANCHES) (see code for VBScript or JavaScript)
- Tags (aka LEAVES) (see code for VBScript or JavaScript)
Each of these browsers has its own dialog which can be called, or has methods available that allow you to programmatically accomplish the same result.
In this page you can see how to use these browsers via code using VBScript or JavaScript.
OPC Server Browsing
VBScript
Copy the following code into a new HTML file:
<html> <head> <title>OPC Web Client Example - Browsing</title>
</head>
<body> <p><b>OPC Web Client Example</b></p> <p><b>Using OPC Server Browser Methods Programmatically</b></p>
<p><input type="button" value="Browse OPC Local Servers" name="b1"></p> </body> <script language="vbscript"> sub b1_onclick
Dim objOWC Set objOWC = CreateObject("OPCLabs.EasyDA3.0")
Dim ServerElements Set ServerElements = objOWC.BrowseServers()
Dim Key For Each Key In ServerElements.Keys Document.Write "<br>"
Document.Write "Key " & Key & ":" Dim ServerElement
Set ServerElement = ServerElements.Item(Key) With ServerElement Document.Write "CLSID: " &
.CLSID & "<br>" Document.Write "ProgID: " & .ProgID & "<br>"
Document.Write "Description: " & .Description & "<br>" Document.Write "Vendor: " &
.Vendor & "<br>" Document.Write "DA 10: " & .ImplementsDA10 & "<br>"
Document.Write "DA 20: " & .ImplementsDA20 & "<br>" End With Next
end sub
</script> </html>
JavaScript
Feature not currently supported within Javascript due to the differences in Array handling for this development language. This feature will be made available in the next product release.
Sign-up to our newsletter to receive product updates & other important information.
OPC Group Browsing
VBScript
Copy the following code into a new HTML file:
<html> <head> <title>OPC Web Client Example - Browsing</title> </head>
<body> <p><b><font size="3">OPC Web Client Example</font></b></p> <p><b><font size="2">Using OPC Server Groups/Branches
Programmatically</font></b></p> <p><input type="button" value="Browse OPC OPC Groups/Branches" name="b1"></p> </body>
<script language="vbscript"> sub b1_onclick Dim EasyDA Set EasyDA = CreateObject("OPCLabs.EasyDA3.0")
Dim BranchElements Set BranchElements = EasyDA.BrowseBranches("", "OPCLabs.KitServer.2", "")
Dim Key
For Each Key In BranchElements.Keys Document.Write "<p>"
Document.Write "Key " & Key & ":" & "<br>" Dim BranchElement
Set BranchElement = BranchElements.Item(Key) With BranchElement Document.Write Space(4) & "Name: " & .Name
& "<br>" Document.Write Space(4) & "ItemID: " & .ItemID & "<br>"
Document.Write Space(4) & "IsBranch: " & .IsBranch & "<br>" Document.Write Space(4) & "IsLeaf: " &
.IsLeaf & "<br>" Document.Write Space(4) & "HasChildren: " & .HasChildren & "</p>" End With
Next end sub </script> </html>
JavaScript
Feature not currently supported within Javascript due to the differences in Array handling for this development language. This feature will be made available in the next product release.
Sign-up to our newsletter to receive product updates & other important information.
OPC Tag Browsing
VBScript
Copy and paste the code below into a new HTML file:
<html> <head> <title>OPC Web Client Example - Browsing</title> </head>
<body>
<p><b><font size="3">OPC Web Client Example</font></b></p>
<p><b><font size="2">Using OPC Server Tags Programmatically</font></b></p>
<p><input type="button" value="Browse OPC OPC Tags" name="b1"></p> </body> <script language="vbscript"> sub b1_onclick
Dim EasyDA Set EasyDA = CreateObject("OPCLabs.EasyDA3.0")
Dim LeafElements
Set LeafElements = EasyDA.BrowseLeafs("", "OPCLabs.KitServer.2", "Simulation")
Dim Key For Each Key In LeafElements.Keys Document.Write "<p>"
Document.Write "Key " & Key & ":<br>" Dim LeafElement
Set LeafElement = LeafElements.Item(Key) With LeafElement Document.Write Space(4) & "Name: " & .Name & "<br>" Document.Write Space(4) & "ItemID: " &
.ItemID & "<br>" Document.Write Space(4) & "IsBranch: " & .IsBranch & "<br>"
Document.Write Space(4) & "IsLeaf: " & .IsLeaf & "<br>" Document.Write Space(4) & "HasChildren: " & .HasChildren & "</p>" End With Next
end sub </script> </html>
JavaScript
Feature not currently supported within Javascript due to the differences in Array handling for this development language. This feature will be made available in the next product release.
Sign-up to our newsletter to receive product updates & other important information.
|