forked from RnD/EVOLV
updated measurement node to match selected units from user and convert it properly
This commit is contained in:
@@ -114,8 +114,8 @@ class nodeClass {
|
|||||||
try {
|
try {
|
||||||
const mode = m.currentMode;
|
const mode = m.currentMode;
|
||||||
const state = m.state.getCurrentState();
|
const state = m.state.getCurrentState();
|
||||||
const flow = Math.round(m.measurements.type("flow").variant("predicted").position('downstream').getCurrentValue());
|
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('upstream').getCurrentValue());
|
const power = Math.round(m.measurements.type("power").variant("predicted").position('atequipment').getCurrentValue('kW'));
|
||||||
let symbolState;
|
let symbolState;
|
||||||
switch(state){
|
switch(state){
|
||||||
case "off":
|
case "off":
|
||||||
|
|||||||
@@ -48,7 +48,17 @@ class Machine {
|
|||||||
this.errorMetrics = new nrmse(errorMetricsConfig, this.logger);
|
this.errorMetrics = new nrmse(errorMetricsConfig, this.logger);
|
||||||
|
|
||||||
// Initialize measurements
|
// 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.interpolation = new interpolation();
|
||||||
|
|
||||||
this.flowDrift = null;
|
this.flowDrift = null;
|
||||||
@@ -68,11 +78,25 @@ class Machine {
|
|||||||
this.updatePosition();
|
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.child = {}; // object to hold child information so we know on what to subscribe
|
||||||
this.childRegistrationUtils = new childRegistrationUtils(this); // Child registration utility
|
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 -------------------*/
|
/*------------------- Register child events -------------------*/
|
||||||
registerChild(child, softwareType) {
|
registerChild(child, softwareType) {
|
||||||
this.logger.debug('Setting up child event for softwaretype ' + 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
|
// Update predicted flow if you have prediction capability
|
||||||
if (this.predictFlow) {
|
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
|
// Helper method for operational state check
|
||||||
_isOperationalState() {
|
_isOperationalState() {
|
||||||
const state = this.state.getCurrentState();
|
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);
|
return ["operational", "accelerating", "decelerating"].includes(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -531,6 +556,9 @@ _callMeasurementHandler(measurementType, value, position, context) {
|
|||||||
this.calcDistanceBEP(efficiency,cog,minEfficiency);
|
this.calcDistanceBEP(efficiency,cog,minEfficiency);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
calcDistanceFromPeak(currentEfficiency,peakEfficiency){
|
calcDistanceFromPeak(currentEfficiency,peakEfficiency){
|
||||||
@@ -561,7 +589,6 @@ _callMeasurementHandler(measurementType, value, position, context) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Calculate the center of gravity for current pressure
|
// Calculate the center of gravity for current pressure
|
||||||
calcCog() {
|
calcCog() {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user