Comparing versions 1 and 2.
TimerInfotron
Everytime a message comes into "trigger", the timer is reset
input terminals: trigger - <type: any>
output_terminals: time_out - <type: any>
properties: timeout - <type: number> timeout_value - <type: any> auto_start - <type: boolean>
Demos that use it
- timer.html
BLUEPRINT(
"~01F5F5C7589CB94811A660996941406A57",
[
["%startup", "onStartUp", 1],
["trigger_in", "onTrigger", 1]
],
[
"timeout_value_out"
],
function()
{
var Blueprint = function(id, props, bp_uuid)
{
this.__init__(id, bp_uuid);
this._id = undefined;
this._timeout = props["timeout"] || 1000;
this._timeout_val = props["timeout_value"];
this._autostart = (props["auto_start"] == false) ? false : true;
};
Blueprint.prototype = new Infotron;
Blueprint.prototype.onStartUp = function(msg)
{
if (this._autostart) {
this.onTrigger(msg);
}
}
Blueprint.prototype.onTrigger = function(msg)
{
var val;
var self = this;
var func = function()
{
if (self._timeout_val === undefined) {
val = new Date();
} else {
val = self._timeout_val;
}
self.postMessage("timeout_value_out", val);
};
if (this._id != undefined) {
__w.clearTimeout(this._id);
}
this._id = __w.setTimeout(func, this._timeout);
};
return Blueprint;
}, "Wait, then Send Message");