oltc-selector 1.2.9 → 2.0.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 +97 -91
  2. package/bin/oltc.js +731 -186
  3. package/package.json +1 -1
package/bin/oltc.js CHANGED
@@ -1,68 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- // lib/deriveUm.ts
4
- var RATED_TO_WINDING_UM = {
5
- 33: 40.5,
6
- 35: 40.5,
7
- 66: 72.5,
8
- 69: 72.5,
9
- 110: 126,
10
- 115: 126,
11
- 132: 145,
12
- 138: 145,
13
- 150: 170,
14
- 220: 252,
15
- 230: 252,
16
- 330: 363
17
- };
18
- var SNAP_UN = Object.keys(RATED_TO_WINDING_UM).map(Number).sort(
19
- (a, b) => a - b
20
- );
21
- function snapRatedKv(ratedKv) {
22
- if (!Number.isFinite(ratedKv) || ratedKv <= 0) return ratedKv;
23
- if (RATED_TO_WINDING_UM[ratedKv] != null) return ratedKv;
24
- let best = SNAP_UN[0];
25
- let bestDist = Math.abs(ratedKv - best);
26
- for (const u of SNAP_UN) {
27
- const d = Math.abs(ratedKv - u);
28
- if (d < bestDist) {
29
- best = u;
30
- bestDist = d;
31
- }
32
- }
33
- const rel = bestDist / Math.max(ratedKv, 1);
34
- if (rel <= 0.12 || bestDist <= 8) return best;
35
- return ratedKv;
36
- }
37
- function windingUmFromRatedKv(ratedKv) {
38
- const snapped = snapRatedKv(ratedKv);
39
- return RATED_TO_WINDING_UM[snapped] ?? snapped;
40
- }
41
- function deriveOltcUm(windingUmKv, connection) {
42
- if (connection !== "Y") return windingUmKv;
43
- if (windingUmKv >= 125.9 && windingUmKv <= 170.1) return 72.5;
44
- return windingUmKv;
45
- }
46
- function oltcUmFromRatedKv(ratedKv, connection) {
47
- return deriveOltcUm(windingUmFromRatedKv(ratedKv), connection);
48
- }
49
- function throughCurrentFromRated(mva, ratedKv, connection) {
50
- if (!(mva > 0) || !(ratedKv > 0)) return NaN;
51
- if (connection === "D") return mva * 1e3 / (3 * ratedKv);
52
- return mva * 1e3 / (Math.sqrt(3) * ratedKv);
53
- }
54
- function stepVoltageFromPercent(ratedKv, stepPercent, connection) {
55
- if (!(ratedKv > 0) || !(stepPercent > 0)) return NaN;
56
- const windingV = connection === "D" ? ratedKv * 1e3 : ratedKv * 1e3 / Math.sqrt(3);
57
- return windingV * stepPercent;
58
- }
59
- function maxThroughCurrent(ratedA, minusSteps, stepPercent) {
60
- if (!(ratedA > 0)) return NaN;
61
- if (!(minusSteps > 0) || !(stepPercent > 0)) return ratedA;
62
- const drop = minusSteps * stepPercent;
63
- if (drop <= 0) return ratedA;
64
- const denom = 1 - Math.min(drop, 0.45);
65
- return ratedA / denom;
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 };
66
15
  }
67
16
 
68
17
  // lib/tapCode.ts
@@ -141,6 +90,11 @@ function lookupDiagram(n, mid, regulation) {
141
90
  (d) => d.plusMinus === n && d.mid === mid
142
91
  ) ?? null;
143
92
  }
