Promotic
WikipediaLinkedInYoutubeTwitterFacebook

AddEventTimer - method of object PmgRoot

Description:
Registers a request into the panel inner timer for unrepeated or repeated calling of a function after a defined time period.
Syntax:
Empty AddEventTimer(Long nTime, Long nType, Function oFunc)
Calling:
oRoot.AddEventTimer(nTime, nType, oFunc)
Parameters:
nTime(Long) Time period (interval or timeout) in miliseconds after which the function is called.
nType(Long) Inner timer request type.
-1 - The function will be called repeatedly with defined period (interval).
1 - The function will be called once with defined delay (timeout).
oFunc(Function) JavaScript function (event, callback) that will be called by panel timer.
Note:

The inner panel timer allows to create panel animations (periodical calling), watch passing of defined time period of some asynchronous event (timeout), or react to some events with delay. All these features are not in any way dependent on the refresh rate of the panel.

This method is also functional in Web panels.

Example:
An 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, OnTick);
}
var tClicked = Pm.Time;
var nCounter = 10;
pMe.Root.AddEventTimer(1000, 1, 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);
oItem.X = oItem.X + 5;
oItem.Refresh();
if (nCounter-- < 0)
pMe.Root.RemoveEventTimer(OnTick);
}
var tClicked = Pm.Time;
var nCounter = 10;
var oItem = pMe.Items("/Ellipse");
pMe.Root.AddEventTimer(60, -1, OnTick);

History:
Pm9.00.06: Created
PROMOTIC 9.0.7 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