Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | 366x 344x 146x 230x 44x 44x 44x 44x 36x 36x 36x 36x 144x 36x 10x 10x 36x 36x 144x 36x 26x 26x 26x 26x 26x 13x 13x 26x 36x | import { HenNodeRead } from "@/api/apiStore.gen";
import { HenNodeMarker } from "../henTypes";
/**
* Decide which side of the pinch to place a stream's unit-ops (markers).
* Uses the stream's target temp vs the pinch temp.
*/
export function getUnitopSide(
temp: number | undefined,
pinch: number | undefined
): "LEFT" | "MIDDLE" | "RIGHT" {
if (pinch == null || temp == null) return "MIDDLE";
if (temp > pinch) return "LEFT";
if (temp < pinch) return "RIGHT";
return "MIDDLE";
}
// is the node a HX?
export function isHeatExchanger(n: HenNodeRead) {
return n.hot_connection != null && n.cold_connection != null;
}
// make a key for HX nodes (undefined for non-HX)
export function makeHxKey(n: HenNodeRead) {
Iif (!isHeatExchanger(n)) return undefined;
const a = String(n.hot_connection);
const b = String(n.cold_connection);
return [a, b].sort().join("|");
}
// get all node markers for each stream, and set node marker properties
export function collectNodeMarkersForSid(
sid: string,
henNodes: HenNodeRead[] | undefined,
counters: { Heater: number; Cooler: number; HeatExchanger: number },
hxLabelByKey: Map<string, string>
): HenNodeMarker[] {
const id = +sid;
const out: HenNodeMarker[] = [];
Iif (!henNodes?.length) return out;
// HEATERS/COOLERS on this SDE
const nonHxNode = henNodes.filter(
(n) => n.stream_data_entry === id && !isHeatExchanger(n)
);
for (const node of nonHxNode) {
const isCooler = !node.cold_connection;
out.push({
sdeId: sid,
henNode: node,
label: isCooler ? `C${counters.Cooler++}` : `H${counters.Heater++}`,
colour: isCooler ? "#0ea5e9" : "#ef4444",
xPositions: [],
});
}
// EXCHANGERS connected to this SDE -> label by hxKey
const seenHxKeys = new Set<string>();
const localHX = henNodes.filter(
(n) =>
isHeatExchanger(n) &&
(n.hot_connection === id || n.cold_connection === id)
);
for (const node of localHX) {
const key = makeHxKey(node)!;
Iif (seenHxKeys.has(key)) continue;
seenHxKeys.add(key);
let label = hxLabelByKey.get(key);
if (!label) {
label = `E${counters.HeatExchanger++}`;
hxLabelByKey.set(key, label);
}
out.push({
sdeId: sid,
henNode: node,
label,
colour: "#a1a1aa",
xPositions: [],
hxKey: key,
});
}
return out;
} |