updates
This commit is contained in:
75
test/integration/prediction-health.integration.test.js
Normal file
75
test/integration/prediction-health.integration.test.js
Normal file
@@ -0,0 +1,75 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
|
||||
const Machine = require('../../src/specificClass');
|
||||
const { makeMachineConfig, makeStateConfig } = require('../helpers/factories');
|
||||
|
||||
test('flow drift is assessed with NRMSE and exposed in output', () => {
|
||||
const machine = new Machine(makeMachineConfig(), makeStateConfig({ state: { current: 'operational' } }));
|
||||
|
||||
machine.updateMeasuredPressure(700, 'upstream', { timestamp: Date.now(), unit: 'mbar', childName: 'pt-up' });
|
||||
machine.updateMeasuredPressure(1100, 'downstream', { timestamp: Date.now(), unit: 'mbar', childName: 'pt-down' });
|
||||
machine.updatePosition();
|
||||
|
||||
const predictedFlow = machine.measurements
|
||||
.type('flow')
|
||||
.variant('predicted')
|
||||
.position('downstream')
|
||||
.getCurrentValue('m3/h');
|
||||
|
||||
for (let i = 0; i < 10; i += 1) {
|
||||
machine.updateMeasuredFlow(predictedFlow * 0.92, 'downstream', {
|
||||
timestamp: Date.now() + i,
|
||||
unit: 'm3/h',
|
||||
childName: 'ft-down',
|
||||
});
|
||||
}
|
||||
|
||||
const output = machine.getOutput();
|
||||
assert.ok(Number.isFinite(output.flowNrmse));
|
||||
assert.equal(typeof output.flowImmediateLevel, 'number');
|
||||
assert.equal(typeof output.flowLongTermLevel, 'number');
|
||||
assert.ok(['high', 'medium', 'low', 'invalid'].includes(output.predictionQuality));
|
||||
assert.ok(Number.isFinite(output.predictionConfidence));
|
||||
assert.equal(output.predictionPressureSource, 'differential');
|
||||
assert.ok(Array.isArray(output.predictionFlags));
|
||||
});
|
||||
|
||||
test('power drift is assessed when measured power is provided', () => {
|
||||
const machine = new Machine(makeMachineConfig(), makeStateConfig({ state: { current: 'operational' } }));
|
||||
|
||||
machine.updateMeasuredPressure(700, 'upstream', { timestamp: Date.now(), unit: 'mbar', childName: 'pt-up' });
|
||||
machine.updateMeasuredPressure(1100, 'downstream', { timestamp: Date.now(), unit: 'mbar', childName: 'pt-down' });
|
||||
machine.updatePosition();
|
||||
|
||||
const predictedPower = machine.measurements
|
||||
.type('power')
|
||||
.variant('predicted')
|
||||
.position('atEquipment')
|
||||
.getCurrentValue('kW');
|
||||
|
||||
for (let i = 0; i < 10; i += 1) {
|
||||
machine.updateMeasuredPower(predictedPower * 1.08, 'atEquipment', {
|
||||
timestamp: Date.now() + i,
|
||||
unit: 'kW',
|
||||
childName: 'power-meter',
|
||||
});
|
||||
}
|
||||
|
||||
const output = machine.getOutput();
|
||||
assert.ok(Number.isFinite(output.powerNrmse));
|
||||
assert.equal(typeof output.powerImmediateLevel, 'number');
|
||||
assert.equal(typeof output.powerLongTermLevel, 'number');
|
||||
});
|
||||
|
||||
test('single-side pressure lowers prediction confidence category', () => {
|
||||
const machine = new Machine(makeMachineConfig(), makeStateConfig({ state: { current: 'operational' } }));
|
||||
machine.updateMeasuredPressure(950, 'downstream', { timestamp: Date.now(), unit: 'mbar', childName: 'pt-down' });
|
||||
|
||||
const output = machine.getOutput();
|
||||
assert.equal(output.predictionPressureSource, 'downstream');
|
||||
assert.ok(output.predictionConfidence < 0.9);
|
||||
assert.equal(output.pressureDriftLevel, 1);
|
||||
assert.ok(Array.isArray(output.predictionFlags));
|
||||
assert.ok(output.predictionFlags.includes('single_side_pressure'));
|
||||
});
|
||||
Reference in New Issue
Block a user