Promotic

GetValueByTime - method of the PmaTrendGroup object

Description:
Returns a value (or more values) of a variable (more variables) by the specified time.
If the time specified in the tTime parameter with the specified precision (in the sStyle parameter) is found, then the values of the required variables that meet the found time, are returned.
Syntax:
Variant GetValueByTime(String sWhat, Date tTime, Long nTimeType, String sStyle)
Parameters:
sWhat(String) Specification of the variable (or variables) whose stored value(s) has to be returned. It is possible to enter, for example:
"a1;" or "a1;a2;a3;" if an array of variables (with names a1..a3) of the "Data" tab has to be returned or
"time;" if even the time has to be returned.

At the variables it is necessary to keep the order by the order on the tab. For example, if the order of variables is a1,a2,a3,... on the tab, then it is possible to enter, for example, "a1;a3;" in the parameter but "a3;a1" is wrong.
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".
tTime(Date) Time whose record of variables values has to be searched.
nTimeType(Long) Time type in the tTime parameter.
1 - tTime 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 depending on the locale setting of Windows system)
2 - tTime is "standard time" (in the daylight-saving and standard season).
sStyle(String) Way of searching the time specified in the tTime parameter.
"eq:xxx" - Record whose timestamp equals the tTime time, is searched. The string xxx specifies the precision of the equality.
For xxx the values Nsec, Nmin are enabled, where N is a real number that sets the number seconds, respectively the number of minutes.
If, for example, 15 seconds (...,14:00,14:15,14:30,...) values are stored by the PmaTrendGroup object, then after entering tTime=time 14:17, sStyle="eq:3sec", the record of variables with a timestamp 14:15 will be found.
"newest" - The latest record is looked for. In the tTime parameter, the value 0 needs to be set.
"oldest" - The oldest record is looked for. In the tTime parameter, the value 0 needs to be set.
Return value:
The method returns the value (the array of values) of a variable (more variables).
If the time specified in the tTime parameter is not found then the method returns: null for JavaScript or Empty for VBScript (it can be tested by the Pm.IsValid method).
Note:
At the same time the method can return, together with the returned values, even the found time that can differ from the time in the tTime parameter but by the above mentioned precision at the most. See examples.
Example1:
Search for a record by the tTime time. The timestamp of record can differ from the tTime time by 1 second at the most. The found time is returned as the first value in the values array, the value of the a0 variable at the found time as the second value, the value of the a1 variable as the third value.
JavaScriptVBScriptSelect and copy to clipboard

var values, tTime;
var oTrend = pMe.Pm("/Trends");
values = oTrend.GetValueByTime("time;a0;a1", tTime, 1, "eq:1sec");

if (Pm.IsValid(values))
{
Pm.Debug(values.GetItem(0));
Pm.Debug(values.GetItem(1));
Pm.Debug(values.GetItem(2));
}
Example2:
Search for a record by the tTime time. The timestamp of record can differ from the tTime time by 1 1/2 minute at the most. The found time IS NOT returned. The value of the a0 variable at the found time is returned as the first value in the values array, the value of the a1 variable as the second value.
JavaScriptVBScriptSelect and copy to clipboard

var values, tTime;
var oTrend = pMe.Pm("/Trends");
values = oTrend.GetValueByTime("a0;a1", tTime, 1, "eq:1.5min");

if (Pm.IsValid(values))
{
Pm.Debug(values.GetItem(0));
Pm.Debug(values.GetItem(1));
}

History:
Pm8.00.03: Fixed bug: did not work if the "Storage type" configurator is set to one of the "cyclic" types.
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

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