2026-05-10 20:45:23 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
// machineGroupControl command registry. Consumed by BaseNodeAdapter via
|
|
|
|
|
// `static commands = require('./commands')`. Each descriptor maps a
|
|
|
|
|
// canonical msg.topic to its handler; legacy names are listed under
|
|
|
|
|
// `aliases` and emit a one-time deprecation warning at runtime.
|
|
|
|
|
|
|
|
|
|
const handlers = require('./handlers');
|
|
|
|
|
|
|
|
|
|
module.exports = [
|
|
|
|
|
{
|
|
|
|
|
topic: 'set.mode',
|
|
|
|
|
aliases: ['setMode'],
|
|
|
|
|
payloadSchema: { type: 'string' },
|
2026-05-19 16:05:48 +02:00
|
|
|
description: 'Switch the operating mode. Allowed: `optimalControl`, `priorityControl`, `maintenance` (schema-validated in `machineGroupControl.json` → `mode.current`).',
|
2026-05-10 20:45:23 +02:00
|
|
|
handler: handlers.setMode,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
topic: 'child.register',
|
|
|
|
|
aliases: ['registerChild'],
|
|
|
|
|
// payload is the Node-RED id (string) of the child node.
|
|
|
|
|
payloadSchema: { type: 'string' },
|
2026-05-11 17:41:07 +02:00
|
|
|
description: 'Register a child machine with this group.',
|
2026-05-10 20:45:23 +02:00
|
|
|
handler: handlers.registerChild,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
topic: 'set.demand',
|
|
|
|
|
aliases: ['Qd'],
|
governance + unit-self-describing demand + dashboard fixes
Two governance items from the 2026-05-14 quality review:
- test/_output-manifest.md enumerates every Port 0/1/2 key MGC emits, its
source, type, range, and which tests cover it in populated/degraded states
(per .claude/rules/output-coverage.md).
- src/control/strategies.js extracts computeEqualFlowDistribution as a pure
function so the equal-flow algorithm is testable without an MGC fixture.
test/basic/equalFlowDistribution.basic.test.js (6 tests) covers all three
demand branches and pins the legacy quirk where the default branch counts
active machines but iterates priority-ordered first-N (documented in the
test so the future cleanup is a deliberate change).
Plus rolled-up session work that landed alongside:
- set.demand is now unit-self-describing ({value, unit:'m3/h'|'l/s'|'%'|...}
or bare number = %); setScaling/scaling.current removed from MGC, commands,
editor (mgc.html), specificClass.
- _optimalControl + equalFlowControl now compute eta = (Q*dP)/P_shaft rather
than Q/P, keeping the metric in the same scale as each child's cog.
- groupEfficiency.calcRelativeDistanceFromPeak returns undefined (was 1) when
pumps are homogeneous (|max-min| < 1e-9). Dashboard treats undefined as
'-' instead of showing a misleading 100% / 0% reading.
- examples/02-Dashboard.json: auto-init inject so the dashboard populates at
deploy, NCog formatter normalizes the SUM emitted by MGC by
machineCountActive, Q-H fanout trims the flat-Q tail so the H axis isn't
stretched to 40m by curve-envelope clamp points, num/pct treat null AND
undefined as no-data (closes the +null === 0 trap).
- new test/integration/dashboard-fanout.integration.test.js (17 tests),
bep-distance-demand-sweep.integration.test.js (3 tests),
group-bep-cascade.integration.test.js -- total suite now 108/108 green.
- .gitignore: wiki/test.gif (143 MB screen recording, kept locally only).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 22:31:25 +02:00
|
|
|
// payload is either a bare number (interpreted as %) or
|
|
|
|
|
// { value: number, unit: '%' | 'm3/h' | 'l/s' | 'm3/s' | ... }.
|
|
|
|
|
// No `units` descriptor — the handler resolves the unit explicitly so
|
|
|
|
|
// commandRegistry._normaliseUnits doesn't pre-convert a percentage into
|
|
|
|
|
// a flow rate. Negative value is the operator stop-all signal.
|
2026-05-10 20:45:23 +02:00
|
|
|
payloadSchema: { type: 'any' },
|
governance + unit-self-describing demand + dashboard fixes
Two governance items from the 2026-05-14 quality review:
- test/_output-manifest.md enumerates every Port 0/1/2 key MGC emits, its
source, type, range, and which tests cover it in populated/degraded states
(per .claude/rules/output-coverage.md).
- src/control/strategies.js extracts computeEqualFlowDistribution as a pure
function so the equal-flow algorithm is testable without an MGC fixture.
test/basic/equalFlowDistribution.basic.test.js (6 tests) covers all three
demand branches and pins the legacy quirk where the default branch counts
active machines but iterates priority-ordered first-N (documented in the
test so the future cleanup is a deliberate change).
Plus rolled-up session work that landed alongside:
- set.demand is now unit-self-describing ({value, unit:'m3/h'|'l/s'|'%'|...}
or bare number = %); setScaling/scaling.current removed from MGC, commands,
editor (mgc.html), specificClass.
- _optimalControl + equalFlowControl now compute eta = (Q*dP)/P_shaft rather
than Q/P, keeping the metric in the same scale as each child's cog.
- groupEfficiency.calcRelativeDistanceFromPeak returns undefined (was 1) when
pumps are homogeneous (|max-min| < 1e-9). Dashboard treats undefined as
'-' instead of showing a misleading 100% / 0% reading.
- examples/02-Dashboard.json: auto-init inject so the dashboard populates at
deploy, NCog formatter normalizes the SUM emitted by MGC by
machineCountActive, Q-H fanout trims the flat-Q tail so the H axis isn't
stretched to 40m by curve-envelope clamp points, num/pct treat null AND
undefined as no-data (closes the +null === 0 trap).
- new test/integration/dashboard-fanout.integration.test.js (17 tests),
bep-distance-demand-sweep.integration.test.js (3 tests),
group-bep-cascade.integration.test.js -- total suite now 108/108 green.
- .gitignore: wiki/test.gif (143 MB screen recording, kept locally only).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 22:31:25 +02:00
|
|
|
description: 'Operator demand setpoint. Bare number = %; {value, unit} for absolute flow units. Negative = stop all.',
|
2026-05-10 20:45:23 +02:00
|
|
|
handler: handlers.setDemand,
|
|
|
|
|
},
|
|
|
|
|
];
|