oltc-selector 1.2.8 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +85 -91
  2. package/bin/oltc.js +346 -99
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,91 +1,85 @@
1
- # OLTC Selector / 有载开关选型
2
-
3
- 填工况,给出 2025 目录里**最低满足**的型号。网页和 `oltc` CLI 共用同一份 `selectOltc` 引擎。
4
-
5
- **CLI(无报价):** `npx -y oltc-selector@1.2.8`,命令是 `oltc`。Agent 技能包在独立仓库 [`erict16/huaming-oltc-selector`](https://github.com/erict16/huaming-oltc-selector)。
6
- **网页:** [oltc-selector.vercel.app](https://oltc-selector.vercel.app/) · [GitHub Pages](https://erict16.github.io/oltc-selector/)
7
-
8
- 私人辅助,不是厂家官网。型号是起点,出 OS 前要工程确认。
9
-
10
- ![工作台](docs/assets/readme.png)
11
-
12
- ## CLI
13
-
14
- 不需要 clone 本仓库。不输出人民币、系数、报价。
15
-
16
- ```bash
17
- npm i -g oltc-selector
18
-
19
- oltc --iu 350 --um 40.5 --conn D --reg W --pm 8
20
- # CV2III-350D/40.5-10193W
21
-
22
- oltc --octc --iu 800 --um 72.5 --conn D --series II --contact 6x5
23
- oltc --iu 600 --um 72.5 --conn Y --reg W --pm 8 --structure combined
24
- oltc --mva 25 --kv 110 --conn Y --reg W --pm 8
25
- ```
26
-
27
- | Flag | Meaning | Default |
28
- |------|---------|---------|
29
- | `--iu` / `--imax` | Max through-current Imax (A). **No** safety factor. | required unless `--mva` |
30
- | `--mva` `--kv` | Transformer MVA + tap-side kV → Imax (min tap + `--k`) | |
31
- | `--k` | Safety factor, **capacity path only** | 1.2 |
32
- | `--um` | Equipment Um (kV) | derived from `--kv` on MVA path |
33
- | `--ust` | Step voltage (V) | 0, or derived on MVA path |
34
- | `--conn Y\|D` | Switch star / delta (not Dyn11) | Y |
35
- | `--reg W\|G\|0` | Reversing / coarse-fine / linear | W |
36
- | `--pm` | ± steps | 8 |
37
- | `--octc` | Off-circuit 无载 (WSL/WSG) | on-load |
38
- | `--structure` | `auto` / `combined` 组合式 / `compound` 复合式 / `cage` 笼式 / `drum` 鼓式 | `auto` |
39
- | `--series` | OCTC wiring II IV V VI VII VIII | auto (Y→IV, D→II) |
40
- | `--mount` | `in-tank` / `on-tank` / `dry` | in-tank |
41
- | `--oil` / `--vacuum` | Switching medium | vacuum (on-load) |
42
- | `--contact` | OCTC contact e.g. `6x5` | |
43
- | `--json` | Machine output, still no prices | |
44
-
45
- `--structure auto` and omitting `--octc` match the web first paint: on-load, in-tank vacuum, minimum-adequate ranking.
46
-
47
- ## Selection rules
48
-
49
- 1. **Minimum-adequate, not SHZV-by-default.** Rank **CV2 → CM2 → SHZV → SDZV → SHZVG**. SDZV (dual-break, Ust 6000 V) only when SHZV step voltage or step capacity is short. Prefer one three-phase unit over `3×` singles when a brochure III type exists.
50
- 2. **OLTC existence comes from brochure / catalogue axes** (`lib/catalog.ts`), **not price-list Y/D twins**. A 2025 list row that prices `CM2III-…D` the same as Y does **not** make `CM2III-…D` a type.
51
- 3. **No CV2-500.** CV2 III currents are 350 and 600 only.
52
- 4. **No combined III-D.** CM / CM2 / CMD / SHZV / SDZV / SHZVG three-phase strings are star-point Y. Cover delta with `3x…I-` when that I type exists. Compound **CV / CV2 / SV** and on-tank **HWV** III-D **do** exist. No SDZV II, I-1200/1500, or III-1300.
53
- 5. **Compound has no selector grade letter.** No `CV2III-350Y/40.5B-…`. Combined in-tank may have B/C/D/DE after Um.
54
- 6. **WSL / WDL existence is 2025-list row keys without prices** (`lib/listIndex.data.json`). Missing rows (no `WSLIV-2000D/126`, no `7x6E` @ 72.5) are not emitted.
55
- 7. **WSG** is catalogue axes only (no 2025 list sheet in the index).
56
- 8. **Typing Imax (`--iu`) does not apply a safety factor.** `--k` only applies on the transformer-capacity (`--mva`) path.
57
-
58
- ## Web app
59
-
60
- 预选 66 / 110 / 220 kV 带常用工况。默认真变压器容量,星/角推出 Imax(最低分接和安全系数)。调压侧电压推出 Um。点「选型」之后才出型号。
61
-
62
- ```bash
63
- npm install
64
- npm run dev # http://127.0.0.1:3000
65
- npm test
66
- npm run pack:cli
67
- ```
68
-
69
- GitHub Pages:`npm run build:gh`(`GH_PAGES=true`)。Vercel 根路径,不要设 `GH_PAGES`。
70
-
71
- 内部看价仍在网页右上角「内部」(口令)。**CLI 包不含价表。** 本地 `.env.local`:
72
-
73
- ```
74
- NEXT_PUBLIC_ADMIN_PASSWORD_SHA256=<sha256 hex of the password>
75
- ```
76
-
77
- 语言:中文、English、Tiếng Việt、Español、Türkçe、Русский。
78
-
79
- ## OS regression
80
-
81
- `docs/replay/2025-os-sales.xlsx` and `2026-os-sales.xlsx` hold sold type plus duty (Imax, Um, Ust, ±, Y/D, phases, serial). Rebuild from JSON:
82
-
83
- ```bash
84
- python scripts/os-to-excel.py
85
- ```
86
-
87
- `npm test` runs shipped `selectOltc` on every complete row: no illegal type out; a legal sold type that covers the duty must appear in ranked results.
88
-
89
- ## 许可
90
-
91
- [条款](https://erict16.github.io/oltc-selector/terms/) · [隐私](https://erict16.github.io/oltc-selector/privacy/)。仅供参考。
1
+ # OLTC Selector / 有载开关选型
2
+
3
+ 填工况,给出 2025 目录里**最低满足**的型号。网页和 `oltc` CLI 共用同一份 `selectOltc` 引擎。
4
+
5
+ **CLI:** `npx -y oltc-selector@1.3.0`,命令是 `oltc`。Agent 技能包另放,不在这个仓库里。
6
+ **网页:** [oltc-selector.vercel.app](https://oltc-selector.vercel.app/) · [GitHub Pages](https://erict16.github.io/oltc-selector/)
7
+
8
+ 私人辅助,不是厂家官网。型号是起点,出 OS 前要工程确认。
9
+
10
+ ![工作台](docs/assets/readme.png)
11
+
12
+ ## CLI
13
+
14
+ 不需要 clone 本仓库。
15
+
16
+ ```bash
17
+ npm i -g oltc-selector
18
+
19
+ oltc --iu 350 --um 40.5 --conn D --reg W --pm 8
20
+ # CV2III-350D/40.5-10193W
21
+
22
+ oltc --octc --iu 800 --um 72.5 --conn D --series II --contact 6x5
23
+ oltc --iu 600 --um 72.5 --conn Y --reg W --pm 8 --structure combined
24
+ oltc --mva 25 --kv 110 --conn Y --reg W --pm 8
25
+ ```
26
+
27
+ | Flag | Meaning | Default |
28
+ |------|---------|---------|
29
+ | `--iu` / `--imax` | Max through-current Imax (A). **No** safety factor. | required unless `--mva` |
30
+ | `--mva` `--kv` | Transformer MVA + tap-side kV → Imax (min tap + `--k`) | |
31
+ | `--k` | Safety factor ≥ 1, **capacity path only** | 1.0 |
32
+ | `--um` | Equipment Um (kV) | derived from `--kv` on MVA path |
33
+ | `--ust` | Step voltage (V) | 0, or derived on MVA path |
34
+ | `--conn Y\|D` | Switch star / delta (not Dyn11) | Y |
35
+ | `--reg W\|G\|0` | Reversing / coarse-fine / linear | W |
36
+ | `--pm` | ± steps | 8 |
37
+ | `--octc` | Off-circuit 无载 (WSL/WSG) | on-load |
38
+ | `--structure` | `auto` / `combined` 组合式 / `compound` 复合式 / `cage` 笼式 / `drum` 鼓式 | `auto` |
39
+ | `--series` | OCTC wiring II IV V VI VII VIII | auto is linear IV for Y and D |
40
+ | `--mount` | `in-tank` / `on-tank` / `dry` | in-tank |
41
+ | `--oil` / `--vacuum` | Switching medium | vacuum (on-load) |
42
+ | `--contact` | OCTC contact e.g. `6x5` | |
43
+ | `--json` | Machine output | |
44
+
45
+ `--structure auto` and omitting `--octc` match the web first paint: on-load, in-tank vacuum, minimum-adequate ranking.
46
+
47
+ ## Selection rules
48
+
49
+ 1. **Minimum-adequate, not SHZV-by-default.** Rank **CV2 → CM2 → SHZV → SDZV → SHZVG**. SDZV (dual-break, Ust 6000 V) only when SHZV step voltage or step capacity is short. Prefer one three-phase unit over `3×` singles when a brochure III type exists.
50
+ 2. **OLTC existence comes from brochure / catalogue axes** (`lib/catalog.ts`), **not price-list Y/D twins**. A 2025 list row that prices `CM2III-…D` the same as Y does **not** make `CM2III-…D` a type.
51
+ 3. **No CV2-500.** CV2 III currents are 350 and 600 only.
52
+ 4. **No combined III-D.** CM / CM2 / CMD / SHZV / SDZV / SHZVG three-phase strings are star-point Y. Cover delta with `3x…I-` when that I type exists. Compound **CV / CV2 / SV** and on-tank **HWV** III-D **do** exist. No SDZV II, I-1200/1500, or III-1300.
53
+ 5. **Compound has no selector grade letter.** No `CV2III-350Y/40.5B-…`. Combined in-tank may have B/C/D/DE after Um.
54
+ 6. **WSL / WDL existence is 2025-list row keys without prices** (`lib/listIndex.data.json`). Missing rows (no `WSLIV-2000D/126`, no `7x6E` @ 72.5) are not emitted.
55
+ 7. **WSG** is catalogue axes only (no 2025 list sheet in the index).
56
+ 8. **Typing Imax (`--iu`) does not apply a safety factor.** `--k` only applies on the transformer-capacity (`--mva`) path.
57
+
58
+ ## Web app
59
+
60
+ 预选 66 / 110 / 220 kV 带常用工况。默认真变压器容量,星/角推出 Imax(最低分接和安全系数)。调压侧电压推出 Um。点「选型」之后才出型号。
61
+
62
+ ```bash
63
+ npm install
64
+ npm run dev # http://127.0.0.1:3000
65
+ npm test
66
+ npm run pack:cli
67
+ ```
68
+
69
+ GitHub Pages:`npm run build:gh`(`GH_PAGES=true`)。Vercel 根路径,不要设 `GH_PAGES`。
70
+
71
+ 语言:中文、English、Tiếng Việt、Español、Türkçe、Русский。
72
+
73
+ ## OS regression
74
+
75
+ `docs/replay/2025-os-sales.xlsx` and `2026-os-sales.xlsx` hold sold type plus duty (Imax, Um, Ust, ±, Y/D, phases, serial). Rebuild from JSON:
76
+
77
+ ```bash
78
+ python scripts/os-to-excel.py
79
+ ```
80
+
81
+ `npm test` runs shipped `selectOltc` on every complete row: no illegal type out; a legal sold type that covers the duty must appear in ranked results.
82
+
83
+ ## 许可
84
+
85
+ [条款](https://erict16.github.io/oltc-selector/terms/) · [隐私](https://erict16.github.io/oltc-selector/privacy/)。仅供参考。
package/bin/oltc.js CHANGED
@@ -1,5 +1,19 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ // lib/decimal.ts
4
+ var GROUPED = /^\d{1,3}([,,]\d{3})+$/;
5
+ var PLAIN = /^\d*\.?\d*$/;
6
+ function parseDecimal(raw) {
7
+ const s = String(raw).trim().replace(/\s+/g, "");
8
+ if (!s) return { ok: false, reason: "empty" };
9
+ if (GROUPED.test(s)) return { ok: false, reason: "ambiguous" };
10
+ const t = s.replace(/[,,]/g, ".");
11
+ if (!PLAIN.test(t) || t === ".") return { ok: false, reason: "invalid" };
12
+ const n = Number(t);
13
+ if (!Number.isFinite(n)) return { ok: false, reason: "invalid" };
14
+ return { ok: true, value: n };
15
+ }
16
+
3
17
  // lib/deriveUm.ts
4
18
  var RATED_TO_WINDING_UM = {
5
19
  33: 40.5,
@@ -141,6 +155,11 @@ function lookupDiagram(n, mid, regulation) {
141
155
  (d) => d.plusMinus === n && d.mid === mid
142
156
  ) ?? null;
143
157
  }
158
+ function lookupByPositions(positions, mid, regulation) {
159
+ return diagramsFor(regulation).find(
160
+ (d) => d.positions === positions && d.mid === mid
161
+ ) ?? null;
162
+ }
144
163
  function pitchFor(n, mid) {
145
164
  if (mid === 3) return n + 2;
146
165
  if (n <= 8) return 2 * n + 2;
@@ -241,6 +260,12 @@ function buildTapCode(opts) {
241
260
  }
242
261
  function resolveTapFields(input) {
243
262
  const reg = input.regulation;
263
+ const isStandard = (positions2, mid2, pitch2) => {
264
+ if (reg === "linear") return true;
265
+ if (mid2 !== 1 && mid2 !== 3) return false;
266
+ const row = lookupByPositions(positions2, mid2, reg);
267
+ return row != null && row.pitch === pitch2;
268
+ };
244
269
  if (reg === "linear") {
245
270
  const positions2 = input.positions ?? 9;
246
271
  const pitch2 = input.pitch ?? defaultPitch(positions2, reg);
@@ -250,7 +275,8 @@ function resolveTapFields(input) {
250
275
  pitch: pitch2,
251
276
  mid: mid2,
252
277
  tapCode: buildTapCode({ pitch: pitch2, positions: positions2, mid: mid2, regulation: reg }),
253
- changeOver: "0"
278
+ changeOver: "0",
279
+ standard: true
254
280
  };
255
281
  }
256
282
  if (input.plusMinusSteps != null && input.plusMinusSteps > 0) {
@@ -270,7 +296,8 @@ function resolveTapFields(input) {
270
296
  pitch: pitch2,
271
297
  mid: mid2,
272
298
  tapCode: buildTapCode({ pitch: pitch2, positions: positions2, mid: mid2, regulation: reg }),
273
- changeOver: changeOverOf(reg)
299
+ changeOver: changeOverOf(reg),
300
+ standard: row != null && isStandard(positions2, mid2, pitch2)
274
301
  };
275
302
  }
276
303
  let positions = input.positions ?? 19;
@@ -288,7 +315,8 @@ function resolveTapFields(input) {
288
315
  pitch,
289
316
  mid,
290
317
  tapCode: buildTapCode({ pitch, positions, mid, regulation: reg }),
291
- changeOver: changeOverOf(reg)
318
+ changeOver: changeOverOf(reg),
319
+ standard: isStandard(positions, mid, pitch)
292
320
  };
293
321
  }
294
322
 
@@ -879,8 +907,8 @@ var SERIES = [
879
907
  maxPositionsLinear: 18,
880
908
  maxPositionsWithChangeOver: 18,
881
909
  defaultMdu: "CMA7",
882
- notesEn: "Cage OCTC. Eligible only when dutyKind=octc. Wiring roman II/IV/V/VI/VII/VIII is a form field, independent of Y/D. Unset auto: Y\u2192WSLIV, D\u2192WSLII; 5x2\u2192VIII, 3x2\u2192VI, 5x4\u2192V. Contact from P or OS. WDL aliases the same list.",
883
- notesZh: "\u7B3C\u5F0F\u65E0\u8F7D\u5F00\u5173\u3002\u4EC5 dutyKind=octc \u65F6\u5165\u9009\u3002\u63A5\u7EBF\u65B9\u5F0F II/IV/V/VI/VII/VIII \u4E0E Y/D \u5206\u5F00\u9009\u3002\u672A\u6307\u5B9A\u65F6\uFF1AY\u2192WSLIV\uFF0CD\u2192WSLII\u3002\u6863\u4F4D\u6620\u5C04\u89E6\u5934 6x5/7x6/12x11/18x17\u3002WDL \u8D70\u540C\u4E00\u4EF7\u76EE\u8868\u3002",
910
+ notesEn: "Cage OCTC. Eligible only when dutyKind=octc. Wiring roman II/IV/V/VI/VII/VIII is a form field, independent of Y/D. Unset auto is linear IV for Y and D; 5x2\u2192VIII, 3x2\u2192VI, 5x4\u2192V, 12x12\u2192VII. Reversing II only when asked. Contact from P or OS. WDL aliases the same list.",
911
+ notesZh: "\u7B3C\u5F0F\u65E0\u8F7D\u5F00\u5173\u3002\u4EC5 dutyKind=octc \u65F6\u5165\u9009\u3002\u63A5\u7EBF\u65B9\u5F0F II/IV/V/VI/VII/VIII \u4E0E Y/D \u5206\u5F00\u9009\u3002\u672A\u6307\u5B9A\u65F6\u661F\u63A5\u548C\u89D2\u63A5\u90FD\u662F\u7EBF\u6027 IV\uFF1B5x2\u2192VIII\uFF0C3x2\u2192VI\uFF0C5x4\u2192V\uFF0C12x12\u2192VII\u3002\u6B63\u53CD\u8C03 II \u8981\u5355\u72EC\u6307\u5B9A\u3002\u6863\u4F4D\u6620\u5C04\u89E6\u5934 6x5/7x6/12x11/18x17\u3002WDL \u8D70\u540C\u4E00\u4EF7\u76EE\u8868\u3002",
884
912
  rank: 5
885
913
  },
886
914
  {
@@ -948,45 +976,37 @@ function firstAllowedAtOrAbove(min, allowed) {
948
976
  }
949
977
  return allowed[allowed.length - 1] ?? "B";
950
978
  }
951
- function pickSelectorSize(um, requested, bilKv, pfKv, acrossTapBilKv, acrossTapPfKv) {
979
+ function coversAcrossTap(size, needALi, needAPf) {
980
+ const ins = INTERNAL_INSULATION[size];
981
+ return ins.a_li + 0.5 >= needALi && ins.a_pf + 0.5 >= needAPf;
982
+ }
983
+ function resolveSelectorSize(um, requested, acrossTapBilKv, acrossTapPfKv) {
952
984
  const allowed = SELECTOR_SIZES_BY_UM[um] ?? ["B", "C", "D", "DE"];
953
- if (requested && requested !== "auto") {
954
- if (allowed.includes(requested)) return requested;
955
- return firstAllowedAtOrAbove(requested, allowed);
956
- }
957
- let floor = defaultSelectorSizeForUm(um);
958
- floor = firstAllowedAtOrAbove(floor, allowed);
959
- const earth = EARTH_INSULATION[um];
960
- if (earth && bilKv && bilKv > earth.bil + 1) {
961
- const i = SIZE_ORDER.indexOf(floor);
962
- floor = firstAllowedAtOrAbove(
963
- SIZE_ORDER[Math.min(SIZE_ORDER.length - 1, i + 1)] ?? "DE",
964
- allowed
965
- );
966
- }
967
- if (earth && pfKv && pfKv > earth.pf + 1) {
968
- const i = SIZE_ORDER.indexOf(floor);
969
- floor = firstAllowedAtOrAbove(
970
- SIZE_ORDER[Math.min(SIZE_ORDER.length - 1, i + 1)] ?? "DE",
971
- allowed
972
- );
973
- }
974
985
  const needALi = acrossTapBilKv ?? 0;
975
986
  const needAPf = acrossTapPfKv ?? 0;
976
- const floorIdx = SIZE_ORDER.indexOf(floor);
977
- for (let i = floorIdx; i < SIZE_ORDER.length; i++) {
987
+ const typed = requested && requested !== "auto" ? requested : null;
988
+ const floor = firstAllowedAtOrAbove(
989
+ typed ?? defaultSelectorSizeForUm(um),
990
+ allowed
991
+ );
992
+ for (let i = SIZE_ORDER.indexOf(floor); i < SIZE_ORDER.length; i++) {
978
993
  const cand = SIZE_ORDER[i];
979
994
  if (!allowed.includes(cand)) continue;
980
- const ins = INTERNAL_INSULATION[cand];
981
- if (needALi <= 0 && needAPf <= 0) return cand;
982
- if (ins.a_li + 0.5 >= needALi && ins.a_pf + 0.5 >= needAPf) return cand;
995
+ if (!coversAcrossTap(cand, needALi, needAPf)) continue;
996
+ return typed && cand !== typed ? { size: cand, raisedFrom: typed } : { size: cand };
983
997
  }
984
- for (const cand of SIZE_ORDER) {
985
- if (!allowed.includes(cand)) continue;
986
- const ins = INTERNAL_INSULATION[cand];
987
- if (ins.a_li + 0.5 >= needALi && ins.a_pf + 0.5 >= needAPf) return cand;
998
+ return { size: null };
999
+ }
1000
+ function umForEarthInsulation(umKv, bilKv, pfKv) {
1001
+ const needBil = bilKv ?? 0;
1002
+ const needPf = pfKv ?? 0;
1003
+ const classes = Object.keys(EARTH_INSULATION).map(Number).sort((a, b) => a - b);
1004
+ for (const u of classes) {
1005
+ if (u < umKv - 0.01) continue;
1006
+ const e = EARTH_INSULATION[u];
1007
+ if (e.bil + 0.5 >= needBil && e.pf + 0.5 >= needPf) return u;
988
1008
  }
989
- return allowed[allowed.length - 1];
1009
+ return null;
990
1010
  }
991
1011
 
992
1012
  // lib/listIndex.data.json
@@ -1237,14 +1257,15 @@ function octcSizeLetter(um, contact, requested) {
1237
1257
  }
1238
1258
  return "B";
1239
1259
  }
1240
- function octcRoman(connection, contact, series) {
1260
+ function octcRoman(connection, contact, series, familyCode) {
1241
1261
  if (series && series !== "auto") return series;
1242
1262
  const c = (contact ?? "").toLowerCase();
1243
1263
  if (c === "5x2" || c === "12x2") return "VIII";
1244
1264
  if (c === "3x2" || c === "6x2") return "VI";
1245
1265
  if (c === "5x4" || c === "4x3") return "V";
1246
1266
  if (c === "12x12") return "VII";
1247
- return connection === "D" ? "II" : "IV";
1267
+ if (familyCode === "WSG" && connection === "D") return "II";
1268
+ return "IV";
1248
1269
  }
1249
1270
  function isOctcSeries(s) {
1250
1271
  return s.dutyKind === "octc";
@@ -1279,7 +1300,8 @@ function buildModelString(series, phases, current, connection, umToken, tapCode,
1279
1300
  const roman = octcRoman(
1280
1301
  yd,
1281
1302
  tapCode.replace(/[A-E]$/i, ""),
1282
- octcSeries
1303
+ octcSeries,
1304
+ series.code
1283
1305
  );
1284
1306
  core = `${series.code}${roman}-${current}${yd}/${umToken}-${tapCode}`;
1285
1307
  } else if (series.code === "HWDK") {
@@ -1304,6 +1326,7 @@ function seriesMatchesMounting(s, input) {
1304
1326
  return s.mounting.includes("in_tank");
1305
1327
  }
1306
1328
  function seriesMatchesMedium(s, input) {
1329
+ if (input.dutyKind === "octc") return s.medium === "oil" && !s.vacuum;
1307
1330
  if (input.mounting === "dry_type") return s.medium === "dry";
1308
1331
  if (input.preferVacuum) return true;
1309
1332
  if (input.medium === "oil_vacuum") return s.vacuum || s.medium === "oil_vacuum";
@@ -1350,7 +1373,7 @@ function buildAttempts(s, input) {
1350
1373
  );
1351
1374
  if (!covering.length) return out;
1352
1375
  const um0 = covering[0];
1353
- const ums = (FAMILY_MIN_RANK[s.id] ?? s.rank) < 40 ? covering : [um0];
1376
+ const ums = !isOctcSeries(s) && (FAMILY_MIN_RANK[s.id] ?? s.rank) < 40 ? covering : [um0];
1354
1377
  if (s.id === "cz") {
1355
1378
  const curI = nearestCurrent(input.throughCurrentA, s.currents.I ?? []);
1356
1379
  if (curI != null && ratingCoversDuty(input.throughCurrentA, curI)) {
@@ -1432,21 +1455,37 @@ function diversifyResults(ranked) {
1432
1455
  function selectOltc(input) {
1433
1456
  const errorsEn = [];
1434
1457
  const errorsZh = [];
1435
- if (!input.throughCurrentA || input.throughCurrentA <= 0) {
1458
+ if (!(Number.isFinite(input.throughCurrentA) && input.throughCurrentA > 0)) {
1436
1459
  errorsEn.push("Enter rated through-current (A).");
1437
1460
  errorsZh.push("\u8BF7\u586B\u5199\u989D\u5B9A\u901A\u8FC7\u7535\u6D41\uFF08A\uFF09\u3002");
1438
1461
  }
1439
- if (!input.umKv || input.umKv <= 0) {
1462
+ if (!(Number.isFinite(input.umKv) && input.umKv > 0)) {
1440
1463
  errorsEn.push("Enter highest voltage for equipment Um (kV).");
1441
1464
  errorsZh.push("\u8BF7\u586B\u5199\u8BBE\u5907\u6700\u9AD8\u7535\u538B Um\uFF08kV\uFF09\u3002");
1442
1465
  }
1443
- if (input.stepVoltageV < 0) {
1444
- errorsEn.push("Step voltage cannot be negative.");
1445
- errorsZh.push("\u7EA7\u7535\u538B\u4E0D\u80FD\u4E3A\u8D1F\u3002");
1466
+ if (!Number.isFinite(input.stepVoltageV) || input.stepVoltageV < 0) {
1467
+ errorsEn.push("Step voltage must be a number \u2265 0 (0 = not given).");
1468
+ errorsZh.push("\u7EA7\u7535\u538B\u987B\u4E3A \u2265 0 \u7684\u6570\u5B57\uFF080 \u8868\u793A\u672A\u7ED9\uFF09\u3002");
1446
1469
  }
1447
1470
  if (errorsEn.length) {
1448
1471
  return { ok: false, results: [], errorsEn, errorsZh };
1449
1472
  }
1473
+ if ((input.bilKv ?? 0) > 0 || (input.pfKv ?? 0) > 0) {
1474
+ const earthUm = umForEarthInsulation(input.umKv, input.bilKv, input.pfKv);
1475
+ if (earthUm == null) {
1476
+ return {
1477
+ ok: false,
1478
+ results: [],
1479
+ errorsEn: [
1480
+ `Earth insulation LI ${input.bilKv ?? "\u2014"} / PF ${input.pfKv ?? "\u2014"} kV is above every catalogue Um. Contact engineering.`
1481
+ ],
1482
+ errorsZh: [
1483
+ `\u5BF9\u5730\u7EDD\u7F18 \u96F7\u7535 ${input.bilKv ?? "\u2014"} / \u5DE5\u9891 ${input.pfKv ?? "\u2014"} kV \u8D85\u51FA\u6240\u6709\u76EE\u5F55 Um\u3002\u8BF7\u8054\u7CFB\u5DE5\u7A0B\u3002`
1484
+ ]
1485
+ };
1486
+ }
1487
+ if (earthUm > input.umKv + 0.01) input = { ...input, umKv: earthUm };
1488
+ }
1450
1489
  const tap = resolveTapFields({
1451
1490
  regulation: input.regulation,
1452
1491
  positions: input.positions,
@@ -1481,8 +1520,12 @@ function selectOltc(input) {
1481
1520
  }
1482
1521
  const results = [];
1483
1522
  const seen = /* @__PURE__ */ new Set();
1523
+ let acrossTapShort = false;
1484
1524
  for (const s of candidates) {
1485
- if (!compoundCoversAcrossTap(s, input)) continue;
1525
+ if (!compoundCoversAcrossTap(s, input)) {
1526
+ acrossTapShort = true;
1527
+ continue;
1528
+ }
1486
1529
  if (!isOctcSeries(s)) {
1487
1530
  const pitchMaxUst = maxStepVoltageForSeries(s, tap.pitch);
1488
1531
  if (input.stepVoltageV > pitchMaxUst + 0.5) continue;
@@ -1503,32 +1546,32 @@ function selectOltc(input) {
1503
1546
  if (psin != null && need > psin + 0.5) return false;
1504
1547
  return true;
1505
1548
  };
1506
- let covering = phaseCurrents.filter((c) => {
1507
- if (!ratingCoversDuty(input.throughCurrentA, c)) return false;
1508
- if (input.throughCurrentA + 1 < c && input.throughCurrentA > c * 0.97) {
1509
- return false;
1510
- }
1511
- return capacityOk(c);
1512
- });
1513
- if (!covering.length) {
1514
- const maxKeep = phaseCurrents.filter(
1515
- (c) => ratingCoversDuty(input.throughCurrentA, c) && capacityOk(c)
1516
- );
1517
- if (maxKeep.length) covering = [Math.max(...maxKeep)];
1518
- }
1549
+ const covering = phaseCurrents.filter(
1550
+ (c) => ratingCoversDuty(input.throughCurrentA, c) && capacityOk(c)
1551
+ );
1519
1552
  if (!covering.length) continue;
1520
1553
  const currentsToEmit = covering.slice(0, 2);
1554
+ const topEmitted = Math.max(...currentsToEmit);
1555
+ const stepUpCurrent = [...phaseCurrents].sort((a, b) => a - b).find(
1556
+ (c) => c > topEmitted + 0.5 && ratingCoversDuty(input.throughCurrentA, c) && capacityOk(c)
1557
+ );
1558
+ if (stepUpCurrent != null && !currentsToEmit.includes(stepUpCurrent)) {
1559
+ currentsToEmit.push(stepUpCurrent);
1560
+ }
1521
1561
  for (const current of currentsToEmit) {
1522
1562
  const octc = isOctcSeries(s);
1523
1563
  const contact = octc ? octcContactCode(input, s.id) : "";
1524
- const selectorSize = octc ? octcSizeLetter(att.um, contact, input.selectorSize ?? "auto") : s.usesSelectorSize ? pickSelectorSize(
1564
+ const gradePick = !octc && s.usesSelectorSize ? resolveSelectorSize(
1525
1565
  att.um,
1526
1566
  input.selectorSize ?? "auto",
1527
- input.bilKv,
1528
- input.pfKv,
1529
1567
  input.acrossTapBilKv,
1530
1568
  input.acrossTapPfKv
1531
- ) : "";
1569
+ ) : null;
1570
+ if (gradePick && gradePick.size == null) {
1571
+ acrossTapShort = true;
1572
+ continue;
1573
+ }
1574
+ const selectorSize = octc ? octcSizeLetter(att.um, contact, input.selectorSize ?? "auto") : gradePick?.size ?? "";
1532
1575
  const tapCode = octc ? contact : tap.tapCode;
1533
1576
  const modelTap = octc ? `${contact}${selectorSize}` : s.id === "cz" || s.id === "hwdk" ? String(tap.positions) : tap.tapCode;
1534
1577
  const umToken = formatUmToken(att.um, selectorSize, s.usesSelectorSize);
@@ -1582,6 +1625,47 @@ function selectOltc(input) {
1582
1625
  const reasonsZh = [];
1583
1626
  const warningsEn = [];
1584
1627
  const warningsZh = [];
1628
+ const cautionsEn = [];
1629
+ const cautionsZh = [];
1630
+ if (input.throughCurrentA > current + 0.01) {
1631
+ const pct = ((input.throughCurrentA / current - 1) * 100).toFixed(1);
1632
+ cautionsEn.push(
1633
+ `Duty ${input.throughCurrentA.toFixed(1)} A is ${pct}% above the ${current} A rating (1% commercial tolerance). Confirm with engineering.`
1634
+ );
1635
+ cautionsZh.push(
1636
+ `\u9700\u6C42 ${input.throughCurrentA.toFixed(1)} A \u8D85\u51FA\u989D\u5B9A ${current} A \u7684 ${pct}%\uFF08\u6309 1% \u5546\u52A1\u5BB9\u5DEE\u653E\u884C\uFF09\uFF0C\u987B\u5DE5\u7A0B\u786E\u8BA4\u3002`
1637
+ );
1638
+ }
1639
+ if (!octc && !(input.stepVoltageV > 0)) {
1640
+ cautionsEn.push(
1641
+ "Step voltage not given: step-voltage and step-capacity limits were not checked."
1642
+ );
1643
+ cautionsZh.push("\u672A\u7ED9\u7EA7\u7535\u538B\uFF1A\u7EA7\u7535\u538B\u548C\u7EA7\u5BB9\u91CF\u90FD\u6CA1\u6709\u6821\u9A8C\u3002");
1644
+ }
1645
+ if (!octc && !tap.standard) {
1646
+ cautionsEn.push(
1647
+ `Tap code ${tap.tapCode} is not a brochure Fig. 3-3 diagram. Engineering must confirm the connection.`
1648
+ );
1649
+ cautionsZh.push(
1650
+ `\u5206\u63A5\u4EE3\u7801 ${tap.tapCode} \u4E0D\u5728\u6837\u672C\u56FE 3-3 \u6807\u51C6\u63A5\u7EBF\u5185\uFF0C\u987B\u5DE5\u7A0B\u786E\u8BA4\u63A5\u7EBF\u3002`
1651
+ );
1652
+ }
1653
+ if (gradePick?.raisedFrom) {
1654
+ cautionsEn.push(
1655
+ `Selector grade raised from ${gradePick.raisedFrom} to ${selectorSize} (Um ${att.um} kV / across-tap stress).`
1656
+ );
1657
+ cautionsZh.push(
1658
+ `\u9009\u62E9\u5668\u7B49\u7EA7\u5DF2\u7531 ${gradePick.raisedFrom} \u5347\u4E3A ${selectorSize}\uFF08Um ${att.um} kV \u6216\u8C03\u538B\u7ED5\u7EC4\u95F4\u7EDD\u7F18\u8981\u6C42\uFF09\u3002`
1659
+ );
1660
+ }
1661
+ if (!octc && !s.usesSelectorSize && s.structure !== "compound" && ((input.acrossTapBilKv ?? 0) > 0 || (input.acrossTapPfKv ?? 0) > 0)) {
1662
+ cautionsEn.push(
1663
+ `${s.code} across-tap withstand is not in the catalogue data: across-tap stress not checked.`
1664
+ );
1665
+ cautionsZh.push(
1666
+ `${s.code} \u8C03\u538B\u7ED5\u7EC4\u95F4\u8010\u53D7\u4E0D\u5728\u76EE\u5F55\u6570\u636E\u91CC\uFF1A\u8C03\u538B\u7ED5\u7EC4\u95F4\u7EDD\u7F18\u672A\u6821\u9A8C\u3002`
1667
+ );
1668
+ }
1585
1669
  const dutyA = input.throughCurrentA >= 100 ? String(Math.round(input.throughCurrentA)) : String(Math.round(input.throughCurrentA * 10) / 10);
1586
1670
  reasonsEn.push(
1587
1671
  `Minimum-adequate path: ${s.nameEn}, Ium ${current} A \u2265 ${dutyA} A, Um ${att.um} kV.`
@@ -1606,7 +1690,7 @@ function selectOltc(input) {
1606
1690
  );
1607
1691
  }
1608
1692
  if (octc) {
1609
- const roman = octcRoman(conn, contact, input.octcSeries);
1693
+ const roman = octcRoman(conn, contact, input.octcSeries, s.code);
1610
1694
  reasonsEn.push(
1611
1695
  `OCTC contact ${contact}${selectorSize} (${s.code}${roman}).`
1612
1696
  );
@@ -1674,6 +1758,7 @@ function selectOltc(input) {
1674
1758
  const stepCapacityKva = s.stepCapacityByCurrent?.[current] ?? null;
1675
1759
  let confidence = 0.88;
1676
1760
  if (att.unitCount > 1) confidence -= 0.08;
1761
+ confidence -= 0.05 * cautionsEn.length;
1677
1762
  if (warningsEn.length > 2) confidence -= 0.03;
1678
1763
  confidence = Math.max(0.45, Math.min(0.96, confidence));
1679
1764
  results.push({
@@ -1703,6 +1788,8 @@ function selectOltc(input) {
1703
1788
  reasonsZh,
1704
1789
  warningsEn,
1705
1790
  warningsZh,
1791
+ cautionsEn,
1792
+ cautionsZh,
1706
1793
  confidence,
1707
1794
  adequacyScore: score
1708
1795
  });
@@ -1710,11 +1797,15 @@ function selectOltc(input) {
1710
1797
  }
1711
1798
  }
1712
1799
  let final = results;
1713
- if (input.preferVacuum) {
1714
- const vac = results.filter(
1800
+ if (wantOctc) {
1801
+ final = results.filter((r) => {
1802
+ const s = SERIES.find((x) => x.id === r.seriesId);
1803
+ return s != null && s.medium === "oil" && !s.vacuum;
1804
+ });
1805
+ } else if (input.preferVacuum) {
1806
+ final = results.filter(
1715
1807
  (r) => SERIES.find((s) => s.id === r.seriesId)?.vacuum
1716
1808
  );
1717
- if (vac.length) final = vac;
1718
1809
  } else if (input.medium === "oil") {
1719
1810
  final = results.filter(
1720
1811
  (r) => SERIES.find((s) => s.id === r.seriesId)?.vacuum === false
@@ -1731,10 +1822,10 @@ function selectOltc(input) {
1731
1822
  ok: false,
1732
1823
  results: [],
1733
1824
  errorsEn: [
1734
- "Parameters out of catalogue range (current, Um, step voltage, or positions)."
1825
+ acrossTapShort ? "Across-tap insulation is above every selector grade that fits this duty. Contact engineering." : "Parameters out of catalogue range (current, Um, step voltage, or positions)."
1735
1826
  ],
1736
1827
  errorsZh: [
1737
- "\u53C2\u6570\u8D85\u51FA\u76EE\u5F55\u8303\u56F4\uFF08\u7535\u6D41\u3001Um\u3001\u7EA7\u7535\u538B\u6216\u6863\u4F4D\u6570\uFF09\u3002"
1828
+ acrossTapShort ? "\u8C03\u538B\u7ED5\u7EC4\u95F4\u7EDD\u7F18\u8D85\u51FA\u6EE1\u8DB3\u6B64\u5DE5\u51B5\u7684\u6240\u6709\u9009\u62E9\u5668\u7B49\u7EA7\u3002\u8BF7\u8054\u7CFB\u5DE5\u7A0B\u3002" : "\u53C2\u6570\u8D85\u51FA\u76EE\u5F55\u8303\u56F4\uFF08\u7535\u6D41\u3001Um\u3001\u7EA7\u7535\u538B\u6216\u6863\u4F4D\u6570\uFF09\u3002"
1738
1829
  ]
1739
1830
  };
1740
1831
  }
@@ -1750,26 +1841,139 @@ function stepUpOf(primary, results) {
1750
1841
  (r) => r.model !== primary.model && r.seriesId === primary.seriesId && r.phases === primary.phases && r.unitCount === primary.unitCount && r.currentA > primary.currentA
1751
1842
  );
1752
1843
  if (!same.length) return null;
1753
- same.sort((a, b) => a.currentA - b.currentA);
1844
+ same.sort((a, b) => {
1845
+ const aUm = Math.abs(a.umKv - primary.umKv) < 0.1 ? 0 : 1;
1846
+ const bUm = Math.abs(b.umKv - primary.umKv) < 0.1 ? 0 : 1;
1847
+ return aUm - bUm || a.currentA - b.currentA;
1848
+ });
1754
1849
  return same[0];
1755
1850
  }
1756
- function pickOtherOptions(results, n = 3) {
1757
- if (results.length <= 1) return [];
1851
+ var NEXT_FAMILY = {
1852
+ cv2: "cm2",
1853
+ cm2: "shzv",
1854
+ cv: "sv",
1855
+ sv: "cm",
1856
+ cm: "cmd"
1857
+ };
1858
+ function sameMachine(a, b) {
1859
+ return a.unitCount === b.unitCount && a.phases === b.phases;
1860
+ }
1861
+ function nextSingleIii(primary, results) {
1862
+ if (primary.seriesId !== "shzv" || primary.currentA + 0.5 < 1e3) return null;
1863
+ const later = results.filter(
1864
+ (r) => r.seriesId === "shzvg" && sameMachine(r, primary) && r.currentA + 0.5 >= primary.currentA && r.umKv + 0.1 >= primary.umKv
1865
+ );
1866
+ later.sort((a, b) => a.currentA - b.currentA || a.umKv - b.umKv);
1867
+ return later[0] ?? null;
1868
+ }
1869
+ var CURRENT_LINE = 0.95;
1870
+ var STEP_VOLTAGE_LINE = 0.9;
1871
+ var STEP_CAPACITY_LINE = 0.95;
1872
+ var INSULATION_LINE = 0.95;
1873
+ var LINE_EPS = 1e-9;
1874
+ function pastLine(use, line) {
1875
+ return use > line + LINE_EPS;
1876
+ }
1877
+ function insulationUse(row, need) {
1878
+ const bil = need?.acrossTapBilKv ?? 0;
1879
+ const pf = need?.acrossTapPfKv ?? 0;
1880
+ if (bil <= 0 && pf <= 0) return 0;
1881
+ const series = SERIES.find((s) => s.id === row.seriesId);
1882
+ let aLi = 0;
1883
+ let aPf = 0;
1884
+ if (series?.structure === "compound") {
1885
+ aLi = 200;
1886
+ aPf = 50;
1887
+ } else if (row.selectorSize) {
1888
+ const ins = INTERNAL_INSULATION[row.selectorSize];
1889
+ aLi = ins?.a_li ?? 0;
1890
+ aPf = ins?.a_pf ?? 0;
1891
+ }
1892
+ let peak = 0;
1893
+ if (bil > 0 && aLi > 0) peak = Math.max(peak, bil / aLi);
1894
+ if (pf > 0 && aPf > 0) peak = Math.max(peak, pf / aPf);
1895
+ return peak;
1896
+ }
1897
+ function primaryIsInsurance(primary, dutyA, stepVoltageV, need) {
1898
+ if (!(dutyA > 0) || !(primary.currentA > dutyA)) return false;
1899
+ const u = dutyUse(primary, dutyA, stepVoltageV, need);
1900
+ return !pastLine(u.iUse, CURRENT_LINE) && !pastLine(u.uUse, STEP_VOLTAGE_LINE) && !pastLine(u.pUse, STEP_CAPACITY_LINE) && !pastLine(u.nUse, INSULATION_LINE);
1901
+ }
1902
+ function dutyUse(row, dutyA, stepVoltageV, need) {
1903
+ const iUse = row.currentA > 0 ? dutyA / row.currentA : 1;
1904
+ const uUse = stepVoltageV > 0 && row.maxStepVoltageV && row.maxStepVoltageV > 0 ? stepVoltageV / row.maxStepVoltageV : 0;
1905
+ const needKva = stepVoltageV > 0 ? dutyA * stepVoltageV / 1e3 : 0;
1906
+ const pUse = needKva > 0 && row.stepCapacityKva && row.stepCapacityKva > 0 ? needKva / row.stepCapacityKva : 0;
1907
+ return { iUse, uUse, pUse, nUse: insulationUse(row, need) };
1908
+ }
1909
+ function currentStepInsures(primary, step, dutyA, stepVoltageV, need) {
1910
+ const a = dutyUse(primary, dutyA, stepVoltageV, need);
1911
+ if (a.uUse >= a.iUse - 1e-9) return false;
1912
+ if (a.pUse >= a.iUse - 1e-9) return false;
1913
+ if (a.nUse >= a.iUse - 1e-9) return false;
1914
+ const b = dutyUse(step, dutyA, stepVoltageV, need);
1915
+ return b.iUse < a.iUse - 1e-9;
1916
+ }
1917
+ function familyInsures(primary, family, dutyA, stepVoltageV, need) {
1918
+ const a = dutyUse(primary, dutyA, stepVoltageV, need);
1919
+ const b = dutyUse(family, dutyA, stepVoltageV, need);
1920
+ const peak = Math.max(a.iUse, a.uUse, a.pUse, a.nUse);
1921
+ const next = Math.max(b.iUse, b.uUse, b.pUse, b.nUse);
1922
+ return next < peak - 1e-9;
1923
+ }
1924
+ function insuringOnFamily(seriesId, primary, results, dutyA, stepVoltageV, need) {
1925
+ const cands = results.filter(
1926
+ (r) => r.seriesId === seriesId && sameMachine(r, primary) && r.currentA + 0.5 >= primary.currentA && r.umKv + 0.1 >= primary.umKv && familyInsures(primary, r, dutyA, stepVoltageV, need)
1927
+ );
1928
+ if (!cands.length) return null;
1929
+ cands.sort((a, b) => {
1930
+ const aUm = Math.abs(a.umKv - primary.umKv) < 0.1 ? 0 : 1;
1931
+ const bUm = Math.abs(b.umKv - primary.umKv) < 0.1 ? 0 : 1;
1932
+ return aUm - bUm || a.umKv - b.umKv || a.currentA - b.currentA;
1933
+ });
1934
+ return cands[0] ?? null;
1935
+ }
1936
+ function insuranceModel(results, dutyA, stepVoltageV, need) {
1758
1937
  const primary = results[0];
1759
- const stepUp = stepUpOf(primary, results);
1760
- const preferred = [];
1761
- const overflow = [];
1762
- if (stepUp) preferred.push(stepUp);
1763
- for (const r of results.slice(1)) {
1764
- if (r.model === primary.model) continue;
1765
- if (preferred.some((x) => x.model === r.model)) continue;
1766
- const sameFamilyUm = preferred.some(
1767
- (x) => x.seriesCode === r.seriesCode && Math.abs(x.umKv - r.umKv) < 0.1
1938
+ if (!primary) return null;
1939
+ if (primaryIsInsurance(primary, dutyA, stepVoltageV, need)) return null;
1940
+ const step = stepUpOf(primary, results);
1941
+ if (step && currentStepInsures(primary, step, dutyA, stepVoltageV, need)) {
1942
+ return step.model;
1943
+ }
1944
+ const seen = /* @__PURE__ */ new Set();
1945
+ let seriesId = primary.seriesId;
1946
+ while (seriesId && !seen.has(seriesId)) {
1947
+ seen.add(seriesId);
1948
+ const nextId = NEXT_FAMILY[seriesId];
1949
+ if (!nextId) break;
1950
+ const hit = insuringOnFamily(
1951
+ nextId,
1952
+ primary,
1953
+ results,
1954
+ dutyA,
1955
+ stepVoltageV,
1956
+ need
1768
1957
  );
1769
- if (sameFamilyUm) overflow.push(r);
1770
- else preferred.push(r);
1958
+ if (hit) return hit.model;
1959
+ seriesId = nextId;
1771
1960
  }
1772
- return [...preferred, ...overflow].slice(0, n);
1961
+ const single = nextSingleIii(primary, results);
1962
+ if (single && familyInsures(primary, single, dutyA, stepVoltageV, need)) {
1963
+ return single.model;
1964
+ }
1965
+ return null;
1966
+ }
1967
+ function optionsWithInsurance(results, dutyA, stepVoltageV, n = 3, need) {
1968
+ const primary = results[0];
1969
+ if (!primary) return [];
1970
+ const id = insuranceModel(results, dutyA, stepVoltageV, need);
1971
+ if (id) {
1972
+ const found = results.find((r) => r.model === id);
1973
+ return found ? [found].slice(0, n) : [];
1974
+ }
1975
+ const step = stepUpOf(primary, results);
1976
+ return step ? [step].slice(0, n) : [];
1773
1977
  }
1774
1978
 
1775
1979
  // lib/cli.ts
@@ -1780,9 +1984,14 @@ var CliError = class extends Error {
1780
1984
  }
1781
1985
  };
1782
1986
  function num(raw, flag) {
1783
- const n = Number(String(raw).replace(",", "."));
1784
- if (!Number.isFinite(n)) throw new CliError(`Invalid number for ${flag}: ${raw}`);
1785
- return n;
1987
+ const p = parseDecimal(raw);
1988
+ if (p.ok) return p.value;
1989
+ if (p.reason === "ambiguous") {
1990
+ throw new CliError(
1991
+ `Ambiguous number for ${flag}: ${raw}. Write 1200 or 1.2 (no thousands separator).`
1992
+ );
1993
+ }
1994
+ throw new CliError(`Invalid number for ${flag}: ${raw}`);
1786
1995
  }
1787
1996
  function parseCliArgs(argv) {
1788
1997
  const out = {
@@ -1932,7 +2141,7 @@ function parseCliArgs(argv) {
1932
2141
  \u7B3C\u5F0F: "cage",
1933
2142
  \u9F13\u5F0F: "drum"
1934
2143
  };
1935
- if (!(s in map) && !(v in map)) {
2144
+ if (!Object.hasOwn(map, s) && !Object.hasOwn(map, v)) {
1936
2145
  throw new CliError(
1937
2146
  `--structure must be auto|combined|compound|cage|drum`
1938
2147
  );
@@ -1996,7 +2205,7 @@ function parseCliArgs(argv) {
1996
2205
  }
1997
2206
  return out;
1998
2207
  }
1999
- var CLI_HELP = `oltc \u2014 Huaming OLTC/OCTC type selection (package: oltc-selector, no prices)
2208
+ var CLI_HELP = `oltc \u2014 OLTC/OCTC type selection (package: oltc-selector, no prices)
2000
2209
 
2001
2210
  Usage:
2002
2211
  oltc --iu 400 --um 72.5 --conn Y --reg W --pm 8
@@ -2017,7 +2226,7 @@ Flags:
2017
2226
  --pos, --positions Linear / OCTC positions.
2018
2227
  --octc Off-circuit (\u65E0\u8F7D). Default on-load.
2019
2228
  --structure auto|combined|compound|cage|drum (\u7EC4\u5408\u5F0F/\u590D\u5408\u5F0F/\u7B3C\u5F0F/\u9F13\u5F0F)
2020
- --series II|IV|V|VI|VII|VIII OCTC wiring. Default auto (Y\u2192IV, D\u2192II).
2229
+ --series II|IV|V|VI|VII|VIII OCTC wiring. Default auto is linear IV (Y and D).
2021
2230
  --mount in-tank|on-tank|dry. Default in-tank.
2022
2231
  --oil / --vacuum Switching medium. Default vacuum (on-load).
2023
2232
  --contact OCTC contact e.g. 6x5.
@@ -2035,6 +2244,18 @@ function cliToSelectInput(args) {
2035
2244
  let iu = args.iu;
2036
2245
  let um = args.um;
2037
2246
  let ust = args.ust ?? 0;
2247
+ if (args.iu != null && args.mva != null) {
2248
+ throw new CliError("Give --iu or --mva/--kv, not both");
2249
+ }
2250
+ if (args.k != null && args.mva == null) {
2251
+ throw new CliError("--k applies only on the --mva path (--iu has no safety factor)");
2252
+ }
2253
+ if (args.k != null && args.k < 1) {
2254
+ throw new CliError("--k must be \u2265 1");
2255
+ }
2256
+ if (args.stepPct != null && args.mva == null) {
2257
+ throw new CliError("--step-pct needs --mva/--kv; give --ust on the --iu path");
2258
+ }
2038
2259
  if (args.mva != null) {
2039
2260
  if (!(args.kv != null && args.kv > 0)) {
2040
2261
  throw new CliError("--mva requires --kv (tap-side rated voltage)");
@@ -2103,7 +2324,7 @@ var MOUNT_ZH = {
2103
2324
  external_compartment: "\u5916\u7F6E\u9694\u5BA4",
2104
2325
  reactor: "\u7535\u6297\u5668"
2105
2326
  };
2106
- function assumptionsFromArgs(args) {
2327
+ function assumptionsFromArgs(args, family) {
2107
2328
  const mark = (key) => args.given.has(key) ? "" : "\uFF08\u9ED8\u8BA4\uFF09";
2108
2329
  const items = [
2109
2330
  `conn=${args.conn} ${args.conn === "Y" ? "\u661F\u70B9" : "\u7EBF\u7AEF"}${mark("conn")}`
@@ -2125,7 +2346,7 @@ function assumptionsFromArgs(args) {
2125
2346
  }
2126
2347
  const s = args.series ?? "auto";
2127
2348
  items.push(
2128
- s === "auto" ? `\u63A5\u7EBF=\u81EA\u52A8\uFF08${args.conn === "Y" ? "IV" : "II"}\uFF09${mark("series")}` : `\u63A5\u7EBF=${s}${mark("series")}`
2349
+ s === "auto" ? `\u63A5\u7EBF=\u81EA\u52A8\uFF08${octcRoman(args.conn, args.contact, void 0, family)}\uFF09${mark("series")}` : `\u63A5\u7EBF=${s}${mark("series")}`
2129
2350
  );
2130
2351
  items.push(`${MOUNT_ZH[args.mount]}${mark("mount")}`);
2131
2352
  items.push(phases);
@@ -2141,13 +2362,16 @@ function assumptionsFromArgs(args) {
2141
2362
  } else {
2142
2363
  items.push(`\xB1${args.pm ?? 8} \u6863${mark("pm")}`);
2143
2364
  }
2365
+ if (!args.given.has("ust") && args.mva == null) {
2366
+ items.push("Ust \u672A\u6307\u5B9A\uFF08\u7EA7\u7535\u538B\u3001\u7EA7\u5BB9\u91CF\u672A\u6821\u9A8C\uFF09");
2367
+ }
2144
2368
  items.push(`${args.oil || !args.vacuum ? "\u6CB9\u6D78" : "\u771F\u7A7A"}${mark("medium")}`);
2145
2369
  items.push(`${MOUNT_ZH[args.mount]}${mark("mount")}`);
2146
2370
  items.push(phases);
2147
2371
  return items;
2148
2372
  }
2149
- function assumptionsLine(args) {
2150
- const items = assumptionsFromArgs(args);
2373
+ function assumptionsLine(args, family) {
2374
+ const items = assumptionsFromArgs(args, family);
2151
2375
  if (items.every((i) => !i.includes("\uFF08\u9ED8\u8BA4\uFF09") && !i.includes("\u672A\u6307\u5B9A"))) {
2152
2376
  return null;
2153
2377
  }
@@ -2163,18 +2387,28 @@ function formatCliText(input, args) {
2163
2387
  if (!commercialTypeExists(primary.model)) {
2164
2388
  throw new CliError(`Engine emitted a non-catalogue type: ${primary.model}`);
2165
2389
  }
2166
- const alts = pickOtherOptions(out.results, 3);
2390
+ const alts = optionsWithInsurance(
2391
+ out.results,
2392
+ input.throughCurrentA,
2393
+ input.stepVoltageV,
2394
+ 3,
2395
+ {
2396
+ acrossTapBilKv: input.acrossTapBilKv,
2397
+ acrossTapPfKv: input.acrossTapPfKv
2398
+ }
2399
+ );
2167
2400
  const lines = [
2168
2401
  primary.model,
2169
2402
  primary.reasonsZh[0] || primary.reasonsEn[0] || "\u6700\u4F4E\u6EE1\u8DB3"
2170
2403
  ];
2404
+ for (const c of primary.cautionsZh) lines.push(`\u6CE8\u610F\uFF1A${c}`);
2171
2405
  if (alts.length) {
2172
2406
  lines.push("");
2173
2407
  lines.push("\u5176\u4ED6");
2174
2408
  for (const a of alts) lines.push(a.model);
2175
2409
  }
2176
2410
  if (args) {
2177
- const assumed = assumptionsLine(args);
2411
+ const assumed = assumptionsLine(args, primary.seriesCode);
2178
2412
  if (assumed) {
2179
2413
  lines.push("");
2180
2414
  lines.push(assumed);
@@ -2185,13 +2419,26 @@ function formatCliText(input, args) {
2185
2419
  function formatCliJson(input, args) {
2186
2420
  const out = selectOltc(input);
2187
2421
  const primary = out.results[0] ?? null;
2188
- const alts = pickOtherOptions(out.results, 3).map((r) => r.model);
2422
+ if (primary && !commercialTypeExists(primary.model)) {
2423
+ throw new CliError(`Engine emitted a non-catalogue type: ${primary.model}`);
2424
+ }
2425
+ const alts = optionsWithInsurance(
2426
+ out.results,
2427
+ input.throughCurrentA,
2428
+ input.stepVoltageV,
2429
+ 3,
2430
+ {
2431
+ acrossTapBilKv: input.acrossTapBilKv,
2432
+ acrossTapPfKv: input.acrossTapPfKv
2433
+ }
2434
+ ).map((r) => r.model);
2189
2435
  const payload = {
2190
2436
  ok: out.ok,
2191
2437
  model: primary?.model ?? null,
2192
2438
  why: primary?.reasonsZh[0] ?? primary?.reasonsEn[0] ?? null,
2193
2439
  alts,
2194
- assumptions: args ? assumptionsFromArgs(args) : [],
2440
+ cautions: primary?.cautionsZh ?? [],
2441
+ assumptions: args ? assumptionsFromArgs(args, primary?.seriesCode) : [],
2195
2442
  errors: out.errorsZh.length ? out.errorsZh : out.errorsEn
2196
2443
  };
2197
2444
  return JSON.stringify(payload, null, 2) + "\n";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oltc-selector",
3
- "version": "1.2.8",
3
+ "version": "1.3.0",
4
4
  "description": "Huaming OLTC/OCTC type selection CLI. No prices. Same engine as the web app.",
5
5
  "bin": {
6
6
  "oltc": "bin/oltc.js"