Promotic
WikipediaLinkedInYoutubeTwitterFacebook

AddEventTimer - method of the PmaRoot object

Description:
Registers a request into the application timer for unrepeated or repeated calling of a function after a defined time period.
Syntax:
Empty AddEventTimer(Long nTime, Long nType, String sFuncId, Function Func)
Parameters:
nTime(Long) Time period (period or timeout) in milliseconds after which the function is called.
nType(Long) Inner timer request type.
-1 - The function will be called repeatedly with defined period.
1 - The function will be called once with defined delay (timeout).
sFuncId(String) Identifier of registered event function.
- allows removal of function by the RemoveEventTimer method
- prevents duplicate registering of the same function
- may contain any characters (this is not a system name)
- it is recommended to use e.g. the whole path to Pma object
Func(Function) JavaScript event function that will be called by application timer.
Example:
The example of repeated (10x) running of a function executed in two ways. The first approach is to repeatedly register new function for single execution while it is needed.
JavaScriptSelect and copy to clipboard

function OnTick()
{
Pm.Debug("OnTick: tClick=" + Pm.FormatDate(tClicked, 1) + "nCounter = " + nCounter);
if (nCounter-- > 0)
pMe.Root.AddEventTimer(1000, 1, pMe.GetPathName(), OnTick);
}
var tClicked = Pm.Time;
var nCounter = 10;
pMe.Root.AddEventTimer(1000, 1, pMe.GetPathName(), OnTick);
Another approach is to register the function once for repeated execution and then un-registering it after it is no longer needed. Simultaneously executes animation of graphic object "Ellipse" in the panel.
JavaScriptSelect and copy to clipboard

function OnTick()
{
Pm.Debug("OnTick: tClick=" + Pm.FormatDate(tClicked, 1) + "nCounter = " + nCounter);
if (nCounter-- < 0)
pMe.Root.RemoveEventTimer(pMe.GetPathName());
}
var tClicked = Pm.Time;
var nCounter = 10;
pMe.Root.AddEventTimer(60, -1, pMe.GetPathName(), OnTick);

History:
Pm9.00.16: New the sFuncId parameter
Pm9.00.09: Created
PROMOTIC 9.0.17 SCADA system documentation - MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice