Promotic
WikipediaLinkedInYoutubeTwitterFacebook

CreateFilter - method of object PmTrend

Description:
Creating the value of the filter range for next methods. By calling the method the value with query parameters for the GetData method is created.
Syntax:
CreateFilter(tFrom As Date, nFromType As Long, tTo As Date, nToType As Long, nPoints As Long) As Variant
Calling:
vFilter = oTrend.CreateFilter(tFrom, nFromType, tTo, nToType, nPoints)
Parameters:
tFrom(Date) Opening time from. If the value -1 is set, then it isn't used and the Range is defined only by the tTo and nPoints parameters.
nFromType(Long) Type of the opening time from
1 - tFrom is "local time" (the "standard time" in the standard season and the "daylight-saving time" in the daylight-saving season, corresponds to the computer time according to the local settings)
2 - tFrom is "standard time" (in the daylight-saving and standard seasons)
10 - The oldest time. In parameter tFrom enter the value -1.
tTo(Date) Closing time to. If the value -1 is set, then it isn't used and the Range is defined only by the tFrom and nPoints parameters.
nToType(Long) Type of the closing time to
1 - tTo is "local time" (the "standard time" in the standard season and the "daylight-saving time" in the daylight-saving season, corresponds to the computer time according to the local settings)
2 - tTo is "standard time" (in the daylight-saving and standard seasons)
11 - the newest time. In parameter tTo enter the value -1.
nPoints(Long) Maximum number of points. If the value -1 is set, then nPoints is set to value, that is readed from configurator Maximum point count returned in message by trend server (for one variable):. If the tFrom, tTo and nPoints parameters are set diverse from -1, the generated query returns the set of points from tFrom to tTo time but nPoints points as the maximum.
Note:
The parameters tFrom, tTo can be generated by calling the GetDateOf method. Thus it is possible, for example, to enter the time to the GetDateOf method as the input parameter and to find out the time so as the tFrom, tTo define for example the begin (time 00:00) and the end (time 24:00) of the day into which thus assigned time belongs.
Example1:
Getting the trend data in the time range <curren time - 1 hour, current time>. Time values are in the aTime array and values of the a1 variable are in the aData array.
Dim vFilter, tNow, aData, aTime
tNow = Now
vFilter = oTrend.CreateFilter(tNow-1/24, 1, tNow, 1, -1)
aTime = oTrend.GetData("time", vFilter)
aData = oTrend.GetData("a1", vFilter)
If Pm.IsValid(aTime) Then
  Pm.Debug "The time of the first value is " & aTime(0)
  Pm.Debug "The value of the a1 variable in this time is " & aData(0)
End If
Example2:
Getting the trend data in the range of 1000 points before the current time. Data values are in the aData 2-dimensional array.
Dim vFilter, aData
vFilter = oTrend.CreateFilter(-1, 0, Now, 1, 1000)
aData = oTrend.GetData("time;attr;a1;a2;", vFilter)
If Pm.IsValid(aData) Then
  Pm.Debug "The time of the first value is " & aData(0,0)
  Pm.Debug "The attribute value in this time is " & aData(1,0)
  Pm.Debug "The value of the a1 variable in this time is " & aData(2,0)
  Pm.Debug "The value of the a2 variable in this time is " & aData(3,0)
End If
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice