P6: convert settler to platform infrastructure
Refactor of settler to use BaseNodeAdapter + commandRegistry + statusBadge. settler follows the platform refactor plan in .claude/refactor/MODULE_SPLIT.md. Tests stay green; CONTRACT.md generated; legacy aliases preserved. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
32
src/commands/handlers.js
Normal file
32
src/commands/handlers.js
Normal file
@@ -0,0 +1,32 @@
|
||||
'use strict';
|
||||
|
||||
// Handler functions for settler commands. Each handler receives:
|
||||
// source: the Settler domain instance.
|
||||
// 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.
|
||||
|
||||
function _logger(source, ctx) {
|
||||
return ctx?.logger || source?.logger || null;
|
||||
}
|
||||
|
||||
// Allows operators / upstream nodes to push an influent stream directly,
|
||||
// bypassing the reactor stateChange path. Payload mirrors the reactor's
|
||||
// `getEffluent` shape: { F, C } where C is the 13-species concentration
|
||||
// vector. Either field may be omitted to update only the other.
|
||||
exports.dataInfluent = (source, msg, ctx) => {
|
||||
const log = _logger(source, ctx);
|
||||
const p = msg?.payload;
|
||||
if (!p || typeof p !== 'object' || Array.isArray(p)) {
|
||||
log?.warn?.(`data.influent expects an object {F, C}; got ${typeof p}`);
|
||||
return;
|
||||
}
|
||||
if (typeof p.F === 'number' && Number.isFinite(p.F)) source.F_in = p.F;
|
||||
if (Array.isArray(p.C)) source.Cs_in = [...p.C];
|
||||
source.notifyOutputChanged();
|
||||
};
|
||||
Reference in New Issue
Block a user