poe-svelte-ui-lib 3.13.0 → 3.13.2
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/dist/WidgetFOC/WidgetFOC.svelte +204 -149
- package/dist/gui.d.ts +3 -0
- package/dist/gui.js +10 -7
- package/dist/locales/translations.d.ts +15 -0
- package/dist/locales/translations.js +3 -0
- package/package.json +1 -1
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
const hints = $derived(hintsSetting("WidgetFOC", persistKey))
|
|
34
34
|
const rootStyle = $derived(accentStyle(accent))
|
|
35
35
|
|
|
36
|
-
/* Свёрнутость: выбор пользователя переживает перезагрузку (persistKey) */
|
|
37
36
|
const guiCollapsed = untrack(() => collapsed)
|
|
38
37
|
collapsed = readPersistedCollapsed(
|
|
39
38
|
untrack(() => persistKey),
|
|
@@ -41,7 +40,6 @@
|
|
|
41
40
|
)
|
|
42
41
|
$effect(() => writePersistedCollapsed(persistKey, collapsed, guiCollapsed))
|
|
43
42
|
|
|
44
|
-
/* Живое состояние: пока виджет раскрыт, раз в refreshMs он просит перечитать группу */
|
|
45
43
|
$effect(() => {
|
|
46
44
|
if (collapsed || !refreshMs || !onRefresh) return
|
|
47
45
|
const timer = setInterval(() => onRefresh?.(), refreshMs)
|
|
@@ -50,7 +48,6 @@
|
|
|
50
48
|
|
|
51
49
|
const finite = (v: unknown) => (v === undefined || v === null || v === "" || !Number.isFinite(Number(v)) ? undefined : Number(v))
|
|
52
50
|
|
|
53
|
-
/* Флаги оси (Flg): 0x01 включён, 0x02 выход в угол, 0x04 калибровка нуля, 0x08 поток уставок прервался, 0x10 ноль известен, 0x20 занят процедурой */
|
|
54
51
|
const flags = $derived(finite(value.Flg))
|
|
55
52
|
const flag = (bit: number) => flags !== undefined && (flags & bit) !== 0
|
|
56
53
|
const enabled = $derived(flag(0x01))
|
|
@@ -67,85 +64,77 @@
|
|
|
67
64
|
],
|
|
68
65
|
)
|
|
69
66
|
|
|
70
|
-
/* Настройки по разделам: ключ, единица (ключ перевода widget.foc.unit.*), выбор - варианты 0..n-1, только чтение */
|
|
71
67
|
type Field = { key: string; unit?: string; options?: string[]; readonly?: boolean; step?: number; torqueModes?: number[] }
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
{ key: "A_Lim", unit: "dps", step: 1 },
|
|
112
|
-
],
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
key: "sensor",
|
|
116
|
-
fields: [
|
|
117
|
-
{ key: "S_Gain", unit: "vpa", step: 0.001 },
|
|
118
|
-
{ key: "S_OffA", unit: "volt", readonly: true },
|
|
119
|
-
{ key: "S_OffB", unit: "volt", readonly: true },
|
|
120
|
-
{ key: "S_OffC", unit: "volt", readonly: true },
|
|
121
|
-
{ key: "S_VTf", unit: "sec", step: 0.001 },
|
|
122
|
-
{ key: "S_CTf", unit: "sec", step: 0.0001 },
|
|
123
|
-
],
|
|
124
|
-
},
|
|
68
|
+
|
|
69
|
+
const motorFields: Field[] = [
|
|
70
|
+
{ key: "M_Type", options: ["bldc", "stepper"] },
|
|
71
|
+
{ key: "M_PP", step: 1 },
|
|
72
|
+
{ key: "M_R", unit: "ohm", step: 0.01 },
|
|
73
|
+
{ key: "M_L", unit: "h", step: 0.0001 },
|
|
74
|
+
{ key: "M_KV", unit: "kv", step: 1 },
|
|
75
|
+
{ key: "M_Dir", readonly: true },
|
|
76
|
+
]
|
|
77
|
+
|
|
78
|
+
const limitsFields: Field[] = [
|
|
79
|
+
{ key: "M_VL", unit: "volt", step: 0.1 },
|
|
80
|
+
{ key: "M_CL", unit: "amp", step: 0.01, torqueModes: [1, 2, 3] },
|
|
81
|
+
{ key: "M_VLL", unit: "dps", step: 1 },
|
|
82
|
+
{ key: "M_CTO", unit: "ms", step: 10 },
|
|
83
|
+
{ key: "M_Torq", options: ["voltage", "estCurrent", "dcCurrent", "focCurrent"] },
|
|
84
|
+
{ key: "M_Mod", options: ["spwm", "svm", "trap120", "trap150"] },
|
|
85
|
+
]
|
|
86
|
+
|
|
87
|
+
const currentFields: Field[] = [
|
|
88
|
+
{ key: "C_Kp", step: 0.001, torqueModes: [2, 3] },
|
|
89
|
+
{ key: "C_Ki", step: 0.001, torqueModes: [2, 3] },
|
|
90
|
+
{ key: "C_Kd", step: 0.001, torqueModes: [2, 3] },
|
|
91
|
+
{ key: "C_Lim", unit: "volt", readonly: true },
|
|
92
|
+
{ key: "C_Ramp", unit: "vps", step: 0.001, torqueModes: [2, 3] },
|
|
93
|
+
]
|
|
94
|
+
|
|
95
|
+
const velocityFields: Field[] = [
|
|
96
|
+
{ key: "V_Kp", step: 0.0001 },
|
|
97
|
+
{ key: "V_Ki", step: 0.0001 },
|
|
98
|
+
{ key: "V_Kd", step: 0.0001 },
|
|
99
|
+
{ key: "V_Lim", readonly: true },
|
|
100
|
+
{ key: "V_Ramp", step: 0.0001 },
|
|
101
|
+
]
|
|
102
|
+
|
|
103
|
+
const angleFields: Field[] = [
|
|
104
|
+
{ key: "A_Kp", step: 0.1 },
|
|
105
|
+
{ key: "A_Lim", unit: "dps", step: 1 },
|
|
106
|
+
{ key: "A_Ramp", unit: "dps2", step: 1 },
|
|
125
107
|
]
|
|
108
|
+
|
|
109
|
+
const sensorFields: Field[] = [
|
|
110
|
+
{ key: "S_Gain", unit: "vpa", step: 0.001 },
|
|
111
|
+
{ key: "S_OffA", unit: "volt", readonly: true },
|
|
112
|
+
{ key: "S_OffB", unit: "volt", readonly: true },
|
|
113
|
+
{ key: "S_OffC", unit: "volt", readonly: true },
|
|
114
|
+
{ key: "S_VTf", unit: "sec", step: 0.001 },
|
|
115
|
+
{ key: "S_CTf", unit: "sec", step: 0.0001 },
|
|
116
|
+
]
|
|
117
|
+
|
|
118
|
+
const allFields = [...motorFields, ...limitsFields, ...currentFields, ...velocityFields, ...angleFields, ...sensorFields]
|
|
119
|
+
|
|
126
120
|
let open = $state<Record<string, boolean>>({})
|
|
127
121
|
let edits = $state<Record<string, number>>({})
|
|
128
122
|
const read = (key: string) => finite(value[key as keyof typeof value])
|
|
123
|
+
|
|
129
124
|
const polePairs = $derived(read("M_PP") ?? 0)
|
|
130
125
|
const zeroTravel = $derived(
|
|
131
126
|
Number.isInteger(polePairs) && polePairs > 0
|
|
132
127
|
? $T("widget.foc.zero.travel", { degrees: (270 / polePairs).toLocaleString($Language, { maximumFractionDigits: 1 }) })
|
|
133
128
|
: $T("widget.foc.zero.travel.unknown"),
|
|
134
129
|
)
|
|
130
|
+
|
|
135
131
|
const torqueMode = $derived(edits.M_Torq ?? read("M_Torq"))
|
|
136
132
|
const motorType = $derived(edits.M_Type ?? read("M_Type"))
|
|
137
133
|
const usesCurrentLoop = $derived(torqueMode === undefined || torqueMode === 2 || torqueMode === 3)
|
|
134
|
+
|
|
138
135
|
const available = (f: Field) => (f.key === "M_Mod" ? motorType !== 1 : !f.torqueModes || torqueMode === undefined || f.torqueModes.includes(torqueMode))
|
|
139
136
|
const shown = (f: Field) => (available(f) ? edits[f.key] : undefined) ?? read(f.key)
|
|
140
|
-
|
|
141
|
-
SECTIONS.flatMap(({ fields }) => fields).filter((f) => !f.readonly && available(f) && edits[f.key] !== undefined && edits[f.key] !== read(f.key)),
|
|
142
|
-
)
|
|
143
|
-
const dirty = $derived(Object.keys(edits).some((key) => edits[key] !== read(key)))
|
|
144
|
-
const save = () => {
|
|
145
|
-
if (!onSave || busy || !changedFields.length) return
|
|
146
|
-
onSave(Object.fromEntries(changedFields.map(({ key }) => [key, edits[key]])))
|
|
147
|
-
edits = {}
|
|
148
|
-
}
|
|
137
|
+
|
|
149
138
|
const fieldName = (f: Field) => {
|
|
150
139
|
const reportedMode = read("M_Torq")
|
|
151
140
|
const unit =
|
|
@@ -161,29 +150,64 @@
|
|
|
161
150
|
return `${$T(`widget.foc.field.${f.key}`)}${unit ? `, ${$T(`widget.foc.unit.${unit}`)}` : ""}`
|
|
162
151
|
}
|
|
163
152
|
const optionText = (f: Field, v: number | undefined) => (v === undefined ? "-" : f.options ? $T(`widget.foc.opt.${f.options[v] ?? v}`) : String(v))
|
|
164
|
-
|
|
165
|
-
|
|
153
|
+
|
|
154
|
+
const summaryOf = (fields: Field[]) =>
|
|
155
|
+
fields
|
|
166
156
|
.filter(available)
|
|
167
157
|
.slice(0, 4)
|
|
168
158
|
.map((f) => `${f.key} ${optionText(f, shown(f))}`)
|
|
169
159
|
.join(" · ")
|
|
170
160
|
|
|
171
|
-
|
|
161
|
+
const changedEntries = $derived(
|
|
162
|
+
Object.entries(edits)
|
|
163
|
+
.filter(([k, v]) => v !== read(k))
|
|
164
|
+
.filter(([k]) => {
|
|
165
|
+
const f = allFields.find((x) => x.key === k)
|
|
166
|
+
return !!f && !f.readonly && available(f)
|
|
167
|
+
}),
|
|
168
|
+
)
|
|
169
|
+
const dirty = $derived(changedEntries.length > 0)
|
|
170
|
+
const save = () => {
|
|
171
|
+
if (!onSave || busy || !changedEntries.length) return
|
|
172
|
+
onSave(Object.fromEntries(changedEntries))
|
|
173
|
+
edits = {}
|
|
174
|
+
}
|
|
175
|
+
|
|
172
176
|
let tuneHz = $state<number | undefined>(undefined)
|
|
173
177
|
const tuneShown = $derived(tuneHz ?? read("TuneHz") ?? 40)
|
|
174
178
|
let tuneWait = $state(false)
|
|
179
|
+
let tuneSeen = false
|
|
175
180
|
let tuneTimer: ReturnType<typeof setTimeout> | undefined
|
|
176
181
|
onDestroy(() => clearTimeout(tuneTimer))
|
|
182
|
+
/* Пока BUSY стоит - замер идёт, страховка перезапускается; снялся - результат готов */
|
|
183
|
+
$effect(() => {
|
|
184
|
+
if (!tuneWait) return
|
|
185
|
+
if (busy) {
|
|
186
|
+
tuneSeen = true
|
|
187
|
+
clearTimeout(tuneTimer)
|
|
188
|
+
tuneTimer = setTimeout(() => (tuneWait = false), 2500)
|
|
189
|
+
return
|
|
190
|
+
}
|
|
191
|
+
if (tuneSeen) {
|
|
192
|
+
tuneWait = false
|
|
193
|
+
tuneSeen = false
|
|
194
|
+
clearTimeout(tuneTimer)
|
|
195
|
+
onRefresh?.()
|
|
196
|
+
}
|
|
197
|
+
})
|
|
177
198
|
const tune = () => {
|
|
178
199
|
if (!onTune) return
|
|
179
200
|
onTune(tuneShown)
|
|
180
201
|
tuneWait = true
|
|
202
|
+
tuneSeen = false
|
|
181
203
|
clearTimeout(tuneTimer)
|
|
182
204
|
tuneTimer = setTimeout(() => {
|
|
183
205
|
tuneWait = false
|
|
184
206
|
onRefresh?.()
|
|
185
207
|
}, 2500)
|
|
186
208
|
}
|
|
209
|
+
|
|
210
|
+
const hasCurrentSensor = $derived(value.IA !== undefined && value.IB !== undefined && value.IC !== undefined)
|
|
187
211
|
</script>
|
|
188
212
|
|
|
189
213
|
{#snippet fieldCell(title: string, samples: string[], inset: string, content: Snippet)}
|
|
@@ -195,7 +219,7 @@
|
|
|
195
219
|
<div class="text-[14px]" style:padding-inline={inset}>{sample}</div>
|
|
196
220
|
{/each}
|
|
197
221
|
</div>
|
|
198
|
-
<div class="[
|
|
222
|
+
<div class="contain-[inline-size]">
|
|
199
223
|
{@render content()}
|
|
200
224
|
</div>
|
|
201
225
|
</div>
|
|
@@ -216,6 +240,59 @@
|
|
|
216
240
|
{/snippet}
|
|
217
241
|
{/snippet}
|
|
218
242
|
|
|
243
|
+
{#snippet selectField(f: Field)}
|
|
244
|
+
{@const options = f.options!.map((o, i) => ({ id: `${f.key}-${o}`, name: $T(`widget.foc.opt.${o}`), value: i }))}
|
|
245
|
+
{@render fieldCell(
|
|
246
|
+
fieldName(f),
|
|
247
|
+
options.map(({ name }) => name),
|
|
248
|
+
"1.5rem",
|
|
249
|
+
select,
|
|
250
|
+
)}
|
|
251
|
+
{#snippet select()}
|
|
252
|
+
<UI.Select
|
|
253
|
+
type="buttons"
|
|
254
|
+
label={{ name: fieldName(f) }}
|
|
255
|
+
{options}
|
|
256
|
+
value={shown(f)}
|
|
257
|
+
disabled={!onSave || busy}
|
|
258
|
+
onUpdate={(v) => (edits = { ...edits, [f.key]: Number(v) })}
|
|
259
|
+
/>
|
|
260
|
+
{/snippet}
|
|
261
|
+
{/snippet}
|
|
262
|
+
|
|
263
|
+
{#snippet field(f: Field)}
|
|
264
|
+
{#if available(f)}
|
|
265
|
+
{#if f.options}
|
|
266
|
+
{@render selectField(f)}
|
|
267
|
+
{:else}
|
|
268
|
+
{@render numberField(f)}
|
|
269
|
+
{/if}
|
|
270
|
+
{/if}
|
|
271
|
+
{/snippet}
|
|
272
|
+
|
|
273
|
+
{#snippet section(key: string, fields: Field[], children?: Snippet)}
|
|
274
|
+
<div class="flex flex-col rounded-[10px] border border-(--hairline-color) bg-(--back-color)">
|
|
275
|
+
<div class="px-3 py-2" use:hint={{ text: $T(`widget.foc.hint.${key}`), enabled: $hints }}>
|
|
276
|
+
<SectionHead
|
|
277
|
+
title={$T(`widget.foc.section.${key}`)}
|
|
278
|
+
summary={summaryOf(fields)}
|
|
279
|
+
open={!!open[key]}
|
|
280
|
+
onToggle={() => (open = { ...open, [key]: !open[key] })}
|
|
281
|
+
/>
|
|
282
|
+
</div>
|
|
283
|
+
{#if open[key]}
|
|
284
|
+
<div class="flex flex-wrap items-end gap-x-3 gap-y-2 border-t border-(--hairline-color) p-3">
|
|
285
|
+
{#each fields as f (f.key)}
|
|
286
|
+
{@render field(f)}
|
|
287
|
+
{/each}
|
|
288
|
+
{#if children}
|
|
289
|
+
{@render children()}
|
|
290
|
+
{/if}
|
|
291
|
+
</div>
|
|
292
|
+
{/if}
|
|
293
|
+
</div>
|
|
294
|
+
{/snippet}
|
|
295
|
+
|
|
219
296
|
<div
|
|
220
297
|
class={twMerge("@container relative flex w-full flex-col gap-4 rounded-2xl border border-(--hairline-color) bg-(--container-color) p-4", wrapperClass)}
|
|
221
298
|
style={rootStyle}
|
|
@@ -236,6 +313,33 @@
|
|
|
236
313
|
</span>
|
|
237
314
|
{/each}
|
|
238
315
|
</div>
|
|
316
|
+
{#if onTune}
|
|
317
|
+
{@const tuneLabel = `${$T("widget.foc.field.TuneHz")}, ${$T("widget.foc.unit.hz")}`}
|
|
318
|
+
<div class="flex flex-wrap items-center gap-2" use:hint={{ text: $T("widget.foc.hint.tune"), enabled: $hints }}>
|
|
319
|
+
<div class="w-24 shrink-0">
|
|
320
|
+
{@render fieldCell(tuneLabel, [String(tuneShown)], "1.5rem", bandwidth)}
|
|
321
|
+
</div>
|
|
322
|
+
{#snippet bandwidth()}
|
|
323
|
+
<UI.Input
|
|
324
|
+
wrapperClass="w-24"
|
|
325
|
+
type="number"
|
|
326
|
+
label={{ name: tuneLabel }}
|
|
327
|
+
value={tuneShown}
|
|
328
|
+
number={{ minNum: 5, maxNum: 60, step: 1 }}
|
|
329
|
+
disabled={busy || tuneWait}
|
|
330
|
+
onUpdate={(v) => (tuneHz = Number(v))}
|
|
331
|
+
/>
|
|
332
|
+
{/snippet}
|
|
333
|
+
<UI.Button
|
|
334
|
+
wrapperClass="w-40"
|
|
335
|
+
variant="primary"
|
|
336
|
+
content={{ name: $T("widget.foc.tune") }}
|
|
337
|
+
disabled={!enabled || busy || tuneWait}
|
|
338
|
+
confirm={$T("widget.foc.tune.confirm")}
|
|
339
|
+
onClick={tune}
|
|
340
|
+
/>
|
|
341
|
+
</div>
|
|
342
|
+
{/if}
|
|
239
343
|
{#if onEnable}
|
|
240
344
|
<div use:hint={{ text: $T("widget.foc.hint.enable"), enabled: $hints }}>
|
|
241
345
|
<UI.Button
|
|
@@ -256,90 +360,41 @@
|
|
|
256
360
|
<SensorReadout label="Uq" value={value.Uq} digits={2} unit={$T("widget.foc.unit.volt")} />
|
|
257
361
|
</div>
|
|
258
362
|
|
|
259
|
-
{#if
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
<
|
|
263
|
-
|
|
264
|
-
{#snippet bandwidth()}
|
|
265
|
-
<UI.Input
|
|
266
|
-
type="number"
|
|
267
|
-
label={{ name: tuneLabel }}
|
|
268
|
-
value={tuneShown}
|
|
269
|
-
number={{ minNum: 5, maxNum: 60, step: 1 }}
|
|
270
|
-
disabled={busy || tuneWait}
|
|
271
|
-
onUpdate={(v) => (tuneHz = Number(v))}
|
|
272
|
-
/>
|
|
273
|
-
{/snippet}
|
|
274
|
-
<UI.Button
|
|
275
|
-
wrapperClass="w-44"
|
|
276
|
-
variant="primary"
|
|
277
|
-
content={{ name: $T("widget.foc.tune") }}
|
|
278
|
-
disabled={!enabled || busy || tuneWait}
|
|
279
|
-
confirm={$T("widget.foc.tune.confirm")}
|
|
280
|
-
onClick={tune}
|
|
281
|
-
/>
|
|
282
|
-
</div>
|
|
363
|
+
{#if hasCurrentSensor}
|
|
364
|
+
<div class="grid grid-cols-3 gap-1.5" use:hint={{ text: $T("widget.foc.hint.phaseCurrents"), enabled: $hints }}>
|
|
365
|
+
<SensorReadout label="IA" value={value.IA} digits={3} unit={$T("widget.foc.unit.amp")} />
|
|
366
|
+
<SensorReadout label="IB" value={value.IB} digits={3} unit={$T("widget.foc.unit.amp")} />
|
|
367
|
+
<SensorReadout label="IC" value={value.IC} digits={3} unit={$T("widget.foc.unit.amp")} />
|
|
283
368
|
</div>
|
|
284
369
|
{/if}
|
|
285
370
|
|
|
286
|
-
{#
|
|
287
|
-
<div class="flex
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
{@const options = f.options.map((o, i) => ({ id: `${f.key}-${o}`, name: $T(`widget.foc.opt.${o}`), value: i }))}
|
|
301
|
-
{@render fieldCell(
|
|
302
|
-
fieldName(f),
|
|
303
|
-
options.map(({ name }) => name),
|
|
304
|
-
"1.5rem",
|
|
305
|
-
select,
|
|
306
|
-
)}
|
|
307
|
-
{#snippet select()}
|
|
308
|
-
<UI.Select
|
|
309
|
-
type="buttons"
|
|
310
|
-
label={{ name: fieldName(f) }}
|
|
311
|
-
{options}
|
|
312
|
-
value={shown(f)}
|
|
313
|
-
disabled={!onSave || busy}
|
|
314
|
-
onUpdate={(v) => (edits = { ...edits, [f.key]: Number(v) })}
|
|
315
|
-
/>
|
|
316
|
-
{/snippet}
|
|
317
|
-
{:else}
|
|
318
|
-
{@render numberField(f)}
|
|
319
|
-
{/if}
|
|
320
|
-
{/each}
|
|
321
|
-
{#if section.key === "motor"}
|
|
322
|
-
<div class="flex max-w-full min-w-0 flex-[0_1_max-content] flex-wrap items-end gap-x-3 gap-y-2">
|
|
323
|
-
{@render numberField({ key: "ZEA", unit: "edeg", readonly: true })}
|
|
324
|
-
{#if onZero}
|
|
325
|
-
<div use:hint={{ text: $T("widget.foc.hint.zero"), enabled: $hints }}>
|
|
326
|
-
<UI.Button
|
|
327
|
-
wrapperClass="w-auto"
|
|
328
|
-
componentClass="px-3 whitespace-nowrap"
|
|
329
|
-
variant="primary"
|
|
330
|
-
content={{ name: $T("widget.foc.zero") }}
|
|
331
|
-
disabled={!enabled || busy}
|
|
332
|
-
confirm={`${$T("widget.foc.zero.confirm")}\n\n${zeroTravel}`}
|
|
333
|
-
onClick={onZero}
|
|
334
|
-
/>
|
|
335
|
-
</div>
|
|
336
|
-
{/if}
|
|
337
|
-
</div>
|
|
338
|
-
{/if}
|
|
371
|
+
{#snippet motorExtra()}
|
|
372
|
+
<div class="flex max-w-full min-w-0 flex-[0_1_max-content] flex-wrap items-end gap-x-3 gap-y-2">
|
|
373
|
+
{@render numberField({ key: "ZEA", unit: "edeg", readonly: true })}
|
|
374
|
+
{#if onZero}
|
|
375
|
+
<div use:hint={{ text: $T("widget.foc.hint.zero"), enabled: $hints }}>
|
|
376
|
+
<UI.Button
|
|
377
|
+
wrapperClass="w-auto"
|
|
378
|
+
componentClass="px-3 whitespace-nowrap"
|
|
379
|
+
variant="primary"
|
|
380
|
+
content={{ name: $T("widget.foc.zero") }}
|
|
381
|
+
disabled={!enabled || busy}
|
|
382
|
+
confirm={`${$T("widget.foc.zero.confirm")}\n\n${zeroTravel}`}
|
|
383
|
+
onClick={onZero}
|
|
384
|
+
/>
|
|
339
385
|
</div>
|
|
340
386
|
{/if}
|
|
341
387
|
</div>
|
|
342
|
-
{/
|
|
388
|
+
{/snippet}
|
|
389
|
+
|
|
390
|
+
{@render section("motor", motorFields, motorExtra)}
|
|
391
|
+
{@render section("limits", limitsFields)}
|
|
392
|
+
{#if usesCurrentLoop}
|
|
393
|
+
{@render section("current", currentFields)}
|
|
394
|
+
{/if}
|
|
395
|
+
{@render section("velocity", velocityFields)}
|
|
396
|
+
{@render section("angle", angleFields)}
|
|
397
|
+
{@render section("sensor", sensorFields)}
|
|
343
398
|
|
|
344
399
|
{#if onSave}
|
|
345
400
|
<div class="flex flex-col items-center gap-2">
|
|
@@ -372,7 +427,7 @@
|
|
|
372
427
|
componentClass="px-2 whitespace-nowrap"
|
|
373
428
|
variant="primary"
|
|
374
429
|
content={{ name: $T("widget.common.save") }}
|
|
375
|
-
disabled={!
|
|
430
|
+
disabled={!changedEntries.length || busy}
|
|
376
431
|
onClick={save}
|
|
377
432
|
/>
|
|
378
433
|
</div>
|
package/dist/gui.d.ts
CHANGED
package/dist/gui.js
CHANGED
|
@@ -171,13 +171,16 @@ export const WIDGET_FIELDS = {
|
|
|
171
171
|
Iq: num,
|
|
172
172
|
Uq: num,
|
|
173
173
|
Flg: num,
|
|
174
|
+
IA: num /* токи фаз, только при наличии датчика тока */,
|
|
175
|
+
IB: num,
|
|
176
|
+
IC: num,
|
|
174
177
|
M_Type: num,
|
|
175
178
|
M_PP: num,
|
|
176
179
|
M_R: num,
|
|
177
180
|
M_L: num,
|
|
178
181
|
M_KV: num,
|
|
179
|
-
M_Dir: num
|
|
180
|
-
ZEA: num
|
|
182
|
+
M_Dir: num /* readonly в прошивке */,
|
|
183
|
+
ZEA: num /* readonly в прошивке */,
|
|
181
184
|
M_VL: num,
|
|
182
185
|
M_CL: num,
|
|
183
186
|
M_VLL: num,
|
|
@@ -198,13 +201,13 @@ export const WIDGET_FIELDS = {
|
|
|
198
201
|
A_Lim: num,
|
|
199
202
|
A_Ramp: num,
|
|
200
203
|
S_Gain: num,
|
|
201
|
-
S_OffA: num
|
|
202
|
-
S_OffB: num
|
|
203
|
-
S_OffC: num
|
|
204
|
+
S_OffA: num /* readonly в прошивке */,
|
|
205
|
+
S_OffB: num /* readonly в прошивке */,
|
|
206
|
+
S_OffC: num /* readonly в прошивке */,
|
|
204
207
|
S_VTf: num,
|
|
205
208
|
S_CTf: num,
|
|
206
|
-
TuneHz: num
|
|
207
|
-
Run: num,
|
|
209
|
+
TuneHz: num /* range 5..100 */,
|
|
210
|
+
Run: num /* 0/1, триггер автонастройки */,
|
|
208
211
|
},
|
|
209
212
|
/* База оси любого привода (группа HOME, компонент homing прошивки): способ, состояние и края - только чтение; Off, Speed, Marg и ключи способа сохраняются */
|
|
210
213
|
WidgetHoming: {
|
|
@@ -1804,6 +1804,11 @@ declare const translations: {
|
|
|
1804
1804
|
en: string;
|
|
1805
1805
|
zh: string;
|
|
1806
1806
|
};
|
|
1807
|
+
"widget.foc.field.A_Ramp": {
|
|
1808
|
+
ru: string;
|
|
1809
|
+
en: string;
|
|
1810
|
+
zh: string;
|
|
1811
|
+
};
|
|
1807
1812
|
"widget.foc.field.M_Type": {
|
|
1808
1813
|
ru: string;
|
|
1809
1814
|
en: string;
|
|
@@ -2014,6 +2019,11 @@ declare const translations: {
|
|
|
2014
2019
|
en: string;
|
|
2015
2020
|
zh: string;
|
|
2016
2021
|
};
|
|
2022
|
+
"widget.foc.unit.dps2": {
|
|
2023
|
+
ru: string;
|
|
2024
|
+
en: string;
|
|
2025
|
+
zh: string;
|
|
2026
|
+
};
|
|
2017
2027
|
"widget.foc.unit.ohm": {
|
|
2018
2028
|
ru: string;
|
|
2019
2029
|
en: string;
|
|
@@ -2119,6 +2129,11 @@ declare const translations: {
|
|
|
2119
2129
|
en: string;
|
|
2120
2130
|
zh: string;
|
|
2121
2131
|
};
|
|
2132
|
+
"widget.foc.hint.phaseCurrents": {
|
|
2133
|
+
ru: string;
|
|
2134
|
+
en: string;
|
|
2135
|
+
zh: string;
|
|
2136
|
+
};
|
|
2122
2137
|
"widget.foc.hint.zero": {
|
|
2123
2138
|
ru: string;
|
|
2124
2139
|
en: string;
|
|
@@ -801,6 +801,7 @@ const translations = {
|
|
|
801
801
|
"widget.foc.section.velocity": { ru: "Контур скорости", en: "Velocity loop", zh: "速度环" },
|
|
802
802
|
"widget.foc.section.angle": { ru: "Контур угла", en: "Angle loop", zh: "角度环" },
|
|
803
803
|
"widget.foc.section.sensor": { ru: "Датчик тока и фильтры", en: "Current sensor and filters", zh: "电流传感器与滤波" },
|
|
804
|
+
"widget.foc.field.A_Ramp": { ru: "Нарастание", en: "Ramp", zh: "斜坡" },
|
|
804
805
|
"widget.foc.field.M_Type": { ru: "Тип", en: "Type", zh: "类型" },
|
|
805
806
|
"widget.foc.field.M_PP": { ru: "Пары полюсов", en: "Pole pairs", zh: "极对数" },
|
|
806
807
|
"widget.foc.field.M_R": { ru: "R фазы", en: "Phase R", zh: "相电阻" },
|
|
@@ -843,6 +844,7 @@ const translations = {
|
|
|
843
844
|
"widget.foc.opt.svm": { ru: "SVM", en: "SVM", zh: "SVM" },
|
|
844
845
|
"widget.foc.opt.trap120": { ru: "Trap 120", en: "Trap 120", zh: "Trap 120" },
|
|
845
846
|
"widget.foc.opt.trap150": { ru: "Trap 150", en: "Trap 150", zh: "Trap 150" },
|
|
847
|
+
"widget.foc.unit.dps2": { ru: "°/с²", en: "°/s²", zh: "°/s²" },
|
|
846
848
|
"widget.foc.unit.ohm": { ru: "Ом", en: "Ω", zh: "Ω" },
|
|
847
849
|
"widget.foc.unit.h": { ru: "Гн", en: "H", zh: "H" },
|
|
848
850
|
"widget.foc.unit.kv": { ru: "об/мин/В", en: "rpm/V", zh: "rpm/V" },
|
|
@@ -896,6 +898,7 @@ const translations = {
|
|
|
896
898
|
en: "**Angle** - shaft angle, 0-360°\n**Speed** - shaft speed, °/s\n**Iq** - torque current, A\n**Uq** - q-axis voltage, V\n**Update** - once a second while the widget is open",
|
|
897
899
|
zh: "**角度** - 轴角度,0-360°\n**速度** - 轴速度,°/s\n**Iq** - 力矩电流,A\n**Uq** - q 轴电压,V\n**更新** - 组件展开时每秒一次",
|
|
898
900
|
},
|
|
901
|
+
"widget.foc.hint.phaseCurrents": { ru: "Токи фаз, А. Плюс — ток в мотор.", en: "Phase currents, A. Positive — current into the motor.", zh: "相电流,A。正值为流入电机的电流。" },
|
|
899
902
|
"widget.foc.hint.zero": {
|
|
900
903
|
ru: "**Поиск электрического нуля** совмещает ротор с полем, затем поворачивает поле на 90 эл. ° для определения направления датчика. После успеха сохраняет `ZEA` и `M_Dir`.\nПовторите поиск после замены мотора, энкодера или магнита. Ось должна свободно поворачиваться в обе стороны.",
|
|
901
904
|
en: "**Electrical zero search** aligns the rotor with the electrical field, then rotates the field by 90 electrical degrees to determine sensor direction. On success it saves `ZEA` and `M_Dir`.\nRepeat after replacing the motor, encoder, or magnet. The axis needs free travel in both directions.",
|