93
+ function lookupByPositions(positions, mid, regulation) {
94
+ return diagramsFor(regulation).find(
95
+ (d) => d.positions === positions && d.mid === mid
96
+ ) ?? null;
97
+ }
144
98
  function pitchFor(n, mid) {
145
99
  if (mid === 3) return n + 2;
146
100
  if (n <= 8) return 2 * n + 2;
@@ -241,6 +195,12 @@ function buildTapCode(opts) {
241
195
  }
242
196
  function resolveTapFields(input) {
243
197
  const reg = input.regulation;
198
+ const isStandard = (positions2, mid2, pitch2) => {
199
+ if (reg === "linear") return true;
200
+ if (mid2 !== 1 && mid2 !== 3) return false;
201
+ const row = lookupByPositions(positions2, mid2, reg);
202
+ return row != null && row.pitch === pitch2;
203
+ };
244
204
  if (reg === "linear") {
245
205
  const positions2 = input.positions ?? 9;
246
206
  const pitch2 = input.pitch ?? defaultPitch(positions2, reg);
@@ -250,7 +210,8 @@ function resolveTapFields(input) {
250
210
  pitch: pitch2,
251
211
  mid: mid2,
252
212
  tapCode: buildTapCode({ pitch: pitch2, positions: positions2, mid: mid2, regulation: reg }),
253
- changeOver: "0"
213
+ changeOver: "0",
214
+ standard: true
254
215
  };
255
216
  }
256
217
  if (input.plusMinusSteps != null && input.plusMinusSteps > 0) {
@@ -270,7 +231,8 @@ function resolveTapFields(input) {
270
231
  pitch: pitch2,
271
232
  mid: mid2,
272
233
  tapCode: buildTapCode({ pitch: pitch2, positions: positions2, mid: mid2, regulation: reg }),
273
- changeOver: changeOverOf(reg)
234
+ changeOver: changeOverOf(reg),
235
+ standard: row != null && isStandard(positions2, mid2, pitch2)
274
236
  };
275
237
  }
276
238
  let positions = input.positions ?? 19;
@@ -288,7 +250,8 @@ function resolveTapFields(input) {
288
250
  pitch,
289
251
  mid,
290
252
  tapCode: buildTapCode({ pitch, positions, mid, regulation: reg }),
291
- changeOver: changeOverOf(reg)
253
+ changeOver: changeOverOf(reg),
254
+ standard: isStandard(positions, mid, pitch)
292
255
  };
293
256
  }
294
257
 
@@ -879,8 +842,8 @@ var SERIES = [
879
842
  maxPositionsLinear: 18,
880
843
  maxPositionsWithChangeOver: 18,
881
844
  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",
845
+ 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.",
846
+ 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
847
  rank: 5
885
848
  },
886
849
  {
@@ -948,45 +911,37 @@ function firstAllowedAtOrAbove(min, allowed) {
948
911
  }
949
912
  return allowed[allowed.length - 1] ?? "B";
950
913
  }
951
- function pickSelectorSize(um, requested, bilKv, pfKv, acrossTapBilKv, acrossTapPfKv) {
914
+ function coversAcrossTap(size, needALi, needAPf) {
915
+ const ins = INTERNAL_INSULATION[size];
916
+ return ins.a_li + 0.5 >= needALi && ins.a_pf + 0.5 >= needAPf;
917
+ }
918
+ function resolveSelectorSize(um, requested, acrossTapBilKv, acrossTapPfKv) {
952
919
  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
920
  const needALi = acrossTapBilKv ?? 0;
975
921
  const needAPf = acrossTapPfKv ?? 0;
976
- const floorIdx = SIZE_ORDER.indexOf(floor);
977
- for (let i = floorIdx; i < SIZE_ORDER.length; i++) {
922
+ const typed = requested && requested !== "auto" ? requested : null;
923
+ const floor = firstAllowedAtOrAbove(
924
+ typed ?? defaultSelectorSizeForUm(um),
925
+ allowed
926
+ );
927
+ for (let i = SIZE_ORDER.indexOf(floor); i < SIZE_ORDER.length; i++) {
978
928
  const cand = SIZE_ORDER[i];
979
929
  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;
930
+ if (!coversAcrossTap(cand, needALi, needAPf)) continue;
931
+ return typed && cand !== typed ? { size: cand, raisedFrom: typed } : { size: cand };
983
932
  }
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;
933
+ return { size: null };
934
+ }
935
+ function umForEarthInsulation(umKv, bilKv, pfKv) {
936
+ const needBil = bilKv ?? 0;
937
+ const needPf = pfKv ?? 0;
938
+ const classes = Object.keys(EARTH_INSULATION).map(Number).sort((a, b) => a - b);
939
+ for (const u of classes) {
940
+ if (u < umKv - 0.01) continue;
941
+ const e = EARTH_INSULATION[u];
942
+ if (e.bil + 0.5 >= needBil && e.pf + 0.5 >= needPf) return u;
988
943
  }
989
- return allowed[allowed.length - 1];
944
+ return null;
990
945
  }
991
946
 
992
947
  // lib/listIndex.data.json
@@ -1237,14 +1192,15 @@ function octcSizeLetter(um, contact, requested) {
1237
1192
  }
1238
1193
  return "B";
1239
1194
  }
1240
- function octcRoman(connection, contact, series) {
1195
+ function octcRoman(connection, contact, series, familyCode) {
1241
1196
  if (series && series !== "auto") return series;
1242
1197
  const c = (contact ?? "").toLowerCase();
1243
1198
  if (c === "5x2" || c === "12x2") return "VIII";
1244
1199
  if (c === "3x2" || c === "6x2") return "VI";
1245
1200
  if (c === "5x4" || c === "4x3") return "V";
1246
1201
  if (c === "12x12") return "VII";
1247
- return connection === "D" ? "II" : "IV";
1202
+ if (familyCode === "WSG" && connection === "D") return "II";
1203
+ return "IV";
1248
1204
  }
1249
1205
  function isOctcSeries(s) {
1250
1206
  return s.dutyKind === "octc";
@@ -1279,7 +1235,8 @@ function buildModelString(series, phases, current, connection, umToken, tapCode,
1279
1235
  const roman = octcRoman(
1280
1236
  yd,
1281
1237
  tapCode.replace(/[A-E]$/i, ""),
1282
- octcSeries
1238
+ octcSeries,
1239
+ series.code
1283
1240
  );
1284
1241
  core = `${series.code}${roman}-${current}${yd}/${umToken}-${tapCode}`;
1285
1242
  } else if (series.code === "HWDK") {
@@ -1304,6 +1261,7 @@ function seriesMatchesMounting(s, input) {
1304
1261
  return s.mounting.includes("in_tank");
1305
1262
  }
1306
1263
  function seriesMatchesMedium(s, input) {
1264
+ if (input.dutyKind === "octc") return s.medium === "oil" && !s.vacuum;
1307
1265
  if (input.mounting === "dry_type") return s.medium === "dry";
1308
1266
  if (input.preferVacuum) return true;
1309
1267
  if (input.medium === "oil_vacuum") return s.vacuum || s.medium === "oil_vacuum";
@@ -1350,7 +1308,7 @@ function buildAttempts(s, input) {
1350
1308
  );
1351
1309
  if (!covering.length) return out;
1352
1310
  const um0 = covering[0];
1353
- const ums = (FAMILY_MIN_RANK[s.id] ?? s.rank) < 40 ? covering : [um0];
1311
+ const ums = !isOctcSeries(s) && (FAMILY_MIN_RANK[s.id] ?? s.rank) < 40 ? covering : [um0];
1354
1312
  if (s.id === "cz") {
1355
1313
  const curI = nearestCurrent(input.throughCurrentA, s.currents.I ?? []);
1356
1314
  if (curI != null && ratingCoversDuty(input.throughCurrentA, curI)) {
@@ -1432,21 +1390,37 @@ function diversifyResults(ranked) {
1432
1390
  function selectOltc(input) {
1433
1391
  const errorsEn = [];
1434
1392
  const errorsZh = [];
1435
- if (!input.throughCurrentA || input.throughCurrentA <= 0) {
1393
+ if (!(Number.isFinite(input.throughCurrentA) && input.throughCurrentA > 0)) {
1436
1394
  errorsEn.push("Enter rated through-current (A).");
1437
1395
  errorsZh.push("\u8BF7\u586B\u5199\u989D\u5B9A\u901A\u8FC7\u7535\u6D41\uFF08A\uFF09\u3002");
1438
1396
  }
1439
- if (!input.umKv || input.umKv <= 0) {
1397
+ if (!(Number.isFinite(input.umKv) && input.umKv > 0)) {
1440
1398
  errorsEn.push("Enter highest voltage for equipment Um (kV).");
1441
1399
  errorsZh.push("\u8BF7\u586B\u5199\u8BBE\u5907\u6700\u9AD8\u7535\u538B Um\uFF08kV\uFF09\u3002");
1442
1400
  }
1443
- if (input.stepVoltageV < 0) {
1444
- errorsEn.push("Step voltage cannot be negative.");
1445
- errorsZh.push("\u7EA7\u7535\u538B\u4E0D\u80FD\u4E3A\u8D1F\u3002");
1401
+ if (!Number.isFinite(input.stepVoltageV) || input.stepVoltageV < 0) {
1402
+ errorsEn.push("Step voltage must be a number \u2265 0 (0 = not given).");
1403
+ errorsZh.push("\u7EA7\u7535\u538B\u987B\u4E3A \u2265 0 \u7684\u6570\u5B57\uFF080 \u8868\u793A\u672A\u7ED9\uFF09\u3002");
1446
1404
  }
1447
1405
  if (errorsEn.length) {
1448
1406
  return { ok: false, results: [], errorsEn, errorsZh };
1449
1407
  }
1408
+ if ((input.bilKv ?? 0) > 0 || (input.pfKv ?? 0) > 0) {
1409
+ const earthUm = umForEarthInsulation(input.umKv, input.bilKv, input.pfKv);
1410
+ if (earthUm == null) {
1411
+ return {
1412
+ ok: false,
1413
+ results: [],
1414
+ errorsEn: [
1415
+ `Earth insulation LI ${input.bilKv ?? "\u2014"} / PF ${input.pfKv ?? "\u2014"} kV is above every catalogue Um. Contact engineering.`
1416
+ ],
1417
+ errorsZh: [
1418
+ `\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`
1419
+ ]
1420
+ };
1421
+ }
1422
+ if (earthUm > input.umKv + 0.01) input = { ...input, umKv: earthUm };
1423
+ }
1450
1424
  const tap = resolveTapFields({
1451
1425
  regulation: input.regulation,
1452
1426
  positions: input.positions,
@@ -1464,6 +1438,21 @@ function selectOltc(input) {
1464
1438
  return s.connections.includes(input.connection) || s.connections.includes("any");
1465
1439
  });
1466
1440
  const wantStruct = input.preferStructure;
1441
+ if (input.transformerKind === "auto" && !wantOctc) {
1442
+ if (wantStruct === "compound") {
1443
+ return {
1444
+ ok: false,
1445
+ results: [],
1446
+ errorsEn: [
1447
+ "Autotransformers take combined types only: compound types (CV/CV2/SV) stop at 200 kV across the tap winding."
1448
+ ],
1449
+ errorsZh: [
1450
+ "\u81EA\u8026\u53D8\u53EA\u7528\u7EC4\u5408\u5F0F\uFF1A\u590D\u5408\u5F0F\uFF08CV/CV2/SV\uFF09\u8DE8\u8C03\u538B\u7ED5\u7EC4\u51B2\u51FB\u4E0A\u9650 200 kV\u3002"
1451
+ ]
1452
+ };
1453
+ }
1454
+ candidates = candidates.filter((s) => s.structure !== "compound");
1455
+ }
1467
1456
  if (wantStruct && wantStruct !== "auto") {
1468
1457
  candidates = candidates.filter((s) => s.structure === wantStruct);
1469
1458
  }
@@ -1481,8 +1470,12 @@ function selectOltc(input) {
1481
1470
  }
1482
1471
  const results = [];
1483
1472
  const seen = /* @__PURE__ */ new Set();
1473
+ let acrossTapShort = false;
1484
1474
  for (const s of candidates) {
1485
- if (!compoundCoversAcrossTap(s, input)) continue;
1475
+ if (!compoundCoversAcrossTap(s, input)) {
1476
+ acrossTapShort = true;
1477
+ continue;
1478
+ }
1486
1479
  if (!isOctcSeries(s)) {
1487
1480
  const pitchMaxUst = maxStepVoltageForSeries(s, tap.pitch);
1488
1481
  if (input.stepVoltageV > pitchMaxUst + 0.5) continue;
@@ -1503,32 +1496,32 @@ function selectOltc(input) {
1503
1496
  if (psin != null && need > psin + 0.5) return false;
1504
1497
  return true;
1505
1498
  };
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
- }
1499
+ const covering = phaseCurrents.filter(
1500
+ (c) => ratingCoversDuty(input.throughCurrentA, c) && capacityOk(c)
1501
+ );
1519
1502
  if (!covering.length) continue;
1520
1503
  const currentsToEmit = covering.slice(0, 2);
1504
+ const topEmitted = Math.max(...currentsToEmit);
1505
+ const stepUpCurrent = [...phaseCurrents].sort((a, b) => a - b).find(
1506
+ (c) => c > topEmitted + 0.5 && ratingCoversDuty(input.throughCurrentA, c) && capacityOk(c)
1507
+ );
1508
+ if (stepUpCurrent != null && !currentsToEmit.includes(stepUpCurrent)) {
1509
+ currentsToEmit.push(stepUpCurrent);
1510
+ }
1521
1511
  for (const current of currentsToEmit) {
1522
1512
  const octc = isOctcSeries(s);
1523
1513
  const contact = octc ? octcContactCode(input, s.id) : "";
1524
- const selectorSize = octc ? octcSizeLetter(att.um, contact, input.selectorSize ?? "auto") : s.usesSelectorSize ? pickSelectorSize(
1514
+ const gradePick = !octc && s.usesSelectorSize ? resolveSelectorSize(
1525
1515
  att.um,
1526
1516
  input.selectorSize ?? "auto",
1527
- input.bilKv,
1528
- input.pfKv,
1529
1517
  input.acrossTapBilKv,
1530
1518
  input.acrossTapPfKv
1531
- ) : "";
1519
+ ) : null;
1520
+ if (gradePick && gradePick.size == null) {
1521
+ acrossTapShort = true;
1522
+ continue;
1523
+ }
1524
+ const selectorSize = octc ? octcSizeLetter(att.um, contact, input.selectorSize ?? "auto") : gradePick?.size ?? "";
1532
1525
  const tapCode = octc ? contact : tap.tapCode;
1533
1526
  const modelTap = octc ? `${contact}${selectorSize}` : s.id === "cz" || s.id === "hwdk" ? String(tap.positions) : tap.tapCode;
1534
1527
  const umToken = formatUmToken(att.um, selectorSize, s.usesSelectorSize);
@@ -1582,6 +1575,47 @@ function selectOltc(input) {
1582
1575
  const reasonsZh = [];
1583
1576
  const warningsEn = [];
1584
1577
  const warningsZh = [];
1578
+ const cautionsEn = [];
1579
+ const cautionsZh = [];
1580
+ if (input.throughCurrentA > current + 0.01) {
1581
+ const pct = ((input.throughCurrentA / current - 1) * 100).toFixed(1);
1582
+ cautionsEn.push(
1583
+ `Duty ${input.throughCurrentA.toFixed(1)} A is ${pct}% above the ${current} A rating (1% commercial tolerance). Confirm with engineering.`
1584
+ );
1585
+ cautionsZh.push(
1586
+ `\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`
1587
+ );
1588
+ }
1589
+ if (!octc && !(input.stepVoltageV > 0)) {
1590
+ cautionsEn.push(
1591
+ "Step voltage not given: step-voltage and step-capacity limits were not checked."
1592
+ );
1593
+ cautionsZh.push("\u672A\u7ED9\u7EA7\u7535\u538B\uFF1A\u7EA7\u7535\u538B\u548C\u7EA7\u5BB9\u91CF\u90FD\u6CA1\u6709\u6821\u9A8C\u3002");
1594
+ }
1595
+ if (!octc && !tap.standard) {
1596
+ cautionsEn.push(
1597
+ `Tap code ${tap.tapCode} is not a brochure Fig. 3-3 diagram. Engineering must confirm the connection.`
1598
+ );
1599
+ cautionsZh.push(
1600
+ `\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`
1601
+ );
1602
+ }
1603
+ if (gradePick?.raisedFrom) {
1604
+ cautionsEn.push(
1605
+ `Selector grade raised from ${gradePick.raisedFrom} to ${selectorSize} (Um ${att.um} kV / across-tap stress).`
1606
+ );
1607
+ cautionsZh.push(
1608
+ `\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`
1609
+ );
1610
+ }
1611
+ if (!octc && !s.usesSelectorSize && s.structure !== "compound" && ((input.acrossTapBilKv ?? 0) > 0 || (input.acrossTapPfKv ?? 0) > 0)) {
1612
+ cautionsEn.push(
1613
+ `${s.code} across-tap withstand is not in the catalogue data: across-tap stress not checked.`
1614
+ );
1615
+ cautionsZh.push(
1616
+ `${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`
1617
+ );
1618
+ }
1585
1619
  const dutyA = input.throughCurrentA >= 100 ? String(Math.round(input.throughCurrentA)) : String(Math.round(input.throughCurrentA * 10) / 10);
1586
1620
  reasonsEn.push(
1587
1621
  `Minimum-adequate path: ${s.nameEn}, Ium ${current} A \u2265 ${dutyA} A, Um ${att.um} kV.`
@@ -1606,7 +1640,7 @@ function selectOltc(input) {
1606
1640
  );
1607
1641
  }
1608
1642
  if (octc) {
1609
- const roman = octcRoman(conn, contact, input.octcSeries);
1643
+ const roman = octcRoman(conn, contact, input.octcSeries, s.code);
1610
1644
  reasonsEn.push(
1611
1645
  `OCTC contact ${contact}${selectorSize} (${s.code}${roman}).`
1612
1646
  );
@@ -1674,6 +1708,7 @@ function selectOltc(input) {
1674
1708
  const stepCapacityKva = s.stepCapacityByCurrent?.[current] ?? null;
1675
1709
  let confidence = 0.88;
1676
1710
  if (att.unitCount > 1) confidence -= 0.08;
1711
+ confidence -= 0.05 * cautionsEn.length;
1677
1712
  if (warningsEn.length > 2) confidence -= 0.03;
1678
1713
  confidence = Math.max(0.45, Math.min(0.96, confidence));
1679
1714
  results.push({
@@ -1703,6 +1738,8 @@ function selectOltc(input) {
1703
1738
  reasonsZh,
1704
1739
  warningsEn,
1705
1740
  warningsZh,
1741
+ cautionsEn,
1742
+ cautionsZh,
1706
1743
  confidence,
1707
1744
  adequacyScore: score
1708
1745
  });
@@ -1710,7 +1747,12 @@ function selectOltc(input) {
1710
1747
  }
1711
1748
  }
1712
1749
  let final = results;
1713
- if (input.preferVacuum) {
1750
+ if (wantOctc) {
1751
+ final = results.filter((r) => {
1752
+ const s = SERIES.find((x) => x.id === r.seriesId);
1753
+ return s != null && s.medium === "oil" && !s.vacuum;
1754
+ });
1755
+ } else if (input.preferVacuum) {
1714
1756
  final = results.filter(
1715
1757
  (r) => SERIES.find((s) => s.id === r.seriesId)?.vacuum
1716
1758
  );
@@ -1730,10 +1772,10 @@ function selectOltc(input) {
1730
1772
  ok: false,
1731
1773
  results: [],
1732
1774
  errorsEn: [
1733
- "Parameters out of catalogue range (current, Um, step voltage, or positions)."
1775
+ 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)."
1734
1776
  ],
1735
1777
  errorsZh: [
1736
- "\u53C2\u6570\u8D85\u51FA\u76EE\u5F55\u8303\u56F4\uFF08\u7535\u6D41\u3001Um\u3001\u7EA7\u7535\u538B\u6216\u6863\u4F4D\u6570\uFF09\u3002"
1778
+ 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"
1737
1779
  ]
1738
1780
  };
1739
1781
  }
@@ -1749,26 +1791,355 @@ function stepUpOf(primary, results) {
1749
1791
  (r) => r.model !== primary.model && r.seriesId === primary.seriesId && r.phases === primary.phases && r.unitCount === primary.unitCount && r.currentA > primary.currentA
1750
1792
  );
1751
1793
  if (!same.length) return null;
1752
- same.sort((a, b) => a.currentA - b.currentA);
1794
+ same.sort((a, b) => {
1795
+ const aUm = Math.abs(a.umKv - primary.umKv) < 0.1 ? 0 : 1;
1796
+ const bUm = Math.abs(b.umKv - primary.umKv) < 0.1 ? 0 : 1;
1797
+ return aUm - bUm || a.currentA - b.currentA;
1798
+ });
1753
1799
  return same[0];
1754
1800
  }
1755
- function pickOtherOptions(results, n = 3) {
1756
- if (results.length <= 1) return [];
1801
+ var NEXT_FAMILY = {
1802
+ cv2: "cm2",
1803
+ cm2: "shzv",
1804
+ cv: "sv",
1805
+ sv: "cm",
1806
+ cm: "cmd"
1807
+ };
1808
+ function sameMachine(a, b) {
1809
+ return a.unitCount === b.unitCount && a.phases === b.phases;
1810
+ }
1811
+ function nextSingleIii(primary, results) {
1812
+ if (primary.seriesId !== "shzv" || primary.currentA + 0.5 < 1e3) return null;
1813
+ const later = results.filter(
1814
+ (r) => r.seriesId === "shzvg" && sameMachine(r, primary) && r.currentA + 0.5 >= primary.currentA && r.umKv + 0.1 >= primary.umKv
1815
+ );
1816
+ later.sort((a, b) => a.currentA - b.currentA || a.umKv - b.umKv);
1817
+ return later[0] ?? null;
1818
+ }
1819
+ var CURRENT_LINE = 0.95;
1820
+ var STEP_VOLTAGE_LINE = 0.9;
1821
+ var STEP_CAPACITY_LINE = 0.95;
1822
+ var INSULATION_LINE = 0.95;
1823
+ var LINE_EPS = 1e-9;
1824
+ function pastLine(use, line) {
1825
+ return use > line + LINE_EPS;
1826
+ }
1827
+ function insulationUse(row, need) {
1828
+ const bil = need?.acrossTapBilKv ?? 0;
1829
+ const pf = need?.acrossTapPfKv ?? 0;
1830
+ if (bil <= 0 && pf <= 0) return 0;
1831
+ const series = SERIES.find((s) => s.id === row.seriesId);
1832
+ let aLi = 0;
1833
+ let aPf = 0;
1834
+ if (series?.structure === "compound") {
1835
+ aLi = 200;
1836
+ aPf = 50;
1837
+ } else if (row.selectorSize) {
1838
+ const ins = INTERNAL_INSULATION[row.selectorSize];
1839
+ aLi = ins?.a_li ?? 0;
1840
+ aPf = ins?.a_pf ?? 0;
1841
+ }
1842
+ let peak = 0;
1843
+ if (bil > 0 && aLi > 0) peak = Math.max(peak, bil / aLi);
1844
+ if (pf > 0 && aPf > 0) peak = Math.max(peak, pf / aPf);
1845
+ return peak;
1846
+ }
1847
+ function primaryIsInsurance(primary, dutyA, stepVoltageV, need) {
1848
+ if (!(dutyA > 0) || !(primary.currentA > dutyA)) return false;
1849
+ const u = dutyUse(primary, dutyA, stepVoltageV, need);
1850
+ return !pastLine(u.iUse, CURRENT_LINE) && !pastLine(u.uUse, STEP_VOLTAGE_LINE) && !pastLine(u.pUse, STEP_CAPACITY_LINE) && !pastLine(u.nUse, INSULATION_LINE);
1851
+ }
1852
+ function dutyUse(row, dutyA, stepVoltageV, need) {
1853
+ const iUse = row.currentA > 0 ? dutyA / row.currentA : 1;
1854
+ const uUse = stepVoltageV > 0 && row.maxStepVoltageV && row.maxStepVoltageV > 0 ? stepVoltageV / row.maxStepVoltageV : 0;
1855
+ const needKva = stepVoltageV > 0 ? dutyA * stepVoltageV / 1e3 : 0;
1856
+ const pUse = needKva > 0 && row.stepCapacityKva && row.stepCapacityKva > 0 ? needKva / row.stepCapacityKva : 0;
1857
+ return { iUse, uUse, pUse, nUse: insulationUse(row, need) };
1858
+ }
1859
+ function currentStepInsures(primary, step, dutyA, stepVoltageV, need) {
1860
+ const a = dutyUse(primary, dutyA, stepVoltageV, need);
1861
+ if (a.uUse >= a.iUse - 1e-9) return false;
1862
+ if (a.pUse >= a.iUse - 1e-9) return false;
1863
+ if (a.nUse >= a.iUse - 1e-9) return false;
1864
+ const b = dutyUse(step, dutyA, stepVoltageV, need);
1865
+ return b.iUse < a.iUse - 1e-9;
1866
+ }
1867
+ function familyInsures(primary, family, dutyA, stepVoltageV, need) {
1868
+ const a = dutyUse(primary, dutyA, stepVoltageV, need);
1869
+ const b = dutyUse(family, dutyA, stepVoltageV, need);
1870
+ const peak = Math.max(a.iUse, a.uUse, a.pUse, a.nUse);
1871
+ const next = Math.max(b.iUse, b.uUse, b.pUse, b.nUse);
1872
+ return next < peak - 1e-9;
1873
+ }
1874
+ function insuringOnFamily(seriesId, primary, results, dutyA, stepVoltageV, need) {
1875
+ const cands = results.filter(
1876
+ (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)
1877
+ );
1878
+ if (!cands.length) return null;
1879
+ cands.sort((a, b) => {
1880
+ const aUm = Math.abs(a.umKv - primary.umKv) < 0.1 ? 0 : 1;
1881
+ const bUm = Math.abs(b.umKv - primary.umKv) < 0.1 ? 0 : 1;
1882
+ return aUm - bUm || a.umKv - b.umKv || a.currentA - b.currentA;
1883
+ });
1884
+ return cands[0] ?? null;
1885
+ }
1886
+ function insuranceModel(results, dutyA, stepVoltageV, need) {
1757
1887
  const primary = results[0];
1758
- const stepUp = stepUpOf(primary, results);
1759
- const preferred = [];
1760
- const overflow = [];
1761
- if (stepUp) preferred.push(stepUp);
1762
- for (const r of results.slice(1)) {
1763
- if (r.model === primary.model) continue;
1764
- if (preferred.some((x) => x.model === r.model)) continue;
1765
- const sameFamilyUm = preferred.some(
1766
- (x) => x.seriesCode === r.seriesCode && Math.abs(x.umKv - r.umKv) < 0.1
1888
+ if (!primary) return null;
1889
+ if (primaryIsInsurance(primary, dutyA, stepVoltageV, need)) return null;
1890
+ const step = stepUpOf(primary, results);
1891
+ if (step && currentStepInsures(primary, step, dutyA, stepVoltageV, need)) {
1892
+ return step.model;
1893
+ }
1894
+ const seen = /* @__PURE__ */ new Set();
1895
+ let seriesId = primary.seriesId;
1896
+ while (seriesId && !seen.has(seriesId)) {
1897
+ seen.add(seriesId);
1898
+ const nextId = NEXT_FAMILY[seriesId];
1899
+ if (!nextId) break;
1900
+ const hit = insuringOnFamily(
1901
+ nextId,
1902
+ primary,
1903
+ results,
1904
+ dutyA,
1905
+ stepVoltageV,
1906
+ need
1767
1907
  );
1768
- if (sameFamilyUm) overflow.push(r);
1769
- else preferred.push(r);
1908
+ if (hit) return hit.model;
1909
+ seriesId = nextId;
1910
+ }
1911
+ const single = nextSingleIii(primary, results);
1912
+ if (single && familyInsures(primary, single, dutyA, stepVoltageV, need)) {
1913
+ return single.model;
1914
+ }
1915
+ return null;
1916
+ }
1917
+ function optionsWithInsurance(results, dutyA, stepVoltageV, n = 3, need) {
1918
+ const primary = results[0];
1919
+ if (!primary) return [];
1920
+ const id = insuranceModel(results, dutyA, stepVoltageV, need);
1921
+ if (id) {
1922
+ const found = results.find((r) => r.model === id);
1923
+ return found ? [found].slice(0, n) : [];
1770
1924
  }
1771
- return [...preferred, ...overflow].slice(0, n);
1925
+ const step = stepUpOf(primary, results);
1926
+ return step ? [step].slice(0, n) : [];
1927
+ }
1928
+
1929
+ // lib/deriveUm.ts
1930
+ var RATED_TO_WINDING_UM = {
1931
+ 33: 40.5,
1932
+ 35: 40.5,
1933
+ 66: 72.5,
1934
+ 69: 72.5,
1935
+ 110: 126,
1936
+ 115: 126,
1937
+ 132: 145,
1938
+ 138: 145,
1939
+ 150: 170,
1940
+ 220: 252,
1941
+ 230: 252,
1942
+ 330: 363
1943
+ };
1944
+ var SNAP_UN = Object.keys(RATED_TO_WINDING_UM).map(Number).sort(
1945
+ (a, b) => a - b
1946
+ );
1947
+ var IEC_UM = [
1948
+ 3.6,
1949
+ 7.2,
1950
+ 12,
1951
+ 17.5,
1952
+ 24,
1953
+ 36,
1954
+ 40.5,
1955
+ 52,
1956
+ 72.5,
1957
+ 100,
1958
+ 123,
1959
+ 145,
1960
+ 170,
1961
+ 245,
1962
+ 300,
1963
+ 362,
1964
+ 420,
1965
+ 550,
1966
+ 800
1967
+ ];
1968
+ var CATALOGUE_UM = [12, 17.5, 40.5, 72.5, 126, 145, 170, 252, 300, 363];
1969
+ function nominalSystemKv(ratedKv) {
1970
+ let best = ratedKv;
1971
+ for (const u of SNAP_UN) {
1972
+ if (u <= ratedKv && (ratedKv - u) / ratedKv <= 0.12) best = u;
1973
+ }
1974
+ return best;
1975
+ }
1976
+ function iecUmFromRatedKv(ratedKv) {
1977
+ if (!(ratedKv > 0)) return NaN;
1978
+ const un = nominalSystemKv(ratedKv);
1979
+ return IEC_UM.find((u) => u >= un * 1.04) ?? NaN;
1980
+ }
1981
+ function catalogueUmFromRatedKv(ratedKv) {
1982
+ const um = iecUmFromRatedKv(ratedKv);
1983
+ if (!Number.isFinite(um)) return NaN;
1984
+ return CATALOGUE_UM.find((c) => c >= um - 1e-9) ?? um;
1985
+ }
1986
+ function maxThroughCurrent(ratedA, minusSteps, stepPercent) {
1987
+ if (!(ratedA > 0)) return NaN;
1988
+ if (!(minusSteps > 0) || !(stepPercent > 0)) return ratedA;
1989
+ const drop = minusSteps * stepPercent;
1990
+ if (drop <= 0) return ratedA;
1991
+ const denom = 1 - Math.min(drop, 0.45);
1992
+ return ratedA / denom;
1993
+ }
1994
+
1995
+ // lib/transformer.ts
1996
+ var TAP_POINTS_FOR = {
1997
+ two_winding: ["neutral", "line_end"],
1998
+ auto: ["auto_junction", "auto_mv_line"]
1999
+ };
2000
+ var SQRT3 = Math.sqrt(3);
2001
+ var fail = (zh, en) => ({
2002
+ ok: false,
2003
+ errorZh: zh,
2004
+ errorEn: en,
2005
+ connection: "Y",
2006
+ umSystemKv: NaN,
2007
+ actualUmKv: NaN,
2008
+ umKv: NaN,
2009
+ umRule: "line",
2010
+ umAssumed: false,
2011
+ ratedA: NaN,
2012
+ maxA: NaN,
2013
+ dutyA: NaN,
2014
+ currentKv: NaN,
2015
+ currentDivisor: "sqrt3",
2016
+ stepV: null,
2017
+ combinedOnly: false,
2018
+ cautionsZh: [],
2019
+ cautionsEn: []
2020
+ });
2021
+ var NEUTRAL_DEFAULT_UM = 72.5;
2022
+ function deriveDuty(spec) {
2023
+ const cautionsZh = [];
2024
+ const cautionsEn = [];
2025
+ const auto = spec.kind === "auto";
2026
+ if (!TAP_POINTS_FOR[spec.kind].includes(spec.tapPoint)) {
2027
+ return fail(
2028
+ "\u5F00\u5173\u4F4D\u7F6E\u548C\u53D8\u538B\u5668\u79CD\u7C7B\u4E0D\u5339\u914D\u3002",
2029
+ "Tap position does not fit the transformer kind."
2030
+ );
2031
+ }
2032
+ if (auto) {
2033
+ if (!(spec.hvKv > 0) || !(spec.mvKv > 0)) {
2034
+ return fail("\u81EA\u8026\u53D8\u8981\u586B\u9AD8\u538B\u548C\u4E2D\u538B\u989D\u5B9A\u7535\u538B\u3002", "Enter the autotransformer's HV and MV rated voltage.");
2035
+ }
2036
+ if (!(spec.hvKv > spec.mvKv)) {
2037
+ return fail("\u81EA\u8026\u53D8\u9AD8\u538B\u8981\u9AD8\u4E8E\u4E2D\u538B\u3002", "Autotransformer HV must be above MV.");
2038
+ }
2039
+ } else {
2040
+ if (!(spec.tapKv > 0)) {
2041
+ return fail("\u8BF7\u586B\u5199\u8C03\u538B\u7ED5\u7EC4\u989D\u5B9A\u7535\u538B\u3002", "Enter the tapped winding's rated voltage.");
2042
+ }
2043
+ if (spec.tapPoint === "neutral" && spec.winding === "delta") {
2044
+ return fail(
2045
+ "\u89D2\u5F62\u7ED5\u7EC4\u6CA1\u6709\u4E2D\u6027\u70B9\uFF0C\u5F00\u5173\u53EA\u80FD\u5728\u7EBF\u7AEF\u3002",
2046
+ "A delta winding has no neutral; the tap changer sits at the line end."
2047
+ );
2048
+ }
2049
+ }
2050
+ let currentKv;
2051
+ let currentDivisor;
2052
+ let stepBaseV;
2053
+ if (auto) {
2054
+ currentKv = spec.tapPoint === "auto_junction" ? spec.hvKv : spec.mvKv;
2055
+ currentDivisor = "sqrt3";
2056
+ stepBaseV = currentKv * 1e3 / SQRT3;
2057
+ } else if (spec.winding === "delta") {
2058
+ currentKv = spec.tapKv;
2059
+ currentDivisor = "three";
2060
+ stepBaseV = spec.tapKv * 1e3;
2061
+ } else {
2062
+ currentKv = spec.tapKv;
2063
+ currentDivisor = "sqrt3";
2064
+ stepBaseV = spec.tapKv * 1e3 / SQRT3;
2065
+ }
2066
+ const ratedA = spec.mva > 0 ? spec.mva * 1e3 / ((currentDivisor === "three" ? 3 : SQRT3) * currentKv) : NaN;
2067
+ const maxA = spec.stepFraction != null && spec.stepFraction > 0 ? maxThroughCurrent(ratedA, spec.minusSteps, spec.stepFraction) : ratedA;
2068
+ const k = spec.safetyK > 0 ? spec.safetyK : 1;
2069
+ const stepV = spec.stepFraction != null && spec.stepFraction > 0 ? stepBaseV * spec.stepFraction : null;
2070
+ let umSystemKv;
2071
+ let umKv;
2072
+ let umRule;
2073
+ let umAssumed = false;
2074
+ if (auto) {
2075
+ umSystemKv = spec.hvKv;
2076
+ umKv = catalogueUmFromRatedKv(spec.hvKv);
2077
+ umRule = "auto_hv";
2078
+ } else if (spec.tapPoint === "neutral") {
2079
+ umSystemKv = spec.tapKv;
2080
+ const lineClass = catalogueUmFromRatedKv(spec.tapKv);
2081
+ if (lineClass <= NEUTRAL_DEFAULT_UM) {
2082
+ umKv = lineClass;
2083
+ umRule = "neutral_full";
2084
+ if (lineClass === 40.5) umAssumed = true;
2085
+ } else {
2086
+ umKv = NEUTRAL_DEFAULT_UM;
2087
+ umRule = "neutral_assumed";
2088
+ umAssumed = true;
2089
+ }
2090
+ } else {
2091
+ umSystemKv = spec.tapKv;
2092
+ umKv = catalogueUmFromRatedKv(spec.tapKv);
2093
+ umRule = "line";
2094
+ }
2095
+ if (!Number.isFinite(umKv) || umKv > 363) {
2096
+ return fail(
2097
+ "\u7535\u538B\u8D85\u51FA\u76EE\u5F55\uFF1A\u5F00\u5173\u6700\u9AD8 Um 363 kV\u3002",
2098
+ "Voltage above the catalogue: the highest switch class is Um 363 kV."
2099
+ );
2100
+ }
2101
+ if (spec.earthUmKv != null && spec.earthUmKv > 0) {
2102
+ umKv = spec.earthUmKv;
2103
+ umRule = "explicit";
2104
+ umAssumed = false;
2105
+ }
2106
+ if (umRule === "neutral_full" && umAssumed) {
2107
+ cautionsZh.push("35 kV \u7EA7\u4E2D\u6027\u70B9\u5148\u6309 Um 40.5 \u9009\uFF1B\u4E0D\u5C11\u8BA2\u5355\uFF08\u4FC4\u7F57\u65AF\u3001\u571F\u8033\u5176\uFF09\u6309 72.5 \u4E70\uFF0C\u4EE5 OS \u4E3A\u51C6\u3002");
2108
+ cautionsEn.push("35 kV-class neutral sized at Um 40.5; many orders (Russia, Turkey) bought 72.5. The OS decides.");
2109
+ }
2110
+ if (umRule === "neutral_assumed") {
2111
+ cautionsZh.push(`\u4E2D\u6027\u70B9\u7EDD\u7F18\u672A\u7ED9\uFF0C\u5148\u6309 Um ${NEUTRAL_DEFAULT_UM} \u9009\uFF0C\u4EE5 OS \u4E3A\u51C6\u3002`);
2112
+ cautionsEn.push(`Neutral insulation not given: sized at Um ${NEUTRAL_DEFAULT_UM}; the OS decides.`);
2113
+ }
2114
+ if (auto) {
2115
+ if (spec.tapPoint === "auto_mv_line" && umRule === "auto_hv") {
2116
+ cautionsZh.push("HMR 230/121 kV \u5148\u4F8B\u6309\u5382\u5BB6\u6570\u636E\u7528 Um 170\u3002");
2117
+ cautionsEn.push("HMR 230/121 kV orders used Um 170 on the maker's data.");
2118
+ } else if (spec.tapPoint === "auto_junction" && umKv === 252 && umRule === "auto_hv") {
2119
+ cautionsZh.push("\u5148\u4F8B\uFF1A125 MVA 225/115/35 kV \xB18\xD71.25% \u2192 3\xD7SHZVI-600/252D-10193W\uFF082026-10-27\uFF09\u3002");
2120
+ cautionsEn.push("Precedent: 125 MVA 225/115/35 kV \xB18\xD71.25% \u2192 3\xD7SHZVI-600/252D-10193W (27 Oct 2026).");
2121
+ }
2122
+ cautionsZh.push("\u672A\u6838\uFF1A\u8DE8\u8C03\u538B\u7ED5\u7EC4\u51B2\u51FB\uFF08a \u503C\uFF09\u3001\u675F\u7F1A\u7535\u963B\u3002");
2123
+ cautionsEn.push("Not checked: impulse across the tap winding (a), tie-in resistor.");
2124
+ }
2125
+ return {
2126
+ ok: true,
2127
+ connection: spec.tapPoint === "neutral" ? "Y" : "D",
2128
+ umSystemKv,
2129
+ actualUmKv: iecUmFromRatedKv(umSystemKv),
2130
+ umKv,
2131
+ umRule,
2132
+ umAssumed,
2133
+ ratedA,
2134
+ maxA,
2135
+ dutyA: maxA * k,
2136
+ currentKv,
2137
+ currentDivisor,
2138
+ stepV,
2139
+ combinedOnly: auto,
2140
+ cautionsZh,
2141
+ cautionsEn
2142
+ };
1772
2143
  }
1773
2144
 
1774
2145
  // lib/cli.ts
@@ -1779,13 +2150,19 @@ var CliError = class extends Error {
1779
2150
  }
1780
2151
  };
1781
2152
  function num(raw, flag) {
1782
- const n = Number(String(raw).replace(",", "."));
1783
- if (!Number.isFinite(n)) throw new CliError(`Invalid number for ${flag}: ${raw}`);
1784
- return n;
2153
+ const p = parseDecimal(raw);
2154
+ if (p.ok) return p.value;
2155
+ if (p.reason === "ambiguous") {
2156
+ throw new CliError(
2157
+ `Ambiguous number for ${flag}: ${raw}. Write 1200 or 1.2 (no thousands separator).`
2158
+ );
2159
+ }
2160
+ throw new CliError(`Invalid number for ${flag}: ${raw}`);
1785
2161
  }
1786
2162
  function parseCliArgs(argv) {
1787
2163
  const out = {
1788
2164
  conn: "Y",
2165
+ kind: "two_winding",
1789
2166
  reg: "reversing",
1790
2167
  octc: false,
1791
2168
  structure: "auto",
@@ -1890,6 +2267,56 @@ function parseCliArgs(argv) {
1890
2267
  i = n;
1891
2268
  continue;
1892
2269
  }
2270
+ if (a === "--kind") {
2271
+ out.given.add("kind");
2272
+ const [v, n] = take(i, a);
2273
+ const k = v.toLowerCase();
2274
+ if (k === "auto" || k === "autotransformer" || k === "\u81EA\u8026") out.kind = "auto";
2275
+ else if (k === "two" || k === "two-winding" || k === "\u53CC\u7ED5\u7EC4") {
2276
+ out.kind = "two_winding";
2277
+ } else throw new CliError(`--kind must be two or auto`);
2278
+ i = n;
2279
+ continue;
2280
+ }
2281
+ if (a === "--auto") {
2282
+ out.given.add("kind");
2283
+ out.kind = "auto";
2284
+ continue;
2285
+ }
2286
+ if (a === "--tap") {
2287
+ out.given.add("tap");
2288
+ const [v, n] = take(i, a);
2289
+ const map = {
2290
+ neutral: "neutral",
2291
+ line: "line_end",
2292
+ "line-end": "line_end",
2293
+ junction: "auto_junction",
2294
+ "mv-line": "auto_mv_line"
2295
+ };
2296
+ const t = map[v.toLowerCase()];
2297
+ if (!t) throw new CliError(`--tap must be neutral|line|junction|mv-line`);
2298
+ out.tap = t;
2299
+ i = n;
2300
+ continue;
2301
+ }
2302
+ if (a === "--winding") {
2303
+ out.given.add("winding");
2304
+ const [v, n] = take(i, a);
2305
+ const w = v.toLowerCase();
2306
+ if (w === "star" || w === "y") out.winding = "star";
2307
+ else if (w === "delta" || w === "d") out.winding = "delta";
2308
+ else throw new CliError(`--winding must be star or delta`);
2309
+ i = n;
2310
+ continue;
2311
+ }
2312
+ if (a === "--hv" || a === "--mv" || a === "--earth-um") {
2313
+ const key = a === "--hv" ? "hv" : a === "--mv" ? "mv" : "earthUm";
2314
+ out.given.add(key);
2315
+ const [v, n] = take(i, a);
2316
+ out[key] = num(v, a);
2317
+ i = n;
2318
+ continue;
2319
+ }
1893
2320
  if (a === "--reg") {
1894
2321
  out.given.add("reg");
1895
2322
  const [v, n] = take(i, a);
@@ -1931,7 +2358,7 @@ function parseCliArgs(argv) {
1931
2358
  \u7B3C\u5F0F: "cage",
1932
2359
  \u9F13\u5F0F: "drum"
1933
2360
  };
1934
- if (!(s in map) && !(v in map)) {
2361
+ if (!Object.hasOwn(map, s) && !Object.hasOwn(map, v)) {
1935
2362
  throw new CliError(
1936
2363
  `--structure must be auto|combined|compound|cage|drum`
1937
2364
  );
@@ -1995,28 +2422,41 @@ function parseCliArgs(argv) {
1995
2422
  }
1996
2423
  return out;
1997
2424
  }
1998
- var CLI_HELP = `oltc \u2014 Huaming OLTC/OCTC type selection (package: oltc-selector, no prices)
2425
+ var CLI_HELP = `oltc \u2014 OLTC/OCTC type selection (package: oltc-selector, no prices)
1999
2426
 
2000
2427
  Usage:
2001
2428
  oltc --iu 400 --um 72.5 --conn Y --reg W --pm 8
2002
- oltc --mva 25 --kv 110 --conn Y --reg W --pm 8
2429
+ oltc --mva 25 --kv 110 --tap neutral --reg W --pm 8
2430
+ oltc --mva 16 --kv 22 --tap line --winding star
2431
+ oltc --mva 125 --kind auto --hv 225 --mv 115 --tap junction
2003
2432
  oltc --octc --iu 800 --um 72.5 --conn D --series II --contact 6x5
2004
2433
  oltc --iu 600 --um 72.5 --conn Y --reg W --pm 8 --structure combined
2005
2434
 
2006
2435
  Flags:
2007
2436
  --iu, --imax A Max through-current (Imax). No safety factor.
2008
2437
  --mva MVA --kv kV Capacity path: Imax from rated I, minus steps, --step-pct, --k
2438
+ --kind two|auto Transformer kind (--auto = --kind auto). Default two-winding.
2439
+ --tap P Where the OLTC sits: neutral|line (two-winding),
2440
+ junction|mv-line (autotransformer, series/common junction
2441
+ or MV line lead). Capacity path; replaces --conn there.
2442
+ --winding star|delta Tapped winding connection (two-winding). Sets the current
2443
+ formula: star I = S/(\u221A3U), delta I = S/(3U).
2444
+ --hv kV --mv kV Autotransformer HV / MV rated voltage (with --kind auto).
2445
+ --earth-um kV OLTC insulation to earth from the OS or maker (catalogue
2446
+ class). Overrides the rule: line end = winding system,
2447
+ neutral \u226472.5 full else 72.5 assumed, autotransformer = HV.
2009
2448
  --um kV Equipment Um (OLTC). With --mva/--kv, derived if omitted.
2010
2449
  --ust V Step voltage. With --mva/--kv/--step-pct, derived if omitted.
2011
2450
  --step-pct % Step as percent (1.25 means 1.25%). Capacity path only.
2012
2451
  --k n Safety factor on capacity path only (default 1.0, same as the web app).
2013
- --conn Y|D Switch connection (star / delta). Default Y.
2452
+ --conn Y|D Switch connection (star point / line end). Default Y.
2453
+ On the capacity path, legacy: Y = star neutral, D = delta line end.
2014
2454
  --reg W|G|0 Reversing / coarse-fine / linear. Default W.
2015
2455
  --pm N \xB1 steps. Default 8.
2016
2456
  --pos, --positions Linear / OCTC positions.
2017
2457
  --octc Off-circuit (\u65E0\u8F7D). Default on-load.
2018
2458
  --structure auto|combined|compound|cage|drum (\u7EC4\u5408\u5F0F/\u590D\u5408\u5F0F/\u7B3C\u5F0F/\u9F13\u5F0F)
2019
- --series II|IV|V|VI|VII|VIII OCTC wiring. Default auto (Y\u2192IV, D\u2192II).
2459
+ --series II|IV|V|VI|VII|VIII OCTC wiring. Default auto is linear IV (Y and D).
2020
2460
  --mount in-tank|on-tank|dry. Default in-tank.
2021
2461
  --oil / --vacuum Switching medium. Default vacuum (on-load).
2022
2462
  --contact OCTC contact e.g. 6x5.
@@ -2027,6 +2467,35 @@ Flags:
2027
2467
  Defaults match the web first paint: on-load, in-tank vacuum, structure auto,
2028
2468
  \xB18 mid-3 reversing. Omitting --octc and --structure auto is minimum-adequate.
2029
2469
  `;
2470
+ function cliDuty(args) {
2471
+ if (args.mva == null) return null;
2472
+ const auto = args.kind === "auto";
2473
+ if (auto) {
2474
+ if (!(args.hv != null && args.hv > 0 && args.mv != null && args.mv > 0)) {
2475
+ throw new CliError("--kind auto with --mva needs --hv and --mv");
2476
+ }
2477
+ } else if (!(args.kv != null && args.kv > 0)) {
2478
+ throw new CliError("--mva requires --kv (tap-side rated voltage)");
2479
+ }
2480
+ const tap = args.tap ?? (auto ? "auto_junction" : args.conn === "D" ? "line_end" : "neutral");
2481
+ const winding = args.winding ?? (tap === "neutral" || args.conn === "Y" ? "star" : "delta");
2482
+ const pct = args.stepPct != null && args.stepPct > 0 ? args.stepPct / 100 : 0.0125;
2483
+ const earth = args.earthUm != null && args.earthUm > 0 ? args.earthUm : args.um != null && args.um > 0 ? args.um : void 0;
2484
+ return deriveDuty({
2485
+ kind: args.kind,
2486
+ tapPoint: tap,
2487
+ winding,
2488
+ mva: args.mva,
2489
+ tapKv: args.kv ?? 0,
2490
+ hvKv: args.hv ?? 0,
2491
+ mvKv: args.mv ?? 0,
2492
+ minusSteps: args.pm != null && args.pm > 0 ? args.pm : 8,
2493
+ stepFraction: pct,
2494
+ // 与网页版首屏一致:容量路径默认不额外加安全系数
2495
+ safetyK: args.k != null && args.k > 0 ? args.k : 1,
2496
+ ...earth != null ? { earthUmKv: earth } : {}
2497
+ });
2498
+ }
2030
2499
  function cliToSelectInput(args) {
2031
2500
  const dutyKind = args.octc ? "octc" : "oltc";
2032
2501
  const oil = args.octc || args.oil || !args.vacuum;
@@ -2034,26 +2503,28 @@ function cliToSelectInput(args) {
2034
2503
  let iu = args.iu;
2035
2504
  let um = args.um;
2036
2505
  let ust = args.ust ?? 0;
2037
- if (args.mva != null) {
2038
- if (!(args.kv != null && args.kv > 0)) {
2039
- throw new CliError("--mva requires --kv (tap-side rated voltage)");
2040
- }
2041
- const rated = throughCurrentFromRated(args.mva, args.kv, args.conn);
2042
- if (!Number.isFinite(rated) || rated <= 0) {
2043
- throw new CliError("Could not compute rated current from --mva/--kv");
2044
- }
2045
- const pct = args.stepPct != null && args.stepPct > 0 ? args.stepPct / 100 : 0.0125;
2046
- const minus = args.pm != null && args.pm > 0 ? args.pm : 8;
2047
- const iMax = maxThroughCurrent(rated, minus, pct);
2048
- const k = args.k != null && args.k > 0 ? args.k : 1;
2049
- iu = iMax * k;
2050
- if (um == null || !(um > 0)) {
2051
- um = oltcUmFromRatedKv(args.kv, args.conn);
2052
- }
2053
- if (!(ust > 0)) {
2054
- const v = stepVoltageFromPercent(args.kv, pct, args.conn);
2055
- if (Number.isFinite(v) && v > 0) ust = v;
2056
- }
2506
+ if (args.iu != null && args.mva != null) {
2507
+ throw new CliError("Give --iu or --mva/--kv, not both");
2508
+ }
2509
+ if (args.k != null && args.mva == null) {
2510
+ throw new CliError("--k applies only on the --mva path (--iu has no safety factor)");
2511
+ }
2512
+ if (args.k != null && args.k < 1) {
2513
+ throw new CliError("--k must be \u2265 1");
2514
+ }
2515
+ if (args.stepPct != null && args.mva == null) {
2516
+ throw new CliError("--step-pct needs --mva/--kv; give --ust on the --iu path");
2517
+ }
2518
+ const duty = cliDuty(args);
2519
+ let conn = args.conn;
2520
+ if (duty) {
2521
+ if (!duty.ok) throw new CliError(duty.errorZh ?? duty.errorEn ?? "Bad transformer data");
2522
+ iu = duty.dutyA;
2523
+ if (um == null || !(um > 0)) um = duty.umKv;
2524
+ if (!(ust > 0) && duty.stepV != null) ust = duty.stepV;
2525
+ conn = duty.connection;
2526
+ } else if (args.tap) {
2527
+ conn = args.tap === "neutral" ? "Y" : "D";
2057
2528
  }
2058
2529
  if (iu == null || !(iu > 0)) {
2059
2530
  throw new CliError("Need --iu (Imax) or --mva plus --kv");
@@ -2067,7 +2538,8 @@ function cliToSelectInput(args) {
2067
2538
  preferVacuum: !oil && dutyKind === "oltc",
2068
2539
  dutyKind,
2069
2540
  phases: args.phases,
2070
- connection: args.conn,
2541
+ connection: conn,
2542
+ ...args.kind === "auto" ? { transformerKind: "auto" } : {},
2071
2543
  throughCurrentA: iu,
2072
2544
  umKv: um,
2073
2545
  stepVoltageV: ust,
@@ -2102,11 +2574,31 @@ var MOUNT_ZH = {
2102
2574
  external_compartment: "\u5916\u7F6E\u9694\u5BA4",
2103
2575
  reactor: "\u7535\u6297\u5668"
2104
2576
  };
2105
- function assumptionsFromArgs(args) {
2577
+ function assumptionsFromArgs(args, family) {
2106
2578
  const mark = (key) => args.given.has(key) ? "" : "\uFF08\u9ED8\u8BA4\uFF09";
2107
- const items = [
2108
- `conn=${args.conn} ${args.conn === "Y" ? "\u661F\u70B9" : "\u7EBF\u7AEF"}${mark("conn")}`
2109
- ];
2579
+ const items = [];
2580
+ const tapZh = {
2581
+ neutral: "\u4E2D\u6027\u70B9",
2582
+ line_end: "\u7EBF\u7AEF",
2583
+ auto_junction: "\u4E32\u8054/\u516C\u5171\u7ED5\u7EC4\u8FDE\u63A5\u70B9",
2584
+ auto_mv_line: "\u4E2D\u538B\u51FA\u7EBF"
2585
+ };
2586
+ if (args.mva != null) {
2587
+ const duty = cliDuty(args);
2588
+ const tap = args.tap ?? (args.kind === "auto" ? "auto_junction" : args.conn === "D" ? "line_end" : "neutral");
2589
+ items.push(`${args.kind === "auto" ? "\u81EA\u8026\u53D8" : "\u53CC\u7ED5\u7EC4"}${mark("kind")}`);
2590
+ items.push(`\u5F00\u5173\u5728${tapZh[tap]}${args.given.has("tap") || args.given.has("conn") ? "" : "\uFF08\u9ED8\u8BA4\uFF09"}`);
2591
+ if (args.kind !== "auto") {
2592
+ const w = args.winding ?? (tap === "neutral" || args.conn === "Y" ? "star" : "delta");
2593
+ items.push(`${w === "star" ? "\u661F\u5F62" : "\u89D2\u5F62"}\u7ED5\u7EC4${args.given.has("winding") ? "" : "\uFF08\u9ED8\u8BA4\uFF09"}`);
2594
+ }
2595
+ if (duty?.umAssumed) items.push(`\u5BF9\u5730 Um ${duty.umKv}\uFF08\u672A\u6307\u5B9A\uFF09`);
2596
+ } else {
2597
+ items.push(
2598
+ `conn=${args.conn} ${args.conn === "Y" ? "\u661F\u70B9" : "\u7EBF\u7AEF"}${mark("conn")}`
2599
+ );
2600
+ if (args.kind === "auto") items.push("\u81EA\u8026\u53D8");
2601
+ }
2110
2602
  if (args.mva != null) {
2111
2603
  items.push(args.given.has("k") ? `k=${args.k}` : "k=1.0\uFF08\u9ED8\u8BA4\uFF09");
2112
2604
  items.push(
@@ -2124,7 +2616,7 @@ function assumptionsFromArgs(args) {
2124
2616
  }
2125
2617
  const s = args.series ?? "auto";
2126
2618
  items.push(
2127
- s === "auto" ? `\u63A5\u7EBF=\u81EA\u52A8\uFF08${args.conn === "Y" ? "IV" : "II"}\uFF09${mark("series")}` : `\u63A5\u7EBF=${s}${mark("series")}`
2619
+ s === "auto" ? `\u63A5\u7EBF=\u81EA\u52A8\uFF08${octcRoman(args.conn, args.contact, void 0, family)}\uFF09${mark("series")}` : `\u63A5\u7EBF=${s}${mark("series")}`
2128
2620
  );
2129
2621
  items.push(`${MOUNT_ZH[args.mount]}${mark("mount")}`);
2130
2622
  items.push(phases);
@@ -2140,18 +2632,28 @@ function assumptionsFromArgs(args) {
2140
2632
  } else {
2141
2633
  items.push(`\xB1${args.pm ?? 8} \u6863${mark("pm")}`);
2142
2634
  }
2635
+ if (!args.given.has("ust") && args.mva == null) {
2636
+ items.push("Ust \u672A\u6307\u5B9A\uFF08\u7EA7\u7535\u538B\u3001\u7EA7\u5BB9\u91CF\u672A\u6821\u9A8C\uFF09");
2637
+ }
2143
2638
  items.push(`${args.oil || !args.vacuum ? "\u6CB9\u6D78" : "\u771F\u7A7A"}${mark("medium")}`);
2144
2639
  items.push(`${MOUNT_ZH[args.mount]}${mark("mount")}`);
2145
2640
  items.push(phases);
2146
2641
  return items;
2147
2642
  }
2148
- function assumptionsLine(args) {
2149
- const items = assumptionsFromArgs(args);
2643
+ function assumptionsLine(args, family) {
2644
+ const items = assumptionsFromArgs(args, family);
2150
2645
  if (items.every((i) => !i.includes("\uFF08\u9ED8\u8BA4\uFF09") && !i.includes("\u672A\u6307\u5B9A"))) {
2151
2646
  return null;
2152
2647
  }
2153
2648
  return `\u5047\u5B9A\uFF1A${items.join(" \xB7 ")}`;
2154
2649
  }
2650
+ var round1 = (n) => Math.round(n * 10) / 10;
2651
+ function basisLineZh(d) {
2652
+ const div = d.currentDivisor === "three" ? "3" : "\u221A3";
2653
+ const um = d.umRule === "explicit" ? `\u5BF9\u5730 Um ${d.umKv}\uFF08\u6307\u5B9A\uFF09` : d.umRule === "neutral_assumed" || d.umRule === "neutral_full" ? `\u4E2D\u6027\u70B9 Um ${d.umKv}${d.umAssumed ? "\uFF08\u5F85 OS \u6838\u5BF9\uFF09" : ""}` : `${d.umSystemKv} kV \u7CFB\u7EDF Um ${d.actualUmKv} \u2192 ${d.umKv} \u7EA7`;
2654
+ const ust = d.stepV == null ? "" : ` \xB7 Ust ${round1(d.stepV)} V`;
2655
+ return `I = S/(${div}\xD7${d.currentKv} kV) = ${round1(d.ratedA)} A\uFF0C\u6700\u4F4E\u6863 ${round1(d.maxA)} A${ust} \xB7 ${um}`;
2656
+ }
2155
2657
  function formatCliText(input, args) {
2156
2658
  const out = selectOltc(input);
2157
2659
  if (!out.ok || !out.results.length) {
@@ -2162,18 +2664,31 @@ function formatCliText(input, args) {
2162
2664
  if (!commercialTypeExists(primary.model)) {
2163
2665
  throw new CliError(`Engine emitted a non-catalogue type: ${primary.model}`);
2164
2666
  }
2165
- const alts = pickOtherOptions(out.results, 3);
2667
+ const alts = optionsWithInsurance(
2668
+ out.results,
2669
+ input.throughCurrentA,
2670
+ input.stepVoltageV,
2671
+ 3,
2672
+ {
2673
+ acrossTapBilKv: input.acrossTapBilKv,
2674
+ acrossTapPfKv: input.acrossTapPfKv
2675
+ }
2676
+ );
2166
2677
  const lines = [
2167
2678
  primary.model,
2168
2679
  primary.reasonsZh[0] || primary.reasonsEn[0] || "\u6700\u4F4E\u6EE1\u8DB3"
2169
2680
  ];
2681
+ const duty = args ? cliDuty(args) : null;
2682
+ if (duty?.ok) lines.push(`\u4F9D\u636E\uFF1A${basisLineZh(duty)}`);
2683
+ for (const c of primary.cautionsZh) lines.push(`\u6CE8\u610F\uFF1A${c}`);
2684
+ for (const c of duty?.cautionsZh ?? []) lines.push(`\u6CE8\u610F\uFF1A${c}`);
2170
2685
  if (alts.length) {
2171
2686
  lines.push("");
2172
2687
  lines.push("\u5176\u4ED6");
2173
2688
  for (const a of alts) lines.push(a.model);
2174
2689
  }
2175
2690
  if (args) {
2176
- const assumed = assumptionsLine(args);
2691
+ const assumed = assumptionsLine(args, primary.seriesCode);
2177
2692
  if (assumed) {
2178
2693
  lines.push("");
2179
2694
  lines.push(assumed);
@@ -2184,13 +2699,43 @@ function formatCliText(input, args) {
2184
2699
  function formatCliJson(input, args) {
2185
2700
  const out = selectOltc(input);
2186
2701
  const primary = out.results[0] ?? null;
2187
- const alts = pickOtherOptions(out.results, 3).map((r) => r.model);
2702
+ if (primary && !commercialTypeExists(primary.model)) {
2703
+ throw new CliError(`Engine emitted a non-catalogue type: ${primary.model}`);
2704
+ }
2705
+ const alts = optionsWithInsurance(
2706
+ out.results,
2707
+ input.throughCurrentA,
2708
+ input.stepVoltageV,
2709
+ 3,
2710
+ {
2711
+ acrossTapBilKv: input.acrossTapBilKv,
2712
+ acrossTapPfKv: input.acrossTapPfKv
2713
+ }
2714
+ ).map((r) => r.model);
2188
2715
  const payload = {
2189
2716
  ok: out.ok,
2190
2717
  model: primary?.model ?? null,
2191
2718
  why: primary?.reasonsZh[0] ?? primary?.reasonsEn[0] ?? null,
2192
2719
  alts,
2193
- assumptions: args ? assumptionsFromArgs(args) : [],
2720
+ cautions: [
2721
+ ...primary?.cautionsZh ?? [],
2722
+ ...(args ? cliDuty(args) : null)?.cautionsZh ?? []
2723
+ ],
2724
+ basis: (() => {
2725
+ const d = args ? cliDuty(args) : null;
2726
+ return d?.ok ? {
2727
+ connection: d.connection,
2728
+ ratedA: round1(d.ratedA),
2729
+ maxA: round1(d.maxA),
2730
+ stepV: d.stepV == null ? null : round1(d.stepV),
2731
+ umSystemKv: d.umSystemKv,
2732
+ actualUmKv: d.actualUmKv,
2733
+ umKv: d.umKv,
2734
+ umRule: d.umRule,
2735
+ umAssumed: d.umAssumed
2736
+ } : null;
2737
+ })(),
2738
+ assumptions: args ? assumptionsFromArgs(args, primary?.seriesCode) : [],
2194
2739
  errors: out.errorsZh.length ? out.errorsZh : out.errorsEn
2195
2740
  };
2196
2741
  return JSON.stringify(payload, null, 2) + "\n";