Compare commits

...

1 Commits

Author SHA1 Message Date
znetsixe
2af30c0bd8 fix(commands): restore child.register handler (alias registerChild)
Same fix as monster: P6.6 refactor dropped the case 'registerChild'
branch when extracting commands. Settler registers reactor + measurement
children — without this, Port 2 inbound handshakes were silently
ignored.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 16:04:32 +02:00
2 changed files with 24 additions and 5 deletions

View File

@@ -5,11 +5,11 @@
// msg: the Node-RED input message.
// ctx: { node, RED, send, logger } — provided by BaseNodeAdapter.
//
// Settler currently accepts no behavioural commands — the legacy
// `registerChild` topic is handled by the BaseNodeAdapter input dispatch
// via the generalFunctions registry (`child.register` canonical) and the
// node never had a public set/cmd surface beyond that. Future
// influent-injection or operator-override topics will land here.
// Settler accepts `child.register` (alias `registerChild`) on Port 0 input
// to register measurement / reactor children, plus `data.influent` for
// manual override. BaseNodeAdapter dispatches msg.topic through the
// per-node registry — there is no implicit `child.register` handler in
// the base, so it must be listed explicitly here.
function _logger(source, ctx) {
return ctx?.logger || source?.logger || null;
@@ -30,3 +30,16 @@ exports.dataInfluent = (source, msg, ctx) => {
if (Array.isArray(p.C)) source.Cs_in = [...p.C];
source.notifyOutputChanged();
};
// Inbound child registration from a measurement (or reactor) child.
// Ported from the legacy `case 'registerChild'` branch in nodeClass.
exports.childRegister = (source, msg, ctx) => {
const log = _logger(source, ctx);
const childId = msg.payload;
const childObj = ctx?.RED?.nodes?.getNode?.(childId);
if (!childObj?.source) {
log?.warn?.(`child.register skipped: missing child/source for id=${childId}`);
return;
}
source.childRegistrationUtils.registerChild(childObj.source, msg.positionVsParent, msg.distance);
};

View File

@@ -14,4 +14,10 @@ module.exports = [
payloadSchema: { type: 'any' },
handler: handlers.dataInfluent,
},
{
topic: 'child.register',
aliases: ['registerChild'],
payloadSchema: { type: 'string' },
handler: handlers.childRegister,
},
];