Promotic

GetData - method of the PmaTrendGroup object

Description:
Returns the stored data from the range specified by the vFilter parameter. According to the way of creating vFilter, either all data are returned or values are filtered if the filtration is used by AddFilter.
The method can return even a calculated value or the array of calculated values from the values of variables that meet the specified filter, see the assignment of the sWhat parameter.
Syntax:
Array GetData(String sWhat, Variant vFilter)
Parameters:
sWhat(String) Specification of what to be returned:

It is possible to enter a list of variables whose values has to be returned:
- "a1;" or "a1;a2;a3;" - If an array of variables of the "Data" tab has to be returned.
It is necessary to keep the order of variables on the tab.
For example, if the order of variables is a1,a2,a3,... on the tab, then in the parameter it is possible to enter, for example, "a1;a3;" but "a3;a1" is wrong.
- "time;" - If an array of the time has to be returned.
Time selection can be changed by entering "time:winter;" and then all time values are returned in the "standard time" otherwise they are in the "local time".
- "attr;" - If an array of the record attributes has to be returned.
- "*data;" - Mean all variables except time and attribute ("time;*data;" returns time and all data variables).
- "*;" - Returns time, attribute and all data variables.


It is possible to enter also a function for calculation whose final values has to be returned. The functions can be concatenated by the ; char, for example "avg(a1);min(a1)". The following functions are supported:
- "avg(xx)" - The method returns the average value of the xx variable from the values that meet filtering conditions specified by the vFilter filter.
- "avg(xx;weighted)" - The method returns the weighed value of the xx variable from the values that meet filtering conditions specified by the vFilter filter. The weight of the value is here the length of its duration until the time of saving the next value.
- "min(xx)" - The method returns the minimum value of the xx variable from the values that meet filtering conditions specified by the vFilter filter.
- "max(xx)" - The method returns the maximum value of the xx variable from the values that meet filtering conditions specified by the vFilter filter.
- "sum(xx)" - The method returns the sum of all values of the xx variable from the values that meet filtering conditions specified by the vFilter filter.
- "count(xx)" - The method returns the number of values of the xx variable from the values that meet filtering conditions specified by the vFilter filter.


It is possible to enter only the list of variables or function for calculation - but not at the same time. For example, "avg(0);a1" is WRONG.
vFilter(Variant) Value that defines, for example, the time range of the got data (time from, time to, number of points, etc.), eventually specifies whether the data have to be filtered by the value. It is created by calling the methods CreateFilter, AddFilter.

The value filter (filter for each value added by the AddFilter method) will be applied following way:
If the sWhat parameter contains the list of variables, then it could happen that for each variable there would be a different number of lines (different number of stored values). Therefore it is necessary to process "lines intersection" - i.e. select only lines common for all variables.
If the sWhat parameter contains the calculation function, then the value filters for each variable will be used only for calculating these variables and will not affect calcualtion of another variables.
Return value:
Returns requested data as 1- or 2-dimensional array of values (PmArray object for JavaScript or Array data type for VBScript).
If such data don't exist or if an error occurred then the method returns: null for JavaScript or Empty for VBScript (it can be tested by the Pm.IsValid method).
If in the sWhat parameter is function for calculation, then it returns either the simple value or the 1-dimensional array array of calculated values.
Note:
Statistical operations over the data field can also be done by the Pm.ArrayOper method.
Example1:
JavaScriptVBScriptSelect and copy to clipboard

var oTrend = pMe.Pm("/Trends");
var arr = oTrend.GetData("time;*data;", vFilter);
Example2:
See examples in the CreateFilter and AddFilter methods
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r.o.