bimdown-cli 0.3.0 → 0.5.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/README.md +24 -3
- package/dist/chunk-4SKM4RHY.js +142 -0
- package/dist/chunk-4SKM4RHY.js.map +1 -0
- package/dist/chunk-4YHVOWS4.js +255 -0
- package/dist/chunk-4YHVOWS4.js.map +1 -0
- package/dist/chunk-AYAXRYGP.js +2129 -0
- package/dist/chunk-AYAXRYGP.js.map +1 -0
- package/dist/chunk-EC5MR5ZH.js +648 -0
- package/dist/chunk-EC5MR5ZH.js.map +1 -0
- package/dist/chunk-HS3PO2LB.js +487 -0
- package/dist/chunk-HS3PO2LB.js.map +1 -0
- package/dist/chunk-IQJA3EFO.js +179 -0
- package/dist/chunk-IQJA3EFO.js.map +1 -0
- package/dist/chunk-JY6KWRDB.js +80 -0
- package/dist/chunk-JY6KWRDB.js.map +1 -0
- package/dist/chunk-KWSGJUMZ.js +2501 -0
- package/dist/chunk-KWSGJUMZ.js.map +1 -0
- package/dist/chunk-LWYIPR64.js +35 -0
- package/dist/chunk-LWYIPR64.js.map +1 -0
- package/dist/chunk-OBY3UYCO.js +44 -0
- package/dist/chunk-OBY3UYCO.js.map +1 -0
- package/dist/chunk-XC6WHJRL.js +29 -0
- package/dist/chunk-XC6WHJRL.js.map +1 -0
- package/dist/chunk-XQU52JKB.js +187 -0
- package/dist/chunk-XQU52JKB.js.map +1 -0
- package/dist/clash-load-D3LNQR6G.js +941 -0
- package/dist/clash-load-D3LNQR6G.js.map +1 -0
- package/dist/cli.js +431 -0
- package/dist/cli.js.map +1 -0
- package/dist/dehydrate-ZHAGOI7Q.js +90 -0
- package/dist/dehydrate-ZHAGOI7Q.js.map +1 -0
- package/dist/diff-T2KOK2WR.js +89 -0
- package/dist/diff-T2KOK2WR.js.map +1 -0
- package/dist/engine-2TPWJVEQ.js +12 -0
- package/dist/engine-2TPWJVEQ.js.map +1 -0
- package/dist/hydrate-V24H7IF3.js +673 -0
- package/dist/hydrate-V24H7IF3.js.map +1 -0
- package/dist/import-ifc-RCZSXDA6.js +5324 -0
- package/dist/import-ifc-RCZSXDA6.js.map +1 -0
- package/dist/info-QC7YXWNX.js +92 -0
- package/dist/info-QC7YXWNX.js.map +1 -0
- package/dist/init-VWDML3UC.js +112 -0
- package/dist/init-VWDML3UC.js.map +1 -0
- package/dist/lib.d.ts +492 -0
- package/dist/lib.js +6528 -0
- package/dist/lib.js.map +1 -0
- package/dist/mep-W4HJI363.js +25 -0
- package/dist/mep-W4HJI363.js.map +1 -0
- package/dist/merge-ESOPDSA5.js +413 -0
- package/dist/merge-ESOPDSA5.js.map +1 -0
- package/dist/publish-3TAXQCUV.js +80 -0
- package/dist/publish-3TAXQCUV.js.map +1 -0
- package/dist/render-UEWYHPN6.js +1807 -0
- package/dist/render-UEWYHPN6.js.map +1 -0
- package/dist/resolve-topology-AQ2RO3W3.js +338 -0
- package/dist/resolve-topology-AQ2RO3W3.js.map +1 -0
- package/dist/spec/csv-schema/annotation/dimension.yaml +77 -0
- package/dist/spec/csv-schema/annotation/tag.yaml +44 -0
- package/dist/spec/csv-schema/annotation/text_note.yaml +52 -0
- package/dist/spec/csv-schema/architecture/ceiling.yaml +8 -1
- package/dist/spec/csv-schema/architecture/column.yaml +5 -1
- package/dist/spec/csv-schema/architecture/curtain_wall.yaml +45 -5
- package/dist/spec/csv-schema/architecture/door.yaml +5 -0
- package/dist/spec/csv-schema/architecture/furniture.yaml +28 -0
- package/dist/spec/csv-schema/architecture/opening.yaml +27 -6
- package/dist/spec/csv-schema/architecture/railing.yaml +35 -0
- package/dist/spec/csv-schema/architecture/roof.yaml +34 -1
- package/dist/spec/csv-schema/architecture/slab.yaml +19 -0
- package/dist/spec/csv-schema/architecture/space.yaml +11 -1
- package/dist/spec/csv-schema/architecture/stair.yaml +49 -0
- package/dist/spec/csv-schema/architecture/stair_landing.yaml +36 -0
- package/dist/spec/csv-schema/architecture/stair_run.yaml +31 -0
- package/dist/spec/csv-schema/architecture/wall.yaml +14 -1
- package/dist/spec/csv-schema/architecture/window.yaml +19 -0
- package/dist/spec/csv-schema/base/element.yaml +20 -11
- package/dist/spec/csv-schema/base/furniture_params.yaml +60 -0
- package/dist/spec/csv-schema/base/hosted_element.yaml +10 -2
- package/dist/spec/csv-schema/base/mep_connectable.yaml +23 -0
- package/dist/spec/csv-schema/base/mep_design.yaml +24 -0
- package/dist/spec/csv-schema/base/mep_insulated.yaml +9 -0
- package/dist/spec/csv-schema/base/mep_system_tag.yaml +12 -0
- package/dist/spec/csv-schema/base/point_element.yaml +1 -0
- package/dist/spec/csv-schema/base/section_profile.yaml +5 -0
- package/dist/spec/csv-schema/base/spatial_line_element.yaml +4 -2
- package/dist/spec/csv-schema/base/structural_section_profile.yaml +50 -0
- package/dist/spec/csv-schema/base/vertical_span.yaml +9 -3
- package/dist/spec/csv-schema/base/wall_bounded.yaml +21 -0
- package/dist/spec/csv-schema/grid.yaml +5 -0
- package/dist/spec/csv-schema/mep/cable_tray.yaml +10 -3
- package/dist/spec/csv-schema/mep/circuit.yaml +70 -0
- package/dist/spec/csv-schema/mep/conduit.yaml +2 -2
- package/dist/spec/csv-schema/mep/connector.yaml +112 -0
- package/dist/spec/csv-schema/mep/duct.yaml +10 -3
- package/dist/spec/csv-schema/mep/equipment.yaml +18 -1
- package/dist/spec/csv-schema/mep/mep_node.yaml +91 -2
- package/dist/spec/csv-schema/mep/mep_system.yaml +21 -0
- package/dist/spec/csv-schema/mep/pipe.yaml +27 -3
- package/dist/spec/csv-schema/mep/terminal.yaml +22 -1
- package/dist/spec/csv-schema/model_group.yaml +40 -0
- package/dist/spec/csv-schema/sheet/sheet.yaml +50 -0
- package/dist/spec/csv-schema/sheet/sheet_viewport.yaml +86 -0
- package/dist/spec/csv-schema/structure/beam.yaml +29 -1
- package/dist/spec/csv-schema/structure/beam_system.yaml +29 -0
- package/dist/spec/csv-schema/structure/brace.yaml +24 -1
- package/dist/spec/csv-schema/structure/foundation.yaml +40 -7
- package/dist/spec/csv-schema/structure/structure_column.yaml +19 -1
- package/dist/spec/csv-schema/structure/structure_slab.yaml +32 -0
- package/dist/spec/csv-schema/structure/structure_wall.yaml +22 -0
- package/dist/spec/csv-schema/types/beam_type.yaml +11 -0
- package/dist/spec/csv-schema/types/ceiling_type.yaml +6 -0
- package/dist/spec/csv-schema/types/column_type.yaml +12 -0
- package/dist/spec/csv-schema/types/curtain_wall_type.yaml +32 -0
- package/dist/spec/csv-schema/types/door_type.yaml +27 -0
- package/dist/spec/csv-schema/types/element_type.yaml +21 -0
- package/dist/spec/csv-schema/types/fenestration.yaml +16 -0
- package/dist/spec/csv-schema/types/foundation_type.yaml +36 -0
- package/dist/spec/csv-schema/types/furniture_type.yaml +11 -0
- package/dist/spec/csv-schema/types/layered_type.yaml +13 -0
- package/dist/spec/csv-schema/types/railing_type.yaml +40 -0
- package/dist/spec/csv-schema/types/roof_type.yaml +7 -0
- package/dist/spec/csv-schema/types/slab_type.yaml +9 -0
- package/dist/spec/csv-schema/types/type_layer.yaml +47 -0
- package/dist/spec/csv-schema/types/wall_type.yaml +6 -0
- package/dist/spec/csv-schema/types/window_type.yaml +31 -0
- package/dist/spec/csv-schema/underlay.yaml +73 -0
- package/dist/spec/csv-schema/view.yaml +36 -0
- package/dist/spec/duckdb-strategy.md +4 -3
- package/dist/spec/geojson-schema/readme.md +380 -0
- package/dist/spec/mep-port-conventions.md +190 -0
- package/dist/spec/migration-guide.md +1 -1
- package/dist/spec/project_metadata.schema.yaml +52 -4
- package/dist/spec/readme.md +356 -97
- package/dist/spec/starter-types/global/beam_type.csv +5 -0
- package/dist/spec/starter-types/global/ceiling_type.csv +3 -0
- package/dist/spec/starter-types/global/column_type.csv +5 -0
- package/dist/spec/starter-types/global/curtain_wall_type.csv +2 -0
- package/dist/spec/starter-types/global/door_type.csv +6 -0
- package/dist/spec/starter-types/global/foundation_type.csv +7 -0
- package/dist/spec/starter-types/global/furniture_type.csv +11 -0
- package/dist/spec/starter-types/global/railing_type.csv +5 -0
- package/dist/spec/starter-types/global/roof_type.csv +3 -0
- package/dist/spec/starter-types/global/slab_type.csv +4 -0
- package/dist/spec/starter-types/global/type_layer.csv +40 -0
- package/dist/spec/starter-types/global/wall_type.csv +8 -0
- package/dist/spec/starter-types/global/window_type.csv +6 -0
- package/dist/spec/svg-schema/readme.md +47 -1
- package/package.json +17 -5
- package/dist/index.js +0 -3366
- package/dist/index.js.map +0 -1
- package/dist/spec/csv-schema/base/mep_connected_segment.yaml +0 -17
- package/dist/spec/csv-schema/base/mep_system.yaml +0 -7
|
@@ -0,0 +1,648 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
loadMep,
|
|
4
|
+
summarizeSystems
|
|
5
|
+
} from "./chunk-IQJA3EFO.js";
|
|
6
|
+
|
|
7
|
+
// src/mep/check.ts
|
|
8
|
+
var PORT_TOLERANCE = 0.05;
|
|
9
|
+
var NODE_TOLERANCE = 2;
|
|
10
|
+
var PHASES = ["L1", "L2", "L3"];
|
|
11
|
+
var DEFAULT_POWER_FACTOR = 0.9;
|
|
12
|
+
var DEFAULT_TRAY_FILL = 40;
|
|
13
|
+
function circuitPhases(phase, poles) {
|
|
14
|
+
const p = (phase ?? "").trim().toUpperCase();
|
|
15
|
+
if (p) return PHASES.filter((x) => p.includes(x));
|
|
16
|
+
return poles === 3 ? [...PHASES] : [];
|
|
17
|
+
}
|
|
18
|
+
function circuitCurrent(loadW, voltage, phases, powerFactor) {
|
|
19
|
+
const pf = powerFactor > 0 && powerFactor <= 1 ? powerFactor : DEFAULT_POWER_FACTOR;
|
|
20
|
+
if (!(voltage > 0) || !(loadW > 0)) return 0;
|
|
21
|
+
return loadW / ((phases === 3 ? Math.sqrt(3) : 1) * voltage * pf);
|
|
22
|
+
}
|
|
23
|
+
function trayFills(model) {
|
|
24
|
+
const limit = model.trayFillLimit > 0 ? model.trayFillLimit : DEFAULT_TRAY_FILL;
|
|
25
|
+
const conduits = model.curves.filter((c) => c.table === "conduit" && c.w > 0);
|
|
26
|
+
const out = [];
|
|
27
|
+
for (const t of model.curves) {
|
|
28
|
+
if (t.table !== "cable_tray" || !(t.w > 0)) continue;
|
|
29
|
+
const w = t.w, h = t.h > 0 ? t.h : t.w;
|
|
30
|
+
let area = 0, cables = 0, inTray = 0;
|
|
31
|
+
for (const c of model.circuits ?? []) {
|
|
32
|
+
if (!(c.cableSize > 0) || !(c.trays ?? []).includes(t.id)) continue;
|
|
33
|
+
if (c.scope !== void 0 && t.scope !== void 0 && c.scope !== t.scope && c.scope !== "global" && t.scope !== "global") continue;
|
|
34
|
+
area += Math.PI * (c.cableSize / 2) ** 2;
|
|
35
|
+
cables++;
|
|
36
|
+
}
|
|
37
|
+
const L = dist(t.a, t.b);
|
|
38
|
+
if (L > 1e-9) {
|
|
39
|
+
const u = [(t.b[0] - t.a[0]) / L, (t.b[1] - t.a[1]) / L, (t.b[2] - t.a[2]) / L];
|
|
40
|
+
const hz = Math.hypot(u[0], u[1]);
|
|
41
|
+
const side = hz > 1e-6 ? [-u[1] / hz, u[0] / hz, 0] : [1, 0, 0];
|
|
42
|
+
const up = [u[1] * side[2] - u[2] * side[1], u[2] * side[0] - u[0] * side[2], u[0] * side[1] - u[1] * side[0]];
|
|
43
|
+
const local = (p) => {
|
|
44
|
+
const v = [p[0] - t.a[0], p[1] - t.a[1], p[2] - t.a[2]];
|
|
45
|
+
return [v[0] * u[0] + v[1] * u[1] + v[2] * u[2], v[0] * side[0] + v[1] * side[1] + v[2] * side[2], v[0] * up[0] + v[1] * up[1] + v[2] * up[2]];
|
|
46
|
+
};
|
|
47
|
+
for (const c of conduits) {
|
|
48
|
+
if ((c.scope ?? "") !== (t.scope ?? "")) continue;
|
|
49
|
+
const la = local(c.a), lb = local(c.b);
|
|
50
|
+
const cl = dist(c.a, c.b);
|
|
51
|
+
if (!(cl > 1e-9) || Math.abs(lb[0] - la[0]) < 0.9 * cl) continue;
|
|
52
|
+
const s0 = Math.max(0, Math.min(la[0], lb[0])), s1 = Math.min(L, Math.max(la[0], lb[0]));
|
|
53
|
+
if (s1 - s0 <= Math.min(0.1 * L, 0.5 * cl)) continue;
|
|
54
|
+
const r = c.w / 2;
|
|
55
|
+
const inside = (q) => Math.abs(q[1]) <= w / 2 - r + 1e-6 && Math.abs(q[2]) <= h / 2 + 1e-6;
|
|
56
|
+
if (!inside(la) || !inside(lb)) continue;
|
|
57
|
+
area += Math.PI * r * r;
|
|
58
|
+
inTray++;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const fill = 100 * area / (w * h);
|
|
62
|
+
const mid = [(t.a[0] + t.b[0]) / 2, (t.a[1] + t.b[1]) / 2, (t.a[2] + t.b[2]) / 2];
|
|
63
|
+
out.push({ id: t.id, scope: t.scope, fill, limit: t.maxFill > 0 ? t.maxFill : limit, cables, conduits: inTray, at: mid });
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
var DOMAIN_TABLES = {
|
|
68
|
+
hvac: ["duct"],
|
|
69
|
+
piping: ["pipe"],
|
|
70
|
+
electrical: ["conduit", "cable_tray"],
|
|
71
|
+
cable_tray_conduit: ["conduit", "cable_tray"]
|
|
72
|
+
};
|
|
73
|
+
var SINGLE_ENDED_FITTINGS = /* @__PURE__ */ new Set(["cap", "open"]);
|
|
74
|
+
function dist(a, b) {
|
|
75
|
+
return Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2]);
|
|
76
|
+
}
|
|
77
|
+
function splitRef(ref) {
|
|
78
|
+
const s = (ref ?? "").trim();
|
|
79
|
+
if (!s) return null;
|
|
80
|
+
const i = s.indexOf(":");
|
|
81
|
+
return i < 0 ? { hostId: s, port: null } : { hostId: s.slice(0, i), port: s.slice(i + 1) };
|
|
82
|
+
}
|
|
83
|
+
function fmtId(id) {
|
|
84
|
+
return id;
|
|
85
|
+
}
|
|
86
|
+
function checkMep(model) {
|
|
87
|
+
const complete = model.complete ?? true;
|
|
88
|
+
const extHosts = model.externalHosts ? new Set(model.externalHosts) : null;
|
|
89
|
+
const missingIsBroken = (hostId) => complete || extHosts !== null && !extHosts.has(hostId);
|
|
90
|
+
const out = [];
|
|
91
|
+
const key = (scope, id) => `${scope ?? ""}/${id}`;
|
|
92
|
+
const hostByKey = /* @__PURE__ */ new Map();
|
|
93
|
+
const hostById = /* @__PURE__ */ new Map();
|
|
94
|
+
for (const h of model.hosts) {
|
|
95
|
+
hostByKey.set(key(h.scope, h.id), h);
|
|
96
|
+
if (!hostById.has(h.id)) hostById.set(h.id, h);
|
|
97
|
+
}
|
|
98
|
+
const findHost = (scope, id) => hostByKey.get(key(scope, id)) ?? hostByKey.get(key("global", id)) ?? hostById.get(id);
|
|
99
|
+
const hkey = (h) => key(h.scope, h.id);
|
|
100
|
+
const portsByHost = /* @__PURE__ */ new Map();
|
|
101
|
+
for (const p of model.ports) {
|
|
102
|
+
const host = findHost(p.scope, p.hostId);
|
|
103
|
+
if (!host) continue;
|
|
104
|
+
const list = portsByHost.get(hkey(host)) ?? [];
|
|
105
|
+
list.push(p);
|
|
106
|
+
portsByHost.set(hkey(host), list);
|
|
107
|
+
}
|
|
108
|
+
const portsOf = (h) => portsByHost.get(hkey(h)) ?? [];
|
|
109
|
+
const usedPorts = /* @__PURE__ */ new Map();
|
|
110
|
+
const nodeCurves = /* @__PURE__ */ new Map();
|
|
111
|
+
const extUsed = /* @__PURE__ */ new Set();
|
|
112
|
+
for (const r of model.externalRefs ?? []) {
|
|
113
|
+
const p = splitRef(r);
|
|
114
|
+
if (!p) continue;
|
|
115
|
+
extUsed.add(p.hostId);
|
|
116
|
+
if (p.port) extUsed.add(`${p.hostId}:${p.port}`);
|
|
117
|
+
}
|
|
118
|
+
for (const c of model.curves) {
|
|
119
|
+
const refs = [{ side: "from", ref: c.from }, { side: "to", ref: c.to }];
|
|
120
|
+
const parsed = refs.map((r) => splitRef(r.ref));
|
|
121
|
+
let fromEnd = c.a, toEnd = c.b;
|
|
122
|
+
const anchorOf = (r) => {
|
|
123
|
+
if (!r) return null;
|
|
124
|
+
const host = findHost(c.scope, r.hostId);
|
|
125
|
+
if (!host) return null;
|
|
126
|
+
const port = r.port ? portsOf(host).find((p) => p.name === r.port) : void 0;
|
|
127
|
+
return port?.pos ?? host.pos;
|
|
128
|
+
};
|
|
129
|
+
const fromAnchor = anchorOf(parsed[0]);
|
|
130
|
+
const toAnchor = anchorOf(parsed[1]);
|
|
131
|
+
if (fromAnchor ? dist(fromAnchor, c.b) < dist(fromAnchor, c.a) : toAnchor && dist(toAnchor, c.a) < dist(toAnchor, c.b)) {
|
|
132
|
+
fromEnd = c.b;
|
|
133
|
+
toEnd = c.a;
|
|
134
|
+
}
|
|
135
|
+
if (parsed[0] && parsed[1] && parsed[0].hostId === parsed[1].hostId && parsed[0].port === parsed[1].port) {
|
|
136
|
+
out.push({
|
|
137
|
+
severity: "warning",
|
|
138
|
+
code: "self_loop",
|
|
139
|
+
id: c.id,
|
|
140
|
+
scope: c.scope,
|
|
141
|
+
table: c.table,
|
|
142
|
+
system: c.system,
|
|
143
|
+
message: `${c.table} ${fmtId(c.id)} starts and ends on the same ${parsed[0].port ? "port" : "fitting"} (${c.from})`,
|
|
144
|
+
at: c.a,
|
|
145
|
+
key: "self_loop",
|
|
146
|
+
vars: { table: c.table, id: c.id, ref: c.from }
|
|
147
|
+
});
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
for (let i = 0; i < 2; i++) {
|
|
151
|
+
const side = refs[i].side;
|
|
152
|
+
const end = i === 0 ? fromEnd : toEnd;
|
|
153
|
+
const r = parsed[i];
|
|
154
|
+
if (!r) {
|
|
155
|
+
const other = i === 0 ? toEnd : fromEnd;
|
|
156
|
+
if (VENT.test((c.system ?? "").split(",")[0].trim()) && end[2] - other[2] > 2 * Math.hypot(end[0] - other[0], end[1] - other[1])) continue;
|
|
157
|
+
out.push({
|
|
158
|
+
severity: "warning",
|
|
159
|
+
code: "open_end",
|
|
160
|
+
id: c.id,
|
|
161
|
+
scope: c.scope,
|
|
162
|
+
table: c.table,
|
|
163
|
+
system: c.system,
|
|
164
|
+
message: `${c.table} ${fmtId(c.id)} has an open end (${side} is empty)`,
|
|
165
|
+
at: end,
|
|
166
|
+
key: "open_end",
|
|
167
|
+
vars: { table: c.table, id: c.id, side }
|
|
168
|
+
});
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
const host = findHost(c.scope, r.hostId);
|
|
172
|
+
if (!host) {
|
|
173
|
+
const broken = missingIsBroken(r.hostId);
|
|
174
|
+
out.push({
|
|
175
|
+
severity: broken ? "warning" : "info",
|
|
176
|
+
code: broken ? "dangling_ref" : "external_ref",
|
|
177
|
+
id: c.id,
|
|
178
|
+
scope: c.scope,
|
|
179
|
+
table: c.table,
|
|
180
|
+
system: c.system,
|
|
181
|
+
message: broken ? `${c.table} ${fmtId(c.id)}.${side} = "${refs[i].ref}" references a missing element` : `${c.table} ${fmtId(c.id)} connects to ${refs[i].ref} on another level`,
|
|
182
|
+
at: end,
|
|
183
|
+
key: broken ? "dangling_ref" : "external_ref",
|
|
184
|
+
vars: { table: c.table, id: c.id, side, ref: refs[i].ref }
|
|
185
|
+
});
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
const used = usedPorts.get(hkey(host)) ?? /* @__PURE__ */ new Set();
|
|
189
|
+
used.add(r.port ?? "");
|
|
190
|
+
usedPorts.set(hkey(host), used);
|
|
191
|
+
if (!r.port) {
|
|
192
|
+
if (host.table === "mep_node" && !host.kind) {
|
|
193
|
+
const list = nodeCurves.get(hkey(host)) ?? [];
|
|
194
|
+
list.push(c);
|
|
195
|
+
nodeCurves.set(hkey(host), list);
|
|
196
|
+
}
|
|
197
|
+
if (dist(end, host.pos) > NODE_TOLERANCE) {
|
|
198
|
+
out.push({
|
|
199
|
+
severity: "warning",
|
|
200
|
+
code: "node_far",
|
|
201
|
+
id: c.id,
|
|
202
|
+
scope: c.scope,
|
|
203
|
+
table: c.table,
|
|
204
|
+
system: c.system,
|
|
205
|
+
message: `${c.table} ${fmtId(c.id)}.${side} references ${host.id} but ends ${dist(end, host.pos).toFixed(2)} away from it`,
|
|
206
|
+
at: end,
|
|
207
|
+
key: "node_far",
|
|
208
|
+
vars: { table: c.table, id: c.id, side, host: host.id, d: dist(end, host.pos).toFixed(2) }
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
const port = portsOf(host).find((p) => p.name === r.port);
|
|
214
|
+
if (!port) {
|
|
215
|
+
out.push({
|
|
216
|
+
severity: "warning",
|
|
217
|
+
code: "dangling_ref",
|
|
218
|
+
id: c.id,
|
|
219
|
+
scope: c.scope,
|
|
220
|
+
table: c.table,
|
|
221
|
+
system: c.system,
|
|
222
|
+
message: `${c.table} ${fmtId(c.id)}.${side} = "${refs[i].ref}": ${host.id} has no port "${r.port}"`,
|
|
223
|
+
at: end,
|
|
224
|
+
key: "dangling_port",
|
|
225
|
+
vars: { table: c.table, id: c.id, side, ref: refs[i].ref, host: host.id, port: r.port }
|
|
226
|
+
});
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
const d = Math.min(dist(c.a, port.pos), dist(c.b, port.pos));
|
|
230
|
+
if (d > PORT_TOLERANCE) {
|
|
231
|
+
out.push({
|
|
232
|
+
severity: "warning",
|
|
233
|
+
code: "port_far",
|
|
234
|
+
id: c.id,
|
|
235
|
+
scope: c.scope,
|
|
236
|
+
table: c.table,
|
|
237
|
+
system: c.system,
|
|
238
|
+
message: `${c.table} ${fmtId(c.id)}.${side} references ${refs[i].ref} but its nearest end is ${d.toFixed(3)} from the port \u2014 move the end onto the port`,
|
|
239
|
+
at: port.pos,
|
|
240
|
+
key: "port_far",
|
|
241
|
+
vars: { table: c.table, id: c.id, side, ref: refs[i].ref, d: d.toFixed(3) }
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
const allowed = DOMAIN_TABLES[port.domain];
|
|
245
|
+
if (allowed && !allowed.includes(c.table)) {
|
|
246
|
+
out.push({
|
|
247
|
+
severity: "warning",
|
|
248
|
+
code: "domain_mismatch",
|
|
249
|
+
id: c.id,
|
|
250
|
+
scope: c.scope,
|
|
251
|
+
table: c.table,
|
|
252
|
+
system: c.system,
|
|
253
|
+
message: `${c.table} ${fmtId(c.id)} connects to ${port.domain} port ${refs[i].ref}`,
|
|
254
|
+
at: port.pos,
|
|
255
|
+
key: "domain_port",
|
|
256
|
+
vars: { table: c.table, id: c.id, domain: port.domain, ref: refs[i].ref }
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
if (port.system && c.system && port.system !== c.system) {
|
|
260
|
+
out.push({
|
|
261
|
+
severity: "warning",
|
|
262
|
+
code: "system_mismatch",
|
|
263
|
+
id: c.id,
|
|
264
|
+
scope: c.scope,
|
|
265
|
+
table: c.table,
|
|
266
|
+
system: c.system,
|
|
267
|
+
message: `${c.table} ${fmtId(c.id)} is ${c.system} but port ${refs[i].ref} is ${port.system}`,
|
|
268
|
+
at: port.pos,
|
|
269
|
+
key: "system_port",
|
|
270
|
+
vars: { table: c.table, id: c.id, system: c.system, ref: refs[i].ref, portSystem: port.system }
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
if (port.domain !== "electrical" && !sameSection(c, port)) {
|
|
274
|
+
out.push({
|
|
275
|
+
severity: host.table === "terminal" ? "info" : "warning",
|
|
276
|
+
code: "size_mismatch",
|
|
277
|
+
id: c.id,
|
|
278
|
+
scope: c.scope,
|
|
279
|
+
table: c.table,
|
|
280
|
+
system: c.system,
|
|
281
|
+
message: `${c.table} ${fmtId(c.id)} is ${sizeText(c)} but port ${refs[i].ref} is ${sizeText(port)} (add a transition)`,
|
|
282
|
+
at: port.pos,
|
|
283
|
+
key: "size_mismatch",
|
|
284
|
+
vars: { table: c.table, id: c.id, size: sizeText(c), ref: refs[i].ref, portSize: sizeText(port) }
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
for (const h of model.hosts) {
|
|
290
|
+
if (h.table !== "mep_node") continue;
|
|
291
|
+
if (h.kind) {
|
|
292
|
+
const used = usedPorts.get(hkey(h)) ?? /* @__PURE__ */ new Set();
|
|
293
|
+
for (const p of portsOf(h)) {
|
|
294
|
+
if (!used.has(p.name) && !extUsed.has(`${h.id}:${p.name}`)) {
|
|
295
|
+
out.push({
|
|
296
|
+
severity: "warning",
|
|
297
|
+
code: "unconnected_port",
|
|
298
|
+
id: h.id,
|
|
299
|
+
scope: h.scope,
|
|
300
|
+
table: h.table,
|
|
301
|
+
system: h.system || p.system,
|
|
302
|
+
message: `${h.kind} ${h.id}: port "${p.name}" is not connected`,
|
|
303
|
+
at: p.pos,
|
|
304
|
+
key: "unconnected_port",
|
|
305
|
+
vars: { kind: h.kind, id: h.id, port: p.name }
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
const curves = nodeCurves.get(hkey(h)) ?? [];
|
|
312
|
+
if (extUsed.has(h.id)) continue;
|
|
313
|
+
if (curves.length === 0) {
|
|
314
|
+
out.push({
|
|
315
|
+
severity: "warning",
|
|
316
|
+
code: "orphan_fitting",
|
|
317
|
+
id: h.id,
|
|
318
|
+
scope: h.scope,
|
|
319
|
+
table: h.table,
|
|
320
|
+
system: h.system,
|
|
321
|
+
message: `fitting ${h.id} has no connected curves`,
|
|
322
|
+
at: h.pos,
|
|
323
|
+
key: "orphan_fitting",
|
|
324
|
+
vars: { id: h.id }
|
|
325
|
+
});
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
if (curves.length === 1 && !SINGLE_ENDED_FITTINGS.has(h.fitting)) {
|
|
329
|
+
out.push({
|
|
330
|
+
severity: "warning",
|
|
331
|
+
code: "open_end",
|
|
332
|
+
id: curves[0].id,
|
|
333
|
+
scope: curves[0].scope,
|
|
334
|
+
table: curves[0].table,
|
|
335
|
+
system: curves[0].system,
|
|
336
|
+
message: `${curves[0].table} ${curves[0].id} ends at ${h.id} with nothing else connected (cap it or connect it)`,
|
|
337
|
+
at: h.pos,
|
|
338
|
+
key: "open_end_node",
|
|
339
|
+
vars: { table: curves[0].table, id: curves[0].id, node: h.id }
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
const systems = new Set(curves.map((c) => c.system).filter(Boolean));
|
|
343
|
+
if (systems.size > 1 && !ventOnStack(systems)) {
|
|
344
|
+
out.push({
|
|
345
|
+
severity: "warning",
|
|
346
|
+
code: "system_mismatch",
|
|
347
|
+
id: h.id,
|
|
348
|
+
scope: h.scope,
|
|
349
|
+
table: h.table,
|
|
350
|
+
system: [...systems].join(","),
|
|
351
|
+
message: `fitting ${h.id} joins different systems: ${[...systems].join(", ")}`,
|
|
352
|
+
at: h.pos,
|
|
353
|
+
key: "system_node",
|
|
354
|
+
vars: { id: h.id, systems: [...systems].join(", ") }
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
const tables = new Set(curves.map((c) => c.table));
|
|
358
|
+
if (tables.size > 1) {
|
|
359
|
+
out.push({
|
|
360
|
+
severity: "warning",
|
|
361
|
+
code: "domain_mismatch",
|
|
362
|
+
id: h.id,
|
|
363
|
+
scope: h.scope,
|
|
364
|
+
table: h.table,
|
|
365
|
+
system: h.system,
|
|
366
|
+
message: `fitting ${h.id} joins ${[...tables].join(" and ")}`,
|
|
367
|
+
at: h.pos,
|
|
368
|
+
key: "domain_node",
|
|
369
|
+
vars: { id: h.id, tables: [...tables].join(" / ") }
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
const circuitIds = new Set((model.circuits ?? []).map((c) => c.id));
|
|
374
|
+
for (const h of model.hosts) {
|
|
375
|
+
if (h.table === "mep_node") continue;
|
|
376
|
+
const ports = portsOf(h);
|
|
377
|
+
const used = new Set(usedPorts.get(hkey(h)) ?? []);
|
|
378
|
+
for (const p of ports) if (extUsed.has(`${h.id}:${p.name}`)) used.add(p.name);
|
|
379
|
+
if (extUsed.has(h.id)) used.add("");
|
|
380
|
+
const isElectric = (p) => p.domain === "electrical" && !used.has(p.name);
|
|
381
|
+
const fluid = ports.filter((p) => !isElectric(p));
|
|
382
|
+
const electric = ports.filter(isElectric);
|
|
383
|
+
if (electric.length > 0 && !h.circuitId && fluid.length === 0 && (model.circuits?.length ?? 0) > 0) {
|
|
384
|
+
out.push({
|
|
385
|
+
severity: "info",
|
|
386
|
+
code: "no_circuit",
|
|
387
|
+
id: h.id,
|
|
388
|
+
scope: h.scope,
|
|
389
|
+
table: h.table,
|
|
390
|
+
system: h.system,
|
|
391
|
+
message: `${h.table} ${h.id} is not on a circuit`,
|
|
392
|
+
at: h.pos,
|
|
393
|
+
key: "no_circuit",
|
|
394
|
+
vars: { table: h.table, id: h.id }
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
if (h.circuitId && complete && !circuitIds.has(h.circuitId)) {
|
|
398
|
+
out.push({
|
|
399
|
+
severity: "warning",
|
|
400
|
+
code: "dangling_ref",
|
|
401
|
+
id: h.id,
|
|
402
|
+
scope: h.scope,
|
|
403
|
+
table: h.table,
|
|
404
|
+
system: h.system,
|
|
405
|
+
message: `${h.table} ${h.id}.circuit_id = "${h.circuitId}" references a missing circuit`,
|
|
406
|
+
at: h.pos,
|
|
407
|
+
key: "dangling_circuit",
|
|
408
|
+
vars: { table: h.table, id: h.id, ref: h.circuitId }
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
if (fluid.length === 0) continue;
|
|
412
|
+
const connected = fluid.filter((p) => used.has(p.name));
|
|
413
|
+
if (connected.length === 0 && !used.has("")) {
|
|
414
|
+
out.push({
|
|
415
|
+
severity: "warning",
|
|
416
|
+
code: "disconnected_device",
|
|
417
|
+
id: h.id,
|
|
418
|
+
scope: h.scope,
|
|
419
|
+
table: h.table,
|
|
420
|
+
system: h.system,
|
|
421
|
+
message: `${h.table} ${h.id} has ${fluid.length} port(s) and none is connected`,
|
|
422
|
+
at: h.pos,
|
|
423
|
+
key: "disconnected_device",
|
|
424
|
+
vars: { table: h.table, id: h.id, n: fluid.length }
|
|
425
|
+
});
|
|
426
|
+
} else {
|
|
427
|
+
for (const p of fluid) {
|
|
428
|
+
if (used.has(p.name)) continue;
|
|
429
|
+
out.push({
|
|
430
|
+
severity: "info",
|
|
431
|
+
code: "unused_port",
|
|
432
|
+
id: h.id,
|
|
433
|
+
scope: h.scope,
|
|
434
|
+
table: h.table,
|
|
435
|
+
system: p.system,
|
|
436
|
+
message: `${h.table} ${h.id}: port "${p.name}" (${p.system || p.domain}) is not connected`,
|
|
437
|
+
at: p.pos,
|
|
438
|
+
key: "unused_port",
|
|
439
|
+
vars: { table: h.table, id: h.id, port: p.name, system: p.system || p.domain }
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
for (const c of model.circuits ?? []) {
|
|
445
|
+
if (!findHost(c.scope, c.hostId)) {
|
|
446
|
+
const broken = missingIsBroken(c.hostId);
|
|
447
|
+
out.push({
|
|
448
|
+
severity: broken ? "warning" : "info",
|
|
449
|
+
code: broken ? "dangling_ref" : "external_ref",
|
|
450
|
+
id: c.id,
|
|
451
|
+
scope: c.scope,
|
|
452
|
+
table: "circuit",
|
|
453
|
+
message: `circuit ${c.id} panel "${c.hostId}" is missing`,
|
|
454
|
+
key: "dangling_panel",
|
|
455
|
+
vars: { id: c.id, ref: c.hostId }
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
if (c.voltage > 0 && c.rating > 0) {
|
|
459
|
+
const load = model.hosts.filter((h) => h.circuitId === c.id).reduce((s, h) => s + (h.load || 0), 0);
|
|
460
|
+
const current = circuitCurrent(load, c.voltage, circuitPhases(c.phase, c.poles).length, c.powerFactor);
|
|
461
|
+
if (current > c.rating * 0.8) {
|
|
462
|
+
const amps = Math.round(current * 10) / 10;
|
|
463
|
+
out.push({
|
|
464
|
+
severity: "warning",
|
|
465
|
+
code: "circuit_overload",
|
|
466
|
+
id: c.id,
|
|
467
|
+
scope: c.scope,
|
|
468
|
+
table: "circuit",
|
|
469
|
+
message: `circuit ${c.number || c.id}: ${Math.round(load)} W draws ${amps} A, over 80 % of its ${c.rating} A breaker (${c.voltage} V)`,
|
|
470
|
+
key: "circuit_overload",
|
|
471
|
+
vars: { id: c.number || c.id, load: Math.round(load), current: amps, rating: c.rating, voltage: c.voltage }
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
for (const f of trayFills(model)) {
|
|
477
|
+
if (f.fill <= f.limit + 1e-9) continue;
|
|
478
|
+
const pct = Math.round(f.fill * 10) / 10;
|
|
479
|
+
out.push({
|
|
480
|
+
severity: "warning",
|
|
481
|
+
code: "tray_fill",
|
|
482
|
+
id: f.id,
|
|
483
|
+
scope: f.scope,
|
|
484
|
+
table: "cable_tray",
|
|
485
|
+
at: f.at,
|
|
486
|
+
message: `cable_tray ${f.id} is ${pct} % full (${f.cables} cable(s), ${f.conduits} conduit(s)), over its ${f.limit} % limit`,
|
|
487
|
+
key: "tray_fill",
|
|
488
|
+
vars: { id: f.id, fill: pct, limit: f.limit, cables: f.cables, conduits: f.conduits }
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
out.push(...duplicateSegments(model.curves));
|
|
492
|
+
out.push(...flowBalance(model, findHost, hkey, portsOf));
|
|
493
|
+
return out;
|
|
494
|
+
}
|
|
495
|
+
var VENT = /^(V|VENT|VTR|SV)$/i;
|
|
496
|
+
var DRAIN = /^(SAN|SS|SW|W|WASTE|SOIL|D|DR|DRAIN)$/i;
|
|
497
|
+
function ventOnStack(systems) {
|
|
498
|
+
const list = [...systems];
|
|
499
|
+
return list.every((s) => VENT.test(s) || DRAIN.test(s)) && list.filter((s) => DRAIN.test(s)).length === 1;
|
|
500
|
+
}
|
|
501
|
+
var roundSection = (table, shape) => table === "pipe" || table === "conduit" || shape === "round";
|
|
502
|
+
var close = (a, b) => Math.abs(a - b) <= Math.max(1e-3, 0.02 * Math.max(Math.abs(a), Math.abs(b)));
|
|
503
|
+
function sameSection(c, p) {
|
|
504
|
+
if (!(c.w > 0) || !(p.w > 0)) return true;
|
|
505
|
+
const cr = roundSection(c.table, c.shape), pr = roundSection(c.table, p.shape) || !(p.h > 0);
|
|
506
|
+
if (cr !== pr) return false;
|
|
507
|
+
if (cr) return close(c.w, p.w);
|
|
508
|
+
const ch = c.h > 0 ? c.h : c.w, ph = p.h;
|
|
509
|
+
return close(c.w, p.w) && close(ch, ph) || close(c.w, ph) && close(ch, p.w);
|
|
510
|
+
}
|
|
511
|
+
function sizeText(x) {
|
|
512
|
+
const f = (v) => String(Math.round(v * 1e4) / 1e4);
|
|
513
|
+
if (!(x.w > 0)) return "?";
|
|
514
|
+
return roundSection(x.table ?? "", x.shape) || !(x.h > 0) ? `\xD8${f(x.w)}` : `${f(x.w)}\xD7${f(x.h)}`;
|
|
515
|
+
}
|
|
516
|
+
var OVERLAP_TOL = 0.01;
|
|
517
|
+
function duplicateSegments(curves) {
|
|
518
|
+
const out = [];
|
|
519
|
+
const items = curves.map((c) => ({ c, lo: Math.min(c.a[0], c.b[0]), hi: Math.max(c.a[0], c.b[0]), len: dist(c.a, c.b) })).filter((i) => i.len > OVERLAP_TOL).sort((p, q) => p.lo - q.lo);
|
|
520
|
+
const flagged = /* @__PURE__ */ new Set();
|
|
521
|
+
for (let i = 0; i < items.length; i++) {
|
|
522
|
+
const A = items[i];
|
|
523
|
+
for (let j = i + 1; j < items.length && items[j].lo <= A.hi + OVERLAP_TOL; j++) {
|
|
524
|
+
const B = items[j];
|
|
525
|
+
if (A.c.table !== B.c.table || (A.c.scope ?? "") !== (B.c.scope ?? "")) continue;
|
|
526
|
+
const u = [(A.c.b[0] - A.c.a[0]) / A.len, (A.c.b[1] - A.c.a[1]) / A.len, (A.c.b[2] - A.c.a[2]) / A.len];
|
|
527
|
+
const off = (p) => {
|
|
528
|
+
const v = [p[0] - A.c.a[0], p[1] - A.c.a[1], p[2] - A.c.a[2]];
|
|
529
|
+
const t = v[0] * u[0] + v[1] * u[1] + v[2] * u[2];
|
|
530
|
+
return { t, d: Math.hypot(v[0] - u[0] * t, v[1] - u[1] * t, v[2] - u[2] * t) };
|
|
531
|
+
};
|
|
532
|
+
const p1 = off(B.c.a), p2 = off(B.c.b);
|
|
533
|
+
if (p1.d > OVERLAP_TOL || p2.d > OVERLAP_TOL) continue;
|
|
534
|
+
const overlap = Math.min(A.len, Math.max(p1.t, p2.t)) - Math.max(0, Math.min(p1.t, p2.t));
|
|
535
|
+
if (overlap <= OVERLAP_TOL) continue;
|
|
536
|
+
const key = `${B.c.scope ?? ""}/${B.c.id}`;
|
|
537
|
+
if (flagged.has(key)) continue;
|
|
538
|
+
flagged.add(key);
|
|
539
|
+
const mid = Math.max(0, Math.min(p1.t, p2.t)) + overlap / 2;
|
|
540
|
+
out.push({
|
|
541
|
+
severity: "warning",
|
|
542
|
+
code: "duplicate_segment",
|
|
543
|
+
id: B.c.id,
|
|
544
|
+
scope: B.c.scope,
|
|
545
|
+
table: B.c.table,
|
|
546
|
+
system: B.c.system,
|
|
547
|
+
other: A.c.id,
|
|
548
|
+
message: `${B.c.table} ${B.c.id} lies on top of ${A.c.id} over ${overlap.toFixed(2)} (duplicate segment, delete one)`,
|
|
549
|
+
at: [A.c.a[0] + u[0] * mid, A.c.a[1] + u[1] * mid, A.c.a[2] + u[2] * mid],
|
|
550
|
+
key: "duplicate_segment",
|
|
551
|
+
vars: { table: B.c.table, id: B.c.id, other: A.c.id, length: overlap.toFixed(2) }
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
return out;
|
|
556
|
+
}
|
|
557
|
+
function flowBalance(model, findHost, hkey, portsOf) {
|
|
558
|
+
const out = [];
|
|
559
|
+
const at = /* @__PURE__ */ new Map();
|
|
560
|
+
const ends = /* @__PURE__ */ new Map();
|
|
561
|
+
for (const c of model.curves) {
|
|
562
|
+
const hs = [];
|
|
563
|
+
for (const ref of [c.from, c.to]) {
|
|
564
|
+
const r = splitRef(ref);
|
|
565
|
+
const h = r ? findHost(c.scope, r.hostId) : void 0;
|
|
566
|
+
if (!h) continue;
|
|
567
|
+
hs.push(h);
|
|
568
|
+
const list = at.get(hkey(h)) ?? [];
|
|
569
|
+
list.push(c);
|
|
570
|
+
at.set(hkey(h), list);
|
|
571
|
+
}
|
|
572
|
+
ends.set(c, hs);
|
|
573
|
+
}
|
|
574
|
+
const passThrough = (h) => {
|
|
575
|
+
const fl = portsOf(h).filter((p) => p.domain === "hvac");
|
|
576
|
+
return fl.length === 2 && fl.map((p) => p.flowDir ?? "").sort().join(",") === "in,out";
|
|
577
|
+
};
|
|
578
|
+
for (const h of model.hosts) {
|
|
579
|
+
if (h.table !== "equipment" || !(h.flow > 0)) continue;
|
|
580
|
+
for (const p of portsOf(h)) {
|
|
581
|
+
if (p.domain !== "hvac" || p.flowDir !== "out") continue;
|
|
582
|
+
const start = (at.get(hkey(h)) ?? []).filter((c) => [c.from, c.to].some((r) => splitRef(r)?.port === p.name));
|
|
583
|
+
if (start.length === 0) continue;
|
|
584
|
+
const seenC = /* @__PURE__ */ new Set(), seenH = /* @__PURE__ */ new Set([hkey(h)]);
|
|
585
|
+
const queue = [...start];
|
|
586
|
+
let sum = 0, n = 0;
|
|
587
|
+
while (queue.length) {
|
|
588
|
+
const c = queue.pop();
|
|
589
|
+
if (seenC.has(c)) continue;
|
|
590
|
+
seenC.add(c);
|
|
591
|
+
for (const o of ends.get(c) ?? []) {
|
|
592
|
+
const k = hkey(o);
|
|
593
|
+
if (seenH.has(k)) continue;
|
|
594
|
+
seenH.add(k);
|
|
595
|
+
if (o.table === "terminal") {
|
|
596
|
+
sum += o.flow ?? 0;
|
|
597
|
+
n++;
|
|
598
|
+
continue;
|
|
599
|
+
}
|
|
600
|
+
if (o.table === "mep_node" || passThrough(o)) queue.push(...at.get(k) ?? []);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
if (n === 0 || !(sum > 0) || Math.abs(sum - h.flow) <= 0.1 * h.flow) continue;
|
|
604
|
+
const f = (v) => String(Math.round(v * 10) / 10);
|
|
605
|
+
out.push({
|
|
606
|
+
severity: "warning",
|
|
607
|
+
code: "flow_balance",
|
|
608
|
+
id: h.id,
|
|
609
|
+
scope: h.scope,
|
|
610
|
+
table: h.table,
|
|
611
|
+
system: p.system || h.system,
|
|
612
|
+
message: `equipment ${h.id} supplies ${f(h.flow)} L/s from port "${p.name}" but its ${n} terminal(s) take ${f(sum)} L/s`,
|
|
613
|
+
at: p.pos,
|
|
614
|
+
key: "flow_balance",
|
|
615
|
+
vars: { id: h.id, flow: f(h.flow), port: p.name, n, sum: f(sum) }
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
return out;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
// src/mep/index.ts
|
|
623
|
+
function mepReport(dir) {
|
|
624
|
+
const m = loadMep(dir);
|
|
625
|
+
const problems = checkMep(m).map((p) => ({ ...p, dir: p.scope ?? "" }));
|
|
626
|
+
return { systems: summarizeSystems(m), problems };
|
|
627
|
+
}
|
|
628
|
+
function formatProblem(p) {
|
|
629
|
+
return `${p.dir ? `${p.dir}/` : ""}${p.table}.csv ${p.id}: [${p.code}] ${p.message}`;
|
|
630
|
+
}
|
|
631
|
+
var ERROR_CODES = /* @__PURE__ */ new Set(["dangling_ref"]);
|
|
632
|
+
function mepWarnings(dir) {
|
|
633
|
+
const r = mepReport(dir);
|
|
634
|
+
return r.problems.filter((p) => p.severity === "warning" && !ERROR_CODES.has(p.code)).map(formatProblem);
|
|
635
|
+
}
|
|
636
|
+
function mepErrors(dir) {
|
|
637
|
+
const r = mepReport(dir);
|
|
638
|
+
return r.problems.filter((p) => p.severity === "warning" && ERROR_CODES.has(p.code)).map(formatProblem);
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
export {
|
|
642
|
+
checkMep,
|
|
643
|
+
mepReport,
|
|
644
|
+
formatProblem,
|
|
645
|
+
mepWarnings,
|
|
646
|
+
mepErrors
|
|
647
|
+
};
|
|
648
|
+
//# sourceMappingURL=chunk-EC5MR5ZH.js.map
|