feat(mgc): rendezvous planner — same-time landing across all modes

Routes every dispatch through a tick-aware planner so all pumps reach
their setpoint at the same wall-clock instant t* = max(eta_i),
regardless of control strategy or per-pump reaction speed.

Architecture (src/movement/):
- machineProfile.js   – pure snapshot of a registered child (state,
                        position, velocityPctPerS, ladder timings,
                        flowAt / positionForFlow). Reads timings from
                        child.state.config.time (the actual storage
                        location — previous fallback paths silently
                        produced 0 s, collapsing every eta to ramp-only).
- moveTrajectory.js   – seconds-to-target per machine; handles
                        idle / starting / warmingup / operational / cooling.
- movementScheduler.js – t* = max eta over ALL non-noop moves. Every
                        command is delayed so its move finishes at t*.
                        Startup execsequence fires at 0; its flowmovement
                        is gated by max(ladderS, t* − rampS) so a fast
                        pump waits before ramping rather than landing
                        early. useRendezvous=false collapses to all
                        fireAtTickN=0 (legacy fire-and-forget).
- movementExecutor.js – wall-clock virtual cursor: each tick fires
                        every command whose fireAtTickN ≤ floor(elapsed/tickS).
                        tick() no longer awaits pending fireCommand
                        promises — the synchronous prologue of
                        handleInput claims the latest-wins gate, which
                        is what race-favouring relies on.

Shared dispatch path (src/specificClass.js):
- _dispatchFlowDistribution(distribution) — extracted from
  _optimalControl. Builds profiles, calls movementScheduler.plan,
  replans the executor, ticks once. Reads
  config.planner.useRendezvous (default true).
- _optimalControl computes its bestCombination and hands off.
- equalFlowControl (priorityControl mode) computes its
  flowDistribution and hands off via ctx.mgc._dispatchFlowDistribution.
  Same-time landing now applies in BOTH modes.

Editor toggle (mgc.html + src/nodeClass.js):
- New "Same-time landing" checkbox under Control Strategy.
- nodeClass.buildDomainConfig bridges uiConfig.useRendezvous →
  config.planner.useRendezvous. Default ON.

Tests:
- New: planner-convergence.integration.test.js (real-time end-to-end
  diagnostic — drives a 3-pump mixed-state dispatch and asserts both
  convergence to the demand setpoint AND same-time landing within
  one tick).
- New: planner-rendezvous.integration.test.js (schedule-shape
  assertions against real pump objects).
- New: movementScheduler.basic.test.js — includes a mixed-speed
  multi-startup case proving the fast pumps wait so all three land
  together (the regression that prompted this work).
- New: movementExecutor.basic.test.js + moveTrajectory.basic.test.js.
- Updated executor contract test: tick() must NOT await pending fires.

Commands + wiki:
- handlers.js: source/mode allow-list gate moved into a shared _gate()
  helper; every command now checks isValidActionForMode +
  isValidSourceForMode before dispatching. Status-level commands
  (set.mode, set.scaling) are allowed in every mode.
- commands.basic.test.js: coverage for the new gate behaviour.
- wiki regen: Home.md visual-first rewrite + Reference-{Architecture,
  Contracts,Examples,Limitations}.md split with _Sidebar.md index.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
znetsixe
2026-05-17 19:43:55 +02:00
parent 26e92b54f7
commit 472402c62d
26 changed files with 3048 additions and 280 deletions

View File

