hydraloop-diagram-react 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,7 +20,7 @@ function formatTime(t) {
20
20
  minute: "2-digit",
21
21
  });
22
22
  }
23
- function Pipe({ d, kind, active, open = false, filled = false, still = false, square = false, arrow, title, }) {
23
+ function Pipe({ d, kind, active, open = false, filled = false, still = false, square = false, arrow, title, phase, }) {
24
24
  const state = active === undefined
25
25
  ? "unknown"
26
26
  : filled
@@ -30,11 +30,15 @@ function Pipe({ d, kind, active, open = false, filled = false, still = false, sq
30
30
  : open
31
31
  ? "open"
32
32
  : "idle";
33
- return (_jsxs("g", { className: `hl-pipe hl-kind-${kind} is-${state}${still ? " is-still" : ""}${square ? " is-square" : ""}`, children: [title && _jsx("title", { children: title }), _jsx("path", { d: d, className: "hl-pipe-base" }), state === "filled" && _jsx("path", { d: d, className: "hl-pipe-water" }), active && _jsx("path", { d: d, className: "hl-pipe-flow" }), arrow && (_jsx("path", { className: "hl-pipe-arrow", d: arrow.dir === "down"
33
+ return (_jsxs("g", { className: `hl-pipe hl-kind-${kind} is-${state}${still ? " is-still" : ""}${square ? " is-square" : ""}`, children: [title && _jsx("title", { children: title }), _jsx("path", { d: d, className: "hl-pipe-base" }), state === "filled" && _jsx("path", { d: d, className: "hl-pipe-water" }), active && (_jsx("path", { d: d, className: "hl-pipe-flow", style: phase === undefined
34
+ ? undefined
35
+ : { animationDelay: `${flowDelay(phase)}s` } })), arrow && (_jsx("path", { className: "hl-pipe-arrow", d: arrow.dir === "down"
34
36
  ? `M${arrow.x - 7} ${arrow.y} L${arrow.x + 7} ${arrow.y} L${arrow.x} ${arrow.y + 9} Z`
35
- : arrow.dir === "right"
36
- ? `M${arrow.x} ${arrow.y - 7} L${arrow.x} ${arrow.y + 7} L${arrow.x + 9} ${arrow.y} Z`
37
- : `M${arrow.x} ${arrow.y - 7} L${arrow.x} ${arrow.y + 7} L${arrow.x - 9} ${arrow.y} Z` }))] }));
37
+ : arrow.dir === "up"
38
+ ? `M${arrow.x - 7} ${arrow.y} L${arrow.x + 7} ${arrow.y} L${arrow.x} ${arrow.y - 9} Z`
39
+ : arrow.dir === "right"
40
+ ? `M${arrow.x} ${arrow.y - 7} L${arrow.x} ${arrow.y + 7} L${arrow.x + 9} ${arrow.y} Z`
41
+ : `M${arrow.x} ${arrow.y - 7} L${arrow.x} ${arrow.y + 7} L${arrow.x - 9} ${arrow.y} Z` }))] }));
38
42
  }
39
43
  function ioTitle(label, name, io, words) {
40
44
  if (!io)
@@ -62,10 +66,25 @@ function Valve({ x, y, vertical = false, kind, io, active = false, name, label,
62
66
  * The pipe between the backwash valves, level with the waste pipes below T1
63
67
  */
64
68
  const RUN_Y = 404;
65
- /** The vertical center of UV-C */
66
- const UV_Y = 466;
67
69
  /** Half the width of a pipe */
68
70
  const PIPE = 3.5;
71
+ /** Half the height of UV-C */
72
+ const UV_H = 17;
73
+ /**
74
+ * The space above and below UV-C: from the bottom edge of the circulation
75
+ * pipe's top run to UV-C's top, and from UV-C's bottom to the top of T3
76
+ */
77
+ const UV_GAP = 57;
78
+ /** The vertical center of UV-C */
79
+ const UV_Y = RUN_Y + PIPE + UV_GAP + UV_H;
80
+ /** The top of T3 and T4 */
81
+ const TANK_Y = UV_Y + UV_H + UV_GAP;
82
+ /** The height of T3 and T4 */
83
+ const TANK_H = 100;
84
+ /** The bottom of T3 and T4 */
85
+ const TANK_BOTTOM = TANK_Y + TANK_H;
86
+ /** The distribution pump and the pipe to the outlets */
87
+ const PUMP_Y = TANK_BOTTOM + 100;
69
88
  /**
70
89
  * The x of each train's T2, which leaves 30 px between the release air labels.
71
90
  * Each train's other parts are placed relative to it
@@ -91,6 +110,11 @@ const SEWER_END = {
91
110
  const MAINS_Y = UV_Y;
92
111
  /** Where the mains pipe enters T4's top */
93
112
  const T4_INLET_X = 167;
113
+ /**
114
+ * The air gap between the end of the mains pipe and T4's top, which keeps
115
+ * mains water from flowing back into the pipe. The water drips across it
116
+ */
117
+ const T4_AIR_GAP = 14;
94
118
  /** The center of each T2, where its backwash pipe enters from below */
95
119
  const T2_CENTER = { A: T2_X.A + 86, B: T2_X.B + 86 };
96
120
  /** Height of a distributor triangle, from its tip to its base */
@@ -142,7 +166,7 @@ function distributorEnds(x, y, tip) {
142
166
  * the common pipe and the open branch's pipe, so it lines up with both. The
143
167
  * rest is an outline.
144
168
  */
145
- function Distributor({ x, y, tip = "up", kind, io, name, label, words, branches, labelAnchor = "middle", labelDx = 0, labelDy = 4, strong = false, idle = false, }) {
169
+ function Distributor({ x, y, tip = "up", kind, io, name, label, words, branches, labelAnchor = "middle", labelDx = 0, labelDy = 4, strong = false, idle = false, phase = 0, }) {
146
170
  const p = PIPE;
147
171
  const w = DISTRIBUTOR;
148
172
  // Drawn with the tip above, then turned for a tip on the left or flipped
@@ -168,6 +192,18 @@ function Distributor({ x, y, tip = "up", kind, io, name, label, words, branches,
168
192
  ? "flowing"
169
193
  : "open";
170
194
  const open = left.open ? -1 : right.open ? 1 : 0;
195
+ // The flow's dashes continue through the open side, along the pipes'
196
+ // center lines: from the common pipe's end to where the pipes cross and on
197
+ // to the branch's end. Into an outlet below, they run the other way
198
+ const flowing = open !== 0 && state(open < 0 ? left : right) === "flowing";
199
+ const d = w - 2 * p;
200
+ const flowPoints = [
201
+ [0, -d],
202
+ [0, 0],
203
+ [open * d, 0],
204
+ ];
205
+ if (tip === "down")
206
+ flowPoints.reverse();
171
207
  const title = ioTitle(label, name, io, words);
172
208
  return (_jsxs("g", { className: `hl-distributor hl-kind-${kind}`, tabIndex: 0, role: "img", "aria-label": title, children: [_jsx("title", { suppressHydrationWarning: true, children: title }), _jsx("rect", { x: up ? x - w - 4 : x + p - w - 4, y: tip === "up" ? y + p - w - 4 : tip === "down" ? y - p - 4 : y - w - 4, width: up ? 2 * w + 8 : w + 8, height: up ? w + 8 : 2 * w + 8, className: "hl-hit" }), _jsx("g", { className: "hl-valve-body", children: open === 0 || left.open === undefined ? (_jsx("polygon", { points: outline([
173
209
  [0, p - w],
@@ -182,7 +218,7 @@ function Distributor({ x, y, tip = "up", kind, io, name, label, words, branches,
182
218
  [-open * p, 2 * p - w],
183
219
  [-open * w, p],
184
220
  [-open * p, p],
185
- ], CLOSED_OUTLINE), className: "is-closed" })] })) }), _jsx("text", { x: x + labelDx, y: y + labelDy, textAnchor: labelAnchor, className: strong ? "hl-diagram-label is-bold" : "hl-diagram-label", children: label })] }));
221
+ ], CLOSED_OUTLINE), className: "is-closed" })] })) }), flowing && (_jsx("g", { className: "hl-pipe is-active is-square", children: _jsx("path", { d: `M${flowPoints.map(at).join(" L")}`, className: "hl-pipe-flow", style: { animationDelay: `${flowDelay(phase)}s` } }) })), _jsx("text", { x: x + labelDx, y: y + labelDy, textAnchor: labelAnchor, className: strong ? "hl-diagram-label is-bold" : "hl-diagram-label", children: label })] }));
186
222
  }
