Compare commits
4 Commits
f083e7596a
...
dev-Rene
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
108d2e23ca | ||
|
|
446ef81f24 | ||
|
|
966ba06faa | ||
|
|
e8c96c4b1e |
@@ -1,6 +1,5 @@
|
|||||||
const EventEmitter = require('events');
|
const EventEmitter = require('events');
|
||||||
const {loadCurve,gravity,logger,configUtils,configManager,state, nrmse, MeasurementContainer, predict, interpolation , childRegistrationUtils,coolprop} = require('generalFunctions');
|
const {loadCurve,gravity,logger,configUtils,configManager,state, nrmse, MeasurementContainer, predict, interpolation , childRegistrationUtils,coolprop} = require('generalFunctions');
|
||||||
const pressure = require('../../generalFunctions/src/convert/definitions/pressure');
|
|
||||||
|
|
||||||
class Machine {
|
class Machine {
|
||||||
|
|
||||||
@@ -17,7 +16,7 @@ class Machine {
|
|||||||
|
|
||||||
// Load a specific curve
|
// Load a specific curve
|
||||||
this.model = machineConfig.asset.model; // Get the model from the machineConfig
|
this.model = machineConfig.asset.model; // Get the model from the machineConfig
|
||||||
this.curve = this.model ? loadCurve(this.model) : null;
|
this.curve = this.model ? loadCurve(this.model) : null; // we need to convert the curve and add units to the curve information
|
||||||
|
|
||||||
//Init config and check if it is valid
|
//Init config and check if it is valid
|
||||||
this.config = this.configUtils.initConfig(machineConfig);
|
this.config = this.configUtils.initConfig(machineConfig);
|
||||||
@@ -97,14 +96,18 @@ class Machine {
|
|||||||
this.measurements.type('temperature').variant('measured').position('atEquipment').value(15).unit('C');
|
this.measurements.type('temperature').variant('measured').position('atEquipment').value(15).unit('C');
|
||||||
//assume standard atm pressure is at sea level
|
//assume standard atm pressure is at sea level
|
||||||
this.measurements.type('atmPressure').variant('measured').position('atEquipment').value(101325).unit('Pa');
|
this.measurements.type('atmPressure').variant('measured').position('atEquipment').value(101325).unit('Pa');
|
||||||
|
//populate min and max
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateState(){
|
_updateState(){
|
||||||
const isOperational = this._isOperationalState();
|
const isOperational = this._isOperationalState();
|
||||||
if(!isOperational){
|
if(!isOperational){
|
||||||
//overrule the last prediction this should be 0 now
|
//overrule the last prediction this should be 0 now
|
||||||
this.measurements.type("flow").variant("predicted").position("downstream").value(0);
|
this.measurements.type("flow").variant("predicted").position("downstream").value(0,Date.now(),this.config.general.unit);
|
||||||
this.measurements.type("flow").variant("predicted").position("atEquipment").value(0);
|
this.measurements.type("flow").variant("predicted").position("atEquipment").value(0,Date.now(),this.config.general.unit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,23 +348,23 @@ _callMeasurementHandler(measurementType, value, position, context) {
|
|||||||
calcFlow(x) {
|
calcFlow(x) {
|
||||||
if(this.hasCurve) {
|
if(this.hasCurve) {
|
||||||
if (!this._isOperationalState()) {
|
if (!this._isOperationalState()) {
|
||||||
this.measurements.type("flow").variant("predicted").position("downstream").value(0);
|
this.measurements.type("flow").variant("predicted").position("downstream").value(0,Date.now(),this.config.general.unit);
|
||||||
this.measurements.type("flow").variant("predicted").position("atEquipment").value(0);
|
this.measurements.type("flow").variant("predicted").position("atEquipment").value(0,Date.now(),this.config.general.unit);
|
||||||
this.logger.debug(`Machine is not operational. Setting predicted flow to 0.`);
|
this.logger.debug(`Machine is not operational. Setting predicted flow to 0.`);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const cFlow = this.predictFlow.y(x);
|
const cFlow = this.predictFlow.y(x);
|
||||||
this.measurements.type("flow").variant("predicted").position("downstream").value(cFlow);
|
this.measurements.type("flow").variant("predicted").position("downstream").value(cFlow,Date.now(),this.config.general.unit);
|
||||||
this.measurements.type("flow").variant("predicted").position("atEquipment").value(cFlow);
|
this.measurements.type("flow").variant("predicted").position("atEquipment").value(cFlow,Date.now(),this.config.general.unit);
|
||||||
//this.logger.debug(`Calculated flow: ${cFlow} for pressure: ${this.getMeasuredPressure()} and position: ${x}`);
|
//this.logger.debug(`Calculated flow: ${cFlow} for pressure: ${this.getMeasuredPressure()} and position: ${x}`);
|
||||||
return cFlow;
|
return cFlow;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no curve data is available, log a warning and return 0
|
// If no curve data is available, log a warning and return 0
|
||||||
this.logger.warn(`No curve data available for flow calculation. Returning 0.`);
|
this.logger.warn(`No curve data available for flow calculation. Returning 0.`);
|
||||||
this.measurements.type("flow").variant("predicted").position("downstream").value(0);
|
this.measurements.type("flow").variant("predicted").position("downstream").value(0, Date.now(),this.config.general.unit);
|
||||||
this.measurements.type("flow").variant("predicted").position("atEquipment").value(0);
|
this.measurements.type("flow").variant("predicted").position("atEquipment").value(0, Date.now(),this.config.general.unit);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -479,6 +482,9 @@ _callMeasurementHandler(measurementType, value, position, context) {
|
|||||||
const efficiency = this.calcEfficiency(this.predictPower.outputY, this.predictFlow.outputY, "predicted");
|
const efficiency = this.calcEfficiency(this.predictPower.outputY, this.predictFlow.outputY, "predicted");
|
||||||
//update the distance from peak
|
//update the distance from peak
|
||||||
this.calcDistanceBEP(efficiency,cog,minEfficiency);
|
this.calcDistanceBEP(efficiency,cog,minEfficiency);
|
||||||
|
//place min and max flow capabilities in containerthis.predictFlow.currentFxyYMax - this.predictFlow.currentFxyYMin
|
||||||
|
this.measurements.type('flow').variant('predicted').position('max').value(this.predictFlow.currentFxyYMax).unit(this.config.general.unit);
|
||||||
|
this.measurements.type('flow').variant('predicted').position('min').value(this.predictFlow.currentFxyYMin).unit(this.config.general.unit);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -598,8 +604,6 @@ _callMeasurementHandler(measurementType, value, position, context) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
calcDistanceFromPeak(currentEfficiency,peakEfficiency){
|
calcDistanceFromPeak(currentEfficiency,peakEfficiency){
|
||||||
@@ -695,6 +699,8 @@ _callMeasurementHandler(measurementType, value, position, context) {
|
|||||||
const g = gravity.getStandardGravity();
|
const g = gravity.getStandardGravity();
|
||||||
const temp = this.measurements.type('temperature').variant('measured').position('atEquipment').getCurrentValue('K');
|
const temp = this.measurements.type('temperature').variant('measured').position('atEquipment').getCurrentValue('K');
|
||||||
const atmPressure = this.measurements.type('atmPressure').variant('measured').position('atEquipment').getCurrentValue('Pa');
|
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');
|
const rho = coolprop.PropsSI('D', 'T', temp, 'P', atmPressure, 'WasteWater');
|
||||||
|
|
||||||
|
|
||||||
@@ -765,15 +771,8 @@ _callMeasurementHandler(measurementType, value, position, context) {
|
|||||||
getOutput() {
|
getOutput() {
|
||||||
|
|
||||||
// Improved output object generation
|
// Improved output object generation
|
||||||
const output = {};
|
|
||||||
|
|
||||||
Object.entries(this.measurements.measurements).forEach(([type, variants]) => {
|
const output = this.measurements.getFlattenedOutput();
|
||||||
Object.entries(variants).forEach(([variant, positions]) => {
|
|
||||||
Object.entries(positions).forEach(([position, measurement]) => {
|
|
||||||
output[`${type}.${variant}.${position}`] = measurement.getCurrentValue();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
//fill in the rest of the output object
|
//fill in the rest of the output object
|
||||||
output["state"] = this.state.getCurrentState();
|
output["state"] = this.state.getCurrentState();
|
||||||
|
|||||||
Reference in New Issue
Block a user