Process output using tick function rather than clock message
This commit is contained in:
@@ -21,6 +21,8 @@ class nodeClass {
|
|||||||
|
|
||||||
this._attachInputHandler();
|
this._attachInputHandler();
|
||||||
this._registerChild();
|
this._registerChild();
|
||||||
|
this._startTickLoop();
|
||||||
|
this._attachCloseHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,7 +34,6 @@ class nodeClass {
|
|||||||
switch (msg.topic) {
|
switch (msg.topic) {
|
||||||
case "clock":
|
case "clock":
|
||||||
this.source.updateState(msg.timestamp);
|
this.source.updateState(msg.timestamp);
|
||||||
send([this.source.getEffluent, null, null]);
|
|
||||||
send([msg, null, null]);
|
send([msg, null, null]);
|
||||||
break;
|
break;
|
||||||
case "Fluent":
|
case "Fluent":
|
||||||
@@ -137,6 +138,22 @@ class nodeClass {
|
|||||||
this.node.source = this.source;
|
this.node.source = this.source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_startTickLoop() {
|
||||||
|
setTimeout(() => {
|
||||||
|
this._tickInterval = setInterval(() => this._tick(), 1000);
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
_tick(){
|
||||||
|
this.node.send([this.source.getEffluent, null, null]);
|
||||||
|
}
|
||||||
|
|
||||||
|
_attachCloseHandler() {
|
||||||
|
this.node.on('close', (done) => {
|
||||||
|
clearInterval(this._tickInterval);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = nodeClass;
|
module.exports = nodeClass;
|
||||||
Reference in New Issue
Block a user