GetValueArrays Method (IPIValues2 interface)

                    

 

This method returns all the data from a PIValues collection as parallel SafeArrays of simple data types. The interpretation of the data arrays are described in the Remarks section below.

Syntax

object.GetValueArrays Values, Times, Flags

The GetValueArrays method syntax has these parts:

Part

Description

object

An object expression that evaluates to a IPIValues2 interface. This interface can be obtained from a PIValues object.

Values

A SafeArray of Variants containing the values of each PIValue objects in the PIValues collection.

Times

A SafeArray of doubles containing the timestamps of each PIValue objects in the PIValues collection. The timestamps should be interpreted as UTC seconds since 1970.

Flags

A SafeArray of long integers containing information about the value attributes of each PIValue objects in the PIValues collection. See the Remarks section for interpretation.

 

Remarks

The three SafeArrays returned from the GetValueArrays methods have the same dimension. They contains the same number of elements as the number of PIValue objects in the PIValues collection. The lower bounds of the arrays are zero. Hence, array element N corresponds to the PIValue object of index N+1 in the PIValues collection.

The variant in N element of the Values array contains the same value as what the Value property from the N+1th PIValue in the PIValues collection would return. The Times array element contains the same value as what the PIValue.TimeStamp.UTCSeconds from the corresponding PIValue object would return, e.g. UTC seconds since 1970.

The Flags array contains long integers that are bit masks for the Annotated, Questionable and the Substituted flags of a PIValue. The Annotated flag is stored in the 0th bit; Questionable flag is stored in the 1st bit and Substituted flag in the 2nd bit. In addition, the sign bit of the Flags array element is used to indicate whether the Value of the PIValue has good status. For example, if the (N+1)th PIValue in the PIValues collection returns FALSE from the IsGood method, the sign bit of the Nth element in the Flags array will be set.

The Flags array does not contain all the information in PIValue.ValueAttributes, especially if the PIValues does not come from a PI server as snapshot or archive events. For example, PIValues generated by PIData.summaries method contains information like PercentGood in the ValueAttributes. You will have to access the PIValue.ValueAttributes directly for those information. If the PIValue contains an Annotations, you can use IPIValues2.GetItemAnnotation to get the annotation value directly rather than going through PIValues(index).ValueAttributs("Annotations").Value.

Trappable Errors

In addition to generic errors (such as Out of Memory), the following errors may occur:

Error

Description

PISDK_E_PIVALUESEMPTY Empty PIValues collection.
PISDK_E_ARRAYCREATE Problem creating SafeArray.
Enabling Operational Intelligence