before functional changes by Codex
This commit is contained in:
@@ -21,6 +21,7 @@ class nodeClass {
|
||||
this.name = nameOfNode; // This is the name of the node, it should match the file name and the node type in Node-RED
|
||||
this.source = null; // Will hold the specific class instance
|
||||
this.config = null; // Will hold the merged configuration
|
||||
this._pressureInitWarned = false;
|
||||
|
||||
// Load default & UI config
|
||||
this._loadConfig(uiConfig,this.node);
|
||||
@@ -117,6 +118,22 @@ class nodeClass {
|
||||
try {
|
||||
const mode = m.currentMode;
|
||||
const state = m.state.getCurrentState();
|
||||
const requiresPressurePrediction = ["operational", "warmingup", "accelerating", "decelerating"].includes(state);
|
||||
const pressureStatus = typeof m.getPressureInitializationStatus === "function"
|
||||
? m.getPressureInitializationStatus()
|
||||
: { initialized: true };
|
||||
|
||||
if (requiresPressurePrediction && !pressureStatus.initialized) {
|
||||
if (!this._pressureInitWarned) {
|
||||
this.node.warn("Pressure input is not initialized (upstream/downstream missing). Predictions are using minimum pressure.");
|
||||
this._pressureInitWarned = true;
|
||||
}
|
||||
return { fill: "yellow", shape: "ring", text: `${mode}: pressure not initialized` };
|
||||
}
|
||||
|
||||
if (pressureStatus.initialized) {
|
||||
this._pressureInitWarned = false;
|
||||
}
|
||||
const flow = Math.round(m.measurements.type("flow").variant("predicted").position('downstream').getCurrentValue('m3/h'));
|
||||
const power = Math.round(m.measurements.type("power").variant("predicted").position('atEquipment').getCurrentValue('kW'));
|
||||
let symbolState;
|
||||
@@ -234,7 +251,7 @@ class nodeClass {
|
||||
const influxMsg = this._output.formatMsg(raw, this.source.config, 'influxdb');
|
||||
|
||||
// Send only updated outputs on ports 0 & 1
|
||||
this.node.send([processMsg, influxMsg]);
|
||||
this.node.send([processMsg, influxMsg, null]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -242,13 +259,20 @@ class nodeClass {
|
||||
*/
|
||||
_attachInputHandler() {
|
||||
this.node.on('input', (msg, send, done) => {
|
||||
/* Update to complete event based node by putting the tick function after an input event */
|
||||
/* Update to complete event based node by putting the tick function after an input event */
|
||||
const m = this.source;
|
||||
switch(msg.topic) {
|
||||
const nodeSend = typeof send === 'function' ? send : (outMsg) => this.node.send(outMsg);
|
||||
|
||||
try {
|
||||
switch(msg.topic) {
|
||||
case 'registerChild':
|
||||
// Register this node as a child of the parent node
|
||||
const childId = msg.payload;
|
||||
const childObj = this.RED.nodes.getNode(childId);
|
||||
const childObj = this.RED.nodes.getNode(childId);
|
||||
if (!childObj || !childObj.source) {
|
||||
this.node.warn(`registerChild failed: child '${childId}' not found or has no source`);
|
||||
break;
|
||||
}
|
||||
m.childRegistrationUtils.registerChild(childObj.source ,msg.positionVsParent);
|
||||
break;
|
||||
case 'setMode':
|
||||
@@ -292,7 +316,11 @@ class nodeClass {
|
||||
|
||||
switch (type) {
|
||||
case 'pressure':
|
||||
m.updateMeasuredPressure(value, position, context);
|
||||
if (typeof m.updateSimulatedMeasurement === "function") {
|
||||
m.updateSimulatedMeasurement(type, position, value, context);
|
||||
} else {
|
||||
m.updateMeasuredPressure(value, position, context);
|
||||
}
|
||||
break;
|
||||
case 'flow':
|
||||
m.updateMeasuredFlow(value, position, context);
|
||||
@@ -306,14 +334,20 @@ class nodeClass {
|
||||
}
|
||||
break;
|
||||
case 'showWorkingCurves':
|
||||
m.showWorkingCurves();
|
||||
send({ topic : "Showing curve" , payload: m.showWorkingCurves() });
|
||||
nodeSend([{ ...msg, topic : "showWorkingCurves" , payload: m.showWorkingCurves() }, null, null]);
|
||||
break;
|
||||
case 'CoG':
|
||||
m.showCoG();
|
||||
send({ topic : "Showing CoG" , payload: m.showCoG() });
|
||||
nodeSend([{ ...msg, topic : "showCoG" , payload: m.showCoG() }, null, null]);
|
||||
break;
|
||||
}
|
||||
if (typeof done === 'function') done();
|
||||
} catch (error) {
|
||||
if (typeof done === 'function') {
|
||||
done(error);
|
||||
} else {
|
||||
this.node.error(error, msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user