From 475caa90db60c35b491f82340069a1ea4ba6757d Mon Sep 17 00:00:00 2001 From: "p.vanderwilt" Date: Mon, 21 Jul 2025 17:32:00 +0200 Subject: [PATCH 1/6] Fixed bugs in connectReactor --- src/helper/childRegistrationUtils.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/helper/childRegistrationUtils.js b/src/helper/childRegistrationUtils.js index 8db49d8..7b3cbb7 100644 --- a/src/helper/childRegistrationUtils.js +++ b/src/helper/childRegistrationUtils.js @@ -237,9 +237,8 @@ class ChildRegistrationUtils { this.logger.info(`Reactor registered successfully.`); reactor.emitter.on("stateChange", (data) => { - this.mainClass.logger.debug(`State change of reactor detected: ${data}`); - this.mainClass.setInflux = data; - this.mainClass.updateState(data.timestamp); + this.mainClass.logger.debug(`State change of upstream reactor detected.`); + this.mainClass.updateState(data); }); } From 71643375fc1ace033bc6d4b2149e81464dab8e05 Mon Sep 17 00:00:00 2001 From: "p.vanderwilt" Date: Thu, 24 Jul 2025 15:09:04 +0200 Subject: [PATCH 2/6] Added additional reactor handling --- src/helper/childRegistrationUtils.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/helper/childRegistrationUtils.js b/src/helper/childRegistrationUtils.js index 7b3cbb7..0a2aaac 100644 --- a/src/helper/childRegistrationUtils.js +++ b/src/helper/childRegistrationUtils.js @@ -233,7 +233,18 @@ class ChildRegistrationUtils { this.logger.warn("Invalid reactor provided."); return; } - this.mainClass.upstreamReactor = reactor; // Add reactor to the main class + + // this is poor code, it should be fixed at some point + if (this.mainClass?.upstreamReactor){ + this.mainClass.upstreamReactor = reactor; // Add reactor to the main class + } else { + if (positionVsParent == "downstream") { + this.mainClass.reactors[0] = reactor; + } + if (positionVsParent == "upstream") { + this.mainClass.reactors[1] = reactor; + } + } this.logger.info(`Reactor registered successfully.`); reactor.emitter.on("stateChange", (data) => { From aec2d3692dbe59f73cf3a2fc91d920db55cb9442 Mon Sep 17 00:00:00 2001 From: "p.vanderwilt" Date: Thu, 31 Jul 2025 11:36:42 +0200 Subject: [PATCH 3/6] Fixed missing reference to position --- src/helper/childRegistrationUtils.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/helper/childRegistrationUtils.js b/src/helper/childRegistrationUtils.js index 0a2aaac..1d1a723 100644 --- a/src/helper/childRegistrationUtils.js +++ b/src/helper/childRegistrationUtils.js @@ -85,12 +85,12 @@ class ChildRegistrationUtils { case "actuator": this.logger.debug(`Registering linear actuator child: ${id}`); - this.connectActuator(child,positionVsParent); + this.connectActuator(child, positionVsParent); break; case "reactor": this.logger.debug(`Registering reactor child: ${id}`); - this.connectReactor(child); + this.connectReactor(child, positionVsParent); break; default: @@ -228,7 +228,7 @@ class ChildRegistrationUtils { //wanneer hij deze ontvangt is deltaP van een van de valves veranderd (kan ook zijn niet child zijn, maar dat maakt niet uit) - connectReactor(reactor) { + connectReactor(reactor, positionVsParent) { if (!reactor) { this.logger.warn("Invalid reactor provided."); return; From 7191e57aeaa864dafa0b5be331b040a82b9ecd73 Mon Sep 17 00:00:00 2001 From: "p.vanderwilt" Date: Thu, 31 Jul 2025 14:57:38 +0200 Subject: [PATCH 4/6] Improved reactor registration --- src/helper/childRegistrationUtils.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/helper/childRegistrationUtils.js b/src/helper/childRegistrationUtils.js index 1d1a723..3ba661a 100644 --- a/src/helper/childRegistrationUtils.js +++ b/src/helper/childRegistrationUtils.js @@ -234,18 +234,20 @@ class ChildRegistrationUtils { return; } - // this is poor code, it should be fixed at some point if (this.mainClass?.upstreamReactor){ this.mainClass.upstreamReactor = reactor; // Add reactor to the main class - } else { + this.logger.info(`Upstream reactor registered successfully.`); + } + + if (this.mainClass?.reactors) { if (positionVsParent == "downstream") { this.mainClass.reactors[0] = reactor; } if (positionVsParent == "upstream") { this.mainClass.reactors[1] = reactor; } + this.logger.info(`Reactor registered successfully.`); } - this.logger.info(`Reactor registered successfully.`); reactor.emitter.on("stateChange", (data) => { this.mainClass.logger.debug(`State change of upstream reactor detected.`); From 0bccad05f8eaa925f05a07bfefcf9416c7e32a59 Mon Sep 17 00:00:00 2001 From: "p.vanderwilt" Date: Fri, 1 Aug 2025 12:30:12 +0200 Subject: [PATCH 5/6] Added error message to node registration --- src/helper/childRegistrationUtils.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/helper/childRegistrationUtils.js b/src/helper/childRegistrationUtils.js index 3ba661a..532e414 100644 --- a/src/helper/childRegistrationUtils.js +++ b/src/helper/childRegistrationUtils.js @@ -237,9 +237,7 @@ class ChildRegistrationUtils { if (this.mainClass?.upstreamReactor){ this.mainClass.upstreamReactor = reactor; // Add reactor to the main class this.logger.info(`Upstream reactor registered successfully.`); - } - - if (this.mainClass?.reactors) { + } else if (this.mainClass?.reactors) { if (positionVsParent == "downstream") { this.mainClass.reactors[0] = reactor; } @@ -247,6 +245,8 @@ class ChildRegistrationUtils { this.mainClass.reactors[1] = reactor; } this.logger.info(`Reactor registered successfully.`); + } else { + this.logger.error(`Reactor not registered!`) } reactor.emitter.on("stateChange", (data) => { From 958ec2269c902f3ebb11b13527fbc860ee9381e7 Mon Sep 17 00:00:00 2001 From: "p.vanderwilt" Date: Wed, 3 Sep 2025 11:13:00 +0200 Subject: [PATCH 6/6] Print reactors state after configuration --- src/helper/childRegistrationUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helper/childRegistrationUtils.js b/src/helper/childRegistrationUtils.js index 532e414..eac2e7d 100644 --- a/src/helper/childRegistrationUtils.js +++ b/src/helper/childRegistrationUtils.js @@ -244,7 +244,7 @@ class ChildRegistrationUtils { if (positionVsParent == "upstream") { this.mainClass.reactors[1] = reactor; } - this.logger.info(`Reactor registered successfully.`); + this.logger.info(`Reactor registered successfully: ${this.mainClass.reactors}`); } else { this.logger.error(`Reactor not registered!`) }