COM - dpGetPeriod()

Returns the values of datapoint attributes over a specific period.

Synopsis

HRESULT dpGetPeriod([in] DATE dtFrom, [in] DATE dtTo, [in] long lCount, [in] VARIANT vDpName, [out] VARIANT *vValues, [out] VARIANT *vTimes, [out] VARIANT *vTypes);

Parameter

Parameter Description
dtFrom Start time
dtTo End time
lCount Number of values before and after the period.
vDpName Datapoint attributes whose values are read.
vValues Variables the values are written to.
vTimes Source times belonging to vValues.
vTypes Field containing the event types.

Description

Returns all values within a time period from dtFrom to dtTo in the vValue parameter.

The type of vValue depends on the type of datapoint attribute. If a datapoint does not exist, a runtime error is displayed.

If several datapoint attributes are queried, the result is returned as two nested one-dimensional arrays, as a different number of values can be returned for each datapoint. This also applies to vTimes and vTypes.

If only the datapoint is specified, :_offline.._value is added.

See also CTRL function dpGetPeriod()

Example

(See ComSample.xls, CComSample)

Public Sub dpGetPeriod()
Dim dtFrom As Date
Dim dtTo As Date
Dim vValue As Variant
Dim vTime As Variant
Dim vType As Variant
Dim i As Integer
'Testdaten setzen
dtFrom = Now
For i = 1 To 10
moComManager.dpSet "ExampleDP_Trend1.", (42 / i)
Application.Wait (Now + TimeValue("0:00:01"))
Next i
dtTo = Now
'Werte aus dem Zeitraum abfragen
moComManager.dpGetPeriod dtFrom, dtTo, 0, "ExampleDP_Trend1.",
vValue, vTime, vType
If Not IsEmpty(vValue) Then
If IsArray(vValue) Then
For i = 0 To UBound(vValue)
Debug.Print vValue(i), vTime(i), vType(i)
Next i
End If
End If
End Sub

Assignment

COM