oltc-selector 2.4.0 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/bin/oltc.js +155 -27
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ oltc --line "220/110/35kV-125MVA 225±8x1,25%/115/35kV YNa0d11"
|
|
|
35
35
|
# 3xCM2I-500/252D-10193W, plus the type at Um 126 / 170 / 252
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
Output is in Chinese by default; `--lang en` gives English. Every run asks npm for a newer version and prints a notice when there is one. Nothing is installed for you.
|
|
38
|
+
Output is in Chinese by default; `--lang en` gives English. An error on a Chinese run prints in Chinese, then English. Every run asks npm for a newer version and prints a notice when there is one. Nothing is installed for you.
|
|
39
39
|
|
|
40
40
|
<details>
|
|
41
41
|
<summary><b>All flags</b></summary>
|
|
@@ -58,7 +58,7 @@ Output is in Chinese by default; `--lang en` gives English. Every run asks npm f
|
|
|
58
58
|
| `--across-li` `--across-ac` | Stated LI / AC withstand across the tap winding (kV): sets the selector grade B/C/D/DE | |
|
|
59
59
|
| `--um` | Equipment Um (kV) | derived from `--kv` if omitted |
|
|
60
60
|
| `--ust` | Step voltage (V) | 0, or derived on MVA path |
|
|
61
|
-
| `--conn Y\|D` | Switch star / delta on the `--iu` path
|
|
61
|
+
| `--conn Y\|D` | Switch star / delta on the `--iu` path. With `--mva` or `--line` it is an error: use `--tap` | Y |
|
|
62
62
|
| `--reg W\|G\|0` | Reversing / coarse-fine / linear | W |
|
|
63
63
|
| `--pm` | ± steps, a whole number | 8 |
|
|
64
64
|
| `--pos` / `--positions` | Operating positions (linear and off-circuit; on W/G the Fig. 3-3 row with that count) | |
|
|
@@ -91,7 +91,7 @@ Every flag with a value also takes `--flag=value`. A flag that cannot take effec
|
|
|
91
91
|
|
|
92
92
|
<br>
|
|
93
93
|
|
|
94
|
-
**`--json`** prints one object. For bad input (a flag that cannot be read) the object holds only `ok`, `version`, `model` and `errors`.
|
|
94
|
+
**`--json`** prints one object, and nothing on stderr. For bad input (a flag that cannot be read) the object holds only `ok`, `version`, `model` and `errors`.
|
|
95
95
|
|
|
96
96
|
| Key | Holds |
|
|
97
97
|
|-----|-------|
|
|
@@ -103,8 +103,8 @@ Every flag with a value also takes `--flag=value`. A flag that cannot take effec
|
|
|
103
103
|
| `line` | The `--line` read-back: `kind`, `mva`, `voltagesKv`, `vectorGroup`, `warnings` (or `null`) |
|
|
104
104
|
| `basis` | Where current, Ust and Um came from on the capacity path (or `null`) |
|
|
105
105
|
| `umChoices` | The type at each Um class when the insulation to earth is open |
|
|
106
|
-
| `assumptions` | Every default that was applied, as text |
|
|
107
|
-
| `errors` | Why there is no type |
|
|
106
|
+
| `assumptions` | Every default that was applied, as text. The text output names only those that could change the type |
|
|
107
|
+
| `errors` | Why there is no type. Chinese then English; English alone with `--lang en` |
|
|
108
108
|
|
|
109
109
|
</details>
|
|
110
110
|
|
package/bin/oltc.js
CHANGED
|
@@ -1,7 +1,106 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// lib/appVersion.ts
|
|
4
|
-
var APP_VERSION = "2.4.
|
|
4
|
+
var APP_VERSION = "2.4.1";
|
|
5
|
+
|
|
6
|
+
// lib/cliErrorsZh.ts
|
|
7
|
+
var WHAT_ZH = {
|
|
8
|
+
"MVA and kV": "\u5BB9\u91CF\u548C\u7535\u538B",
|
|
9
|
+
"the MVA rating": "\u5BB9\u91CF",
|
|
10
|
+
"the kV ratio": "\u7535\u538B\u6BD4",
|
|
11
|
+
"the kV ratio and range": "\u7535\u538B\u6BD4\u548C\u8C03\u538B\u8303\u56F4"
|
|
12
|
+
};
|
|
13
|
+
var ROWS = [
|
|
14
|
+
[/^(\S+) must be greater than 0 \(got (.+)\)$/, "$1 \u5FC5\u987B\u5927\u4E8E 0\uFF08\u6536\u5230 $2\uFF09"],
|
|
15
|
+
[/^(\S+) must not be negative \(got (.+)\)$/, "$1 \u4E0D\u80FD\u4E3A\u8D1F\uFF08\u6536\u5230 $2\uFF09"],
|
|
16
|
+
[/^Ambiguous number for (\S+): (.+)\. Write 1200 or 1\.2 \(no thousands separator\)\.$/, "$1 \u7684\u6570\u5B57\u6709\u6B67\u4E49\uFF1A$2\u3002\u8BF7\u5199 1200 \u6216 1.2\uFF0C\u4E0D\u8981\u7528\u5343\u5206\u4F4D\u3002"],
|
|
17
|
+
[/^Invalid number for (\S+): (.*)$/, "$1 \u7684\u6570\u5B57\u65E0\u6548\uFF1A$2"],
|
|
18
|
+
[
|
|
19
|
+
/^Unknown flag: (\S+?)\.(?: Did you mean (\S+)\?)?.* Run oltc --help for the list\.$/,
|
|
20
|
+
(m) => `\u672A\u77E5\u53C2\u6570\uFF1A${m[1]}\u3002${m[2] ? `\u662F\u4E0D\u662F\u60F3\u5199 ${m[2]}\uFF1F` : ""}\u8FD0\u884C oltc --help \u67E5\u770B\u5168\u90E8\u53C2\u6570\u3002`
|
|
21
|
+
],
|
|
22
|
+
[/^(\S+) takes no value$/, "$1 \u4E0D\u5E26\u503C"],
|
|
23
|
+
[/^Missing value for (\S+)$/, "$1 \u7F3A\u5C11\u503C"],
|
|
24
|
+
[/^(\S+) is given twice$/, "$1 \u7ED9\u4E86\u4E24\u6B21"],
|
|
25
|
+
[/^--lang must be en or zh$/, "--lang \u53EA\u80FD\u662F en \u6216 zh"],
|
|
26
|
+
[/^--octc conflicts with --duty oltc\. Drop one\.$/, "--octc \u548C --duty oltc \u77DB\u76FE\uFF0C\u8BF7\u53BB\u6389\u4E00\u4E2A\u3002"],
|
|
27
|
+
[/^Give --oil or --vacuum, not both$/, "--oil \u548C --vacuum \u53EA\u80FD\u7ED9\u4E00\u4E2A"],
|
|
28
|
+
[/^Give --iu or --imax, not both$/, "--iu \u548C --imax \u53EA\u80FD\u7ED9\u4E00\u4E2A"],
|
|
29
|
+
[/^--market is removed\./, "--market \u5DF2\u5220\u9664\u3002\u5F00\u5173\u5BF9\u5730\u7EDD\u7F18\u8BF7\u7528 --earth-um\uFF0C\u8DE8\u8C03\u538B\u7ED5\u7EC4\u7684\u8010\u538B\u8BF7\u7528 --across-li / --across-ac\u3002"],
|
|
30
|
+
[/^--conn must be Y or D$/, "--conn \u53EA\u80FD\u662F Y \u6216 D"],
|
|
31
|
+
[/^--kind must be two or auto$/, "--kind \u53EA\u80FD\u662F two \u6216 auto"],
|
|
32
|
+
[/^--tap must be neutral\|line\|junction\|mv-line$/, "--tap \u53EA\u80FD\u662F neutral\u3001line\u3001junction \u6216 mv-line"],
|
|
33
|
+
[/^--winding must be star or delta$/, "--winding \u53EA\u80FD\u662F star \u6216 delta"],
|
|
34
|
+
[/^--reg must be W, G, or 0$/, "--reg \u53EA\u80FD\u662F W\u3001G \u6216 0"],
|
|
35
|
+
[/^--pm must be a whole number of at least 1$/, "--pm \u5FC5\u987B\u662F\u4E0D\u5C0F\u4E8E 1 \u7684\u6574\u6570"],
|
|
36
|
+
[/^(\S+) must be a whole number of at least 2$/, "$1 \u5FC5\u987B\u662F\u4E0D\u5C0F\u4E8E 2 \u7684\u6574\u6570"],
|
|
37
|
+
[/^--structure must be auto\|combined\|compound\|cage\|drum$/, "--structure \u53EA\u80FD\u662F auto\u3001combined\u3001compound\u3001cage \u6216 drum"],
|
|
38
|
+
[/^--series must be II\|IV\|V\|VI\|VII\|VIII$/, "--series \u53EA\u80FD\u662F II\u3001IV\u3001V\u3001VI\u3001VII \u6216 VIII"],
|
|
39
|
+
[/^--mount must be in-tank\|on-tank\|dry\|reactor$/, "--mount \u53EA\u80FD\u662F in-tank\u3001on-tank\u3001dry \u6216 reactor"],
|
|
40
|
+
[/^--contact must look like 6x5 or 12x11D$/, "--contact \u7684\u5199\u6CD5\u5982 6x5 \u6216 12x11D"],
|
|
41
|
+
[/^--phases must be I, II, or III$/, "--phases \u53EA\u80FD\u662F I\u3001II \u6216 III"],
|
|
42
|
+
[/^--minus must be a whole number of steps$/, "--minus \u5FC5\u987B\u662F\u6574\u6570\u7EA7\u6570"],
|
|
43
|
+
[/^--mid must be 1 or 3$/, "--mid \u53EA\u80FD\u662F 1 \u6216 3"],
|
|
44
|
+
[/^--duty must be oltc or octc$/, "--duty \u53EA\u80FD\u662F oltc \u6216 octc"],
|
|
45
|
+
[/^--range must look like \+4\/-12 or \+4\/-12x1\.25%$/, "--range \u7684\u5199\u6CD5\u5982 +4/-12 \u6216 +4/-12x1.25%"],
|
|
46
|
+
[/^--mid (\S+) does not fit (\S+): the Fig\. 3-3 row has mid (\S+)\.$/, "--mid $1 \u548C $2 \u4E0D\u5339\u914D\uFF1A\u6837\u672C\u56FE 3-3 \u5BF9\u5E94\u7684\u4E2D\u95F4\u4F4D\u662F $3\u3002"],
|
|
47
|
+
[
|
|
48
|
+
/^--line reads an autotransformer without both HV and MV kV: (.*)\. Give --hv and --mv\.$/s,
|
|
49
|
+
"--line \u8BFB\u51FA\u662F\u81EA\u8026\u53D8\uFF0C\u4F46\u7F3A\u9AD8\u538B\u6216\u4E2D\u538B\u7535\u538B\uFF1A$1\u3002\u8BF7\u7ED9 --hv \u548C --mv\u3002"
|
|
50
|
+
],
|
|
51
|
+
[
|
|
52
|
+
/^Could not read (MVA and kV|the MVA rating|the kV ratio|the kV ratio and range) from --line: (.*)\. Write it like "25MVA 110±8x1\.25%\/10\.5kV YNd11", or give --mva\/--kv \(or --hv\/--mv\) instead\.$/s,
|
|
53
|
+
(m) => `--line \u8BFB\u4E0D\u51FA${WHAT_ZH[m[1]]}\uFF1A${m[2]}\u3002\u8BF7\u5199\u6210 "25MVA 110\xB18x1.25%/10.5kV YNd11" \u8FD9\u6837\uFF0C\u6216\u6539\u7528 --mva/--kv\uFF08\u81EA\u8026\u53D8\u7528 --hv/--mv\uFF09\u3002`
|
|
54
|
+
],
|
|
55
|
+
[/^--kind auto with --mva needs --hv and --mv$/, "--kind auto \u914D --mva \u65F6\u9700\u8981 --hv \u548C --mv"],
|
|
56
|
+
[/^--mva requires --kv \(tap-side rated voltage\)$/, "--mva \u9700\u8981 --kv\uFF08\u8C03\u538B\u4FA7\u989D\u5B9A\u7535\u538B\uFF09"],
|
|
57
|
+
[/^--series is off-circuit wiring: add --octc$/, "--series \u662F\u65E0\u8F7D\u63A5\u7EBF\u65B9\u5F0F\uFF1A\u8BF7\u52A0 --octc"],
|
|
58
|
+
[/^--contact is an off-circuit contact: add --octc$/, "--contact \u662F\u65E0\u8F7D\u89E6\u5934\u89C4\u683C\uFF1A\u8BF7\u52A0 --octc"],
|
|
59
|
+
[/^--structure (\S+) is off-circuit: add --octc \(on-load takes combined or compound\)$/, "--structure $1 \u662F\u65E0\u8F7D\u7ED3\u6784\uFF1A\u8BF7\u52A0 --octc\uFF08\u6709\u8F7D\u7528 combined \u6216 compound\uFF09"],
|
|
60
|
+
[/^--structure (\S+) is on-load only: with --octc use cage or drum$/, "--structure $1 \u53EA\u7528\u4E8E\u6709\u8F7D\uFF1A--octc \u65F6\u7528 cage \u6216 drum"],
|
|
61
|
+
[/^--vacuum does not apply with --octc /, "--vacuum \u4E0D\u9002\u7528\u4E8E --octc\uFF08\u65E0\u8F7D\u5F00\u5173\u4E0D\u5207\u65AD\u7535\u6D41\uFF09"],
|
|
62
|
+
[/^--oil does not apply with --mount dry$/, "--oil \u4E0D\u9002\u7528\u4E8E --mount dry"],
|
|
63
|
+
[/^--vacuum does not apply with --mount reactor /, "--vacuum \u4E0D\u9002\u7528\u4E8E --mount reactor\uFF08\u7535\u6297\u5668\u5F00\u5173\u662F\u6CB9\u6D78\u7684\uFF09"],
|
|
64
|
+
[/^--conn D conflicts with --tap neutral: /, "--conn D \u548C --tap neutral \u77DB\u76FE\uFF1A\u4E2D\u6027\u70B9\u662F\u661F\u5F62\uFF08Y\uFF09\u3002\u8BF7\u53BB\u6389\u4E00\u4E2A\u3002"],
|
|
65
|
+
[/^--conn Y conflicts with --tap line: /, "--conn Y \u548C --tap line \u77DB\u76FE\uFF1A\u7EBF\u7AEF\u662F\u89D2\u5F62\uFF08D\uFF09\u3002\u8BF7\u53BB\u6389\u4E00\u4E2A\u3002"],
|
|
66
|
+
[/^--conn does not apply with --mva: /, "--conn \u4E0D\u7528\u4E8E --mva\uFF1AY \u6216 D \u7531\u5F00\u5173\u4F4D\u7F6E\u51B3\u5B9A\u3002\u7EBF\u7AEF\u7528 --tap line\uFF0C\u89D2\u5F62\u7ED5\u7EC4\u7528 --winding delta\u3002"],
|
|
67
|
+
[/^--hv and --mv are autotransformer voltages: /, "--hv \u548C --mv \u662F\u81EA\u8026\u53D8\u7684\u7535\u538B\uFF1A\u8BF7\u52A0 --kind auto\uFF08\u53CC\u7ED5\u7EC4\u7528 --kv\uFF09"],
|
|
68
|
+
[/^--minus sets the lowest-tap current on the --mva path; /, "--minus \u53EA\u5728 --mva \u8DEF\u5F84\u4E0A\u7528\u6765\u7B97\u6700\u4F4E\u6863\u7535\u6D41\uFF1B--iu \u8DEF\u5F84\u8BF7\u76F4\u63A5\u7ED9\u7535\u6D41"],
|
|
69
|
+
[/^Give --um or --earth-um, not both: (\S+) and (\S+) disagree\.$/, "--um \u548C --earth-um \u53EA\u80FD\u7ED9\u4E00\u4E2A\uFF1A$1 \u548C $2 \u4E0D\u4E00\u81F4\u3002"],
|
|
70
|
+
[/^--step-pct is a percent: 1\.25 means 1\.25 %\. (\S+) is too small\.$/, "--step-pct \u662F\u767E\u5206\u6570\uFF1A1.25 \u8868\u793A 1.25%\u3002$1 \u592A\u5C0F\u3002"],
|
|
71
|
+
[/^--pm (\S+) and --pos (\S+) disagree\. Give one of them\.$/, "--pm $1 \u548C --pos $2 \u4E0D\u4E00\u81F4\uFF0C\u8BF7\u53EA\u7ED9\u4E00\u4E2A\u3002"],
|
|
72
|
+
[/^Give --iu or --mva\/--kv, not both /, "--iu \u548C --mva/--kv \u53EA\u80FD\u7ED9\u4E00\u79CD\uFF08--mva \u65C1\u8FB9\u7684\u8BA2\u8D27\u89C4\u8303 Imax \u7528 --os-imax\uFF09"],
|
|
73
|
+
[/^--os-imax needs --mva\/--kv; /, "--os-imax \u9700\u8981 --mva/--kv\uFF1B--iu \u8DEF\u5F84\u4E0A\u7535\u6D41\u76F4\u63A5\u7528 --iu"],
|
|
74
|
+
[/^--k applies only on the --mva path /, "--k \u53EA\u7528\u4E8E --mva \u8DEF\u5F84\uFF08--iu \u4E0D\u4E58\u5B89\u5168\u7CFB\u6570\uFF09"],
|
|
75
|
+
[/^--k must be ≥ 1$/, "--k \u5FC5\u987B\u4E0D\u5C0F\u4E8E 1"],
|
|
76
|
+
[/^--step-pct needs --mva\/--kv; give --ust on the --iu path$/, "--step-pct \u9700\u8981 --mva/--kv\uFF1B--iu \u8DEF\u5F84\u8BF7\u7ED9 --ust"],
|
|
77
|
+
[/^Give --um or --earth-um, not both, when no winding voltage \(--kv\) is given$/, "\u6CA1\u7ED9\u7ED5\u7EC4\u7535\u538B\uFF08--kv\uFF09\u65F6\uFF0C--um \u548C --earth-um \u53EA\u80FD\u7ED9\u4E00\u4E2A"],
|
|
78
|
+
[/^Need --iu \(Imax\) or --mva plus --kv$/, "\u9700\u8981 --iu\uFF08\u6700\u5927\u7535\u6D41\uFF09\uFF0C\u6216 --mva \u52A0 --kv"],
|
|
79
|
+
[/^Need --um, or --mva\/--kv so Um can be derived$/, "\u9700\u8981 --um\uFF0C\u6216\u7ED9 --mva/--kv \u4EE5\u63A8\u51FA Um"],
|
|
80
|
+
[/^Engine emitted a non-catalogue type: (.*)$/, "\u5F15\u64CE\u7ED9\u51FA\u4E86\u6837\u672C\u518C\u91CC\u6CA1\u6709\u7684\u578B\u53F7\uFF1A$1"],
|
|
81
|
+
[/^Bad transformer data$/, "\u53D8\u538B\u5668\u53C2\u6570\u6709\u8BEF"],
|
|
82
|
+
[/^No type found\.$/, "\u6CA1\u6709\u627E\u5230\u578B\u53F7\u3002"]
|
|
83
|
+
];
|
|
84
|
+
function cliErrorZh(en) {
|
|
85
|
+
for (const [re, to] of ROWS) {
|
|
86
|
+
const m = en.match(re);
|
|
87
|
+
if (!m) continue;
|
|
88
|
+
return typeof to === "function" ? to(m) : to.replace(/\$(\d)/g, (_, d) => m[Number(d)] ?? "");
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
var HAS_HAN = /[一-鿿]/;
|
|
93
|
+
function cliErrorLines(message, lang) {
|
|
94
|
+
const lines = message.split("\n").filter((l) => l !== "");
|
|
95
|
+
if (lang === "en") return lines;
|
|
96
|
+
if (lines.some((l) => HAS_HAN.test(l))) return lines;
|
|
97
|
+
const whole = cliErrorZh(message);
|
|
98
|
+
if (whole) return [whole, ...lines];
|
|
99
|
+
return lines.flatMap((l) => {
|
|
100
|
+
const zh = cliErrorZh(l);
|
|
101
|
+
return zh ? [zh, l] : [l];
|
|
102
|
+
});
|
|
103
|
+
}
|
|
5
104
|
|
|
6
105
|
// lib/decimal.ts
|
|
7
106
|
var GROUPED = /^\d{1,3}([,,]\d{3})+$/;
|
|
@@ -3045,6 +3144,9 @@ function normalizeTenderText(raw) {
|
|
|
3045
3144
|
}
|
|
3046
3145
|
function parseVectorGroup(raw) {
|
|
3047
3146
|
const text = raw.replace(
|
|
3147
|
+
/(?<![A-Za-z0-9])(yn|zn|y|d|z)((?:(?:yn|zn|y|d|z|a)\d{1,2}){1,3})(?![A-Za-z0-9])/g,
|
|
3148
|
+
(_m, head, rest) => head.toUpperCase() + rest
|
|
3149
|
+
).replace(
|
|
3048
3150
|
/\b(?:YN|Yn|Y|D|ZN|Z)(?:(?:yn|y|d|zn|z|a)[0-9Oo]{0,2}){1,3}(?![A-Za-z0-9])/g,
|
|
3049
3151
|
(g) => g.replace(/(?<=(?:yn|y|d|zn|z|a)\d?)[Oo]/g, "0")
|
|
3050
3152
|
).replace(/(?<![A-Za-z])Y[oO0](?![A-Za-z0-9])/g, "YN").replace(/[Δ△]/g, "D").replace(/\b(YN|Yn|Y|D|ZN|Z)\s*-\s*(?=(?:yn|y|d|zn|z|YN|Yn|Y|D)\s*\d)/g, "$1").replace(
|
|
@@ -3285,6 +3387,9 @@ var DRY_TYPE = /\bdry[\s-]?type\b|\bcast[\s-]?resin\b|\bresin[\s-]?(?:cast|encap
|
|
|
3285
3387
|
var OFF_CIRCUIT_TAP = new RegExp(
|
|
3286
3388
|
[
|
|
3287
3389
|
String.raw`\b(?:DETC|OCTC|NLTC)\b`,
|
|
3390
|
+
// 2026-11-14: "Dyn11 off-circuit ±2x2.5%" names no tap word. "Off-circuit"
|
|
3391
|
+
// and "de-energized" are never loss words; "no-load" is, so it still needs one.
|
|
3392
|
+
String.raw`\b(?:off[\s-]?circuit|de-?energi[sz]ed)\b`,
|
|
3288
3393
|
String.raw`\b(?:off[\s-]?(?:circuit|load)|no[\s-]?load|de-?energi[sz]ed)\s+tap`,
|
|
3289
3394
|
String.raw`\btap[\s-]?chang\w*\s*[(:,-]?\s*(?:off[\s-]?(?:circuit|load)|no[\s-]?load|de-?energi[sz]ed)`,
|
|
3290
3395
|
String.raw`(?:conmutador|cambiador)[^,;.]{0,30}(?:sin\s+carga|desenergizad)`,
|
|
@@ -4557,7 +4662,7 @@ Flags:
|
|
|
4557
4662
|
--step-pct % Step as percent (1.25 means 1.25%). Capacity path only.
|
|
4558
4663
|
--k n Safety factor on capacity path only (default 1.0, same as the web app).
|
|
4559
4664
|
--conn Y|D Switch connection (star point / line end). Default Y.
|
|
4560
|
-
|
|
4665
|
+
--iu path only. With --mva or --line it is an error: use --tap.
|
|
4561
4666
|
--reg W|G|0 Reversing / coarse-fine / linear. Default W.
|
|
4562
4667
|
--pm N \xB1 steps. Default 8.
|
|
4563
4668
|
--range +a/-b[xs%] Uneven range, e.g. +4/-12x1.25%. W/G takes the Fig. 3-3
|
|
@@ -4710,6 +4815,11 @@ function checkConflicts(args) {
|
|
|
4710
4815
|
throw new CliError("--conn D conflicts with --tap neutral: a neutral tap point is star (Y). Drop one.");
|
|
4711
4816
|
}
|
|
4712
4817
|
const typed = (...flags) => flags.some((f) => args.typed?.has(f));
|
|
4818
|
+
if (typed("--conn", "--connection") && args.mva != null) {
|
|
4819
|
+
throw new CliError(
|
|
4820
|
+
"--conn does not apply with --mva: the tap point sets Y or D. Use --tap line for a line end, --winding delta for a delta winding."
|
|
4821
|
+
);
|
|
4822
|
+
}
|
|
4713
4823
|
if (typed("--conn", "--connection") && typed("--tap") && args.conn === "Y" && args.tap === "line_end") {
|
|
4714
4824
|
throw new CliError("--conn Y conflicts with --tap line: a line-end tap point is delta (D). Drop one.");
|
|
4715
4825
|
}
|
|
@@ -4864,7 +4974,7 @@ function assumptionsFromArgs(args, family) {
|
|
|
4864
4974
|
const conn = cliConnection(args);
|
|
4865
4975
|
const derived = tapSetsConnection(args);
|
|
4866
4976
|
items.push(
|
|
4867
|
-
|
|
4977
|
+
`${conn} ${conn === "Y" ? "\u661F\u70B9" : "\u7EBF\u7AEF"}${derived ? "" : mark("conn")}`
|
|
4868
4978
|
);
|
|
4869
4979
|
if (args.kind === "auto") items.push("\u81EA\u8026\u53D8");
|
|
4870
4980
|
if (derived) {
|
|
@@ -4876,10 +4986,10 @@ function assumptionsFromArgs(args, family) {
|
|
|
4876
4986
|
if (args.mva != null) {
|
|
4877
4987
|
items.push(args.given.has("k") ? `k=${args.k}` : "k=1.0\uFF08\u9ED8\u8BA4\uFF09");
|
|
4878
4988
|
items.push(
|
|
4879
|
-
args.given.has("stepPct") ?
|
|
4989
|
+
args.given.has("stepPct") ? `\u6BCF\u7EA7 ${args.stepPct}%` : "\u6BCF\u7EA7 1.25%\uFF08\u9ED8\u8BA4\uFF09"
|
|
4880
4990
|
);
|
|
4881
4991
|
if (!args.given.has("minus") && !args.given.has("range")) {
|
|
4882
|
-
items.push(`\u6700\u4F4E\u6863\u6309 \u2212${cliMinusSteps(args)}
|
|
4992
|
+
items.push(`\u6700\u4F4E\u6863\u6309 \u2212${cliMinusSteps(args)}\uFF08\u672A\u6307\u5B9A\uFF09`);
|
|
4883
4993
|
}
|
|
4884
4994
|
if (args.lineRangeAssumed && args.range) {
|
|
4885
4995
|
const { plus, minus } = args.range;
|
|
@@ -4914,7 +5024,7 @@ function assumptionsFromArgs(args, family) {
|
|
|
4914
5024
|
return items;
|
|
4915
5025
|
}
|
|
4916
5026
|
items.push(
|
|
4917
|
-
|
|
5027
|
+
`${args.reg === "reversing" ? "W \u6B63\u53CD\u8C03" : args.reg === "coarse_fine" ? "G \u7C97\u7EC6\u8C03" : "0 \u7EBF\u6027\u8C03"}${mark("reg")}`
|
|
4918
5028
|
);
|
|
4919
5029
|
const uneven = args.range && args.range.plus !== args.range.minus ? `+${args.range.plus}/\u2212${args.range.minus}` : null;
|
|
4920
5030
|
if (args.reg === "linear") {
|
|
@@ -4942,21 +5052,31 @@ function assumptionsFromArgs(args, family) {
|
|
|
4942
5052
|
items.push(phases);
|
|
4943
5053
|
return items;
|
|
4944
5054
|
}
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
|
|
5055
|
+
var QUIET_ASSUMPTIONS = [
|
|
5056
|
+
/^(双绕组|自耦变)(默认)$/,
|
|
5057
|
+
/^(星形|角形)绕组(默认)$/,
|
|
5058
|
+
/^k=1\.0(默认)$/,
|
|
5059
|
+
/^(真空|油浸)(默认)$/,
|
|
5060
|
+
/^相数=.+(默认)$/,
|
|
5061
|
+
// The note and the per-class line under the type already say it.
|
|
5062
|
+
/^对地 Um [\d.]+(未指定)$/,
|
|
5063
|
+
// The engine's own note says the step voltage was not given.
|
|
5064
|
+
/^Ust 未指定/,
|
|
5065
|
+
new RegExp(`^(${Object.values(MOUNT_ZH).map((m) => m.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&")).join("|")})\uFF08\u9ED8\u8BA4\uFF09$`)
|
|
5066
|
+
];
|
|
5067
|
+
function assumptionsShown(args, family) {
|
|
5068
|
+
const assumed = (i) => i.includes("\uFF08\u9ED8\u8BA4") || i.includes("\u672A\u6307\u5B9A") || i.includes("\u62DB\u6807\u884C");
|
|
5069
|
+
const workedOut = (i) => /(由 |(±|→/.test(i) || i.startsWith("\u5F00\u5173\u5728") && !args.given.has("tap") || /^[YD] (星点|线端)$/.test(i) && args.mva == null && !args.given.has("conn");
|
|
5070
|
+
return assumptionsFromArgs(args, family).filter((i) => assumed(i) || workedOut(i)).filter((i) => !QUIET_ASSUMPTIONS.some((re) => re.test(i))).map((i) => i.replace(/(默认)$/, ""));
|
|
4951
5071
|
}
|
|
4952
5072
|
var round1 = (n) => Math.round(n * 10) / 10;
|
|
4953
5073
|
var ASSUMPTION_EN = [
|
|
5074
|
+
[/^最低档按 −(\d+)(未指定)$/, "lowest tap at \u2212$1 (not stated)"],
|
|
4954
5075
|
["\uFF08\u9ED8\u8BA4\uFF0C\u62DB\u6807\u884C\u672A\u5199\u5168\uFF09", " (default; the line does not give it all)"],
|
|
4955
5076
|
["\uFF08\u9ED8\u8BA4\uFF09", " (default)"],
|
|
4956
5077
|
["\uFF08\u672A\u6307\u5B9A\uFF09", " (not stated)"],
|
|
4957
5078
|
["\uFF08\u5F85 OS \u6838\u5BF9\uFF09", " (check the OS)"],
|
|
4958
5079
|
[/(只给一项:等级不低于 Um 默认)/, " (one value only: grade not below the Um default)"],
|
|
4959
|
-
[/^最低档按 −(\d+) 算(−档未指定,\+a\/−b 用 --range 或 --minus)$/, "lowest tap at \u2212$1 (minus not stated; give +a/\u2212b with --range or --minus)"],
|
|
4960
5080
|
[/^无载开关取 ([\d.]+) kV 绕组的范围((默认,)?招标行有两个调压范围)$/, "off-circuit range from the $1 kV winding (two ranges on the line)"],
|
|
4961
5081
|
[/^对地 Um ([\d.]+)(招标行中性点 BIL ([\d.]+) kV)$/, "Um to earth $1 (line neutral BIL $2 kV)"],
|
|
4962
5082
|
["Ust \u672A\u6307\u5B9A\uFF08\u7EA7\u7535\u538B\u3001\u7EA7\u5BB9\u91CF\u672A\u6821\u9A8C\uFF09", "Ust not stated (step voltage and capacity not checked)"],
|
|
@@ -4968,6 +5088,7 @@ var ASSUMPTION_EN = [
|
|
|
4968
5088
|
["\u81EA\u8026\u53D8", "autotransformer"],
|
|
4969
5089
|
["\u53CC\u7ED5\u7EC4", "two-winding"],
|
|
4970
5090
|
[/^容量 /, "power "],
|
|
5091
|
+
[/^每级 /, "step "],
|
|
4971
5092
|
["\u661F\u5F62\u7ED5\u7EC4", "star winding"],
|
|
4972
5093
|
["\u89D2\u5F62\u7ED5\u7EC4", "delta winding"],
|
|
4973
5094
|
[/^调压绕组间 /, "across tap winding "],
|
|
@@ -5007,7 +5128,7 @@ function assumptionEn(item) {
|
|
|
5007
5128
|
}
|
|
5008
5129
|
function basisLineEn(d) {
|
|
5009
5130
|
const div = d.currentDivisor === "three" ? "3" : "\u221A3";
|
|
5010
|
-
const um = d.umRule === "explicit" ? `Um to earth ${d.umKv} (stated)` : d.umRule === "neutral_assumed" || d.umRule === "neutral_full" ? `neutral Um ${d.umKv}
|
|
5131
|
+
const um = d.umRule === "explicit" ? `Um to earth ${d.umKv} (stated)` : d.umRule === "neutral_assumed" || d.umRule === "neutral_full" ? `neutral Um ${d.umKv}` : `${d.umSystemKv} kV system Um ${d.actualUmKv} \u2192 class ${d.umKv}`;
|
|
5011
5132
|
const ust = d.stepV == null ? "" : ` \xB7 Ust ${round1(d.stepV)} V`;
|
|
5012
5133
|
const max = d.maxRule === "stated" ? "OS Imax" : "lowest tap";
|
|
5013
5134
|
if (!(d.ratedA > 0)) return `Imax as given \xB7 ${um}`;
|
|
@@ -5015,7 +5136,7 @@ function basisLineEn(d) {
|
|
|
5015
5136
|
}
|
|
5016
5137
|
function basisLineZh(d) {
|
|
5017
5138
|
const div = d.currentDivisor === "three" ? "3" : "\u221A3";
|
|
5018
|
-
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}
|
|
5139
|
+
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.umSystemKv} kV \u7CFB\u7EDF Um ${d.actualUmKv} \u2192 ${d.umKv} \u7EA7`;
|
|
5019
5140
|
const ust = d.stepV == null ? "" : ` \xB7 Ust ${round1(d.stepV)} V`;
|
|
5020
5141
|
const max = d.maxRule === "stated" ? "OS Imax" : "\u6700\u4F4E\u6863";
|
|
5021
5142
|
if (!(d.ratedA > 0)) return `Imax \u6309\u7ED9\u5B9A\u503C \xB7 ${um}`;
|
|
@@ -5091,7 +5212,7 @@ function formatCliText(input, args) {
|
|
|
5091
5212
|
if (choices.length > 1) {
|
|
5092
5213
|
const list = choices.map((c) => `Um ${c.um} \u2192 ${c.model ?? (en ? "none" : "\u65E0")}`).join(" \xB7 ");
|
|
5093
5214
|
lines.push(
|
|
5094
|
-
en ? `
|
|
5215
|
+
en ? `By insulation class: ${list} (set it with --earth-um)` : `\u5404\u7EDD\u7F18\u7B49\u7EA7\u5BF9\u5E94\u578B\u53F7\uFF1A${list}\uFF08\u7528 --earth-um \u6307\u5B9A\uFF09`
|
|
5095
5216
|
);
|
|
5096
5217
|
}
|
|
5097
5218
|
if (args?.line) {
|
|
@@ -5103,14 +5224,14 @@ function formatCliText(input, args) {
|
|
|
5103
5224
|
}
|
|
5104
5225
|
if (alts.length) {
|
|
5105
5226
|
lines.push("");
|
|
5106
|
-
lines.push(en ? "Other" : "\u5176\u4ED6");
|
|
5227
|
+
lines.push(en ? "Other types that cover the duty" : "\u5176\u4ED6\u53EF\u9009");
|
|
5107
5228
|
for (const a of alts) lines.push(a.model);
|
|
5108
5229
|
}
|
|
5109
5230
|
if (args) {
|
|
5110
|
-
const
|
|
5111
|
-
if (
|
|
5231
|
+
const shown = assumptionsShown(args, primary.seriesCode);
|
|
5232
|
+
if (shown.length) {
|
|
5112
5233
|
lines.push("");
|
|
5113
|
-
lines.push(en ? `Assumed: ${
|
|
5234
|
+
lines.push(en ? `Assumed: ${shown.map(assumptionEn).join(" \xB7 ")}` : `\u5047\u5B9A\uFF1A${shown.join(" \xB7 ")}`);
|
|
5114
5235
|
}
|
|
5115
5236
|
}
|
|
5116
5237
|
return lines.join("\n") + "\n";
|
|
@@ -5179,7 +5300,8 @@ function formatCliJson(input, args) {
|
|
|
5179
5300
|
})(),
|
|
5180
5301
|
umChoices: args ? umChoicesFor(args, input) : [],
|
|
5181
5302
|
assumptions: args ? assumptionsFromArgs(args, primary?.seriesCode).map((a) => en ? assumptionEn(a) : a) : [],
|
|
5182
|
-
|
|
5303
|
+
// Same lines as the text output: Chinese then English, or English alone.
|
|
5304
|
+
errors: [...en ? out.errorsEn : [...out.errorsZh, ...out.errorsEn], ...hint ? [hint] : []]
|
|
5183
5305
|
};
|
|
5184
5306
|
return JSON.stringify(payload, null, 2) + "\n";
|
|
5185
5307
|
}
|
|
@@ -5217,11 +5339,17 @@ function runCli(argv2, io = {
|
|
|
5217
5339
|
return 0;
|
|
5218
5340
|
}
|
|
5219
5341
|
const wantsJson = argv2.includes("--json");
|
|
5342
|
+
const langAt = argv2.findIndex((a) => a === "--lang" || a.startsWith("--lang="));
|
|
5343
|
+
const langArg = langAt < 0 ? void 0 : argv2[langAt].includes("=") ? argv2[langAt].split("=")[1] : argv2[langAt + 1];
|
|
5344
|
+
const envLang = typeof process !== "undefined" ? process.env?.OLTC_LANG : void 0;
|
|
5345
|
+
const lang = (langArg ?? envLang ?? "zh").toLowerCase() === "en" ? "en" : "zh";
|
|
5220
5346
|
try {
|
|
5221
5347
|
const args = parseCliArgs(argv2);
|
|
5222
5348
|
if (args.version) {
|
|
5223
|
-
io.stdout(
|
|
5224
|
-
`
|
|
5349
|
+
io.stdout(
|
|
5350
|
+
wantsJson ? JSON.stringify({ ok: true, version: APP_VERSION }, null, 2) + "\n" : `oltc-selector ${APP_VERSION}
|
|
5351
|
+
`
|
|
5352
|
+
);
|
|
5225
5353
|
return 0;
|
|
5226
5354
|
}
|
|
5227
5355
|
const input = cliToSelectInput(args);
|
|
@@ -5234,12 +5362,12 @@ function runCli(argv2, io = {
|
|
|
5234
5362
|
return 0;
|
|
5235
5363
|
} catch (err) {
|
|
5236
5364
|
const msg = err instanceof Error ? err.message : String(err);
|
|
5365
|
+
const lines = cliErrorLines(msg, lang);
|
|
5237
5366
|
if (wantsJson) {
|
|
5238
|
-
io.stdout(
|
|
5239
|
-
|
|
5240
|
-
);
|
|
5367
|
+
io.stdout(JSON.stringify({ ok: false, version: APP_VERSION, model: null, errors: lines }, null, 2) + "\n");
|
|
5368
|
+
return 1;
|
|
5241
5369
|
}
|
|
5242
|
-
io.stderr(
|
|
5370
|
+
io.stderr(lines.join("\n") + "\n");
|
|
5243
5371
|
return 1;
|
|
5244
5372
|
}
|
|
5245
5373
|
}
|