AddFilter - method of the PmaTrendGroup object
Description:
The filter for the filtration of one variable value is added to existing filter. 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 two filters at the most can be created). The final filter that is created by calling the
CreateFilter method and by repeated calling
AddFilter method, is passed to the
GetData method.
Syntax:
Variant AddFilter(Variant vFilter, String sTrend, String sFilterType, Double nVal1)
Parameters:
vFilter | (Variant) Value of the filter created by calling the CreateFilter method, eventually modified by the AddFilter method. |
sTrend | (String) Name of the variable (see the "Data" tab) over which the filter has to be applied. |
sFilterType | (String) Type of the filter, specifies the way of testing the value of the variable.
"gt" - Value of the variable meets the filter, if it is greater than the value in the vVal1 parameter.
"ge" - Value of the variable meets the filter, if it is greater or equal to the value in the vVal1 parameter.
"le" - Value of the variable meets the filter, if it is less then or equal to the value in the vVal1 parameter.
"lt" - Value of the variable meets the filter, if it is less than the value in the vVal1 parameter. |
nVal1 | (Double) Value towards which the values of the variable are tested |
---|
Example1:
Detects 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 values of the time and variables a1,a2 there the a1 variable is in the range from 30 to 70.
JavaScriptVBScriptSelect and copy to clipboard
var tNow, vFilter, aData;
tNow = Pm.Time;
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))
{
Pm.Debug("The time of the first value is " + aData.GetItem(0, 0));
Pm.Debug("The value of the a1 variable in this time is " + aData.GetItem(1, 0));
Pm.Debug("The value of the a2 variable in this time is " + aData.GetItem(2, 0));
}
Dim tNow, vFilter, aData
tNow = Pm.Time
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 the
CreateFilter method.
The data are not filtered by the values.
JavaScriptVBScriptSelect and copy to clipboard
var tNow, vFilter, aData;
tNow = Pm.Time;
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))
{
Pm.Debug("The average values of the a1,a2 variables are " + aData.GetItem(0) + "; " + aData.GetItem(4));
Pm.Debug("The weighted average values of the a1,a2 variables are " + aData.GetItem(1) + "; " + aData.GetItem(5));
Pm.Debug("The minimum values of the a1,a2 variables are " + aData.GetItem(2) + "; " + aData.GetItem(6));
Pm.Debug("The value counts of the a1,a2 variables are " + aData.GetItem(3) + "; " + aData.GetItem(7));
}
Dim tNow, vFilter, aData
tNow = Pm.Time
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 values of the a1,a2 variables 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 the
CreateFilter method and they are filtered by the values of the filter of the
AddFilter method.
JavaScriptVBScriptSelect and copy to clipboard
var tNow, vFilter, aData;
tNow = Pm.Time;
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("avg(a1);avg(a1;weighted);min(a1);count(a1);avg(a2);avg(a2;weighted);min(a2);count(a2)", vFilter);
if (Pm.IsValid(aData))
{
Pm.Debug("The average values of the a1,a2 variables are " + aData.GetItem(0) + "; " + aData.GetItem(4));
Pm.Debug("The weighted average values of the a1,a2 variables are " + aData.GetItem(1) + "; " + aData.GetItem(5));
Pm.Debug("The minimum values of the a1,a2 variables are " + aData.GetItem(2) + "; " + aData.GetItem(6));
Pm.Debug("The value counts of the a1,a2 variables are " + aData.GetItem(3) + "; " + aData.GetItem(7));
}
Dim tNow, vFilter, aData
tNow = Pm.Time
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("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 values of the a1,a2 variables 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