QueryBlock(vValues As Variant,vPvIDs As Variant) As Boolean
Parameters
vValues As Variant
"Variant" variable for the "QueryBlock" method, in order to
store a cascaded array which is filled with the filtered variables
and the recorded values.
The array is returned by the method, hence the user has only to
pass an "Variant" variable.
vPvIDs As Variant
"Variant" variable for the "QueryBlock" method, in order to
store an array of IDs of the corresponding filtered archive
variables.
The array is returned by the method, hence the user has only to
pass an "Variant" variable.
ED
not used
RT
avaliable
Remarks
Like the "Query" method, the "QueryBlock" command initiates the
filtering of the data.
The difference between these two methods is, that the "QueryBlock"
method is dedicated for performance oriented tasks, because the
usage of arrays is faster than the approach of the "Query" method
with the collections. The drawback of the "QueryBlock" method is
the increased complexity of coding.
The "QueryBlock" command requires two parameters:
vPvIDs: A variant variable which will constitute an
array containing all IDs of the filtered variables.
vValues: A variant variable which will store an cascaded
array designed the following way:
Level: Return type, e.g.
'Declaration Dim zValues As
Variant 'Initiates the filtering
zArvFilter.QueryBlock zPvIDs, zValues 'zValues is the return type, which contains all
variables and the corresponding values
Level: Variable, e.g.
'Declaration Dim vVarTemp As
Variant 'Assign the first variable within the cascaded
"zValues" array to "vVarTemp"
vVarTemp = zValues(0)
Level: Variable values, e.g.
'Declaration Dim vValTemp As
Variant 'Assign the the third value within the vVarTemp
variable to "vValTemp"
vValTemp = vVarTemp(2) 'Alternatively: Third value of the first variable
within "zValues"
vValTemp = zValues(0)(2)
Level: Value parameters
vValTemp (0)
'Returns the date and time when the value was
recorded 'Hint: The time has to be converted from zenOn
internally UTC into local time. 'Use the zenOn "clsTimeConvert" macro to do
so.
zValues (0)(2)(0) 'Alternatively
vValTemp (1) 'Returns the milliseconds, in
addition to the time, when the value was recorded
zValues (0)(2)(1) 'Alternatively
vValTemp (2) 'Returns the value that was recorded
at the specified time and date
zValues (0)(2)(1) 'Alternatively
vValTemp (3) 'Returns the state type, e.g.
&H40000 -> I-BIT
zValues (0)(2)(1) 'Alternatively
Sample
The following example initiates a filtering with the "QueryBlock"
command and outputs the details of the filter result.
ATTENTION: The passed "ArchiveFilter" object has to be
initialized beforehand, i.e. filter starttime and endtime, etc.
Hint:
In order to output the correct date and time of the filter result,
the zenOn "clsTimeConvert" macro should be used.
For the macro code and further information on the macro and the
time conversion, please have a look at the StartTime part.
Public Sub zenOn_ArchiveFilter_QueryBlock(ByRef zArvFilter As ArchiveFilter)
'DeclarationsDim zTimeConvert As clsTimeConvert
Dim zPvIDs As VariantDim zValues As VariantDim i As IntegerDim j As IntegerDim vVarTemp As VariantDim vValTemp As VariantDim nVarCount As IntegerDim nValCount As Integer'Initialize zTimeConvert by creating a new instance of the zenOn "clsTimeConvert" macroSet zTimeConvert = New clsTimeConvert
zArvFilter.QueryBlock zPvIDs, zValues
'Get the number of variables and assign it to "nVarCount"
nVarCount = UBound(zValues, 1)
'For every filtered variable output the recorded valuesFor i = 0 To nVarCount
'Assign the current variable to "vVarTemp"
vVarTemp = zValues(i)
'Get the number of values within the variable and assign it to "nValCount"
nValCount = UBound(vVarTemp, 1)
'For every value within the filtered variable output the recorded detailsFor j = 0 To nValCount
'Assign the current value to "vValTemp"
vValTemp = vVarTemp(j)
'Output the count number of the current value
Debug.Print j + 1 & ". Value"
'Output the variable name to which the value belongs
Debug.Print vbTab & "Var-Name: " & zArvFilter.ArchiveFilterVariables.ItemById(zPvIDs(i)).ArchiveVariable.Name
'Output the ID of the variable
Debug.Print vbTab & "Var-ID" & vbTab & ": " & CStr(zPvIDs(i))
'Output the date and time when the value was recorded -> Format: year-month-day hour:minute:second.millisecond
Debug.Print vbTab & "Time" & vbTab & ": " & Format(zTimeConvert.zenOn2System((vValTemp(0))), "yyyy-mm-dd hh:mm:ss") & "." & CStr(vValTemp(1))
'Output the value that was recorded
Debug.Print vbTab & "Value" & vbTab & ": " & CStr(vValTemp(2))
'Output the state of the value
Debug.Print vbTab & "State" & vbTab & ": &H" & Hex(vValTemp(3))
Next j
Next i
End Sub