diff --git a/src/nodeClass.js b/src/nodeClass.js index 989b806..97ec545 100644 --- a/src/nodeClass.js +++ b/src/nodeClass.js @@ -28,14 +28,12 @@ class nodeClass { */ _attachInputHandler() { this.node.on('input', (msg, send, done) => { - let toggleUpdate = false; switch (msg.topic) { case "clock": - toggleUpdate = true; this.source.updateState(msg.timestamp); send([this.source.getEffluent, null, null]); - send([msg, null, null]) + send([msg, null, null]); break; case "Fluent": this.source.setInfluent = msg; @@ -53,7 +51,6 @@ class nodeClass { // Register this node as a child of the parent node const childId = msg.payload; const childObj = this.RED.nodes.getNode(childId); - console.log(childObj.source); this.source.childRegistrationUtils.registerChild(childObj.source, msg.positionVsParent); break; default: @@ -139,6 +136,7 @@ class nodeClass { this.source = new_reactor; // protect from reassignment this.node.source = this.source; } + } module.exports = nodeClass; \ No newline at end of file diff --git a/src/specificClass.js b/src/specificClass.js index 99ed988..a240275 100644 --- a/src/specificClass.js +++ b/src/specificClass.js @@ -25,6 +25,7 @@ class Reactor { this.logger = new logger(undefined, undefined, config.general.name); this.emitter = new EventEmitter(); this.measurements = new MeasurementContainer(); + this.upstreamReactor = null; this.childRegistrationUtils = new childRegistrationUtils(this); // Child registration utility this.asm = new ASM3(); @@ -115,6 +116,10 @@ class Reactor { updateState(newTime) { // expect update with timestamp const day2ms = 1000 * 60 * 60 * 24; + if (this.upstreamReactor) { + this.setInfluent = this.upstreamReactor.getEffluent; + } + let n_iter = Math.floor(this.speedUpFactor * (newTime-this.currentTime) / (this.timeStep*day2ms)); if (n_iter) { let n = 0; @@ -123,7 +128,7 @@ class Reactor { n += 1; } this.currentTime += n_iter * this.timeStep * day2ms / this.speedUpFactor; - this.emitter.emit("stateChange", this.getEffluent); + this.emitter.emit("stateChange", newTime); } } }