Update generalFunctions dependency and enhance reactor child registration logic

This commit is contained in:
2025-09-05 15:26:00 +02:00
parent 0b49642668
commit c2cd29db56
3 changed files with 42 additions and 14 deletions

2
package-lock.json generated
View File

@@ -62,7 +62,7 @@
},
"node_modules/generalFunctions": {
"version": "1.0.0",
"resolved": "git+https://gitea.centraal.wbd-rd.nl/p.vanderwilt/generalFunctions.git#50f99fa64286b35dbb6ba1b6918ebe1175756ebc",
"resolved": "git+https://gitea.centraal.wbd-rd.nl/p.vanderwilt/generalFunctions.git#302e12238745766a679ef11ca6ed5f4ea1548f87",
"license": "SEE LICENSE"
},
"node_modules/javascript-natural-sort": {

View File

@@ -49,7 +49,7 @@ class nodeClass {
this.source.setDispersion = msg;
break;
case 'registerChild':
// Register this node as a child of the parent node
// Register this node as a parent of the child node
const childId = msg.payload;
const childObj = this.RED.nodes.getNode(childId);
this.source.childRegistrationUtils.registerChild(childObj.source, msg.positionVsParent);

View File

@@ -44,18 +44,6 @@ class Reactor {
this.speedUpFactor = 60; // speed up factor for simulation, 60 means 1 minute per simulated second
}
updateMeasurement(variant, subType, value, position) {
this.logger.debug(`---------------------- updating ${subType} ------------------ `);
switch (subType) {
case "temperature":
this.temperature = value;
break;
default:
this.logger.error(`Type '${subType}' not recognized for measured update.`);
return;
}
}
/**
* Setter for influent data.
* @param {object} input - Input object (msg) containing payload with inlet index, flow rate, and concentrations.
@@ -109,6 +97,46 @@ class Reactor {
}
}
registerChild(child, softwareType) {
switch (softwareType) {
case "reactor":
this.logger.debug(`Registering reactor child.`);
this.connectReactor(child);
break;
default:
this.logger.error(`Unrecognized softwareType: ${softwareType}`);
}
}
connectReactor(reactor) {
if (!reactor) {
this.logger.warn("Invalid reactor provided.");
return;
}
this.upstreamReactor = reactor;
reactor.emitter.on("stateChange", (data) => {
this.logger.debug(`State change of upstream reactor detected.`);
this.updateState(data);
});
}
updateMeasurement(variant, subType, value, position) {
this.logger.debug(`---------------------- updating ${subType} ------------------ `);
switch (subType) {
case "temperature":
this.temperature = value;
break;
default:
this.logger.error(`Type '${subType}' not recognized for measured update.`);
return;
}
}
/**
* Update the reactor state based on the new time.
* @param {number} newTime - New time to update reactor state to, in milliseconds since epoch.