Partial implementation of children handlers
This commit is contained in:
@@ -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;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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 };
|
||||
Reference in New Issue
Block a user