From edd37a707bce092ef069d4ea188fb9033bb7f38d Mon Sep 17 00:00:00 2001
From: "p.vanderwilt"
Date: Thu, 24 Jul 2025 15:07:00 +0200
Subject: [PATCH] Partial implementation of children handlers
---
src/nodeClass.js | 21 +++------------------
src/specificClass.js | 17 +++++++++++++++++
2 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/src/nodeClass.js b/src/nodeClass.js
index 91a6098..16a467a 100644
--- a/src/nodeClass.js
+++ b/src/nodeClass.js
@@ -28,9 +28,8 @@ class nodeClass {
this._setupSpecificClass();
// Wire up event and lifecycle handlers
- // this._registerChild();
this._startTickLoop();
- // this._attachInputHandler();
+ this._attachInputHandler();
this._attachCloseHandler();
}
@@ -45,7 +44,7 @@ class nodeClass {
general: {
name: uiConfig.name,
id: this.node.id, // node.id is for the child registration process
- unit: uiConfig.unit, // add converter options later to convert to default units (need like a model that defines this which units we are going to use and then conver to those standards)
+ unit: null,
logging: {
enabled: uiConfig.enableLog,
logLevel: uiConfig.logLevel
@@ -68,20 +67,6 @@ class nodeClass {
this.node.source = this.source; // Store the source in the node instance for easy access
}
- /**
- * Register this node as a child upstream and downstream.
- * Delayed to avoid Node-RED startup race conditions.
- */
- _registerChild() {
- setTimeout(() => {
- this.node.send([
- null,
- null,
- { topic: 'registerChild', payload: this.config.general.id, positionVsParent: this.config?.functionality?.positionVsParent || 'atEquipment' },
- ]);
- }, 100);
- }
-
/**
* Start the periodic tick loop.
*/
@@ -113,7 +98,7 @@ class nodeClass {
// Register this node as a child of the parent node
const childId = msg.payload;
const childObj = this.RED.nodes.getNode(childId);
- this.source.childRegistrationUtils.registerChild(childObj.source ,msg.positionVsParent);
+ this.source.childRegistrationUtils.registerChild(childObj.source, msg.positionVsParent);
break;
}
});
diff --git a/src/specificClass.js b/src/specificClass.js
index d1e0a28..eee7a8b 100644
--- a/src/specificClass.js
+++ b/src/specificClass.js
@@ -6,8 +6,25 @@ class liquidFlowHandler {
this.config = config;
this.logger = new logger(this.config.general.logging.enabled, this.config.general.logging.logLevel, config.general.name);
+ this.reactors = Array(2);
+ this.machines = {};
+ this.debit = 0;
this.childRegistrationUtils = new childRegistrationUtils(this);
}
+
+ updateState(timeStamp) {
+ effluent = this.reactors[1].getEffluent();
+ effluent.F = this.debit;
+ this.reactors[0].setInfluent = effluent;
+ }
+
+ handleChildChange() {
+
+ }
+
+ handlePressureChange(machine) {
+ this.debit = machine.measurements.type("flow").variant("predicted").position("downstream").getCurrentValue();
+ }
}
module.exports = { liquidFlowHandler };
\ No newline at end of file