hydraloop-diagram-react 1.1.0 → 1.2.1
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.
- package/dist/flow-diagram.js +125 -39
- package/dist/model.d.ts +25 -1
- package/dist/model.js +136 -10
- package/dist/styles.css +15 -6
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/readme.md +3 -1
package/dist/flow-diagram.js
CHANGED
|
@@ -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"
|
|
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 === "
|
|
36
|
-
? `M${arrow.x} ${arrow.y
|
|
37
|
-
:
|
|
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
|
|
283
|
-
const anchor = small
|
|
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:
|
|
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 &&
|
|
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:
|
|
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 =
|
|
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
|
|
448
|
-
//
|
|
449
|
-
//
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
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:
|
|
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 }),
|
|
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: "
|
|
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:
|
|
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 +
|
|
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 -
|
|
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:
|
|
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.d.ts
CHANGED
|
@@ -254,10 +254,34 @@ export declare const SKIM_STATES: Set<string>;
|
|
|
254
254
|
export declare function routineAt(ds: Pick<Dataset, "routines">, side: RoutineSide, t: number): {
|
|
255
255
|
current: RoutineEvent | undefined;
|
|
256
256
|
start: number | undefined;
|
|
257
|
-
lastIncoming: number | undefined;
|
|
258
257
|
lastTransfer: number | undefined;
|
|
259
258
|
};
|
|
260
259
|
export declare function stateAt(ds: Dataset, t: number): DeviceState;
|
|
260
|
+
export type RoutineSegment = Interval & {
|
|
261
|
+
side: RoutineSide;
|
|
262
|
+
name: string;
|
|
263
|
+
phase: TrainPhase;
|
|
264
|
+
/** Sub-states in order, with their start time */
|
|
265
|
+
states: {
|
|
266
|
+
t: number;
|
|
267
|
+
state: string;
|
|
268
|
+
}[];
|
|
269
|
+
};
|
|
270
|
+
/** Routines as intervals per side. Consecutive sub-states are merged. */
|
|
271
|
+
export declare function routineSegments(ds: Dataset): RoutineSegment[];
|
|
272
|
+
export type ValveRoutineSegment = RoutineSegment & {
|
|
273
|
+
/** The train the A/B valve selects instead, so this train takes no water */
|
|
274
|
+
valve?: Side;
|
|
275
|
+
};
|
|
276
|
+
export declare function valveRoutineSegments(ds: Dataset): ValveRoutineSegment[];
|
|
277
|
+
/**
|
|
278
|
+
* When greywater last entered `side` before `t`: the start of the latest
|
|
279
|
+
* INCOMING_WATER the A/B valve sent to it. That is either the train's own
|
|
280
|
+
* INCOMING_WATER while the valve selects it, or the other train's while the
|
|
281
|
+
* valve selects this one, as HDM sometimes only reports it for the train the
|
|
282
|
+
* valve doesn't select.
|
|
283
|
+
*/
|
|
284
|
+
export declare function lastIncomingWater(segments: ValveRoutineSegment[], side: Side, t: number): number | undefined;
|
|
261
285
|
/** T2 at which a train is full and starts FILTH_REMOVAL */
|
|
262
286
|
export declare const TRAIN_FULL_LITERS = 134;
|
|
263
287
|
/** Routines in which a train accepts greywater */
|
package/dist/model.js
CHANGED
|
@@ -187,7 +187,6 @@ export const SKIM_STATES = new Set([
|
|
|
187
187
|
export function routineAt(ds, side, t) {
|
|
188
188
|
let current;
|
|
189
189
|
let start;
|
|
190
|
-
let lastIncoming;
|
|
191
190
|
let lastTransfer;
|
|
192
191
|
for (const r of ds.routines) {
|
|
193
192
|
if (r.t > t)
|
|
@@ -196,14 +195,12 @@ export function routineAt(ds, side, t) {
|
|
|
196
195
|
continue;
|
|
197
196
|
if (!current || current.name !== r.name) {
|
|
198
197
|
start = r.t;
|
|
199
|
-
if (r.name === "INCOMING_WATER")
|
|
200
|
-
lastIncoming = r.t;
|
|
201
198
|
if (r.name === "TRANSFER")
|
|
202
199
|
lastTransfer = r.t;
|
|
203
200
|
}
|
|
204
201
|
current = r;
|
|
205
202
|
}
|
|
206
|
-
return { current, start,
|
|
203
|
+
return { current, start, lastTransfer };
|
|
207
204
|
}
|
|
208
205
|
export function stateAt(ds, t) {
|
|
209
206
|
const tanks = {};
|
|
@@ -238,8 +235,11 @@ export function stateAt(ds, t) {
|
|
|
238
235
|
const active = (ds.behaviors ?? []).filter((b) => !OTHER_BEHAVIORS.has(b.name) &&
|
|
239
236
|
b.start <= t &&
|
|
240
237
|
(b.open ? t <= b.end : t < b.end));
|
|
238
|
+
const segments = valveRoutineSegments(ds);
|
|
239
|
+
/** Trains with reported incoming water while the A/B valve selects the other */
|
|
240
|
+
const incomingElsewhere = new Set();
|
|
241
241
|
const train = (side) => {
|
|
242
|
-
const { current, start,
|
|
242
|
+
const { current, start, lastTransfer } = routineAt(ds, side, t);
|
|
243
243
|
if (current)
|
|
244
244
|
routine[side] = current;
|
|
245
245
|
const waste = io[sideIo("waste_clean_tank", side)];
|
|
@@ -267,7 +267,7 @@ export function stateAt(ds, t) {
|
|
|
267
267
|
const behaviors = active.filter((b) => b.side === side);
|
|
268
268
|
const base = {
|
|
269
269
|
side,
|
|
270
|
-
lastIncoming,
|
|
270
|
+
lastIncoming: lastIncomingWater(segments, side, t),
|
|
271
271
|
lastTransfer,
|
|
272
272
|
evidence,
|
|
273
273
|
t2ToT1,
|
|
@@ -298,6 +298,25 @@ export function stateAt(ds, t) {
|
|
|
298
298
|
since: (draining ? waste : transfer)?.since,
|
|
299
299
|
};
|
|
300
300
|
}
|
|
301
|
+
// HDM runs INCOMING_WATER and the SKIM_LEVEL_DETERMINATION after it on
|
|
302
|
+
// both trains, but greywater only enters the train the A/B valve selects
|
|
303
|
+
const segment = segments.find((s) => s.side === side &&
|
|
304
|
+
s.start <= t &&
|
|
305
|
+
(t < s.end || (s.open && t === s.end)));
|
|
306
|
+
if (current && segment?.valve && routinePhase(current.name) !== "idle") {
|
|
307
|
+
if (routinePhase(current.name) === "receiving") {
|
|
308
|
+
incomingElsewhere.add(side);
|
|
309
|
+
}
|
|
310
|
+
return {
|
|
311
|
+
...base,
|
|
312
|
+
evidence: [...evidence, `A/B valve set to ${segment.valve}`],
|
|
313
|
+
phase: "idle",
|
|
314
|
+
label: PHASE_LABELS.idle,
|
|
315
|
+
detail: `HDM routine: ${routineText}`,
|
|
316
|
+
confidence: "valve",
|
|
317
|
+
since: segment.start,
|
|
318
|
+
};
|
|
319
|
+
}
|
|
301
320
|
if (current) {
|
|
302
321
|
return {
|
|
303
322
|
...base,
|
|
@@ -403,13 +422,14 @@ export function stateAt(ds, t) {
|
|
|
403
422
|
// the A/B valve doesn't select, while only the selected train's T2 rises.
|
|
404
423
|
// So incoming water on either side goes to the train of the A/B valve.
|
|
405
424
|
const filling = fillingTrain(ds, t);
|
|
406
|
-
const incoming = ["A", "B"].filter((s) => trains[s].phase === "receiving");
|
|
425
|
+
const incoming = ["A", "B"].filter((s) => trains[s].phase === "receiving" || incomingElsewhere.has(s));
|
|
407
426
|
if (filling && incoming.length > 0) {
|
|
408
427
|
const other = filling === "A" ? "B" : "A";
|
|
409
428
|
if (trains[other].phase === "receiving") {
|
|
410
429
|
trains[other] = {
|
|
411
430
|
...trains[other],
|
|
412
431
|
phase: "idle",
|
|
432
|
+
label: PHASE_LABELS.idle,
|
|
413
433
|
confidence: "valve",
|
|
414
434
|
evidence: [...trains[other].evidence, `A/B valve set to ${filling}`],
|
|
415
435
|
};
|
|
@@ -445,6 +465,105 @@ export function stateAt(ds, t) {
|
|
|
445
465
|
room: roomAt(ds, t),
|
|
446
466
|
};
|
|
447
467
|
}
|
|
468
|
+
/** Routines as intervals per side. Consecutive sub-states are merged. */
|
|
469
|
+
export function routineSegments(ds) {
|
|
470
|
+
const result = [];
|
|
471
|
+
const open = new Map();
|
|
472
|
+
for (const r of ds.routines) {
|
|
473
|
+
if (r.t > ds.until)
|
|
474
|
+
break;
|
|
475
|
+
const current = open.get(r.side);
|
|
476
|
+
if (current && current.name === r.name) {
|
|
477
|
+
current.states.push({ t: r.t, state: r.state });
|
|
478
|
+
continue;
|
|
479
|
+
}
|
|
480
|
+
if (current) {
|
|
481
|
+
current.end = r.t;
|
|
482
|
+
current.open = false;
|
|
483
|
+
result.push(current);
|
|
484
|
+
}
|
|
485
|
+
open.set(r.side, {
|
|
486
|
+
side: r.side,
|
|
487
|
+
name: r.name,
|
|
488
|
+
phase: routinePhase(r.name),
|
|
489
|
+
start: r.t,
|
|
490
|
+
end: ds.until,
|
|
491
|
+
open: true,
|
|
492
|
+
clipped: r.t < ds.from,
|
|
493
|
+
states: [{ t: r.t, state: r.state }],
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
result.push(...open.values());
|
|
497
|
+
return result
|
|
498
|
+
.filter((s) => s.end > ds.from)
|
|
499
|
+
.map((s) => ({ ...s, start: Math.max(s.start, ds.from) }))
|
|
500
|
+
.sort((a, b) => a.start - b.start);
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Routine segments where STANDBY, INCOMING_WATER and SKIM_LEVEL_DETERMINATION
|
|
504
|
+
* are split at A/B valve switches. The parts while the valve selects the other
|
|
505
|
+
* train get `valve` set to that train, as no greywater enters, and get the
|
|
506
|
+
* "idle" phase (see `stateAt`). The firmware runs INCOMING_WATER and the
|
|
507
|
+
* SKIM_LEVEL_DETERMINATION after it on both trains, but on the train that
|
|
508
|
+
* takes no water it only closes the release air valve again. Unless it checks
|
|
509
|
+
* the level of a full train (FIND_HIGHEST_WATER_POINT), which starts filth
|
|
510
|
+
* removal.
|
|
511
|
+
*/
|
|
512
|
+
const VALVE_ROUTINES = new Set([
|
|
513
|
+
"STANDBY",
|
|
514
|
+
"INCOMING_WATER",
|
|
515
|
+
"SKIM_LEVEL_DETERMINATION",
|
|
516
|
+
]);
|
|
517
|
+
export function valveRoutineSegments(ds) {
|
|
518
|
+
const switches = (ds.io[IO.abSelector] ?? []).map((p) => p.t);
|
|
519
|
+
return routineSegments(ds).flatMap((s) => {
|
|
520
|
+
if (!VALVE_ROUTINES.has(s.name) || s.side === "SYSTEM")
|
|
521
|
+
return [s];
|
|
522
|
+
if (s.states.some((x) => x.state === "FIND_HIGHEST_WATER_POINT")) {
|
|
523
|
+
return [s];
|
|
524
|
+
}
|
|
525
|
+
const cuts = [s.start, ...switches.filter((t) => t > s.start && t < s.end)];
|
|
526
|
+
const parts = [];
|
|
527
|
+
cuts.forEach((start, i) => {
|
|
528
|
+
const end = cuts[i + 1] ?? s.end;
|
|
529
|
+
const filling = fillingTrain(ds, start);
|
|
530
|
+
const valve = filling && filling !== s.side ? filling : undefined;
|
|
531
|
+
const last = parts[parts.length - 1];
|
|
532
|
+
if (last && last.valve === valve) {
|
|
533
|
+
last.end = end;
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
parts.push({
|
|
537
|
+
...s,
|
|
538
|
+
start,
|
|
539
|
+
end,
|
|
540
|
+
open: s.open && end === s.end,
|
|
541
|
+
phase: valve ? "idle" : s.phase,
|
|
542
|
+
valve,
|
|
543
|
+
});
|
|
544
|
+
});
|
|
545
|
+
return parts;
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* When greywater last entered `side` before `t`: the start of the latest
|
|
550
|
+
* INCOMING_WATER the A/B valve sent to it. That is either the train's own
|
|
551
|
+
* INCOMING_WATER while the valve selects it, or the other train's while the
|
|
552
|
+
* valve selects this one, as HDM sometimes only reports it for the train the
|
|
553
|
+
* valve doesn't select.
|
|
554
|
+
*/
|
|
555
|
+
export function lastIncomingWater(segments, side, t) {
|
|
556
|
+
let last;
|
|
557
|
+
for (const s of segments) {
|
|
558
|
+
if (s.start > t)
|
|
559
|
+
break;
|
|
560
|
+
if (s.name !== "INCOMING_WATER" || s.side === "SYSTEM")
|
|
561
|
+
continue;
|
|
562
|
+
if ((s.valve ?? s.side) === side)
|
|
563
|
+
last = s.start;
|
|
564
|
+
}
|
|
565
|
+
return last;
|
|
566
|
+
}
|
|
448
567
|
// ── Room for greywater ─────────────────────────────────────────────────────
|
|
449
568
|
// Derived from 30 days of an H600's data, not documented by Hydraloop:
|
|
450
569
|
// - Greywater only enters the train selected by the A/B valve, and only in
|
|
@@ -455,7 +574,9 @@ export function stateAt(ds, t) {
|
|
|
455
574
|
// doesn't accept water for the ~4.5 h it lasts.
|
|
456
575
|
// - The bypass opens when neither train can accept water. It is also tested
|
|
457
576
|
// for about a minute every 12 hours, while the trains accept water.
|
|
458
|
-
// So T2 is taken from its last venting
|
|
577
|
+
// So T2 is taken from its last venting. Besides each incoming water, T2 is
|
|
578
|
+
// vented for 30–80 s by the PRESSURE_RESET of STANDBY, about every 2 hours
|
|
579
|
+
// and right after each TRANSFER, which settles it just as well.
|
|
459
580
|
// Greywater also fills T1, but T1 holds at most about 24 L.
|
|
460
581
|
/** T2 at which a train is full and starts FILTH_REMOVAL */
|
|
461
582
|
export const TRAIN_FULL_LITERS = 134;
|
|
@@ -518,8 +639,13 @@ function holdsPressure(ds, side, t) {
|
|
|
518
639
|
const released = onIntervals(ds.io[sideIo("release_air", side)], -Infinity, t).at(-1)?.end;
|
|
519
640
|
return added > (released ?? -Infinity);
|
|
520
641
|
}
|
|
521
|
-
/**
|
|
522
|
-
|
|
642
|
+
/**
|
|
643
|
+
* Vent openings shorter than this don't settle the levels. The vents of
|
|
644
|
+
* `STANDBY` · `PRESSURE_RESET` last 33–80 s and settle T2 within about
|
|
645
|
+
* 1–2 L of the long vents of `INCOMING_WATER`. Shorter openings, e.g. of
|
|
646
|
+
* 11 s during `FILTH_REMOVAL`, don't.
|
|
647
|
+
*/
|
|
648
|
+
const MIN_VENT = 30_000;
|
|
523
649
|
/** Openings of a release air valve that are long enough to settle T2 */
|
|
524
650
|
export function ventings(points, until) {
|
|
525
651
|
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
|
|
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
|
|
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
|
|
508
|
-
out by the air pump's radius, 13 of the
|
|
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:
|
|
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
|
|
1
|
+
export declare const VERSION = "1.2.1";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "1.1
|
|
1
|
+
export const VERSION = "1.2.1";
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -62,6 +62,7 @@ Times in the tooltips use the runtime's locale and time zone. As they can differ
|
|
|
62
62
|
|
|
63
63
|
- `stateAt(dataset, t)`: the `DeviceState` at time `t` (milliseconds since epoch): tank levels and trends, IO values, the phase of each train and how it was determined, T3, T4, the supply of the outlets, and `room`.
|
|
64
64
|
- `roomAt(dataset, t)`: how many liters of greywater the H600 can take before they are bypassed to the sewer.
|
|
65
|
+
- `valveRoutineSegments(dataset)`: the routines of each side as intervals (`routineSegments(dataset)`), split where the A/B valve switches. HDM runs `INCOMING_WATER` and the `SKIM_LEVEL_DETERMINATION` after it on both trains, but greywater only enters the train the valve selects. The parts of the other train have `valve` set to the selected train. `lastIncomingWater(segments, side, t)` is when greywater last entered a train. `stateAt()` uses both.
|
|
65
66
|
- `routineAt(dataset, side, t)`, `fillingTrain(dataset, t)`, `isScheduledRestart(dataset, interval)`, `ventedLevels(dataset, side)`, `onIntervals(points, from, until)`, `stepAt(points, t)`, `valueAt(points, t)`
|
|
66
67
|
- `IO`: the names of the IO signals with known roles. `sideIo(name, side)` adds the `_b` suffix of train B.
|
|
67
68
|
- `caption(captions, name)`, `humanize(text)`, `capacityNote(level)`: labels
|
|
@@ -108,7 +109,8 @@ The colors are custom properties on `:root` without specificity, so the page can
|
|
|
108
109
|
| `--hl-bg` | Background of tanks, valves and pumps, and the gaps where pipes cross. Must match the page's background |
|
|
109
110
|
| `--hl-fg`, `--hl-muted`, `--hl-subtle` | Text, outlines and unknown states |
|
|
110
111
|
| `--hl-border` | Hatching of tanks without level data |
|
|
111
|
-
| `--hl-border-strong` |
|
|
112
|
+
| `--hl-border-strong` | UV-C's outline, and pipes with unknown state |
|
|
113
|
+
| `--hl-tank-border` | Outlines of tanks and of the pipes between T1 and T2 while they hold water |
|
|
112
114
|
| `--hl-focus` | Focused valves, pumps and tanks |
|
|
113
115
|
| `--hl-grey`, `--hl-clean`, `--hl-mains`, `--hl-waste`, `--hl-air`, `--hl-uv` | The kinds of water, air and UV-C |
|
|
114
116
|
| `--hl-pipe-idle`, `--hl-pipe-open` | Pipes without water moving, closed and open |
|