feat(mgc): editor defaults, compact status badge, mode-case fix, real example flows + dashboard

Editor (mgc.html)
- Drag-in defaults now expose mode (optimalControl) and scaling (normalized)
  via dropdowns in the edit dialog. Was: no control fields in the UI at all,
  so users had to send set.mode/set.scaling after deploy or live with the
  hidden schema defaults.

Wire-up (src/nodeClass.js)
- buildDomainConfig now bridges the flat editor fields (mode, scaling) into
  the nested schema shape (mode.current, scaling.current). Was: returned {}
  so the editor's mode/scaling never reached the runtime.

Mode-case bug fix (src/specificClass.js)
- Schema enum values are camelCase (optimalControl, priorityControl) but the
  runtime switch in _runDispatch matched lowercase only. With the default
  config, dispatch silently fell through to the warning branch and nothing
  ran. Normalise via String(this.mode).toLowerCase() so both forms work.

Status badge (src/io/output.js)
- Compacted from ~80 chars (mode | Ⓝ: 💨=Q/Qmax | =P | N machine(s)) to
  ~50 chars (mode | norm | Q=Q/Qmax m³/h | P=P kW | active/total x).
  Drops emoji glyphs that rendered inconsistently across themes; uses the
  same dot+fill convention as pumpingStation.

Output extension (src/io/output.js)
- getOutput() now also emits flowCapacityMin/Max, machineCount,
  machineCountActive. Was: only group-level totals + dist-from-peak +
  mode/scaling, so dashboards couldn't show capacity / active count
  without subscribing to each rotatingMachine individually.

Examples
- Drop pre-refactor stubs (basic.flow.json, integration.flow.json,
  edge.flow.json). They had a single MGC + inject + debug, no children,
  and never dispatched anything.
- 01-Basic.json: 1 MGC + 3 rotatingMachine pumps + Setup once-fires
  virtualControl + cmd.startup on all pumps via fan-out function. Numbered
  driver groups for Control mode / Scaling / Operator demand. Pumps
  register with MGC via Port 2 (child.register, automatic).
- 02-Dashboard.json: same plumbing + FlowFuse Dashboard 2.0 page with
  Controls (mode + scaling buttons, demand slider 0–100, stop + init
  buttons), Status (7 ui-text rows), Trends (3 charts: flow + capacity,
  power, BEP rel %), and a raw-output ui-template dumping every Port 0
  field. Fan-out function caches last-known values so deltas don't blank.

Wiki + README
- examples/README.md rewritten for the two-file set with canonical command
  surface table and "what to try" recipes.
- wiki/Home.md §11 (Examples) updated; §14 #4 (TODO flow item) replaced
  with the actual current limitation (no per-pump fan-out on Port 0).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
znetsixe
2026-05-12 15:24:03 +02:00
parent 05de4ee29a
commit 4cb9c5084c
11 changed files with 1996 additions and 43 deletions

677
examples/01-Basic.json Normal file
View File