187
223
  /** Curved impeller blades around (0, 0), from the hub out to radius r */
188
224
  function impellerPath(r) {
@@ -279,8 +315,8 @@ function Tank({ x, y, w, h, level, kind, label, sub, side, aeration, circulation
279
315
  const rings = Math.ceil(Math.hypot(Math.max(ringX - x, x + w - ringX), h - fillHeight) / 14) + 1;
280
316
  // Venting rings vanish where the pipe's dashes start, at its beginning
281
317
  const phase = venting === undefined && pressurized ? flowDelay(pressurized) : 0;
282
- const textX = small === "end" ? x + w + 10 : small ? x - 10 : x + 12;
283
- const anchor = small === "start" ? "end" : "start";
318
+ const textX = small ? x + w / 2 : x + 12;
319
+ const anchor = small ? "middle" : "start";
284
320
  return (_jsxs("g", { className: `hl-tank hl-kind-${kind}`, tabIndex: 0, role: "img", "aria-label": title, children: [_jsx("title", { children: title }), _jsx("rect", { x: x, y: y, width: w, height: h, rx: square ? 0 : 5, className: known ? "hl-tank-shell" : "hl-tank-shell is-unknown" }), known && (_jsxs(_Fragment, { children: [_jsx("rect", { x: x + 1, y: y + h - fillHeight, width: w - 2, height: Math.max(0, fillHeight - 1), rx: !square && fillHeight > 8 ? 4 : 0, className: "hl-tank-fill" }), _jsx("line", { x1: x + 1, x2: x + w - 1, y1: y + h - fillHeight, y2: y + h - fillHeight, className: "hl-tank-surface" })] })), known && circulation && fillHeight > 4 && (
285
321
  // The water spreads into the tank as rings, as the air does when
286
322
  // pressurized, and gathers towards the pipe it leaves through. Rings
@@ -301,13 +337,13 @@ function Tank({ x, y, w, h, level, kind, label, sub, side, aeration, circulation
301
337
  transform: `scale(${i / rings})`,
302
338
  animationDuration: `${rings * 0.9}s`,
303
339
  animationDelay: `${phase - i * 0.9}s`,
304
- } }, i))) })] })] })), _jsxs("text", { x: textX, y: small ? y + h / 2 - 6 : y + 22, textAnchor: anchor, className: "hl-tank-label", children: [label, sub && (_jsx("tspan", { className: "hl-tank-sub", dx: 6, children: sub }))] }), pressureHeld && (
340
+ } }, i))) })] })] })), _jsxs("text", { x: textX, y: y + 22, textAnchor: anchor, className: "hl-tank-label", children: [label, sub && (_jsx("tspan", { className: "hl-tank-sub", dx: 6, children: sub }))] }), pressureHeld && (
305
341
  // Air pumped in before holds its pressure, in the top right corner,
306
342
  // level with the label
307
- _jsx("text", { x: x + w - 12, y: y + 22, textAnchor: "end", className: "hl-tank-meta", children: "pressurized" })), known && small && (_jsx("text", { x: textX, y: y + h / 2 + 20, textAnchor: anchor, className: "hl-tank-value", children: percent })), known && !small && inlinePercent && (_jsxs("text", { x: x + 12, y: y + h - 14, className: "hl-tank-value", children: [Math.round(level.liters), " L", " ", arrow && _jsxs("tspan", { className: "hl-tank-trend", children: [arrow, " "] }), _jsx("tspan", { className: "hl-tank-meta", children: percent })] })), known && !small && !inlinePercent && (_jsxs(_Fragment, { children: [_jsxs("text", { x: x + 12, y: y + h - (h > 100 ? 30 : 26), className: "hl-tank-value", children: [Math.round(level.liters), " L", " ", arrow && _jsx("tspan", { className: "hl-tank-trend", children: arrow })] }), _jsxs("text", { x: x + 12, y: y + h - 12, className: "hl-tank-meta", children: [percent, " of ", level.capacity ? "~" : "", Math.round(size), " L"] })] }))] }));
343
+ _jsx("text", { x: x + w - 12, y: y + 22, textAnchor: "end", className: "hl-tank-meta", children: "pressurized" })), known && !small && inlinePercent && (_jsxs("text", { x: x + 12, y: y + h - 14, className: "hl-tank-value", children: [Math.round(level.liters), " L", " ", arrow && _jsxs("tspan", { className: "hl-tank-trend", children: [arrow, " "] }), _jsx("tspan", { className: "hl-tank-meta", children: percent })] })), known && !small && !inlinePercent && (_jsxs(_Fragment, { children: [_jsxs("text", { x: x + 12, y: y + h - (h > 100 ? 30 : 26), className: "hl-tank-value", children: [Math.round(level.liters), " L", " ", arrow && _jsx("tspan", { className: "hl-tank-trend", children: arrow })] }), _jsxs("text", { x: x + 12, y: y + h - 12, className: "hl-tank-meta", children: [percent, " of ", level.capacity ? "~" : "", Math.round(size), " L"] })] }))] }));
308
344
  }
309
345
  /** T4 has float sensors instead of a level reading */
310
- function BackupTank({ x, y, w, h, state, inletX, filling = false, }) {
346
+ function BackupTank({ x, y, w, h, state, inletX, inletY, filling = false, }) {
311
347
  const { t4, io } = state;
312
348
  const maxY = y + h * 0.55;
313
349
  const minY = y + h * 0.82;
@@ -315,7 +351,7 @@ function BackupTank({ x, y, w, h, state, inletX, filling = false, }) {
315
351
  const fillTop = t4.max ? maxY : t4.min ? minY : undefined;
316
352
  return (_jsxs("g", { className: "hl-tank hl-kind-mains", children: [_jsx("rect", { x: x, y: y, width: w, height: h, className: t4.max === undefined && t4.min === undefined
317
353
  ? "hl-tank-shell is-unknown"
318
- : "hl-tank-shell" }), fillTop !== undefined && (_jsxs(_Fragment, { children: [_jsx("rect", { x: x + 1, y: fillTop, width: w - 2, height: y + h - fillTop - 1, className: "hl-tank-fill" }), _jsx("line", { x1: x + 1, x2: x + w - 1, y1: fillTop, y2: fillTop, className: "hl-tank-surface is-dashed" })] })), _jsxs("text", { x: x + 12, y: y + 22, className: "hl-tank-label", children: ["T4", _jsx("tspan", { className: "hl-tank-sub", dx: 6, children: "Backup" })] }), _jsx(Sensor, { x: x + w - 14, y: maxY, kind: "mains", io: io[IO.t4Max], name: IO.t4Max, label: "Max", labelAnchor: "end", labelDx: -12 }), _jsx(Sensor, { x: x + w - 14, y: minY, kind: "mains", io: io[IO.t4Min], name: IO.t4Min, label: "Min", labelAnchor: "end", labelDx: -12 }), _jsx("text", { x: x + 12, y: y + 40, className: "hl-tank-meta", children: t4.label }), _jsx(Drips, { x: inletX, y: y, bottom: fillTop ?? y + h, active: filling, kind: "mains" })] }));
354
+ : "hl-tank-shell" }), _jsx("path", { d: `M${inletX - PIPE} ${y} H${inletX + PIPE}`, className: "hl-tank-gap" }), fillTop !== undefined && (_jsxs(_Fragment, { children: [_jsx("rect", { x: x + 1, y: fillTop, width: w - 2, height: y + h - fillTop - 1, className: "hl-tank-fill" }), _jsx("line", { x1: x + 1, x2: x + w - 1, y1: fillTop, y2: fillTop, className: "hl-tank-surface is-dashed" })] })), _jsxs("text", { x: x + 12, y: y + 22, className: "hl-tank-label", children: ["T4", _jsx("tspan", { className: "hl-tank-sub", dx: 6, children: "Backup" })] }), _jsx(Sensor, { x: x + w - 14, y: maxY, kind: "mains", io: io[IO.t4Max], name: IO.t4Max, label: "Max", labelAnchor: "end", labelDx: -12 }), _jsx(Sensor, { x: x + w - 14, y: minY, kind: "mains", io: io[IO.t4Min], name: IO.t4Min, label: "Min", labelAnchor: "end", labelDx: -12 }), _jsx("text", { x: x + 12, y: y + 40, className: "hl-tank-meta", children: t4.label }), _jsx(Drips, { x: inletX, y: inletY, bottom: fillTop ?? y + h, active: filling, kind: "mains" })] }));
319
355
  }
