forked from RnD/rotatingMachine
test
This commit is contained in:
@@ -198,6 +198,32 @@ _callMeasurementHandler(measurementType, value, position, context) {
|
|||||||
return reversedCurve;
|
return reversedCurve;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getHealthIndex() {
|
||||||
|
if (!this.driftHistory || this.driftHistory.length === 0) {
|
||||||
|
this.logger.debug("HealthIndex: No drift history yet.");
|
||||||
|
return 1; // 1.0 = fully healthy
|
||||||
|
}
|
||||||
|
|
||||||
|
const avg = (arr) => {
|
||||||
|
if (!arr || arr.length === 0) return 0;
|
||||||
|
return arr.reduce((sum, d) => sum + (d.nrmse || 0), 0) / arr.length;
|
||||||
|
};
|
||||||
|
|
||||||
|
const flowDrift = this.driftHistory.filter(d => d.measurement === "flow");
|
||||||
|
const powerDrift = this.driftHistory.filter(d => d.measurement === "power");
|
||||||
|
|
||||||
|
const avgDrift = (avg(flowDrift) + avg(powerDrift)) / 2;
|
||||||
|
|
||||||
|
// relDistFromPeak is already stored internally (0 = best, 1 = worst)
|
||||||
|
const efficiencyScore = 1 - (this.relDistFromPeak || 0);
|
||||||
|
|
||||||
|
const healthIndex = (0.6 * efficiencyScore + 0.4 * (1 - avgDrift));
|
||||||
|
|
||||||
|
this.logger.debug(`💚 Health Index Calculated: ${healthIndex.toFixed(3)} (eff=${efficiencyScore.toFixed(3)}, drift=${avgDrift.toFixed(3)})`);
|
||||||
|
|
||||||
|
return healthIndex.toFixed(3);
|
||||||
|
}
|
||||||
|
|
||||||
// -------- Config -------- //
|
// -------- Config -------- //
|
||||||
updateConfig(newConfig) {
|
updateConfig(newConfig) {
|
||||||
this.config = this.configUtils.updateConfig(this.config, newConfig);
|
this.config = this.configUtils.updateConfig(this.config, newConfig);
|
||||||
|
|||||||
Reference in New Issue
Block a user