Promotic

SetValueByTime - method of the PmaTrendGroup object

Description:
The method searches the record with a timestamp by the tTime parameter and if such record is found, then it writes the value (the array of values) of a variable (more variables) from the vData parameter into it. The timestamp of record is searched by the tTime and sParam parameters and it can differ from the time in the tTime parameter by the specified precision at the most. See the parameters description.
Syntax:
Boolean SetValueByTime(Variant vData, String sWhat, Date tTime, Long nTimeType, String sParam)
Parameters:
vData(Variant) Value or array of values. The number of values unambiguously refers to the number of variables in the sWhat parameter.
The order of variables in the sWhat string specifies the order of values in the vData array if more variables are defined in the sWhat.
If the sWhat parameter contains only one variable, then there is either a single value or an array with one item in vData.
sWhat(String) Specification of the variable (or of variables) whose stored value(s) has to be passed. It is possible to enter, for example, "a1;" or "a1;a2;a3;" if there has to be written into the array of variables on the "Data" tab.
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.
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).
sParam(String) Way of searching the time specified in the tTime parameter.
"eq:xxx" - A 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=14:17, sParam="eq:3sec", the record of variables with a timestamp 14:15 will be found.
Return value:
If the record is found by the time and the writing proceeded in order, then returns the true value, otherwise returns the false value.
Example:
Search for a record by the tTime time. The timestamp of record can differ from the tTime time by 1 second at the most. If the record is found, then the value of the a0 variable that corresponds to this time, is overwritten by the value of the vData(0) parameter and the value of the a1 variable is overwritten by the value of the vData(1) parameter.
JavaScriptVBScriptSelect and copy to clipboard

var oTrend = pMe.Pm("/Trends");
var vData = Pm.Array1(10, 20);
var tTime = Pm.CreateDate(2023, 3, 22, 12, 30, 30, 500);   // tTime setting

if (oTrend.SetValueByTime(vData, "a0;a1", tTime, 1, "eq:1sec"))
{
// variables a0,a1 are overwritten by values 10,20 successfully.
}

History:
Pm8.00.00: Fixed bug: Now it is possible to enter a single item array in the vData parameter.
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

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