|
|
|
|
@@ -35,10 +35,8 @@ class Machine {
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
this.hasCurve = true;
|
|
|
|
|
this.config = this.configUtils.updateConfig(this.config, {
|
|
|
|
|
asset: { ...this.config.asset, machineCurve: this.curve }
|
|
|
|
|
});
|
|
|
|
|
machineConfig = { ...machineConfig, asset: { ...machineConfig.asset, machineCurve: this.curve } }; // Merge curve into machineConfig
|
|
|
|
|
this.config = this.configUtils.updateConfig(this.config, { asset: { ...this.config.asset, machineCurve: this.curve } });
|
|
|
|
|
//machineConfig = { ...machineConfig, asset: { ...machineConfig.asset, machineCurve: this.curve } }; // Merge curve into machineConfig
|
|
|
|
|
this.predictFlow = new predict({ curve: this.config.asset.machineCurve.nq }); // load nq (x : ctrl , y : flow relationship)
|
|
|
|
|
this.predictPower = new predict({ curve: this.config.asset.machineCurve.np }); // load np (x : ctrl , y : power relationship)
|
|
|
|
|
this.predictCtrl = new predict({ curve: this.reverseCurve(this.config.asset.machineCurve.nq) }); // load reversed nq (x: flow, y: ctrl relationship)
|
|
|
|
|
@@ -106,6 +104,7 @@ class Machine {
|
|
|
|
|
if(!isOperational){
|
|
|
|
|
//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("atEquipment").value(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -127,7 +126,7 @@ class Machine {
|
|
|
|
|
this.logger.debug(`🔄 ${position} ${measurementType} from ${eventData.childName}: ${eventData.value} ${eventData.unit}`);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log(` Emitting... ${eventName} with data:`);
|
|
|
|
|
this.logger.debug(` Emitting... ${eventName} with data:`);
|
|
|
|
|
// Store directly in parent's measurement container
|
|
|
|
|
this.measurements
|
|
|
|
|
.type(measurementType)
|
|
|
|
|
@@ -347,13 +346,14 @@ _callMeasurementHandler(measurementType, value, position, context) {
|
|
|
|
|
if(this.hasCurve) {
|
|
|
|
|
if (!this._isOperationalState()) {
|
|
|
|
|
this.measurements.type("flow").variant("predicted").position("downstream").value(0);
|
|
|
|
|
this.measurements.type("flow").variant("predicted").position("atEquipment").value(0);
|
|
|
|
|
this.logger.debug(`Machine is not operational. Setting predicted flow to 0.`);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//this.predictFlow.currentX = x; Decrepated
|
|
|
|
|
const cFlow = this.predictFlow.y(x);
|
|
|
|
|
this.measurements.type("flow").variant("predicted").position("downstream").value(cFlow);
|
|
|
|
|
this.measurements.type("flow").variant("predicted").position("atEquipment").value(cFlow);
|
|
|
|
|
//this.logger.debug(`Calculated flow: ${cFlow} for pressure: ${this.getMeasuredPressure()} and position: ${x}`);
|
|
|
|
|
return cFlow;
|
|
|
|
|
}
|
|
|
|
|
@@ -361,6 +361,7 @@ _callMeasurementHandler(measurementType, value, position, context) {
|
|
|
|
|
// 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.measurements.type("flow").variant("predicted").position("downstream").value(0);
|
|
|
|
|
this.measurements.type("flow").variant("predicted").position("atEquipment").value(0);
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@@ -425,6 +426,11 @@ _callMeasurementHandler(measurementType, value, position, context) {
|
|
|
|
|
// returns the best available pressure measurement to use in the prediction calculation
|
|
|
|
|
// this will be either the differential pressure, downstream or upstream pressure
|
|
|
|
|
getMeasuredPressure() {
|
|
|
|
|
if(this.hasCurve === false){
|
|
|
|
|
this.logger.error(`No valid curve available to calculate prediction using last known pressure`);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const pressureDiff = this.measurements.type('pressure').variant('measured').difference();
|
|
|
|
|
|
|
|
|
|
// Both upstream & downstream => differential
|
|
|
|
|
@@ -560,6 +566,7 @@ _callMeasurementHandler(measurementType, value, position, context) {
|
|
|
|
|
// Update predicted flow if you have prediction capability
|
|
|
|
|
if (this.predictFlow) {
|
|
|
|
|
this.measurements.type("flow").variant("predicted").position("downstream").value(this.predictFlow.outputY || 0);
|
|
|
|
|
this.measurements.type("flow").variant("predicted").position("atEquipment").value(this.predictFlow.outputY || 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|