updates to rotating machine struct
This commit is contained in:
@@ -118,7 +118,7 @@ class nodeClass {
|
||||
const mode = m.currentMode;
|
||||
const state = m.state.getCurrentState();
|
||||
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'));
|
||||
const power = Math.round(m.measurements.type("power").variant("predicted").position('atEquipment').getCurrentValue('kW'));
|
||||
let symbolState;
|
||||
switch(state){
|
||||
case "off":
|
||||
@@ -189,7 +189,7 @@ class nodeClass {
|
||||
}
|
||||
return status;
|
||||
} catch (error) {
|
||||
node.error("Error in updateNodeStatus: " + error.message);
|
||||
this.node.error("Error in updateNodeStatus: " + error.message);
|
||||
return { fill: "red", shape: "ring", text: "Status Error" };
|
||||
}
|
||||
}
|
||||
@@ -271,6 +271,40 @@ class nodeClass {
|
||||
const { source: esSource, action: esAction } = msg.payload;
|
||||
m.handleInput(esSource, esAction);
|
||||
break;
|
||||
case 'simulateMeasurement':
|
||||
{
|
||||
const payload = msg.payload || {};
|
||||
const type = String(payload.type || '').toLowerCase();
|
||||
const position = payload.position || 'atEquipment';
|
||||
const value = Number(payload.value);
|
||||
const unit = payload.unit;
|
||||
const context = {
|
||||
timestamp: payload.timestamp || Date.now(),
|
||||
unit,
|
||||
childName: 'dashboard-sim',
|
||||
childId: 'dashboard-sim',
|
||||
};
|
||||
|
||||
if (!Number.isFinite(value)) {
|
||||
this.node.warn('simulateMeasurement payload.value must be a finite number');
|
||||
break;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case 'pressure':
|
||||
m.updateMeasuredPressure(value, position, context);
|
||||
break;
|
||||
case 'flow':
|
||||
m.updateMeasuredFlow(value, position, context);
|
||||
break;
|
||||
case 'temperature':
|
||||
m.updateMeasuredTemperature(value, position, context);
|
||||
break;
|
||||
default:
|
||||
this.node.warn(`Unsupported simulateMeasurement type: ${type}`);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'showWorkingCurves':
|
||||
m.showWorkingCurves();
|
||||
send({ topic : "Showing curve" , payload: m.showWorkingCurves() });
|
||||
|
||||
@@ -96,10 +96,15 @@ class Machine {
|
||||
this.measurements.type('temperature').variant('measured').position('atEquipment').value(15).unit('C');
|
||||
//assume standard atm pressure is at sea level
|
||||
this.measurements.type('atmPressure').variant('measured').position('atEquipment').value(101325).unit('Pa');
|
||||
//populate min and max
|
||||
//populate min and max when curve data is available
|
||||
const flowunit = this.config.general.unit;
|
||||
this.measurements.type('flow').variant('predicted').position('max').value(this.predictFlow.currentFxyYMax, Date.now() , flowunit)
|
||||
this.measurements.type('flow').variant('predicted').position('min').value(this.predictFlow.currentFxyYMin).unit(this.config.general.unit);
|
||||
if (this.predictFlow) {
|
||||
this.measurements.type('flow').variant('predicted').position('max').value(this.predictFlow.currentFxyYMax, Date.now() , flowunit);
|
||||
this.measurements.type('flow').variant('predicted').position('min').value(this.predictFlow.currentFxyYMin).unit(this.config.general.unit);
|
||||
} else {
|
||||
this.measurements.type('flow').variant('predicted').position('max').value(0, Date.now(), flowunit);
|
||||
this.measurements.type('flow').variant('predicted').position('min').value(0, Date.now(), flowunit);
|
||||
}
|
||||
}
|
||||
|
||||
_updateState(){
|
||||
@@ -705,7 +710,14 @@ _callMeasurementHandler(measurementType, value, position, context) {
|
||||
const atmPressure = this.measurements.type('atmPressure').variant('measured').position('atEquipment').getCurrentValue('Pa');
|
||||
|
||||
console.log(`--------------------calc efficiency : Pressure diff:${pressureDiff},${temp}, ${g} `);
|
||||
const rho = coolprop.PropsSI('D', 'T', temp, 'P', atmPressure, 'WasteWater');
|
||||
let rho = null;
|
||||
try {
|
||||
rho = coolprop.PropsSI('D', 'T', temp, 'P', atmPressure, 'WasteWater');
|
||||
} catch (error) {
|
||||
// coolprop can throw transient initialization errors; keep machine calculations running.
|
||||
this.logger.warn(`CoolProp density lookup failed: ${error.message}. Using fallback density.`);
|
||||
rho = 1000; // kg/m3 fallback for water-like fluids
|
||||
}
|
||||
|
||||
|
||||
this.logger.debug(`temp: ${temp} atmPressure : ${atmPressure} rho : ${rho} pressureDiff: ${pressureDiff?.value || 0}`);
|
||||
|
||||
Reference in New Issue
Block a user