Promotic
WikipediaLinkedInYoutubeTwitterFacebook

AddFilter - method of object PmTrend

Description:
The filter for the filtration of one variable value is added to existing filtr. The method must be called always after calling the CreateFilter method that specifies the time range of the query. The method can be called repeatedly and so it can create more filters for one or even more variables (over one variable it is possible to create two filters at the most). The final filter that is created by calling the CreateFilter method and by repeated calling AddFilter, is passed to the GetData method.
Syntax:
AddFilter(vFilter As Variant, sTrend As String, sFilterType As String, nVal1 As Double) As Variant
Calling:
vFilter = oTrend.AddFilter(vFilter, sTrend, sTypeFilter, nVal)
Parameters:
vFilter(Variant) Value of the filter created by the previous calling CreateFilter, possibly modified by the AddFilter method.
sTrend(String) Name of the variable (see the Data page) over which the filter has to be applied.
sFilterType(String) Type of the filter that specifies the way of testing the values of the variable.
"gt" - Value of the variable meets the filter if it is greater sharp than the value of the parameter vVal1.
"ge" - Value of the variable meets the filter if it is greater or equal to the value of the parameter vVal1.
"le" - Value of the variable meets the filter if it is less or equal to the value of the parameter vVal1.
"lt" - Value of the variable meets the filter if it is less sharp than the value of the parameter vVal1.
nVal1(Double) Value towards which the values of the variable are tested
Example1:
Getting the trend data in the time range <current time - 1 hour, current time>. The trend data are filtered and they are returned in the form of the data matrix with the values of the time and variables a1,a2 there the variable a1 is in the range from 30 to 70.
Dim vFilter, tNow, aData
tNow = Now
vFilter = oTrend.CreateFilter(tNow-1/24, 1, tNow, 1, -1)
vFilter = oTrend.AddFilter(vFilter, "a1", "lt", 70)
vFilter = oTrend.AddFilter(vFilter, "a1", "gt", 30)
aData = oTrend.GetData("time;a1;a2", vFilter)
If Pm.IsValid(aData) Then
  Pm.Debug "The time of the first value is " & aData(0,0)
  Pm.Debug "The value of the a1 variable in this time is " & aData(1,0)
  Pm.Debug "The value of the a2 variable in this time is " & aData(2,0)
End If
Example2:
Calculated values that are returned in the array of values by the order of entering in the GetData method, are got. The calculation proceeds over all data from the time range by entering in CreateFilter. The data are not filtered by the values.
Dim vFilter, tNow, aData
tNow = Now
vFilter = oTrend.CreateFilter(tNow-1/24, 1, tNow, 1, -1)
aData = oTrend.GetData("avg(a1);avg(a1;weighted);min(a1);count(a1);avg(a2);avg(a2;weighted);min(a2);count(a2)", vFilter)
If Pm.IsValid(aData) Then
  Pm.Debug "The average value of the a1,a2 variable are " & aData(0)&"; "& aData(4)
  Pm.Debug "The weighted average values of the a1,a2 variables are " & aData(1)&"; "& aData(5)
  Pm.Debug "The minimum values of the a1,a2 variables are " & aData(2)&"; "& aData(6)
  Pm.Debug "The value counts of the a1,a2 variables are " & aData(3)&"; "& aData(7)
End If
Example3:
Calculated values that are returned in the array of values by the order of entering in the GetData method, are got. The calculation proceeds over the data from the time range by entering in CreateFilter and they are filtered by the values of the filter in AddFilter.
Dim vFilter, tNow, aData
tNow = Now
vFilter = oTrend.CreateFilter(tNow-1/24, 1, tNow, 1, -1)
vFilter = oTrend.AddFilter(vFilter, "a1", "lt", 70)
vFilter = oTrend.AddFilter(vFilter, "a2", "gt", 30)
aData = oTrend.GetData("avg(a1);avg(a1;weighted);min(a1);count(a1);avg(a2);avg(a2;weighted);min(a2);count(a2)", vFilter)
If Pm.IsValid(aData) Then
  Pm.Debug "The average value of the a1,a2 variable are " & aData(0)&"; "& aData(4)
  Pm.Debug "The weighted average values of the a1,a2 variables are " & aData(1)&"; "& aData(5)
  Pm.Debug "The minimum values of the a1,a2 variables are " & aData(2)&"; "& aData(6)
  Pm.Debug "The value counts of the a1,a2 variables are " & aData(3)&"; "& aData(7)
End If
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice