W&T 57630 Manual page 138

Web-io series 12+12 digital
Table of Contents

Advertisement

W&T
OPC
Option Base 1
Sub OpcGetNames()
' Enters the available variable names in column 1
Dim TheOpcServer As OPCServer
Dim MyBrowser As OPCBrowser
Set TheOpcServer = New OPCServer
TheOpcServer.Connect („Wiesemann-Theis.DigitalIO")
Set MyBrowser = TheOpcServer.CreateBrowser
Dim i As Integer
' First clear contents of column 1.
Columns(„A").ClearContents
MyBrowser.ShowLeafs (True)
For i = 1 To MyBrowser.Count
Cells(i, 1) = MyBrowser.Item(i)
Next i
Set MyBrowser = Nothing
TheOpcServer.Disconnect
Set TheOpcServer = Nothing
End Sub
Example: Read values
This example reads the properties „Value", „Unit" and
„Description" for all variable names appearing in column 1 of
the current Excel table and enters them in the adjacent
columns.
The property „Signal quality" has a special significance, and
essentially tells you whether the OPC server has a valid value for
a particular variable. A possible and unfortunately not improbable
cause of problems in this respect can be that the OPC server has
just started (automatically due to the request from the macro) and
was not able to open a TCP connection to its terminal devices.
Option Base 1
Sub OpcUpdate()
' Queries description and current contents
' for all variable names in column 1
Dim TheOpcServer As OPCServer
Set TheOpcServer = New OPCServer
TheOpcServer.Connect („Wiesemann-Theis.DigitalIO")
Dim PropertyIDs(5) As Long
138

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

57631

Table of Contents