Update generalFunctions dependency and enhance reactor child registration logic
This commit is contained in:
2
package-lock.json
generated
2
package-lock.json
generated
@@ -62,7 +62,7 @@
|
|||||||
},
|
},
|
||||||
"node_modules/generalFunctions": {
|
"node_modules/generalFunctions": {
|
||||||
"version": "1.0.0",
|
"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"
|
"license": "SEE LICENSE"
|
||||||
},
|
},
|
||||||
"node_modules/javascript-natural-sort": {
|
"node_modules/javascript-natural-sort": {
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class nodeClass {
|
|||||||
this.source.setDispersion = msg;
|
this.source.setDispersion = msg;
|
||||||
break;
|
break;
|
||||||
case 'registerChild':
|
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 childId = msg.payload;
|
||||||
const childObj = this.RED.nodes.getNode(childId);
|
const childObj = this.RED.nodes.getNode(childId);
|
||||||
this.source.childRegistrationUtils.registerChild(childObj.source, msg.positionVsParent);
|
this.source.childRegistrationUtils.registerChild(childObj.source, msg.positionVsParent);
|
||||||
|
|||||||
@@ -44,18 +44,6 @@ class Reactor {
|
|||||||
this.speedUpFactor = 60; // speed up factor for simulation, 60 means 1 minute per simulated second
|
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.
|
* Setter for influent data.
|
||||||
* @param {object} input - Input object (msg) containing payload with inlet index, flow rate, and concentrations.
|
* @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.
|
* Update the reactor state based on the new time.
|
||||||
* @param {number} newTime - New time to update reactor state to, in milliseconds since epoch.
|
* @param {number} newTime - New time to update reactor state to, in milliseconds since epoch.
|
||||||
|
|||||||
Reference in New Issue
Block a user