'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(); };