138
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
Содержание 57630
Страница 8: ...8 W T Content...
Страница 22: ...22 W T Assigning the IP address...
Страница 44: ...44 W T configuring the network parameters...
Страница 194: ...194 W T Diacnostics and testing...
Страница 211: ...211 W T Decalration of conformity Subject to errors and modifications 7 9 Declaration of Conformity...