W&T 57630 Manual page 139

Web-io series 12+12 digital
Table of Contents

Advertisement

W&T
OPC
Dim Data() As Variant
Dim Errors() As Long
Dim i, j As Integer
PropertyIDs(1) = 3 ' OPC_PROP_QUALITY
PropertyIDs(2) = 2 ' OPC_PROP_VALUE
PropertyIDs(3) = 100 ' OPC_PROP_UNIT
PropertyIDs(4) = 101 ' OPC_PROP_DESC
PropertyIDs(5) = 4 ' OPC_PROP_TIME
Columns(„B").ClearContents
Columns(„E:F").ClearContents
i = 1
While Cells(i, 1) <> „"
TheOpcServer.GetItemProperties Cells(i, 1), 5, PropertyIDs, Data,
Errors
For j = 2 To 5
Cells(i, j) = Data(j)
Next j
If Data(1) = 20 Then ' OPC_QUALITY_LAST_KNOWN
Cells(i, 6) = „DEPRECATED"
ElseIf Data(1) <> 192 Then ' OPC_QUALITY_GOOD
Cells(i, 6) = „ERROR"
Range(Cells(i, 2), Cells(i, 3)).ClearContents
End If
n = n + 1
Wend
TheOpcServer.Disconnect
Set TheOpcServer = Nothing
End Sub
Allocate values
Here a variable name is read from column 1 of the current Excel
table cell, a value is read from column 2 and this value allocated
to the variable.
As opposed to reading out values, this procedure cannot be
implemented using the „Item Properties" of the OPC server, but
rather only directly through the corresponding OPCItem object.
By the way, for reasons of efficiency you should not normally
read variables by this means in the first place, nor using the
method shown in Example 2. And other than in this macro you
Subject to errors and modifications:
139

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

57631

Table of Contents