src/curves/ loader + normalizer (with cross-pressure anomaly
detection) + reverseCurve helper
src/prediction/ predictors (predictFlow/Power/Ctrl) +
groupPredictors (lazy group-scope views) +
OperatingPoint (pressure-driven prediction setpoints)
src/drift/ DriftAssessor (per-metric drift) + PredictionHealth
(composes flow/power/pressure into HealthStatus +
confidence sibling — see OPEN_QUESTIONS 2026-05-10)
src/pressure/ VirtualPressureChildren (dashboard-sim) +
PressureInitialization (real-vs-virtual tracking) +
PressureRouter (dispatches by position)
src/state/ stateBindings (state.emitter listener helper) +
isOperationalState
src/measurement/ measurementHandlers (dispatcher for flow/power/temp/pressure)
src/flow/ flowController (handleInput body — execSequence,
execMovement, flowMovement, emergencystop)
src/display/ workingCurves (showWorkingCurves + showCoG admin)
src/commands/ canonical names: set.mode, cmd.startup/shutdown/estop,
set.setpoint, set.flow-setpoint,
data.simulate-measurement, query.curves, query.cog,
child.register. execSequence demuxes by payload.action
to canonical cmd.* handlers.
CONTRACT.md inputs/outputs/events/children surface
110 basic tests pass (100 new + 10 pre-existing).
specificClass.js / nodeClass.js untouched — integration in P5 wave 2.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
50 lines
2.1 KiB
JavaScript
50 lines
2.1 KiB
JavaScript
const test = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
|
|
const { predict } = require('generalFunctions');
|
|
const { buildPredictors } = require('../../src/prediction/predictors');
|
|
|
|
function makeCanonicalCurve() {
|
|
// Canonical units already applied: pressure Pa, flow m3/s, power W,
|
|
// x-axis is control %. Two pressure levels, monotonically rising y.
|
|
return {
|
|
nq: {
|
|
100000: { x: [0, 50, 100], y: [0, 0.005, 0.01] },
|
|
120000: { x: [0, 50, 100], y: [0, 0.006, 0.012] },
|
|
},
|
|
np: {
|
|
100000: { x: [0, 50, 100], y: [0, 500, 1000] },
|
|
120000: { x: [0, 50, 100], y: [0, 600, 1200] },
|
|
},
|
|
};
|
|
}
|
|
|
|
test('buildPredictors: returns three Predict instances', () => {
|
|
const predictors = buildPredictors(makeCanonicalCurve());
|
|
assert.ok(predictors.predictFlow instanceof predict);
|
|
assert.ok(predictors.predictPower instanceof predict);
|
|
assert.ok(predictors.predictCtrl instanceof predict);
|
|
});
|
|
|
|
test('buildPredictors: predictFlow yMax/yMin reflect input range', () => {
|
|
const predictors = buildPredictors(makeCanonicalCurve());
|
|
// After buildAllFxyCurves the fDimension is initialised to fValues.min.
|
|
// currentFxyYMin/Max are the y-range at that pressure curve.
|
|
assert.ok(Number.isFinite(predictors.predictFlow.currentFxyYMax));
|
|
assert.ok(Number.isFinite(predictors.predictFlow.currentFxyYMin));
|
|
assert.ok(predictors.predictFlow.currentFxyYMax > predictors.predictFlow.currentFxyYMin);
|
|
});
|
|
|
|
test('buildPredictors: predictCtrl is built from reversed nq (flow->ctrl mapping)', () => {
|
|
const predictors = buildPredictors(makeCanonicalCurve());
|
|
// predictCtrl's x-axis values must come from y-values in nq.
|
|
// sanity-check via currentFxyXMax being in the flow range
|
|
assert.ok(predictors.predictCtrl.currentFxyXMax <= 0.02, // flow range upper bound
|
|
`expected predictCtrl xMax in flow-range, got ${predictors.predictCtrl.currentFxyXMax}`);
|
|
});
|
|
|
|
test('buildPredictors: throws when machineCurve is missing nq or np', () => {
|
|
assert.throws(() => buildPredictors(null), /machineCurve\.nq and \.np are required/);
|
|
assert.throws(() => buildPredictors({ nq: {} }), /required/);
|
|
});
|