This synchronous function reads the attribute values and timestamps from the history database for the specified time domain for an item.
If the current values for the attributes are desired, startTime shall be set to "NOW" and endTime shall be null (Nothing).
This function is intended to be used to retrieve attributes that have changed to correlate the values of these attributes with the values of their data. For example, the recalibration of a sensor may have required the normal maximum and minimum attributes to be changed.
Visual Basic (Declaration) | |
---|---|
Public Overloads Function ReadAttribute( _ ByVal startTime As OPCHDA.NET.OPCHDAtime, _ ByVal endTime As OPCHDA.NET.OPCHDAtime, _ ByVal handleServer As Integer, _ ByVal attributeIDs() As Integer, _ ByRef attrValues As OPCHDA.NET.OPCHDAattribute(), _ ByRef errors As Integer() _ ) As Integer |
C# | |
---|---|
public int ReadAttribute( OPCHDA.NET.OPCHDAtime startTime, OPCHDA.NET.OPCHDAtime endTime, int handleServer, int[] attributeIDs, out OPCHDA.NET.OPCHDAattribute[] attrValues, out int[] errors ) |
Parameters
- startTime
- The beginning of the attribute read period.
- endTime
- The end of the attribute read period.
- handleServer
- The server item handle for the item to be read.
- attributeIDs
- The list of attribute IDs to be read.
- attrValues
- OUT: Array of structures in which the item attribute values are returned. The order of the structures in the array shall be the same as the order of attribute IDs.
- errors
- OUT: Array of HRESULTs indicating the success of the individual attribute reads. The errors correspond to the attribute IDs passed in dwAttributeIDs. This indicates whether the read succeeded in obtaining a defined value for the requested attribute. NOTE any FAILED error code indicates that the corresponding attribute value is UNDEFINED.
Return Value
S_OK, S_FALSE, OPC_E_INVALIDHANDLE, E_INVALIDARG, E_FAILIf the only attribute values available for the item are the current values, these shall be returned and the error set to OPC_S_CURRENTVALUE.
Except for the case where current values are requested (startTime = NOW, endTime = null (Nothing)), the server shall always return a beginning bounding value. Thus, if the client requests attribute values for Jan 1, 1997 to October 1, 1997, the server shall return a value for the attribute on Jan 1, 1997, rather than the first value returned being the first new value for the attribute after Jan 1, 1997.
Likewise, the timestamp for that first value shall be Jan 1, 1997, regardless of when the attribute actually took that value. All other timestamps shall be for the time when the value of the attribute changed.
Note that while the client can query the server for the native datatype of an ItemID, the client cannot assume that all data sent from the server will be that datatype. The datatype of a given ItemID may have changed over the life of the Item, and thus clients should be able to handle receiving data of a different datatype than that returned from this call.
Target Platforms: Windows 7/8/10, Windows Server 2008/2012/2016, .NET 4.x