|
|
|
|
@@ -48,7 +48,17 @@ class Machine {
|
|
|
|
|
this.errorMetrics = new nrmse(errorMetricsConfig, this.logger);
|
|
|
|
|
|
|
|
|
|
// Initialize measurements
|
|
|
|
|
this.measurements = new MeasurementContainer();
|
|
|
|
|
this.measurements = new MeasurementContainer({
|
|
|
|
|
autoConvert: true,
|
|
|
|
|
windowSize: 50,
|
|
|
|
|
defaultUnits: {
|
|
|
|
|
pressure: 'mbar',
|
|
|
|
|
flow: this.config.general.unit,
|
|
|
|
|
power: 'kW',
|
|
|
|
|
temperature: 'C'
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.interpolation = new interpolation();
|
|
|
|
|
|
|
|
|
|
this.flowDrift = null;
|
|
|
|
|
@@ -68,11 +78,25 @@ class Machine {
|
|
|
|
|
this.updatePosition();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//When state changes look if we need to do other updates
|
|
|
|
|
this.state.emitter.on("stateChange", (newState) => {
|
|
|
|
|
this.logger.debug(`State change detected: ${newState}`);
|
|
|
|
|
this._updateState();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.child = {}; // object to hold child information so we know on what to subscribe
|
|
|
|
|
this.childRegistrationUtils = new childRegistrationUtils(this); // Child registration utility
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_updateState(){
|
|
|
|
|
const isOperational = this._isOperationalState();
|
|
|
|
|
if(!isOperational){
|
|
|
|
|
//overrule the last prediction this should be 0 now
|
|
|
|
|
this.measurements.type("flow").variant("predicted").position("downstream").value(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*------------------- Register child events -------------------*/
|
|
|
|
|
registerChild(child, softwareType) {
|
|
|
|
|
this.logger.debug('Setting up child event for softwaretype ' + softwareType);
|
|
|
|
|
@@ -501,13 +525,14 @@ _callMeasurementHandler(measurementType, value, position, context) {
|
|
|
|
|
|
|
|
|
|
// Update predicted flow if you have prediction capability
|
|
|
|
|
if (this.predictFlow) {
|
|
|
|
|
this.measurements.type("flow").variant("predicted").position("atEquipment").value(this.predictFlow.outputY || 0);
|
|
|
|
|
this.measurements.type("flow").variant("predicted").position("downstream").value(this.predictFlow.outputY || 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Helper method for operational state check
|
|
|
|
|
_isOperationalState() {
|
|
|
|
|
const state = this.state.getCurrentState();
|
|
|
|
|
this.logger.debug(`Checking operational state ${this.state.getCurrentState()} ? ${["operational", "accelerating", "decelerating"].includes(state)}`);
|
|
|
|
|
return ["operational", "accelerating", "decelerating"].includes(state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -531,6 +556,9 @@ _callMeasurementHandler(measurementType, value, position, context) {
|
|
|
|
|
this.calcDistanceBEP(efficiency,cog,minEfficiency);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
calcDistanceFromPeak(currentEfficiency,peakEfficiency){
|
|
|
|
|
@@ -561,7 +589,6 @@ _callMeasurementHandler(measurementType, value, position, context) {
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Calculate the center of gravity for current pressure
|
|
|
|
|
calcCog() {
|
|
|
|
|
|
|
|
|
|
|