320
356
  export function FlowDiagram({ state, device, }) {
321
357
  const { io, tanks, inlet, supply, t3 } = state;
@@ -339,8 +375,18 @@ export function FlowDiagram({ state, device, }) {
339
375
  const bypassEnds = distributorEnds(500, inletY, "left");
340
376
  const abEnds = distributorEnds(500, abY, "up");
341
377
  // The backup valve lines up with the bottom of T3 and T4
342
- const backupY = 640 - PIPE;
378
+ const backupY = TANK_BOTTOM - PIPE;
343
379
  const backupEnds = distributorEnds(260, backupY, "down");
380
+ // How far the water has come at each pipe and valve along the way, so the
381
+ // flow's dashes continue from one into the next, see flowDelay. The way
382
+ // through a distributor runs along the pipes' center lines
383
+ const throughDistributor = 2 * (DISTRIBUTOR - 2 * PIPE);
384
+ const bypassPhase = bypassEnds.common - 60;
385
+ const toAbPhase = bypassPhase + throughDistributor;
386
+ const abPhase = toAbPhase + abEnds.common - bypassEnds.branches[0];
387
+ const trainInletPhase = abPhase + throughDistributor;
388
+ const fromT4Length = backupEnds.branches[0] - 190;
389
+ const fromT3Length = 346 - backupEnds.branches[1];
344
390
  const train = (side) => {
345
391
  const a = side === "A";
346
392
  // Tank areas are to scale: T1 ~24 L, T2 ~200 L, T3 ~280 L (TANK_CAPACITY),
@@ -375,6 +421,10 @@ export function FlowDiagram({ state, device, }) {
375
421
  // with the air pump's center, open to the room
376
422
  const release = io[sideIo("release_air", side)];
377
423
  const releaseX = a ? t2x + 172 - 57 : t2x + 57;
424
+ // The pipe ends in an arrow (9 px tall) whose tip is level with the air
425
+ // pump's center, where the released air's arcs grow from
426
+ const releaseTip = pumpY;
427
+ const releaseTop = releaseTip + 9;
378
428
  // The air pipe into T1 branches off above the add air valve, runs down
379
429
  // between T1 and T2, and enters T1's bottom from below, next to the waste
380
430
  // pipe. The waste pipe leaves T1's bottom on the outer side
@@ -429,6 +479,18 @@ export function FlowDiagram({ state, device, }) {
429
479
  const circulating = bubbling === true && exchangeFilled(exchangeYs[0]);
430
480
  // Otherwise, the upper pipe's way down holds water up to T2's surface, as
431
481
  // its lower end is always below it
482
+ /** The exchange pipe at `exchangeYs[i]`, from where it leaves to where it enters */
483
+ const exchangePoints = (i) => i === 0
484
+ ? [
485
+ [t1Edge, exchangeYs[0]],
486
+ [exchangeX, exchangeYs[0]],
487
+ [exchangeX, exchangeYs[1]],
488
+ [t2FarEdge, exchangeYs[1]],
489
+ ]
490
+ : [
491
+ [t2Edge, exchangeYs[1]],
492
+ [t1Edge, exchangeYs[1]],
493
+ ];
432
494
  const exchangeSurface = t2Fill === undefined
433
495
  ? undefined
434
496
  : Math.max(exchangeYs[0], 360 - 128 * t2Fill);
@@ -441,27 +503,28 @@ export function FlowDiagram({ state, device, }) {
441
503
  // inlet pipes (the label's cap height is 0.72 of its 15 px)
442
504
  y: abY - PIPE + 15 * 0.72, textAnchor: a ? "start" : "end", className: "hl-train-label", children: ["Train ", side] }), _jsx(Pipe, { d: a
443
505
  ? `M${abEnds.branches[0]} ${abY} H${t1c} V232`
444
- : `M${abEnds.branches[1]} ${abY} H${t1c} V232`, kind: "grey", active: receiving, open: selected === side, square: true }), _jsx(Pipe, { d: `M${t2c} ${teeY} H${bubblesX}`, kind: "air", active: air?.on }), _jsx(Pipe, { d: `M${bubblesX} ${teeY} H${gapX} V${airBelowY} H${airX} V${t1Bottom}`, kind: "air", active: bubbling, open: bubblesValve?.on, square: true }), _jsx(Valve, { x: bubblesX, y: teeY, kind: "air", io: bubblesValve, active: bubbling, name: sideIo("bubbles_block", side), label: "Bubbles block",
506
+ : `M${abEnds.branches[1]} ${abY} H${t1c} V232`, kind: "grey", active: receiving, open: selected === side, square: true, phase: trainInletPhase }), _jsx(Pipe, { d: `M${t2c} ${teeY} H${bubblesX}`, kind: "air", active: air?.on }), _jsx(Pipe, { d: `M${bubblesX} ${teeY} H${gapX} V${airBelowY} H${airX} V${t1Bottom}`, kind: "air", active: bubbling, open: air?.on && bubblesValve?.on, square: true }), _jsx(Valve, { x: bubblesX, y: teeY, kind: "air", io: bubblesValve, active: bubbling, name: sideIo("bubbles_block", side), label: "Bubbles block",
445
507
  // Above the pipe, ending short of the air pump
446
- labelAnchor: a ? "end" : "start", labelDx: t2c + (a ? -21 : 21) - bubblesX, labelDy: -14 }), _jsx(Pipe, { d: `M${t2c} ${airTop} V${addAirY}`, kind: "air", active: air?.on }), _jsx(Pipe, { d: `M${t2c} ${addAirY} V232`, kind: "air", active: addingAir || holdingAir, still: holdingAir, open: addAir?.on, square: true }), _jsx(Valve, { x: t2c, y: addAirY, vertical: true, kind: "air", io: addAir, active: addingAir, name: sideIo("add_air_valve", side), label: "Add air", labelAnchor: a ? "end" : "start", labelDx: a ? -16 : 16 }), _jsx(Pump, { x: t2c, y: pumpY, r: pumpR, kind: "air", io: air, name: sideIo("air_pump", side), label: "Air", labelAnchor: a ? "start" : "end", labelDx: 20 }), release?.on && (
447
- // The air leaves the pipe's open end as circles that fade out at
448
- // the size of the air pump. A circle starts where the pipe's dashes
449
- // leave off, 96 px up the pipe, see the rings in Tank
450
- _jsx("circle", { cx: releaseX, cy: 136, r: 14, className: "hl-vent-ring", style: {
451
- animationDelay: `${(-((14 - (96 % 14)) % 14) / 14) * 0.9}s`,
452
- }, "aria-hidden": true })), _jsx(Pipe, { d: `M${releaseX} 232 V136`, kind: "air", active: release?.on, open: release?.on, square: true }), _jsx(Valve, { x: releaseX,
453
- // Level with the top run of the air pipe into T1
454
- y: teeY, vertical: true, kind: "air", io: release, active: release?.on, name: sideIo("release_air", side), label: "Release air", labelAnchor: a ? "start" : "end", labelDx: a ? 16 : -16 }), exchangeYs.map((y, i) => {
508
+ labelAnchor: a ? "end" : "start", labelDx: t2c + (a ? -21 : 21) - bubblesX, labelDy: -14 }), _jsx(Pipe, { d: `M${t2c} ${airTop} V${addAirY}`, kind: "air", active: air?.on }), _jsx(Pipe, { d: `M${t2c} ${addAirY} V232`, kind: "air", active: addingAir || holdingAir, still: holdingAir, open: air?.on && addAir?.on, square: true }), _jsx(Valve, { x: t2c, y: addAirY, vertical: true, kind: "air", io: addAir, active: addingAir, name: sideIo("add_air_valve", side), label: "Add air", labelAnchor: a ? "end" : "start", labelDx: a ? -16 : 16 }), _jsx(Pump, { x: t2c, y: pumpY, r: pumpR, kind: "air", io: air, name: sideIo("air_pump", side), label: "Air", labelAnchor: a ? "start" : "end", labelDx: 20 }), release?.on && (
509
+ // The air leaves past the arrow's tip as arcs that fade out at the
510
+ // size of the air pump. Each arc spans 270°, open towards the
511
+ // arrow, so its ends run out from the tip at 45° on either side. An
512
+ // arc starts where the pipe's dashes would leave off, continued
513
+ // through the arrow, see the rings in Tank
514
+ _jsx("path", { d: `M${releaseX - 14 * Math.SQRT1_2} ${releaseTip + 14 * Math.SQRT1_2} A14 14 0 1 1 ${releaseX + 14 * Math.SQRT1_2} ${releaseTip + 14 * Math.SQRT1_2}`, className: "hl-vent-ring", style: {
515
+ transformOrigin: `${releaseX}px ${releaseTip}px`,
516
+ animationDelay: `${flowDelay(232 - releaseTip)}s`,
517
+ }, "aria-hidden": true })), _jsx(Pipe, { d: `M${releaseX} 232 V${releaseTop}`, kind: "air", active: release?.on, open: release?.on, square: true, arrow: { x: releaseX, y: releaseTop, dir: "up" } }), _jsx(Valve, { x: releaseX,
518
+ // Level with the add air valve
519
+ y: addAirY, vertical: true, kind: "air", io: release, active: release?.on, name: sideIo("release_air", side), label: "Release air", labelAnchor: a ? "start" : "end", labelDx: a ? 16 : -16 }), exchangeYs.map((y, i) => {
455
520
  const filled = exchangeFilled(y);
456
- return (_jsxs("g", { children: [_jsx("path", { d: `M${gapX - 4} ${y} H${gapX + 4}`, className: "hl-pipe-gap" }), _jsx(Pipe, { d: i === 0
457
- ? `M${t1Edge} ${y} H${exchangeX} V${exchangeYs[1]} H${t2FarEdge}`
458
- : `M${t2Edge} ${y} H${t1Edge}`, kind: "grey", active: filled && bubbling === true, filled: filled, square: true }), i === 0 &&
521
+ return (_jsxs("g", { children: [_jsx("path", { d: `M${gapX - 4} ${y} H${gapX + 4}`, className: "hl-pipe-gap" }), _jsx(Pipe, { d: `M${exchangePoints(i).join(" L")}`, kind: "grey", active: filled && bubbling === true, filled: filled, square: true }), i === 0 &&
459
522
  !filled &&
460
523
  exchangeSurface !== undefined &&
461
524
  exchangeSurface < exchangeYs[1] && (_jsx(Pipe, { d: `M${exchangeX} ${exchangeYs[1]} V${exchangeSurface}`, kind: "grey", active: false, filled: true, square: true })), i === 0 && (
462
525
  // Gaps where the upper pipe passes behind T2's walls
463
526
  _jsx("path", { d: `M${t2Edge + (a ? -3 : 3)} ${y} H${t2Edge} M${t2FarEdge} ${y} H${t2FarEdge + (a ? 3 : -3)}`, className: "hl-pipe-gap" }))] }, y));
464
- }), _jsx(Tank, { x: t1x, y: 232, w: 21, h: t1Bottom - 232, level: tanks[a ? "t1a" : "t1b"], kind: "grey", label: "T1", side: side, aeration: bubbling, small: a ? "start" : "end", square: true, base: t1Bottom - 360 }), _jsx(Drips, { x: t1c, y: 232, bottom: t1Surface, active: receiving }), _jsx(Tank, { x: t2x, y: 232, w: 172, h: 128, level: t2Level, kind: "grey", label: "T2", side: side, circulation: circulating
527
+ }), _jsx(Tank, { x: t1x, y: 232, w: 21, h: t1Bottom - 232, level: tanks[a ? "t1a" : "t1b"], kind: "grey", label: "T1", side: side, aeration: bubbling, small: true, square: true, base: t1Bottom - 360 }), _jsx(Drips, { x: t1c, y: 232, bottom: t1Surface, active: receiving }), _jsx(Tank, { x: t2x, y: 232, w: 172, h: 128, level: t2Level, kind: "grey", label: "T2", side: side, circulation: circulating
465
528
  ? {
466
529
  from: t2FarEdge,
467
530
  to: t2Edge,
@@ -471,12 +534,35 @@ export function FlowDiagram({ state, device, }) {
471
534
  exchangeYs[0] +
472
535
  Math.abs(exchangeX - t2FarEdge),
473
536
  }
474
- : undefined, pressurized: (addingAir || holdingAir) && 232 - addAirY, pressureHeld: holdingAir, airX: t2c, venting: release?.on ? releaseX : undefined, inlinePercent: true }), _jsx(Pipe, { d: a
537
+ : undefined, pressurized: (addingAir || holdingAir) && 232 - addAirY, pressureHeld: holdingAir, airX: t2c, venting: release?.on ? releaseX : undefined, inlinePercent: true }), exchangeYs.map((y, i) => {
538
+ const filled = exchangeFilled(y);
539
+ const points = exchangePoints(i);
540
+ const length = points
541
+ .slice(1)
542
+ .reduce((sum, [x2, y2], j) => sum + Math.hypot(x2 - points[j][0], y2 - points[j][1]), 0);
543
+ /**
544
+ * 1 px on either side of `at`, in the pipe's direction from one
545
+ * point to the next
546
+ */
547
+ const across = (at, [x1, y1], [x2, y2]) => {
548
+ const d = Math.hypot(x2 - x1, y2 - y1);
549
+ const [dx, dy] = [(x2 - x1) / d, (y2 - y1) / d];
550
+ return `M${at[0] - dx} ${at[1] - dy} L${at[0] + dx} ${at[1] + dy}`;
551
+ };
552
+ const n = points.length;
553
+ return [
554
+ { d: across(points[0], points[0], points[1]), phase: -1 },
555
+ {
556
+ d: across(points[n - 1], points[n - 2], points[n - 1]),
557
+ phase: length - 1,
558
+ },
559
+ ].map(({ d, phase }) => (_jsx(Pipe, { d: d, kind: "grey", active: filled && bubbling === true, filled: filled, square: true, phase: phase }, `${y}-${phase}`)));
560
+ }), _jsx(Pipe, { d: a
475
561
  ? `M${t1x} 237 H${drainX} V${wasteY}`
476
- : `M${t1x + 21} 237 H${drainX} V${wasteY}`, kind: "waste", active: skimming, title: `Skim overflow of T1 ${side}${skimming ? ": filth spilling over to the drain (inferred from the FILTH_REMOVAL routine)" : ""}`, square: true }), _jsx("text", { x: drainX + (a ? 27 : -27), y: 228, textAnchor: "middle", className: "hl-diagram-label", children: "Skim" }), _jsx(Pipe, { d: `M${wasteX} ${t1Bottom} V${wasteY} H${drainX}`, kind: "waste", active: waste?.on, open: waste?.on, square: true }), _jsx(Pipe, { d: `M${drainX} ${wasteY} H${drainEnd}`, kind: "waste", active: skimming || waste?.on, open: waste?.on, arrow: { x: drainEnd, y: wasteY, dir: a ? "left" : "right" } }), _jsx(Valve, { x: (wasteX + drainX) / 2, y: wasteY, kind: "waste", io: waste, active: waste?.on, name: sideIo("waste_clean_tank", side), label: "Waste", labelAnchor: "middle", labelDx: 0, labelDy: 24 }), _jsx("text", { x: a ? SEWER_LABEL_X.left : SEWER_LABEL_X.right, y: wasteY + 4, textAnchor: a ? "start" : "end", className: "hl-diagram-label", children: "Sewer" })] }, side));
562
+ : `M${t1x + 21} 237 H${drainX} V${wasteY}`, kind: "waste", active: skimming, title: `Skim overflow of T1 ${side}${skimming ? ": filth spilling over to the drain (inferred from the FILTH_REMOVAL routine)" : ""}`, square: true }), _jsx("text", { x: drainX + (a ? 27 : -27), y: 228, textAnchor: "middle", className: "hl-diagram-label", children: "Skim" }), _jsx(Pipe, { d: `M${wasteX} ${t1Bottom} V${wasteY} H${drainX}`, kind: "waste", active: waste?.on, open: waste?.on, square: true }), _jsx(Pipe, { d: `M${drainX} ${wasteY} H${drainEnd}`, kind: "waste", active: skimming || waste?.on, open: waste?.on, arrow: { x: drainEnd, y: wasteY, dir: a ? "left" : "right" } }), _jsx(Valve, { x: (wasteX + drainX) / 2, y: wasteY, kind: "waste", io: waste, active: waste?.on, name: sideIo("waste_clean_tank", side), label: "Waste", labelAnchor: "middle", labelDx: 0, labelDy: 24 }), _jsx("text", { x: a ? SEWER_LABEL_X.left : SEWER_LABEL_X.right, y: wasteY + 4, textAnchor: a ? "start" : "end", className: "hl-diagram-label", children: "Sewer" })] }, `body-${side}`));
477
563
  // Drawn after the circulation pipes, so the transfer pipe passes in