@@ -0,0 +1,677 @@
[
{
"id": "tab_mgc_basic",
"type": "tab",
"label": "MGC - Basic",
"disabled": false,
"info": "Tier 1: one machineGroupControl (MGC) coordinating three rotatingMachine pumps. Setup once-fires virtualControl + cmd.startup on all three pumps; then operator demand drives the MGC, which dispatches per-pump flow setpoints."
},
{
"id": "grp_mgc_unit",
"type": "group",
"z": "tab_mgc_basic",
"name": "Machine Group (Unit)",
"style": {
"label": true,
"stroke": "#000000",
"fill": "#50a8d9",
"fill-opacity": "0.10"
},
"nodes": [
"mgc_basic_node"
],
"x": 974,
"y": 359,
"w": 152,
"h": 122
},
{
"id": "grp_pump_a",
"type": "group",
"z": "tab_mgc_basic",
"name": "Pump A (Equipment)",
"style": {
"label": true,
"stroke": "#000000",
"fill": "#86bbdd",
"fill-opacity": "0.10"
},
"nodes": [
"rm_basic_pump_a"
],
"x": 694,
"y": 199,
"w": 142,
"h": 82
},
{
"id": "grp_pump_b",
"type": "group",
"z": "tab_mgc_basic",
"name": "Pump B (Equipment)",
"style": {
"label": true,
"stroke": "#000000",
"fill": "#86bbdd",
"fill-opacity": "0.10"
},
"nodes": [
"rm_basic_pump_b"
],
"x": 694,
"y": 379,
"w": 142,
"h": 82
},
{
"id": "grp_pump_c",
"type": "group",
"z": "tab_mgc_basic",
"name": "Pump C (Equipment)",
"style": {
"label": true,
"stroke": "#000000",
"fill": "#86bbdd",
"fill-opacity": "0.10"
},
"nodes": [
"rm_basic_pump_c"
],
"x": 694,
"y": 559,
"w": 142,
"h": 82
},
{
"id": "grp_drv_mode",
"type": "group",
"z": "tab_mgc_basic",
"name": "1. Control mode",
"style": {
"stroke": "#666666",
"fill": "#ffdf7f",
"fill-opacity": "0.15",
"label": true,
"color": "#333333"
},
"nodes": [
"inj_mode_optimal",
"inj_mode_priority"
],
"x": 94,
"y": 99,
"w": 312,
"h": 122
},
{
"id": "grp_drv_scaling",
"type": "group",
"z": "tab_mgc_basic",
"name": "2. Scaling",
"style": {
"stroke": "#666666",
"fill": "#ffdf7f",
"fill-opacity": "0.15",
"label": true,
"color": "#333333"
},
"nodes": [
"inj_scaling_norm",
"inj_scaling_abs"
],
"x": 94,
"y": 259,
"w": 312,
"h": 122
},
{
"id": "grp_drv_demand",
"type": "group",
"z": "tab_mgc_basic",
"name": "3. Operator demand (% of group capacity)",
"style": {
"stroke": "#666666",
"fill": "#ffdf7f",
"fill-opacity": "0.15",
"label": true,
"color": "#333333"
},
"nodes": [
"inj_demand_25",
"inj_demand_50",
"inj_demand_75",
"inj_demand_100",
"inj_demand_0"
],
"x": 94,
"y": 419,
"w": 312,
"h": 222
},
{
"id": "grp_setup",
"type": "group",
"z": "tab_mgc_basic",
"name": "Setup — once on deploy",
"style": {
"stroke": "#666666",
"fill": "#dddddd",
"fill-opacity": "0.20",
"label": true,
"color": "#333333"
},
"nodes": [
"inj_setup_start",
"fn_setup_fanout"
],
"x": 94,
"y": 679,
"w": 532,
"h": 82
},
{
"id": "grp_dbg",
"type": "group",
"z": "tab_mgc_basic",
"name": "Debug outputs (sidebar)",
"style": {
"stroke": "#666666",
"fill": "#d1d1d1",
"fill-opacity": "0.2",
"label": true,
"color": "#333333"
},
"nodes": [
"dbg_port0",
"dbg_port1",
"dbg_port2"
],
"x": 1234,
"y": 339,
"w": 232,
"h": 202
},
{
"id": "cmt_title",
"type": "comment",
"z": "tab_mgc_basic",
"name": "MGC — Basic (Tier 1)",
"info": "One machineGroupControl coordinating three rotatingMachine pumps.\n\nDefaults: mode=optimalControl, scaling=normalized.\n\nSETUP — fires once on deploy\n- Switches all 3 pumps to virtualControl mode\n- Sends cmd.startup to all 3 pumps\nPumps register with the MGC automatically via Port 2 (child.register).\n\nHOW TO USE\n1. Deploy — the Setup group auto-runs after ~1.5 s, putting pumps in virtual + started.\n2. Click any \"set.demand = N %\" — MGC dispatches per-pump flow setpoints by BEP-gravitation (default) or priority list, depending on the mode.\n3. Switch scaling to `absolute` to interpret set.demand as m³/h instead of %.\n4. Switch mode to `priorityControl` for sequential equal-flow control; `optimalControl` (default) picks the best combination automatically.\n5. Send `set.demand = 0` to drain the group (turnOffAllMachines).\n\nPORTS (MGC)\n- Port 0: process output (mode, scaling, totals, dist-from-peak)\n- Port 1: InfluxDB-shaped payload\n- Port 2: parent-registration handshake (when wired into a pumpingStation)",
"x": 1100,
"y": 280,
"wires": []
},
{
"id": "inj_mode_optimal",
"type": "inject",
"z": "tab_mgc_basic",
"g": "grp_drv_mode",
"name": "set.mode = optimalControl",
"props": [
{ "p": "topic", "vt": "str" },
{ "p": "payload", "v": "optimalControl", "vt": "str" }
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": "",
"topic": "set.mode",
"x": 260,
"y": 140,
"wires": [
[
"mgc_basic_node"
]
]
},
{
"id": "inj_mode_priority",
"type": "inject",
"z": "tab_mgc_basic",
"g": "grp_drv_mode",
"name": "set.mode = priorityControl",
"props": [
{ "p": "topic", "vt": "str" },
{ "p": "payload", "v": "priorityControl", "vt": "str" }
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": "",
"topic": "set.mode",
"x": 260,
"y": 180,
"wires": [
[
"mgc_basic_node"
]
]
},
{
"id": "inj_scaling_norm",
"type": "inject",
"z": "tab_mgc_basic",
"g": "grp_drv_scaling",
"name": "set.scaling = normalized",
"props": [
{ "p": "topic", "vt": "str" },
{ "p": "payload", "v": "normalized", "vt": "str" }
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": "",
"topic": "set.scaling",
"x": 260,
"y": 300,
"wires": [
[
"mgc_basic_node"
]
]
},
{
"id": "inj_scaling_abs",
"type": "inject",
"z": "tab_mgc_basic",
"g": "grp_drv_scaling",
"name": "set.scaling = absolute",
"props": [
{ "p": "topic", "vt": "str" },
{ "p": "payload", "v": "absolute", "vt": "str" }
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": "",
"topic": "set.scaling",
"x": 260,
"y": 340,
"wires": [
[
"mgc_basic_node"
]
]
},
{
"id": "inj_demand_0",
"type": "inject",
"z": "tab_mgc_basic",
"g": "grp_drv_demand",
"name": "set.demand = 0 (stop)",
"props": [
{ "p": "topic", "vt": "str" },
{ "p": "payload", "v": "0", "vt": "num" }
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": "",
"topic": "set.demand",
"x": 260,
"y": 460,
"wires": [
[
"mgc_basic_node"
]
]
},
{
"id": "inj_demand_25",
"type": "inject",
"z": "tab_mgc_basic",
"g": "grp_drv_demand",
"name": "set.demand = 25 %",
"props": [
{ "p": "topic", "vt": "str" },
{ "p": "payload", "v": "25", "vt": "num" }
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": "",
"topic": "set.demand",
"x": 260,
"y": 500,
"wires": [
[
"mgc_basic_node"
]
]
},
{
"id": "inj_demand_50",
"type": "inject",
"z": "tab_mgc_basic",
"g": "grp_drv_demand",
"name": "set.demand = 50 %",
"props": [
{ "p": "topic", "vt": "str" },
{ "p": "payload", "v": "50", "vt": "num" }
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": "",
"topic": "set.demand",
"x": 260,
"y": 540,
"wires": [
[
"mgc_basic_node"
]
]
},
{
"id": "inj_demand_75",
"type": "inject",
"z": "tab_mgc_basic",
"g": "grp_drv_demand",
"name": "set.demand = 75 %",
"props": [
{ "p": "topic", "vt": "str" },
{ "p": "payload", "v": "75", "vt": "num" }
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": "",
"topic": "set.demand",
"x": 260,
"y": 580,
"wires": [
[
"mgc_basic_node"
]
]
},
{
"id": "inj_demand_100",
"type": "inject",
"z": "tab_mgc_basic",
"g": "grp_drv_demand",
"name": "set.demand = 100 %",
"props": [
{ "p": "topic", "vt": "str" },
{ "p": "payload", "v": "100", "vt": "num" }
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": "",
"topic": "set.demand",
"x": 260,
"y": 620,
"wires": [
[
"mgc_basic_node"
]
]
},
{
"id": "inj_setup_start",
"type": "inject",
"z": "tab_mgc_basic",
"g": "grp_setup",
"name": "Auto-start pumps",
"props": [
{ "p": "payload", "v": "go", "vt": "str" }
],
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": "1.5",
"topic": "",
"x": 220,
"y": 720,
"wires": [
[
"fn_setup_fanout"
]
]
},
{
"id": "fn_setup_fanout",
"type": "function",
"z": "tab_mgc_basic",
"g": "grp_setup",
"name": "fan-out: virtualControl + startup → A/B/C",
"func": "// Fire two messages per pump: set.mode = virtualControl, then cmd.startup.\n// Each output is a message array — Node-RED dispatches them sequentially.\nconst setMode = { topic: 'set.mode', payload: 'virtualControl' };\nconst startup = { topic: 'cmd.startup', payload: {} };\nreturn [\n [setMode, startup], // → Pump A\n [setMode, startup], // → Pump B\n [setMode, startup], // → Pump C\n];\n",
"outputs": 3,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 480,
"y": 720,
"wires": [
[
"rm_basic_pump_a"
],
[
"rm_basic_pump_b"
],
[
"rm_basic_pump_c"
]
]
},
{
"id": "rm_basic_pump_a",
"type": "rotatingMachine",
"z": "tab_mgc_basic",
"g": "grp_pump_a",
"name": "Pump A",
"speed": "1",
"startup": "2",
"warmup": "1",
"shutdown": "2",
"cooldown": "1",
"movementMode": "staticspeed",
"machineCurve": "",
"uuid": "mgc-basic-pump-a",
"supplier": "hidrostal",
"category": "pump",
"assetType": "pump-centrifugal",
"model": "hidrostal-H05K-S03R",
"unit": "m3/h",
"curvePressureUnit": "mbar",
"curveFlowUnit": "m3/h",
"curvePowerUnit": "kW",
"curveControlUnit": "%",
"enableLog": false,
"logLevel": "info",
"positionVsParent": "atEquipment",
"positionIcon": "",
"hasDistance": false,
"distance": "",
"distanceUnit": "m",
"distanceDescription": "",
"x": 760,
"y": 240,
"wires": [
[],
[],
[
"mgc_basic_node"
]
]
},
{
"id": "rm_basic_pump_b",
"type": "rotatingMachine",
"z": "tab_mgc_basic",
"g": "grp_pump_b",
"name": "Pump B",
"speed": "1",
"startup": "2",
"warmup": "1",
"shutdown": "2",
"cooldown": "1",
"movementMode": "staticspeed",
"machineCurve": "",
"uuid": "mgc-basic-pump-b",
"supplier": "hidrostal",
"category": "pump",
"assetType": "pump-centrifugal",
"model": "hidrostal-H05K-S03R",
"unit": "m3/h",
"curvePressureUnit": "mbar",
"curveFlowUnit": "m3/h",
"curvePowerUnit": "kW",
"curveControlUnit": "%",
"enableLog": false,
"logLevel": "info",
"positionVsParent": "atEquipment",
"positionIcon": "",
"hasDistance": false,
"distance": "",
"distanceUnit": "m",
"distanceDescription": "",
"x": 760,
"y": 420,
"wires": [
[],
[],
[
"mgc_basic_node"
]
]
},
{
"id": "rm_basic_pump_c",
"type": "rotatingMachine",
"z": "tab_mgc_basic",
"g": "grp_pump_c",
"name": "Pump C",
"speed": "1",
"startup": "2",
"warmup": "1",
"shutdown": "2",
"cooldown": "1",
"movementMode": "staticspeed",
"machineCurve": "",
"uuid": "mgc-basic-pump-c",
"supplier": "hidrostal",
"category": "pump",
"assetType": "pump-centrifugal",
"model": "hidrostal-H05K-S03R",
"unit": "m3/h",
"curvePressureUnit": "mbar",
"curveFlowUnit": "m3/h",
"curvePowerUnit": "kW",
"curveControlUnit": "%",
"enableLog": false,
"logLevel": "info",
"positionVsParent": "atEquipment",
"positionIcon": "",
"hasDistance": false,
"distance": "",
"distanceUnit": "m",
"distanceDescription": "",
"x": 760,
"y": 600,
"wires": [
[],
[],
[
"mgc_basic_node"
]
]
},
{
"id": "mgc_basic_node",
"type": "machineGroupControl",
"z": "tab_mgc_basic",
"g": "grp_mgc_unit",
"name": "Machine Group",
"processOutputFormat": "process",
"dbaseOutputFormat": "influxdb",
"mode": "optimalControl",
"scaling": "normalized",
"uuid": "",
"supplier": "",
"category": "",
"assetType": "",
"model": "",
"unit": "",
"enableLog": false,
"logLevel": "info",
"positionVsParent": "atEquipment",
"positionIcon": "",
"hasDistance": false,
"distance": "",
"distanceUnit": "m",
"distanceDescription": "",
"x": 1050,
"y": 420,
"wires": [
[
"dbg_port0"
],
[
"dbg_port1"
],
[
"dbg_port2"
]
]
},
{
"id": "dbg_port0",
"type": "debug",
"z": "tab_mgc_basic",
"g": "grp_dbg",
"name": "Port 0: Process",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"x": 1340,
"y": 380,
"wires": []
},
{
"id": "dbg_port1",
"type": "debug",
"z": "tab_mgc_basic",
"g": "grp_dbg",
"name": "Port 1: InfluxDB",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 1340,
"y": 440,
"wires": []
},
{
"id": "dbg_port2",
"type": "debug",
"z": "tab_mgc_basic",
"g": "grp_dbg",
"name": "Port 2: Parent reg",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 1350,
"y": 500,
"wires": []
},
{
"id": "mgc_global_cfg",
"type": "global-config",
"env": [],
"modules": {
"EVOLV": "1.0.29"
}
}
]

1205
examples/02-Dashboard.json Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,51 @@
# machineGroupControl Example Flows # machineGroupControl - Example Flows
Import-ready Node-RED examples for machineGroupControl. Import-ready Node-RED examples for `machineGroupControl` (MGC). MGC is not a standalone node — it needs at least one `rotatingMachine` child to dispatch demand to. Both flows below ship three child pumps.
## Files ## Files
- basic.flow.json
- integration.flow.json | File | Tier | What it shows |
- edge.flow.json |---|---|---|
| `01-Basic.json` | 1 | One MGC + three `rotatingMachine` pumps driven by inject buttons. Setup once-fires `virtualControl` + `cmd.startup` on all three pumps; mode / scaling / demand are then driven by buttons. |
| `02-Dashboard.json` | 2 | Same command surface driven by a FlowFuse Dashboard 2.0 page — mode + scaling buttons, demand slider, live status rows, three trend charts, and a raw-output table. |
## Prerequisites
- Node-RED with the EVOLV package installed (`machineGroupControl` and `rotatingMachine` registered).
- For `02-Dashboard.json`: `@flowfuse/node-red-dashboard` (Dashboard 2.0).
## Load a flow
```bash
curl -X POST -H 'Content-Type: application/json' \
--data @nodes/machineGroupControl/examples/01-Basic.json \
http://localhost:1880/flows
```
Or in the editor: Menu → Import → drag the file → Import.
## Canonical command surface
| Topic | Aliases | Payload | What it does |
|---|---|---|---|
| `set.mode` | `setMode` | `"optimalControl"`, `"priorityControl"`, `"prioritypercentagecontrol"`, `"maintenance"` | Switch dispatch strategy |
| `set.scaling` | `setScaling` | `"normalized"`, `"absolute"` | Interpret demand as 0100 % vs m³/h |
| `set.demand` | `Qd` | number | Operator demand setpoint |
| `child.register` | `registerChild` | child node id (string) | Manually register a child (Port 2 wiring does this automatically) |
## 01-Basic — what to try
1. Deploy. After ~1.5 s the Setup group auto-fires, putting all three pumps in `virtualControl` mode + sending `cmd.startup` to each.
2. Click `set.demand = 50 %` — MGC's `optimalControl` picks the best pump combination by BEP-gravitation and dispatches `flowmovement` to the selected pumps.
3. Click `set.demand = 100 %` — MGC switches to a higher combination, possibly engaging an extra pump.
4. Switch mode to `priorityControl` and try the same demands — pumps now run equal-flow by priority order.
5. Switch scaling to `absolute` — set.demand is now interpreted as m³/h (capped at the group min / max).
6. `set.demand = 0` — MGC calls `turnOffAllMachines`, all pumps shut down.
## 02-Dashboard — what to try
1. Deploy → open `http://localhost:1880/dashboard/mgc-basic`.
2. The dashboard auto-initialises the pumps; the `Initialize pumps` button on the page re-runs the setup manually.
3. Drag the **Demand** slider — MGC dispatches and the Flow / Power / BEP charts react.
4. Switch modes and scalings via the buttons; the Mode / Scaling rows in the Status panel reflect the change.
5. Inspect the **Raw output** table for the full Port 0 surface (every field MGC emits, including `flowCapacityMax`, `machineCountActive`, `absDistFromPeak`, `relDistFromPeak`).

View File

@@ -1,6 +0,0 @@
[
{"id":"machineGroupControl_basic_tab","type":"tab","label":"machineGroupControl basic","disabled":false,"info":"machineGroupControl basic example"},
{"id":"machineGroupControl_basic_node","type":"machineGroupControl","z":"machineGroupControl_basic_tab","name":"machineGroupControl basic","x":420,"y":180,"wires":[["machineGroupControl_basic_dbg"]]},
{"id":"machineGroupControl_basic_inj","type":"inject","z":"machineGroupControl_basic_tab","name":"basic trigger","props":[{"p":"topic","vt":"str"},{"p":"payload","vt":"str"}],"topic":"ping","payload":"1","payloadType":"str","x":160,"y":180,"wires":[["machineGroupControl_basic_node"]]},
{"id":"machineGroupControl_basic_dbg","type":"debug","z":"machineGroupControl_basic_tab","name":"machineGroupControl basic debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":660,"y":180,"wires":[]}
]

View File

@@ -1,6 +0,0 @@
[
{"id":"machineGroupControl_edge_tab","type":"tab","label":"machineGroupControl edge","disabled":false,"info":"machineGroupControl edge example"},
{"id":"machineGroupControl_edge_node","type":"machineGroupControl","z":"machineGroupControl_edge_tab","name":"machineGroupControl edge","x":420,"y":180,"wires":[["machineGroupControl_edge_dbg"]]},
{"id":"machineGroupControl_edge_inj","type":"inject","z":"machineGroupControl_edge_tab","name":"unknown topic","props":[{"p":"topic","vt":"str"},{"p":"payload","vt":"str"}],"topic":"doesNotExist","payload":"x","payloadType":"str","x":170,"y":180,"wires":[["machineGroupControl_edge_node"]]},
{"id":"machineGroupControl_edge_dbg","type":"debug","z":"machineGroupControl_edge_tab","name":"machineGroupControl edge debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":660,"y":180,"wires":[]}
]

View File

@@ -1,6 +0,0 @@
[
{"id":"machineGroupControl_int_tab","type":"tab","label":"machineGroupControl integration","disabled":false,"info":"machineGroupControl integration example"},
{"id":"machineGroupControl_int_node","type":"machineGroupControl","z":"machineGroupControl_int_tab","name":"machineGroupControl integration","x":420,"y":180,"wires":[["machineGroupControl_int_dbg"]]},
{"id":"machineGroupControl_int_inj","type":"inject","z":"machineGroupControl_int_tab","name":"registerChild","props":[{"p":"topic","vt":"str"},{"p":"payload","vt":"str"}],"topic":"registerChild","payload":"example-child-id","payloadType":"str","x":170,"y":180,"wires":[["machineGroupControl_int_node"]]},
{"id":"machineGroupControl_int_dbg","type":"debug","z":"machineGroupControl_int_tab","name":"machineGroupControl integration debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":680,"y":180,"wires":[]}
]

View File

@@ -21,6 +21,10 @@
processOutputFormat: { value: "process" }, processOutputFormat: { value: "process" },
dbaseOutputFormat: { value: "influxdb" }, dbaseOutputFormat: { value: "influxdb" },
// Control strategy
mode: { value: "optimalControl" }, // optimalControl | priorityControl | prioritypercentagecontrol | maintenance
scaling: { value: "normalized" }, // normalized (0100 %) | absolute (m³/h)
//define asset properties //define asset properties
uuid: { value: "" }, uuid: { value: "" },
supplier: { value: "" }, supplier: { value: "" },
@@ -84,6 +88,24 @@
<script type="text/html" data-template-name="machineGroupControl"> <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="prioritypercentagecontrol">prioritypercentagecontrol &mdash; sequential percentage control (requires normalized scaling)</option>
<option value="maintenance">maintenance &mdash; monitoring only, no dispatch</option>
</select>
</div>
<div class="form-row">
<label for="node-input-scaling"><i class="fa fa-arrows-h"></i> Scaling</label>
<select id="node-input-scaling" style="width:60%;">
<option value="normalized">normalized &mdash; demand interpreted as 0&ndash;100 % of group capacity</option>
<option value="absolute">absolute &mdash; demand interpreted as /h, capped by group min/max</option>
</select>
</div>
<h3>Output Formats</h3> <h3>Output Formats</h3>
<div class="form-row"> <div class="form-row">
<label for="node-input-processOutputFormat"><i class="fa fa-random"></i> Process Output</label> <label for="node-input-processOutputFormat"><i class="fa fa-random"></i> Process Output</label>

View File

@@ -41,6 +41,18 @@ function getOutput(mgc) {
out.scaling = scaling; out.scaling = scaling;
out.absDistFromPeak = absDistFromPeak; out.absDistFromPeak = absDistFromPeak;
out.relDistFromPeak = relDistFromPeak; out.relDistFromPeak = relDistFromPeak;
// Group capacity + active-machine counts. Surfaced so dashboards can
// show the same numbers the status badge does without subscribing to
// every child node individually.
out.flowCapacityMax = mgc.dynamicTotals?.flow?.max ?? 0;
out.flowCapacityMin = mgc.dynamicTotals?.flow?.min ?? 0;
out.machineCount = Object.keys(mgc.machines || {}).length;
out.machineCountActive = Object.values(mgc.machines || {}).filter((m) => {
const s = m?.state?.getCurrentState?.();
const md = m?.currentMode;
return s && s !== 'off' && s !== 'maintenance' && md !== 'maintenance';
}).length;
return out; return out;
} }
@@ -55,15 +67,16 @@ function getStatusBadge(mgc) {
const md = m?.currentMode; const md = m?.currentMode;
return s && s !== 'off' && s !== 'maintenance' && md !== 'maintenance'; return s && s !== 'off' && s !== 'maintenance' && md !== 'maintenance';
}); });
const status = available.length > 0 ? `${available.length} machine(s)` : 'No machines'; const machineCount = Object.keys(mgc.machines || {}).length;
let scalingSymbol; const scaling = String(mgc.scaling || '').toLowerCase() === 'absolute' ? 'abs' : 'norm';
switch ((mgc.scaling || '').toLowerCase()) { const parts = [
case 'absolute': scalingSymbol = ''; break; mgc.mode || '?',
case 'normalized': scalingSymbol = 'Ⓝ'; break; scaling,
default: scalingSymbol = mgc.mode || ''; break; `Q=${Math.round(totalFlow)}/${Math.round(totalCapacity)} m³/h`,
} `P=${Math.round(totalPower)} kW`,
const text = ` ${mgc.mode || 'Unknown'} | ${scalingSymbol}: 💨=${Math.round(totalFlow)}/${Math.round(totalCapacity)} | ⚡=${Math.round(totalPower)} | ${status}`; `${available.length}/${machineCount}x`,
return statusBadge.text(text, { fill: available.length > 0 ? 'green' : 'red', shape: 'dot' }); ];
return statusBadge.compose(parts, { fill: available.length > 0 ? 'green' : (machineCount > 0 ? 'yellow' : 'grey'), shape: 'dot' });
} }
module.exports = { getOutput, getStatusBadge }; module.exports = { getOutput, getStatusBadge };

View File

@@ -12,8 +12,14 @@ class nodeClass extends BaseNodeAdapter {
static tickInterval = null; static tickInterval = null;
static statusInterval = 1000; static statusInterval = 1000;
buildDomainConfig() { buildDomainConfig(uiConfig = {}) {
return {}; // Schema shape is mode.current / scaling.current (the schema nests
// value + allowedActions/allowedSources under `current`). Editor field
// names are flat — bridge here.
const out = {};
if (uiConfig.mode) out.mode = { current: uiConfig.mode };
if (uiConfig.scaling) out.scaling = { current: uiConfig.scaling };
return out;
} }
} }

View File

@@ -260,8 +260,11 @@ class MachineGroup extends BaseDomain {
demandQout = this.interpolation.interpolate_lin_single_point(demandQ, 0, 100, dt.flow.min, dt.flow.max); demandQout = this.interpolation.interpolate_lin_single_point(demandQ, 0, 100, dt.flow.min, dt.flow.max);
} }
// Normalize for the switch — schema enum values use camelCase
// (optimalControl, priorityControl) while legacy callers send
// lowercase. Accept both rather than silently falling through.
const ctx = { mgc: this }; const ctx = { mgc: this };
switch (this.mode) { switch (String(this.mode || '').toLowerCase()) {
case 'prioritycontrol': await control.equalFlowControl(ctx, demandQout, powerCap, priorityList); break; case 'prioritycontrol': await control.equalFlowControl(ctx, demandQout, powerCap, priorityList); break;
case 'prioritypercentagecontrol': case 'prioritypercentagecontrol':
if (this.scaling !== 'normalized') { this.logger.warn('Priority percentage control needs normalized scaling.'); return; } if (this.scaling !== 'normalized') { this.logger.warn('Priority percentage control needs normalized scaling.'); return; }

View File

@@ -243,13 +243,15 @@ While `dispatching`, additional `handleInput` calls are absorbed by `DemandDispa
## 11. Examples ## 11. Examples
| Tier | File | What it shows | Status | | Tier | File | What it shows |
|---|---|---|---| |---|---|---|
| Basic | `examples/basic.flow.json` | Single MGC + 2 pumps, manual setDemand | ⚠️ legacy shape, pre-refactor | | 1 | `examples/01-Basic.json` | One MGC + three `rotatingMachine` pumps driven by inject buttons. Setup auto-fires `virtualControl` + `cmd.startup` on all three pumps; numbered driver groups for mode / scaling / demand. |
| Integration | `examples/integration.flow.json` | MGC wired under pumpingStation | ⚠️ legacy shape, pre-refactor | | 2 | `examples/02-Dashboard.json` | Same command surface driven by a FlowFuse Dashboard 2.0 page — Mode + Scaling buttons, Demand slider, live Status rows (mode / scaling / total flow / total power / capacity / active machines / BEP %), three trend charts, and a raw-output table. |
| Edge | `examples/edge.flow.json` | Mid-flight demand override + abort | ⚠️ legacy shape, pre-refactor |
Tier 1/2/3 visual-first example flows are still TODO (see `MEMORY.md` "TODO: Example Flows"). Screenshots will land under `wiki/_partial-screenshots/machineGroupControl/` when the new flows ship. See [`examples/README.md`](https://gitea.wbd-rd.nl/RnD/machineGroupControl/src/branch/development/examples/README.md) for the canonical command surface table and step-by-step "what to try" recipes.
> [!IMPORTANT]
> **Screenshots needed.** Capture both flows in the editor + the rendered dashboard. Save under `wiki/_partial-screenshots/machineGroupControl/` as `01-basic-flow.png`, `02-dashboard-editor.png`, `03-dashboard-rendered.png`. Replace this callout with the image links.
## 12. Debug recipes ## 12. Debug recipes
@@ -277,6 +279,6 @@ Tier 1/2/3 visual-first example flows are still TODO (see `MEMORY.md` "TODO: Exa
| 1 | `optimalControl` requires every machine to expose a curve — null-curve members silently exclude themselves from combinations. | `combinatorics/pumpCombinations`. | | 1 | `optimalControl` requires every machine to expose a curve — null-curve members silently exclude themselves from combinations. | `combinatorics/pumpCombinations`. |
| 2 | Mid-flight setpoint overrides on `accelerating` / `decelerating` rely on `abortActiveMovements` per dispatch — a sequence with no awaitable `abortMovement` will warn but proceed. | `abortActiveMovements`. | | 2 | Mid-flight setpoint overrides on `accelerating` / `decelerating` rely on `abortActiveMovements` per dispatch — a sequence with no awaitable `abortMovement` will warn but proceed. | `abortActiveMovements`. |
| 3 | Power-cap parameter exposed but not surfaced as a topic input — only programmatic via `handleInput(source, demand, powerCap)`. | `commands/index.js` — no canonical topic. | | 3 | Power-cap parameter exposed but not surfaced as a topic input — only programmatic via `handleInput(source, demand, powerCap)`. | `commands/index.js` — no canonical topic. |
| 4 | Tier 1/2/3 visual-first example flows not yet written. | P9 follow-up. | | 4 | Per-pump fan-out for dashboard charts (per-machine flow / power series) not surfaced from MGC's Port 0 — only group aggregates appear. Subscribe to each rotatingMachine's Port 0 if you need per-pump trends. | `io/output.js` aggregates only. |
| 5 | **`maxEfficiency` naming bug** — `GroupEfficiency.calcGroupEfficiency` returns `{ maxEfficiency, lowestEfficiency }` but `maxEfficiency` is actually the **mean cog** across all machines (not the maximum). The name is deliberately preserved for behavioural parity; callers using it as "the peak" will over-estimate the BEP target. | `efficiency/groupEfficiency.js` comment + `OPEN_QUESTIONS.md` 2026-05-10. | | 5 | **`maxEfficiency` naming bug** — `GroupEfficiency.calcGroupEfficiency` returns `{ maxEfficiency, lowestEfficiency }` but `maxEfficiency` is actually the **mean cog** across all machines (not the maximum). The name is deliberately preserved for behavioural parity; callers using it as "the peak" will over-estimate the BEP target. | `efficiency/groupEfficiency.js` comment + `OPEN_QUESTIONS.md` 2026-05-10. |
| 6 | **`calcAbsoluteTotals` implicit pressure-key coupling** — iterates `machine.predictFlow.inputCurve` and re-uses the same pressure key to index `machine.predictPower.inputCurve[pressure]`. If the two curves were sampled at different pressures the lookup is `undefined` and the call throws. Enforcement or defensive skip deferred to P5 (rotatingMachine curveLoader). | `totals/totalsCalculator.js` + `OPEN_QUESTIONS.md` 2026-05-10. | | 6 | **`calcAbsoluteTotals` implicit pressure-key coupling** — iterates `machine.predictFlow.inputCurve` and re-uses the same pressure key to index `machine.predictPower.inputCurve[pressure]`. If the two curves were sampled at different pressures the lookup is `undefined` and the call throws. Enforcement or defensive skip deferred to P5 (rotatingMachine curveLoader). | `totals/totalsCalculator.js` + `OPEN_QUESTIONS.md` 2026-05-10. |