RollupIterator Methods

The RollupIterator object contains the following methods:

Initialize

The Initialize method initializes the rollup iterator.

Syntax

Initialize(VhsSiteService As String, TagString As String, TimeStampEarliest As Date, TimeStampLatest As Date, RollupType As Integer, RollupUnits As Integer, RollupPeriod As Integer, TopOfDayHour As Integer) As Long

Parameters

Parameter Required Description

VhsSiteService

Yes

The site and service name of the VHS point tag, in "site.service" format.

TagString

Yes

The point tag from which data is being retrieved in valid CygNet tag string format.

TimeStampEarliest

Yes

The starting date of the retrieval period. This field must be a valid date/time (not 0).

TimeStampLatest

Yes

The ending date of the retrieval period. Enter 0 for the date of the latest timestamp.

RollupType

Yes

the rollup type of the value entry. The possible values are listed on the CxRollupType enum table.

RollupUnits

Yes

the rollup units of the value entry. This refers to time increments, such as seconds, minutes, hours, or days. The possible values are listed on the CxRollupUnits enum table.

RollupPeriod

Yes

the rollup period of the value entry. Rollup period refers to the quantity of units in a period. For example, to rollup 30 days, the RollupPeriod is 30 and the RollupUnit is "days."

TopOfDayHour

Yes

the offset value to use if the subunit to the major unit (i.e. hours to a day) does not start at the time unit expected. For example, to accommodate contract days starting at 5 AM, the TopOfDayHour would be 5 (indicating 5 hours from midnight).

Remarks

Returns a value based on whether the initialization was successful or not (1 = Success; 0 = Failure). The cursor is placed at the first (earliest) value by default.

Example

The following method displays a day’s worth of maximum values, calculated every half hour. This is accomplished using a rollup type CalcMax (4), rollup unit Minutes (1), and a rollup period of 30. The point name and date are accepted as parameters.

Copy
Initialize
Usage:  DisplayDailyMaxs  "CYGDEMO.UIS:POINT1", "05/24/2022"
 
    Sub DisplayDailyMaxs (tagString, curDay)
    Dim vhsRollupIter, histEntry
    lstValues.ResetContent
     
    Set vhsRollupIter = CreateObject("CxVhsLib.RollupIterator")
    Set histEntry = CreateObject("CxVhsLib.HistoryEntryEx")
     
    'Initialize rollup iterator
    vhsRollupIter.Initialize "CYGDEMO.VHS", tagString, CStr(curDay),CStr(curDay) & " 23:59:59", 4, 1, 30, 0
    vhsRollupIter.MoveFirst
     
    'Show all max values in a list box
    While (vhsRollupIter.GetForward(histEntry))
        lstValues.AddString CStr(histEntry.TimeStamp) & "  "& CStr(histEntry.Value)
    Wend
End Sub

Back to top

GetForwardEx

The GetForwardEx method retrieves information about the next value in the iteration list. Returns a ValueEntryEx object in the pVal variable.

Syntax

GetForwardEx(pVal As Variant) As Long

Parameters

Parameter Required Description Variant

pVal

Yes

Returns the timestamp, status, user status, value, time ordinal, and rollup information for the value entry.

ValueEntryEx

Remarks

The GetForwardEx function retrieves information for the next value and moves the cursor forward to the value. Returns 0 until TimeStampLatest is reached. This method is identical to GetForward, except that the value is returned as a ValueEntryEx object rather than a HistoryEntryEx object.

Example

The following method displays a day’s worth of maximum values, calculated every half hour. This is accomplished using a rollup type CalcMax (4), rollup unit Minutes (1), and a rollup period of 30.

Copy
GetForwardEx
Sub DisplayDailyMaxsEx ()
    Dim vhsRollupIter, valEntry, tag
    lstValues.ResetContent
     
    Set vhsRollupIter = CreateObject("CxVhsLib.RollupIterator")
    Set valEntry = CreateObject("CxVhsLib.ValueEntryEx")
    tag = "CYGDEMO.UIS:POINT1"
     
    'Initialize rollup iterator
    vhsRollupIter.Initialize "CYGDEMO.VHS", tag, Now,_
    Now & " 23:59:59", 4, 1, 30, 0
    vhsRollupIter.MoveFirst
     
    'Show all max values in a list box
    While (vhsRollupIter.GetForwardEx(valEntry))
        lstValues.AddString CStr(valEntry.TimeStamp) & "  "& CStr(valEntry.Value)
    Wend
End Sub

Back to top

MoveFirst

The MoveFirst method moves to the first value in the iteration list.

Syntax

MoveFirst() As Long

Remarks

Returns a value based on whether the initialization was successful or not (1 = Success; 0 = Failure).

Example

See RollupIterator.Initialize for example.

Back to top