Process output using tick function rather than clock message

This commit is contained in:
2025-07-22 12:20:29 +02:00
parent 57aafe3e0b
commit f81161b2d5

View File

@@ -21,6 +21,8 @@ class nodeClass {
this._attachInputHandler();
this._registerChild();
this._startTickLoop();
this._attachCloseHandler();
}
/**
@@ -32,7 +34,6 @@ class nodeClass {
switch (msg.topic) {
case "clock":
this.source.updateState(msg.timestamp);
send([this.source.getEffluent, null, null]);
send([msg, null, null]);
break;
case "Fluent":
@@ -137,6 +138,22 @@ class nodeClass {
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;