478
564
  // front of them
479
- const transferPipe = (_jsxs("g", { children: [_jsx("path", { d: `M${gapX - 4} ${transferY} H${gapX + 4}`, className: "hl-pipe-gap" }), _jsx(Pipe, { d: `M${t1Edge} ${transferY} H${transferX} V${UV_Y} H${a ? 460 : 540}`, kind: "clean", active: transferring, open: transferring, square: true }), _jsx(Valve, { x: T2_CENTER[side], y: UV_Y, kind: "clean", io: transfer, active: transferring, name: sideIo("transfer_path", side), label: "Transfer", labelAnchor: "middle", labelDx: 0, labelDy: 24 })] }, side));
565
+ const transferPipe = (_jsxs("g", { children: [_jsx("path", { d: `M${gapX - 4} ${transferY} H${gapX + 4}`, className: "hl-pipe-gap" }), _jsx(Pipe, { d: `M${t1Edge} ${transferY} H${transferX} V${UV_Y} H${a ? 460 : 540}`, kind: "grey", active: transferring, open: transferring, square: true }), _jsx(Valve, { x: T2_CENTER[side], y: UV_Y, kind: "grey", io: transfer, active: transferring, name: sideIo("transfer_path", side), label: "Transfer", labelAnchor: "middle", labelDx: 0, labelDy: 24 })] }, `transfer-${side}`));
480
566
  return { body, transferPipe };