@@ -8,8 +8,32 @@
| **Control Module** | `#a9daee` | zwart |
-->
<script src="/machineGroupControl/menu.js"></script> <!-- Load the menu script for dynamic dropdowns -->
<script src="/machineGroupControl/configData.js"></script> <!-- Load the config script for node information -->
<script src="/machineGroupControl/menu.js"></script> <!-- Load the menu script for dynamic dropdowns -->
<script src="/machineGroupControl/configData.js"></script> <!-- Load the config script for node information -->
<!-- Editor JS modules — see nodes/machineGroupControl/src/editor/. Loaded in
dependency order: index.js (namespace + helpers) → modules → oneditprepare. -->
<script src="/machineGroupControl/editor/index.js"></script>
<script src="/machineGroupControl/editor/mode-cards.js"></script>
<script src="/machineGroupControl/editor/oneditprepare.js"></script>
<style>
/* Mode-card picker. Three cards stack horizontally; on a narrow editor pane
they wrap. Selected card gets a thick #50a8d9 (Unit-colour) border. */
.mgc-mode-cards { display:flex; gap:8px; flex-wrap:wrap; margin:6px 0 4px 0; }
.mgc-mode-card {
flex:1 1 0; min-width:140px; box-sizing:border-box;
border:2px solid #d0d0d0; border-radius:4px; background:#fafafa;
padding:6px 8px 8px 8px; cursor:pointer; user-select:none;
display:flex; flex-direction:column; gap:4px;
transition:border-color 80ms ease-out, background 80ms ease-out;
}
.mgc-mode-card:hover { border-color:#86bbdd; background:#f5fafd; }
.mgc-mode-card-on { border-color:#50a8d9; background:#eaf4fb; }
.mgc-mode-card-svg svg { width:100%; height:auto; max-height:90px; display:block; }
.mgc-mode-card-label { font-weight:600; font-size:12px; color:#333; }
.mgc-mode-card-caption { font-size:10px; color:#666; line-height:1.3; }
</style>
<script>
RED.nodes.registerType('machineGroupControl',{
@@ -24,6 +48,12 @@
// Control strategy
mode: { value: "optimalControl" }, // optimalControl | priorityControl | maintenance
// Same-time landing (rendezvous planner). When ON the planner
// delays each pump's move so all pumps reach their setpoint at
// the same wall-clock instant t* = max(eta_i). When OFF each
// pump moves at its own pace and lands at its own eta.
useRendezvous: { value: true },
//define asset properties
uuid: { value: "" },
supplier: { value: "" },
@@ -55,10 +85,17 @@
return (this.positionIcon || "") + " machineGroup";
},
oneditprepare: function() {
// Initialize the menu data for the node
const self = this;
// Initialize the menu data for the node, then the visual modules.
// Both attach to window.EVOLV.nodes.machineGroupControl.* — the
// menu endpoint populates loggerMenu/positionMenu/initEditor; the
// editor scripts populate editor.modeCards/demandContract.
const waitForMenuData = () => {
if (window.EVOLV?.nodes?.machineGroupControl?.initEditor) {
window.EVOLV.nodes.machineGroupControl.initEditor(this);
window.EVOLV.nodes.machineGroupControl.initEditor(self);
if (window.EVOLV.nodes.machineGroupControl.editor?.initVisuals) {
window.EVOLV.nodes.machineGroupControl.editor.initVisuals(self);
}
} else {
setTimeout(waitForMenuData, 50);
}
@@ -88,14 +125,15 @@
<script type="text/html" data-template-name="machineGroupControl">
<h3>Control strategy</h3>
<div class="form-row">
<label for="node-input-mode"><i class="fa fa-cogs"></i> Mode</label>
<select id="node-input-mode" style="width:60%;">
<option value="optimalControl">optimalControl &mdash; pick the best valid pump combination by BEP-gravitation / NCog</option>
<option value="priorityControl">priorityControl &mdash; sequential equal-flow control by priority list</option>
<option value="maintenance">maintenance &mdash; monitoring only, no dispatch</option>
</select>
<!-- Hidden input is the canonical Node-RED-readable field. The visible
picker is rendered by src/editor/mode-cards.js into the placeholder
below, and clicks on a card write back to this input. -->
<input type="hidden" id="node-input-mode" />
<div id="mgc-mode-cards" class="mgc-mode-cards"
role="radiogroup" aria-label="Control strategy mode">
<!-- mode-cards.js renders three card divs here -->
</div>
<p style="margin-top:8px;color:#666;font-size:11px;">
Demand is self-describing per <code>set.demand</code> message: a bare number is
treated as % of group capacity; <code>{value, unit}</code> with a flow unit
@@ -103,6 +141,23 @@
in absolute terms. Negative value stops all pumps.
</p>
<h3>Rendezvous planner</h3>
<div class="form-row" style="display:flex;align-items:center;gap:8px;">
<input type="checkbox" id="node-input-useRendezvous"
style="width:auto;margin:0;vertical-align:middle;" />
<label for="node-input-useRendezvous" style="width:auto;margin:0;cursor:pointer;">
Same-time landing
</label>
</div>
<p style="margin-top:4px;color:#666;font-size:11px;">
When enabled (default), every dispatch is routed through the rendezvous
planner regardless of control strategy: per-pump moves are delayed so all
pumps reach their setpoint at the same wall-clock instant
<code>t* = max(eta<sub>i</sub>)</code>. When disabled, every
<code>flowmovement</code> fires immediately and each pump ramps at its
own configured reaction speed (legacy behaviour).
</p>
<h3>Output Formats</h3>
<div class="form-row">
<label for="node-input-processOutputFormat"><i class="fa fa-random"></i> Process Output</label>