ps: setDemand reads unit-normalised payload from commandRegistry
generalFunctions' commandRegistry._normaliseUnits now converts {value, unit}
or unit-tagged payloads to the descriptor's default unit (m3/h for set.demand)
before the handler runs. setDemand just reads Number(payload) — no inline
unit-conversion, no scaling state. Matches the same shift done in MGC for
unit-self-describing demand commands.
Pre-existing test failure: test/integration/basic-dashboard-flow.test.js
references examples/basic-dashboard.flow.json which was renamed to
02-Dashboard.json in commit fe5fa35 (feat(pumpingStation): … dashboard
example). The 3 stale-path failures are unrelated to this commit — they
were broken before this change.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -88,9 +88,14 @@ exports.setOutflow = (source, msg) => {
|
||||
|
||||
exports.setDemand = (source, msg, ctx) => {
|
||||
const log = _logger(source, ctx);
|
||||
const demand = Number(msg.payload);
|
||||
// generalFunctions/commandRegistry's _normaliseUnits has already converted
|
||||
// msg.payload to m3/h (the descriptor's units.default — see
|
||||
// commands/index.js). Accepts {value, unit} objects upstream; we just read
|
||||
// the normalized number here. _manualDemand is stored in m3/h, no further
|
||||
// conversion needed.
|
||||
const demand = Number(msg?.payload);
|
||||
if (!Number.isFinite(demand)) {
|
||||
log?.warn?.(`set.demand: invalid Qd value '${msg.payload}'`);
|
||||
log?.warn?.(`set.demand: invalid Qd value '${JSON.stringify(msg?.payload)}'`);
|
||||
return;
|
||||
}
|
||||
if (source.mode !== 'manual') {
|
||||
|
||||
Reference in New Issue
Block a user