481
567
  };
482
568
  const trains = { A: train("A"), B: train("B") };
@@ -505,17 +591,17 @@ export function FlowDiagram({ state, device, }) {
505
591
  ? outletKind
506
592
  : "clean";
507
593
  const off = (connected) => connected === false ? " is-disconnected" : "";
508
- return (_jsxs("svg", { viewBox: "0 -15 1000 840", className: "hl-flow-diagram", role: "group", "aria-label": "Water flow through the H600", children: [_jsx("defs", { children: _jsx("pattern", { id: "hl-hatch", width: "6", height: "6", patternUnits: "userSpaceOnUse", patternTransform: "rotate(45)", children: _jsx("line", { x1: "0", y1: "0", x2: "0", y2: "6", className: "hl-hatch-line" }) }) }), _jsx("text", { x: 60, y: inletY - 14, className: "hl-diagram-label is-strong", children: "Greywater from showers and baths" }), _jsx(Pipe, { d: `M60 ${inletY} H${bypassEnds.common}`, kind: "grey", active: receivingSides.length > 0
594
+ return (_jsxs("svg", { viewBox: `0 -15 1000 ${PUMP_Y + 100}`, className: "hl-flow-diagram", role: "group", "aria-label": "Water flow through the H600", children: [_jsx("defs", { children: _jsx("pattern", { id: "hl-hatch", width: "6", height: "6", patternUnits: "userSpaceOnUse", patternTransform: "rotate(45)", children: _jsx("line", { x1: "0", y1: "0", x2: "0", y2: "6", className: "hl-hatch-line" }) }) }), _jsx("text", { x: 60, y: inletY - 14, className: "hl-diagram-label is-strong", children: "Greywater from showers and baths" }), _jsx(Pipe, { d: `M60 ${inletY} H${bypassEnds.common}`, kind: "grey", active: receivingSides.length > 0
509
595
  ? true
510
596
  : inlet.bypass === undefined
511
597
  ? undefined
512
- : false, open: bypassOpen || (bypass?.on === false && selected !== undefined), square: true }), _jsx(Pipe, { d: `M500 ${bypassEnds.branches[0]} V${abEnds.common}`, kind: "grey", active: receivingSides.length > 0, open: bypass?.on === false && selected !== undefined, square: true }), _jsx(Pipe, { d: `M500 ${bypassEnds.branches[1]} V${sewerY} H${SEWER_END.right}`, kind: "grey", active: inlet.bypass === undefined ? undefined : false, open: bypassOpen, square: true, arrow: { x: SEWER_END.right, y: sewerY, dir: "right" } }), _jsx(Distributor, { x: 500, y: inletY, tip: "left", kind: "grey", io: bypass, name: IO.bypass, label: bypassOverride ? "Bypass (user override)" : "Bypass", strong: bypassOverride, words: ["to the sewer", "to the trains"], branches: [
598
+ : false, open: bypassOpen || (bypass?.on === false && selected !== undefined), square: true }), _jsx(Pipe, { d: `M500 ${bypassEnds.branches[0]} V${abEnds.common}`, kind: "grey", active: receivingSides.length > 0, open: bypass?.on === false && selected !== undefined, square: true, phase: toAbPhase }), _jsx(Pipe, { d: `M500 ${bypassEnds.branches[1]} V${sewerY} H${SEWER_END.right}`, kind: "grey", active: inlet.bypass === undefined ? undefined : false, open: bypassOpen, square: true, arrow: { x: SEWER_END.right, y: sewerY, dir: "right" }, phase: toAbPhase }), _jsx(Distributor, { x: 500, y: inletY, tip: "left", kind: "grey", io: bypass, name: IO.bypass, label: bypassOverride ? "Bypass (user override)" : "Bypass", strong: bypassOverride, words: ["to the sewer", "to the trains"], branches: [
513
599
  { open: bypass?.on, active: false },
514
600
  {
515
601
  open: bypass && !bypass.on,
516
602
  active: receivingSides.length > 0,
517
603
  },
518
- ], labelAnchor: "start", labelDx: 14 }), _jsx("text", { x: SEWER_LABEL_X.right, y: sewerY + 4, textAnchor: "end", className: "hl-diagram-label", children: "Sewer" }), trains.A.body, trains.B.body, _jsx(Distributor, { x: 500, y: abY, kind: "grey", io: ab, name: IO.abSelector, label: "A/B valve", idle: bypassOpen, words: ["to train B", "to train A"], branches: [
604
+ ], labelAnchor: "start", labelDx: 14, phase: bypassPhase }), _jsx("text", { x: SEWER_LABEL_X.right, y: sewerY + 4, textAnchor: "end", className: "hl-diagram-label", children: "Sewer" }), trains.A.body, trains.B.body, _jsx(Distributor, { x: 500, y: abY, kind: "grey", io: ab, name: IO.abSelector, label: "A/B valve", idle: bypassOpen, words: ["to train B", "to train A"], branches: [
519
605
  {
520
606
  open: abSide && abSide === "A",
521
607
  active: receivingSides.includes("A"),
@@ -524,15 +610,15 @@ export function FlowDiagram({ state, device, }) {
524
610
  open: abSide && abSide === "B",
525
611
  active: receivingSides.includes("B"),
526
612
  },
527
- ], labelDy: 24 }), _jsx(Pipe, { d: `M500 ${UV_Y + 17} V540`, kind: uvOutletKind, active: t3ReceivingFromUv, open: io[IO.uvValve]?.on, square: true }), _jsxs("g", { className: `hl-uv is-${t3.uv === undefined ? "unknown" : t3.uv ? "on" : "off"}`, tabIndex: 0, role: "img", "aria-label": ioTitle("UV-C", IO.uvPower, io[IO.uvPower], ["on", "off"]), children: [_jsx("title", { suppressHydrationWarning: true, children: ioTitle("UV-C", IO.uvPower, io[IO.uvPower], ["on", "off"]) }), _jsx("rect", { x: 460, y: UV_Y - 17, width: 80, height: 34, rx: 6 }), _jsx("text", { x: 500, y: UV_Y + 5, textAnchor: "middle", children: "UV-C" })] }), _jsx(Valve, { x: 500, y: (UV_Y + 17 + 540) / 2, vertical: true, kind: uvOutletKind, io: io[IO.uvValve], active: t3ReceivingFromUv, name: IO.uvValve, label: "UV valve" }), _jsx(Tank, { x: 346, y: 540, w: 309, h: 100, level: tanks.t3, kind: "clean", label: "T3", sub: "Recycled water", square: true }), _jsx(Drips, { x: 500, y: 540, bottom: t3Fill === undefined ? undefined : 640 - 100 * t3Fill, active: !!t3ReceivingFromUv, kind: uvOutletKind }), _jsx(Pipe, { d: `M655 ${backupY} H${SEWER_END.right}`, kind: "waste", active: t3.draining, open: io[IO.wasteStorageTank]?.on, square: true, arrow: { x: SEWER_END.right, y: backupY, dir: "right" } }), _jsx(Valve, { x: 790, y: backupY, kind: "waste", io: io[IO.wasteStorageTank], active: t3.draining, name: IO.wasteStorageTank, label: "T3 drain", labelAnchor: "middle", labelDx: 0, labelDy: -16 }), _jsx("text", { x: SEWER_LABEL_X.right, y: backupY + 4, textAnchor: "end", className: "hl-diagram-label", children: "Sewer" }), _jsx(Pipe, { d: `M${T4_X} ${MAINS_Y} H${T4_INLET_X} V540`, kind: "mains", active: preBackup?.on, open: preBackup?.on, square: true }), _jsx(Valve, { x: (T4_X + T4_INLET_X) / 2, y: MAINS_Y, kind: "mains", io: preBackup, active: preBackup?.on, name: IO.preBackupWater, label: "Mains", labelAnchor: "middle", labelDx: 0, labelDy: -16 }), _jsx(BackupTank, { x: T4_X, y: 540, w: 130, h: 100, state: state, inletX: T4_INLET_X, filling: preBackup?.on }), _jsx("path", { d: `M700 ${backupY - 4} V${backupY + 4}`, className: "hl-pipe-gap" }), _jsx(Pipe, { d: `M560 740 H700 V${RUN_Y} H${T2_CENTER.B}`, kind: outletKind, active: circulatingThroughUv || backwashing.A || backwashing.B, open: t3.circulating || backwash.A?.on || backwash.B?.on }), _jsx(Pipe, { d: `M${T2_CENTER.B} ${RUN_Y} H500`, kind: outletKind, active: circulatingThroughUv || backwashing.A, open: t3.circulating || backwash.A?.on }), _jsx(Pipe, { d: `M500 ${RUN_Y} V${UV_Y - 17}`, kind: outletKind, active: circulatingThroughUv, open: t3.circulating, square: true }), ["A", "B"].map((side) => {
613
+ ], labelDy: 24, phase: abPhase }), _jsx(Pipe, { d: `M500 ${UV_Y + UV_H} V${TANK_Y}`, kind: uvOutletKind, active: t3ReceivingFromUv, open: io[IO.uvValve]?.on, square: true }), _jsxs("g", { className: `hl-uv is-${t3.uv === undefined ? "unknown" : t3.uv ? "on" : "off"}`, tabIndex: 0, role: "img", "aria-label": ioTitle("UV-C", IO.uvPower, io[IO.uvPower], ["on", "off"]), children: [_jsx("title", { suppressHydrationWarning: true, children: ioTitle("UV-C", IO.uvPower, io[IO.uvPower], ["on", "off"]) }), _jsx("rect", { x: 460, y: UV_Y - UV_H, width: 80, height: 2 * UV_H, rx: 6 }), _jsx("text", { x: 500, y: UV_Y + 5, textAnchor: "middle", children: "UV-C" })] }), _jsx(Valve, { x: 500, y: (UV_Y + UV_H + TANK_Y) / 2, vertical: true, kind: uvOutletKind, io: io[IO.uvValve], active: t3ReceivingFromUv, name: IO.uvValve, label: "UV valve" }), _jsx(Tank, { x: 346, y: TANK_Y, w: 309, h: TANK_H, level: tanks.t3, kind: "clean", label: "T3", sub: "Recycled water", square: true }), _jsx(Drips, { x: 500, y: TANK_Y, bottom: t3Fill === undefined ? undefined : TANK_BOTTOM - TANK_H * t3Fill, active: !!t3ReceivingFromUv, kind: uvOutletKind }), _jsx(Pipe, { d: `M655 ${backupY} H${SEWER_END.right}`, kind: "waste", active: t3.draining, open: io[IO.wasteStorageTank]?.on, square: true, arrow: { x: SEWER_END.right, y: backupY, dir: "right" } }), _jsx(Valve, { x: 790, y: backupY, kind: "waste", io: io[IO.wasteStorageTank], active: t3.draining, name: IO.wasteStorageTank, label: "T3 drain", labelAnchor: "middle", labelDx: 0, labelDy: -16 }), _jsx("text", { x: SEWER_LABEL_X.right, y: backupY + 4, textAnchor: "end", className: "hl-diagram-label", children: "Sewer" }), _jsx(Pipe, { d: `M${T4_X} ${MAINS_Y} H${T4_INLET_X} V${TANK_Y - T4_AIR_GAP}`, kind: "mains", active: preBackup?.on, open: preBackup?.on, square: true }), _jsx(Valve, { x: (T4_X + T4_INLET_X) / 2, y: MAINS_Y, kind: "mains", io: preBackup, active: preBackup?.on, name: IO.preBackupWater, label: "Mains", labelAnchor: "middle", labelDx: 0, labelDy: -16 }), _jsx(BackupTank, { x: T4_X, y: TANK_Y, w: 130, h: TANK_H, state: state, inletX: T4_INLET_X, inletY: TANK_Y - T4_AIR_GAP, filling: preBackup?.on }), _jsx("path", { d: `M700 ${backupY - 4} V${backupY + 4}`, className: "hl-pipe-gap" }), _jsx(Pipe, { d: `M560 ${PUMP_Y} H700 V${RUN_Y} H${T2_CENTER.B}`, kind: outletKind, active: circulatingThroughUv || backwashing.A || backwashing.B, open: t3.circulating || backwash.A?.on || backwash.B?.on }), _jsx(Pipe, { d: `M${T2_CENTER.B} ${RUN_Y} H500`, kind: outletKind, active: circulatingThroughUv || backwashing.A, open: t3.circulating || backwash.A?.on }), _jsx(Pipe, { d: `M500 ${RUN_Y} V${UV_Y - UV_H}`, kind: outletKind, active: circulatingThroughUv, open: t3.circulating, square: true }), ["A", "B"].map((side) => {
528
614
  const a = side === "A";
529
615
  return (_jsxs("g", { children: [_jsx(Pipe, { d: a
530
616
  ? `M500 ${RUN_Y} H${T2_CENTER.A} V360`
531
617
  : `M${T2_CENTER.B} ${RUN_Y} V360`, kind: outletKind, active: backwashing[side], open: backwash[side]?.on, square: true }), _jsx(Valve, { x: T2_CENTER[side], y: (RUN_Y + 360) / 2, vertical: true, kind: outletKind, io: backwash[side], active: backwashing[side], name: sideIo("diffuser_backwash", side), label: "Backwash", labelAnchor: a ? "end" : "start", labelDx: a ? -16 : 16 })] }, side));
532
- }), _jsx(Valve, { x: 500, y: (RUN_Y + UV_Y - 17) / 2, vertical: true, kind: outletKind, io: io[IO.circulation], active: circulatingThroughUv, name: IO.circulation, label: "Circulation", labelAnchor: "end", labelDx: -14 }), _jsx("path", { d: `M696 ${UV_Y} H704`, className: "hl-pipe-gap" }), trains.A.transferPipe, trains.B.transferPipe, _jsx(Pipe, { d: `M190 ${backupY} H${backupEnds.branches[0]}`, kind: "mains", active: backupToPump, open: backup?.on, square: true }), _jsx(Pipe, { d: `M346 ${backupY} H${backupEnds.branches[1]}`, kind: "clean", active: recycledToPump, open: backup?.on === false, square: true }), _jsx(Pipe, { d: `M260 ${backupEnds.common} V724`, kind: outletKind, active: supply.pumping, open: backup !== undefined, square: true }), _jsx(Distributor, { x: 260, y: backupY, tip: "down", kind: outletKind, io: backup, name: IO.backupWater, label: "Backup valve", words: ["from T4", "from T3"], branches: [
618
+ }), _jsx(Valve, { x: 500, y: (RUN_Y + UV_Y - UV_H) / 2, vertical: true, kind: outletKind, io: io[IO.circulation], active: circulatingThroughUv, name: IO.circulation, label: "Circulation", labelAnchor: "end", labelDx: -14 }), _jsx("path", { d: `M696 ${UV_Y} H704`, className: "hl-pipe-gap" }), trains.A.transferPipe, trains.B.transferPipe, _jsx(Pipe, { d: `M190 ${backupY} H${backupEnds.branches[0]}`, kind: "mains", active: backupToPump, open: backup?.on, square: true }), _jsx(Pipe, { d: `M346 ${backupY} H${backupEnds.branches[1]}`, kind: "clean", active: recycledToPump, open: backup?.on === false, square: true }), _jsx(Pipe, { d: `M260 ${backupEnds.common} V${PUMP_Y - 16}`, kind: outletKind, active: supply.pumping, open: backup !== undefined, square: true, phase: (backup?.on ? fromT4Length : fromT3Length) + throughDistributor }), _jsx(Distributor, { x: 260, y: backupY, tip: "down", kind: outletKind, io: backup, name: IO.backupWater, label: "Backup valve", words: ["from T4", "from T3"], branches: [
533
619
  { open: backup?.on, active: backupToPump === true },
534
620
  { open: backup && !backup.on, active: recycledToPump === true },
535
- ], labelDy: -14 }), _jsx(Pump, { x: 260, y: 740, r: 16, kind: outletKind, io: io[IO.distributionPump], name: IO.distributionPump, label: "Distribution pump", labelAnchor: "end" }), _jsx(Pipe, { d: "M500 740 V640", kind: outletKind, active: backFlushing, open: io[IO.backFlush]?.on, square: true }), _jsx(Valve, { x: 500, y: 690, vertical: true, kind: outletKind, io: io[IO.backFlush], active: backFlushing, name: IO.backFlush, label: "Back flush" }), _jsx(Pipe, { d: "M276 740 H560", kind: outletKind, active: supply.toOutlets ?? false, open: true }), _jsxs("g", { className: `hl-outlet${off(device.outlets.toilet)}`, children: [_jsx(Pipe, { d: "M360 740 V790", kind: outletKind, active: supply.toilet ?? false, open: true, arrow: { x: 360, y: 790, dir: "down" } }), _jsx(Sensor, { x: 360, y: 765, kind: outletKind, io: io[IO.toilet], name: IO.toilet, label: "" }), _jsx("text", { x: 360, y: 815, textAnchor: "middle", className: "hl-diagram-label", children: "Toilets" })] }), _jsxs("g", { className: `hl-outlet${off(device.outlets.washingMachine)}`, children: [_jsx(Pipe, { d: "M460 740 V790", kind: outletKind, active: supply.wash ?? false, open: true, arrow: { x: 460, y: 790, dir: "down" } }), _jsx(Sensor, { x: 460, y: 765, kind: outletKind, io: io[IO.wash], name: IO.wash, label: "" }), _jsx("text", { x: 460, y: 815, textAnchor: "middle", className: "hl-diagram-label", children: "Washer" })] }), _jsxs("g", { className: `hl-outlet${off(device.outlets.auxiliary)}`, children: [_jsx(Pipe, { d: "M560 740 V790", kind: outletKind, active: supply.auxiliary, open: io[IO.auxiliary]?.on, arrow: { x: 560, y: 790, dir: "down" } }), _jsx(Valve, { x: 560, y: 765, vertical: true, kind: outletKind, io: io[IO.auxiliary], active: supply.auxiliary, name: IO.auxiliary, label: "" }), _jsx("text", { x: 560, y: 815, textAnchor: "middle", className: "hl-diagram-label", children: "Auxiliary" })] })] }));
621
+ ], labelDy: -14, phase: backup?.on ? fromT4Length : fromT3Length }), _jsx(Pump, { x: 260, y: PUMP_Y, r: 16, kind: outletKind, io: io[IO.distributionPump], name: IO.distributionPump, label: "Distribution pump", labelAnchor: "end" }), _jsx(Pipe, { d: `M500 ${PUMP_Y} V${TANK_BOTTOM}`, kind: outletKind, active: backFlushing, open: io[IO.backFlush]?.on, square: true }), _jsx(Valve, { x: 500, y: (PUMP_Y + TANK_BOTTOM) / 2, vertical: true, kind: outletKind, io: io[IO.backFlush], active: backFlushing, name: IO.backFlush, label: "Back flush" }), _jsx(Pipe, { d: `M276 ${PUMP_Y} H560`, kind: outletKind, active: supply.toOutlets ?? false, open: true }), _jsxs("g", { className: `hl-outlet${off(device.outlets.toilet)}`, children: [_jsx(Pipe, { d: `M360 ${PUMP_Y} V${PUMP_Y + 50}`, kind: outletKind, active: supply.toilet ?? false, open: true, arrow: { x: 360, y: PUMP_Y + 50, dir: "down" } }), _jsx(Sensor, { x: 360, y: PUMP_Y + 25, kind: outletKind, io: io[IO.toilet], name: IO.toilet, label: "" }), _jsx("text", { x: 360, y: PUMP_Y + 75, textAnchor: "middle", className: "hl-diagram-label", children: "Toilets" })] }), _jsxs("g", { className: `hl-outlet${off(device.outlets.washingMachine)}`, children: [_jsx(Pipe, { d: `M460 ${PUMP_Y} V${PUMP_Y + 50}`, kind: outletKind, active: supply.wash ?? false, open: true, arrow: { x: 460, y: PUMP_Y + 50, dir: "down" } }), _jsx(Sensor, { x: 460, y: PUMP_Y + 25, kind: outletKind, io: io[IO.wash], name: IO.wash, label: "" }), _jsx("text", { x: 460, y: PUMP_Y + 75, textAnchor: "middle", className: "hl-diagram-label", children: "Washer" })] }), _jsxs("g", { className: `hl-outlet${off(device.outlets.auxiliary)}`, children: [_jsx(Pipe, { d: `M560 ${PUMP_Y} V${PUMP_Y + 50}`, kind: outletKind, active: supply.auxiliary, open: io[IO.auxiliary]?.on, arrow: { x: 560, y: PUMP_Y + 50, dir: "down" } }), _jsx(Valve, { x: 560, y: PUMP_Y + 25, vertical: true, kind: outletKind, io: io[IO.auxiliary], active: supply.auxiliary, name: IO.auxiliary, label: "" }), _jsx("text", { x: 560, y: PUMP_Y + 75, textAnchor: "middle", className: "hl-diagram-label", children: "Auxiliary" })] })] }));
536
622
  }
537
623
  export function DiagramLegend() {
538
624
  const items = [
package/dist/model.js CHANGED
@@ -455,7 +455,9 @@ export function stateAt(ds, t) {
455
455
  // doesn't accept water for the ~4.5 h it lasts.
456
456
  // - The bypass opens when neither train can accept water. It is also tested
457
457
  // for about a minute every 12 hours, while the trains accept water.
458
- // So T2 is taken from its last venting, which happens about once an hour.
458
+ // So T2 is taken from its last venting. Besides each incoming water, T2 is
459
+ // vented for 30–80 s by the PRESSURE_RESET of STANDBY, about every 2 hours
460
+ // and right after each TRANSFER, which settles it just as well.
459
461
  // Greywater also fills T1, but T1 holds at most about 24 L.
460
462
  /** T2 at which a train is full and starts FILTH_REMOVAL */
461
463
  export const TRAIN_FULL_LITERS = 134;
@@ -518,8 +520,13 @@ function holdsPressure(ds, side, t) {
518
520
  const released = onIntervals(ds.io[sideIo("release_air", side)], -Infinity, t).at(-1)?.end;
519
521
  return added > (released ?? -Infinity);
520
522
  }
521
- /** Vent openings shorter than this don't settle the levels */
522
- const MIN_VENT = 60_000;
523
+ /**
524
+ * Vent openings shorter than this don't settle the levels. The vents of
525
+ * `STANDBY` · `PRESSURE_RESET` last 33–80 s and settle T2 within about
526
+ * 1–2 L of the long vents of `INCOMING_WATER`. Shorter openings, e.g. of
527
+ * 11 s during `FILTH_REMOVAL`, don't.
528
+ */
529
+ const MIN_VENT = 30_000;
523
530
  /** Openings of a release air valve that are long enough to settle T2 */
524
531
  export function ventings(points, until) {
525
532
  return onIntervals(points, -Infinity, until).filter((i) => i.end - i.start >= MIN_VENT);
package/dist/styles.css CHANGED
@@ -22,6 +22,7 @@
22
22
  --hl-subtle: #8f8f8f;
23
23
  --hl-border: #ebebeb;
24
24
  --hl-border-strong: #d4d4d4;
25
+ --hl-tank-border: #999999;
25
26
  --hl-focus: #0070f3;
26
27
 
27
28
  --hl-grey: #b26a00;
@@ -42,6 +43,7 @@
42
43
  --hl-subtle: #707070;
43
44
  --hl-border: #262626;
44
45
  --hl-border-strong: #3d3d3d;
46
+ --hl-tank-border: #6b6b6b;
45
47
  --hl-focus: #52a8ff;
46
48
 
47
49
  --hl-grey: #f0a43a;
@@ -62,6 +64,7 @@
62
64
  --hl-subtle: #707070;
63
65
  --hl-border: #262626;
64
66
  --hl-border-strong: #3d3d3d;
67
+ --hl-tank-border: #6b6b6b;
65
68
  --hl-focus: #52a8ff;
66
69
 
67
70
  --hl-grey: #f0a43a;
@@ -169,8 +172,9 @@
169
172
  .hl-pipe.is-open .hl-pipe-base {
170
173
  stroke: var(--hl-pipe-open);
171
174
  }
175
+ /* A pipe full of standing water, drawn like a tank, with its outline */
172
176
  .hl-pipe.is-filled .hl-pipe-base {
173
- stroke: var(--hl-border-strong);
177
+ stroke: var(--hl-tank-border);
174
178
  }
175
179
  /* The same color as .hl-tank-fill over the tank's background */
176
180
  .hl-pipe-water {
@@ -373,9 +377,14 @@
373
377
 
374
378
  .hl-tank-shell {
375
379
  fill: var(--hl-bg);
376
- stroke: var(--hl-border-strong);
380
+ stroke: var(--hl-tank-border);
377
381
  stroke-width: 1.5;
378
382
  }
383
+ /* An opening in a tank's wall, covering its outline */
384
+ .hl-tank-gap {
385
+ stroke: var(--hl-bg);
386
+ stroke-width: 3;
387
+ }
379
388
  .hl-tank-shell.is-unknown {
380
389
  fill: url(#hl-hatch);
381
390
  }
@@ -504,15 +513,15 @@
504
513
  transform: scale(1);
505
514
  }
506
515
  }
507
- /* Air leaving the release air pipe's open end, at the rings' pace. It fades
508
- out by the air pump's radius, 13 of the circle's 14 px */
516
+ /* Air leaving past the release air arrow's tip, at the rings' pace. It
517
+ fades out by the air pump's radius, 13 of the arc's 14 px. It grows from
518
+ the tip, set as its transform-origin inline */
509
519
  .hl-vent-ring {
510
520
  fill: none;
511
521
  stroke: var(--hl-air);
512
522
  stroke-width: 1.5;
513
523
  vector-effect: non-scaling-stroke;
514
- transform-box: fill-box;
515
- transform-origin: center;
524
+ transform-box: view-box;
516
525
  animation: hl-vent 0.9s linear infinite;
517
526
  }
518
527
  @keyframes hl-vent {
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "1.1.0";
1
+ export declare const VERSION = "1.2.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "1.1.0";
1
+ export const VERSION = "1.2.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hydraloop-diagram-react",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "React flow diagram of a Hydraloop H600, and the model that derives what the device is doing from its signals",
5
5
  "type": "module",
6
6
  "exports": {
package/readme.md CHANGED
@@ -108,7 +108,8 @@ The colors are custom properties on `:root` without specificity, so the page can
108
108
  | `--hl-bg` | Background of tanks, valves and pumps, and the gaps where pipes cross. Must match the page's background |
109
109
  | `--hl-fg`, `--hl-muted`, `--hl-subtle` | Text, outlines and unknown states |
110
110
  | `--hl-border` | Hatching of tanks without level data |
111
- | `--hl-border-strong` | Tank outlines, and pipes with unknown state |
111
+ | `--hl-border-strong` | UV-C's outline, and pipes with unknown state |
112
+ | `--hl-tank-border` | Outlines of tanks and of the pipes between T1 and T2 while they hold water |
112
113
  | `--hl-focus` | Focused valves, pumps and tanks |
113
114
  | `--hl-grey`, `--hl-clean`, `--hl-mains`, `--hl-waste`, `--hl-air`, `--hl-uv` | The kinds of water, air and UV-C |
114
115
  | `--hl-pipe-idle`, `--hl-pipe-open` | Pipes without water moving, closed and open |