A collection of OPCItem objects. This is the default property of the OPCGroup object.
This function reads the value, quality and timestamp information for one or more items in a group.
Variant, ByRef Errors() As Long, Optional ByRef Qualities As Variant, Optional ByRef
OPC Data Access Automation Specification2.02
TimeStamps As Variant)
Part Description
Source
The ‘data source’; OPC_DS_CACHE or OPC_DS_DEVICE
NumItems
The number of items to be read.
ServerHandles
Array of server item handles for the items to be read
Values
Array of values.
Errors
Array of Long’s indicating the success of the individual item reads.
This indicates whether the read succeeded in obtaining a defined
value, quality and timestamp. NOTE any FAILED error code
indicates that the corresponding Value, Quality and Time stamp are
UNDEFINED.
Qualities
Variant containing an Integer Array of Qualities.
TimeStamps
Variant containing a Date Array of UTC TimeStamps. If the device
cannot provide a timestamp then the server will provide one.
Remarks
The function runs to completion before returning. The data can be read from CACHE in which case
it should be accurate to within the ‘UpdateRate’ and percent deadband of the group. The data can be
read from the DEVICE in which case an actual read of the physical device is to be performed. The
exact implementation of CACHE and DEVICE reads is not defined by this specification.
When reading from CACHE, the data is only valid if both the group and the item are active. If either
the group or the item is inactive, then the Quality will indicate out of service
(OPC_QUALITY_OUT_OF_SERVICE). Refer to the discussion of the quality bits later in this
document for further information.
DEVICE reads are not affected by the ACTIVE state of the group or item.
Example
Private Sub ReadButton_Click()
Dim Source As Integer
Dim NumItems As Long
Dim ServerIndex As Long
Dim ServerHandles(10) As Long
Dim Values() As Variant
Dim Errors() As Long
Dim Qualities() As Variant
Dim TimeStamps() As Variant
Source = OPC_DS_DEVICE
53
OPC Data Access Automation Specification2.02
NumItems = 10
For ServerIndex = 1 to NumItems
‘ set up which items to be read
ServerHandles(ServerIndex) = AnOPCItemServerHandles(ServerIndex)
Next ServerIndex
OneGroup.SyncRead Source, NumItems, ServerHandles, Values, Errors, Qualities, TimeStamps
For ServerIndex = 1 to NumItems
‘ process the values
TextBox(ServerIndex).Text = Values(ServerIndex)
Next ServerIndex
End Sub
Do'stlaringiz bilan baham: