struct2ui 0.5.1__tar.gz → 0.7.0__tar.gz
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.
- {struct2ui-0.5.1/src/struct2ui.egg-info → struct2ui-0.7.0}/PKG-INFO +78 -23
- {struct2ui-0.5.1 → struct2ui-0.7.0}/README.md +77 -22
- {struct2ui-0.5.1 → struct2ui-0.7.0}/src/struct2ui/__init__.py +1 -1
- {struct2ui-0.5.1 → struct2ui-0.7.0}/src/struct2ui/editor.py +2110 -1924
- {struct2ui-0.5.1 → struct2ui-0.7.0}/src/struct2ui/exporters/c_emitter.py +304 -292
- {struct2ui-0.5.1 → struct2ui-0.7.0}/src/struct2ui/schema.py +29 -121
- {struct2ui-0.5.1 → struct2ui-0.7.0}/src/struct2ui/ui/renderers.py +366 -333
- {struct2ui-0.5.1 → struct2ui-0.7.0}/src/struct2ui/ui/tables.py +189 -69
- {struct2ui-0.5.1 → struct2ui-0.7.0}/src/struct2ui/ui/widgets.py +1116 -1155
- {struct2ui-0.5.1 → struct2ui-0.7.0/src/struct2ui.egg-info}/PKG-INFO +78 -23
- struct2ui-0.7.0/tests/test_editor.py +615 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/tests/test_load_report.py +140 -116
- {struct2ui-0.5.1 → struct2ui-0.7.0}/tests/test_union.py +107 -65
- struct2ui-0.5.1/tests/test_editor.py +0 -287
- {struct2ui-0.5.1 → struct2ui-0.7.0}/LICENSE +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/pyproject.toml +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/setup.cfg +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/src/struct2ui/exporters/__init__.py +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/src/struct2ui/exporters/bin_emitter.py +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/src/struct2ui/exporters/bin_reader.py +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/src/struct2ui/exporters/c_parser.py +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/src/struct2ui/exporters/elf_verifier.py +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/src/struct2ui/exporters/json_format.py +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/src/struct2ui/icons/c2j.png +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/src/struct2ui/icons/elf.png +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/src/struct2ui/icons/export_notes_24dp_000000_FILL0_wght400_GRAD0_opsz24.png +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/src/struct2ui/icons/flowchart_24dp_000000_FILL0_wght400_GRAD0_opsz24.png +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/src/struct2ui/icons/refresh_24dp_000000_FILL0_wght400_GRAD0_opsz24.png +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/src/struct2ui/icons/report_24dp_000000_FILL0_wght400_GRAD0_opsz24.png +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/src/struct2ui/icons/save_24dp_000000_FILL0_wght400_GRAD0_opsz24.png +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/src/struct2ui/icons/save_as_24dp_000000_FILL0_wght400_GRAD0_opsz24.png +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/src/struct2ui/icons/settings_24dp_000000_FILL0_wght400_GRAD0_opsz24.png +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/src/struct2ui/icons/widgets_24dp_000000_FILL0_wght400_GRAD0_opsz24.png +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/src/struct2ui/ui/__init__.py +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/src/struct2ui.egg-info/SOURCES.txt +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/src/struct2ui.egg-info/dependency_links.txt +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/src/struct2ui.egg-info/requires.txt +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/src/struct2ui.egg-info/top_level.txt +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/tests/test_bin_emitter.py +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/tests/test_bin_reader.py +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/tests/test_c_emitter.py +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/tests/test_c_parser.py +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/tests/test_choices.py +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/tests/test_container_verify.py +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/tests/test_elf_verifier.py +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/tests/test_float_precision.py +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/tests/test_int_checkbox.py +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/tests/test_json_format.py +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/tests/test_macro_bounds.py +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/tests/test_save.py +0 -0
- {struct2ui-0.5.1 → struct2ui-0.7.0}/tests/test_value_readback.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: struct2ui
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.0
|
|
4
4
|
Summary: Render C struct / JSON schema as editable PySide6 UI, export to C/JSON/bin
|
|
5
5
|
Author-email: Jay <huoyj0108@163.com>
|
|
6
6
|
License: MIT License
|
|
@@ -63,6 +63,7 @@ Render C structs / JSON schemas as an **editable PySide6 UI**, and convert freel
|
|
|
63
63
|
- **Read bin back**: `import_bin` loads a raw `.bin` (e.g. read back from the chip) into the UI — the byte-for-byte inverse of the binary export.
|
|
64
64
|
- **Validation**: keyword spell-checking (with “Did you mean X?” hints), semantic audits (`min<=max`, `step>0`), and pipeline cross-validation.
|
|
65
65
|
- **ELF layout check**: optionally verify each module — and the whole pipeline against its SDK container struct — against a compiled ELF's DWARF layout, catching offset/size drift and wrong stage order.
|
|
66
|
+
- **Pipeline note sources**: a pipeline file can pin its own Modules / ELF paths (`note` → `"Modules"` / `"ELF"`) — picking one file switches the whole setup, while the UI-picked paths keep the highest priority.
|
|
66
67
|
- **Qt-binding agnostic**: built on [Qt.py](https://github.com/mottosso/Qt.py) — works with PySide6 / PyQt6 / PySide2 / PyQt5.
|
|
67
68
|
|
|
68
69
|
## Installation
|
|
@@ -91,8 +92,8 @@ app = QtWidgets.QApplication([])
|
|
|
91
92
|
|
|
92
93
|
editor = StructEditor()
|
|
93
94
|
editor.set_sources(
|
|
94
|
-
cfg_dir="cfg_t", # modules dir: *.json holding struct/enum/typedef
|
|
95
95
|
flow_file="abc.json", # pipeline definition file
|
|
96
|
+
cfg_dir="cfg_t", # modules dir: *.json holding struct/enum/typedef
|
|
96
97
|
)
|
|
97
98
|
editor.resize(480, 600)
|
|
98
99
|
editor.show()
|
|
@@ -143,7 +144,7 @@ generated from it. Files live in the **modules directory** (`cfg_dir`), one
|
|
|
143
144
|
| --- | --- | --- |
|
|
144
145
|
| `struct` | `type`, `items` (list of field specs) | `items` is required |
|
|
145
146
|
| `enum` | `type`, `items` (object `{NAME: value}`) | reads back the enumerator name |
|
|
146
|
-
| `union` | `type`, `items` (list of branch structs)
|
|
147
|
+
| `union` | `type`, `items` (list of branch structs) | tagged union; each branch is an inline `struct` selected by its `when` (see below; a legacy `branch` key is accepted but ignored) |
|
|
147
148
|
| `typedefs` | object `{alias: real_type}` | resolved before field building |
|
|
148
149
|
|
|
149
150
|
Free-form metadata keys are allowed and ignored at any level: `version`,
|
|
@@ -184,7 +185,7 @@ When omitted, the widget is inferred from `type` (and from `min/max`,
|
|
|
184
185
|
| `dial` | int | Rotary dial popup (requires `min` & `max`). |
|
|
185
186
|
| `file` | array | Path label + Browse button; loads array values from a text file. |
|
|
186
187
|
| `multiline` | array | Single-line shell that pops up a multi-line editor. |
|
|
187
|
-
| `table` | struct array |
|
|
188
|
+
| `table` | struct array | Express grid-layout intent (one column per struct member; a union member expands the branch inferred from the pipeline rows into columns — see the union section below). |
|
|
188
189
|
|
|
189
190
|
Numeric fields without an explicit `widget` become a `QSpinBox` /
|
|
190
191
|
`QDoubleSpinBox`; scalar arrays become a comma-separated line edit.
|
|
@@ -217,7 +218,7 @@ match (logical AND):
|
|
|
217
218
|
The dependency name is matched against the dotted leaf name in scope. When a
|
|
218
219
|
dependency is not found, the field stays enabled.
|
|
219
220
|
|
|
220
|
-
### `union` (tagged union)
|
|
221
|
+
### `union` (tagged union)
|
|
221
222
|
|
|
222
223
|
A `union` block declares overlapping branches, each an inline `struct` in
|
|
223
224
|
`items`. At runtime the branch whose `when` matches is the one shown / exported
|
|
@@ -233,16 +234,29 @@ and unmatched exports are zero-padded.
|
|
|
233
234
|
] }
|
|
234
235
|
```
|
|
235
236
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
237
|
+
#### Union inside a table-rendered struct array
|
|
238
|
+
|
|
239
|
+
A struct array containing a union renders as a **table** when all its rows use
|
|
240
|
+
the same union branch. The branch is **inferred from the pipeline data** —
|
|
241
|
+
nothing is pinned in the modules file (the legacy `branch` key is accepted but
|
|
242
|
+
silently ignored):
|
|
243
|
+
|
|
244
|
+
- **Uniform rows** → the inferred branch's members expand into columns. Two
|
|
245
|
+
applications can therefore share one `FilterCoeffs` and still each get a
|
|
246
|
+
table: one pipeline writes only `raw` rows, the other only `design` rows.
|
|
247
|
+
- **Mixed rows** (e.g. one `RAW` row next to `PEAKINGEQ` rows) → the array
|
|
248
|
+
falls back to the **tree** layout, where each row keeps its own branch.
|
|
249
|
+
- **No rows written** → the discriminator's schema `value` picks the branch.
|
|
250
|
+
- **Tail rows** (the pipeline wrote fewer rows than `count`) follow the first
|
|
251
|
+
written row: the discriminator continues its value (rule A) and the branch
|
|
252
|
+
members use their defaults.
|
|
253
|
+
|
|
254
|
+
The discriminator combos in the table are filtered down to the values that
|
|
255
|
+
satisfy the inferred branch's `when`, so a mixed-branch row can never be
|
|
256
|
+
created from the UI — there are no greyed-out cells and no zero-padded exports.
|
|
257
|
+
For the same reason, `widget: "table"` on a union-bearing struct array is only
|
|
258
|
+
an *intent*: the data still decides table vs. tree, and the column-count limit
|
|
259
|
+
does not apply when the intent succeeds.
|
|
246
260
|
|
|
247
261
|
### `count` expressions & multi-dimensional arrays
|
|
248
262
|
|
|
@@ -265,6 +279,9 @@ Loading runs three layers of checks, surfaced in the **load report** panel:
|
|
|
265
279
|
bounds, default is one of the choices.
|
|
266
280
|
- **Pipeline cross-validation** — values in the pipeline file are checked
|
|
267
281
|
against the schema (range, choices, enum membership).
|
|
282
|
+
- **Duplicate type definitions** — the same struct / enum / union defined in
|
|
283
|
+
two module files is an error; the first definition found wins and the
|
|
284
|
+
duplicate is reported.
|
|
268
285
|
|
|
269
286
|
## Pipeline File
|
|
270
287
|
|
|
@@ -277,6 +294,7 @@ tuning name) whose value is the group body:
|
|
|
277
294
|
```jsonc
|
|
278
295
|
{
|
|
279
296
|
"Speech Tuning": {
|
|
297
|
+
"note": { "Modules": "cfg_t", "ELF": "../elf/fw.elf" }, // optional sources
|
|
280
298
|
"flow": ["RX NS", "RX DRC", "RX EQ"], // stage order, optional
|
|
281
299
|
"container": "SpeechConfig", // optional, enables layout check
|
|
282
300
|
|
|
@@ -293,12 +311,43 @@ tuning name) whose value is the group body:
|
|
|
293
311
|
| --- | --- | --- |
|
|
294
312
|
| `flow` | no | Ordered list of stage names. The flow buttons and the export order follow it. **Omit it and the stages run in the order they appear in the JSON.** When present, every listed name must have a stage block; defined stages missing from `flow` are a warning. |
|
|
295
313
|
| `container` | no | Name of the SDK struct that holds all modules (see [Container layout check](#container-layout-check)). Omit to disable that check. |
|
|
314
|
+
| `note` | no | Free-form metadata dict. Two keys are special — `"Modules"` / `"ELF"` pin the pipeline's companion sources (see [Source overrides via `note`](#source-overrides-via-note)); everything else in it is ignored. |
|
|
296
315
|
| *stage name* | — | Any other key is a **stage block**; its name is the label shown on the flow button. |
|
|
297
316
|
|
|
298
317
|
All keys are **lowercase and case-sensitive** — write `flow`, not `Flow`. A
|
|
299
318
|
mistyped key (`Flow`, `flwo`, …) is reported with a "Did you mean `flow`?" hint.
|
|
300
|
-
Free-form metadata keys (`version`, `description`, `author`, `comment
|
|
301
|
-
|
|
319
|
+
Free-form metadata keys (`version`, `description`, `author`, `comment`) are
|
|
320
|
+
allowed and ignored.
|
|
321
|
+
|
|
322
|
+
### Source overrides via `note`
|
|
323
|
+
|
|
324
|
+
A pipeline file can pin its own companion sources, so picking **one file
|
|
325
|
+
switches the whole tuning setup** — no need to re-pick the Modules directory
|
|
326
|
+
and ELF by hand:
|
|
327
|
+
|
|
328
|
+
```jsonc
|
|
329
|
+
"note": {
|
|
330
|
+
"Send Format": "Speech Tuning", // free-form fields stay ignored
|
|
331
|
+
"Modules": "cfg_t", // modules directory
|
|
332
|
+
"ELF": "../elf/best1702_ibrt.elf" // ELF for layout verification
|
|
333
|
+
}
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
Both keys are optional and take absolute or **pipeline-file-relative** paths.
|
|
337
|
+
Selecting the pipeline applies them in Settings:
|
|
338
|
+
|
|
339
|
+
- The matching row's checkbox is **unchecked** — exactly as if the user had —
|
|
340
|
+
and the note's path feeds the slot. The checkbox stays clickable and the
|
|
341
|
+
UI-picked path is kept and still displayed, so re-checking the row switches
|
|
342
|
+
back to it at any time.
|
|
343
|
+
- **UI settings always win**: a checked row forces the UI-picked path no
|
|
344
|
+
matter what the note says. The note can only take over a row the user left
|
|
345
|
+
unchecked.
|
|
346
|
+
- Neither side providing Modules is a load error (with a hint to enable the
|
|
347
|
+
Settings row or add a note path); neither side providing an ELF simply
|
|
348
|
+
skips layout verification.
|
|
349
|
+
- Reload re-reads the note from disk, so editing it takes effect without
|
|
350
|
+
re-picking the pipeline file — but a reload never flips a checkbox.
|
|
302
351
|
|
|
303
352
|
### Stage block
|
|
304
353
|
|
|
@@ -329,7 +378,7 @@ class MyWindow(QtWidgets.QMainWindow):
|
|
|
329
378
|
def __init__(self):
|
|
330
379
|
super().__init__()
|
|
331
380
|
editor = StructEditor()
|
|
332
|
-
editor.set_sources(
|
|
381
|
+
editor.set_sources(flow_file="abc.json", cfg_dir="cfg_t")
|
|
333
382
|
self.setCentralWidget(editor)
|
|
334
383
|
```
|
|
335
384
|
|
|
@@ -354,21 +403,27 @@ Omitting an argument leaves that slot untouched.
|
|
|
354
403
|
|
|
355
404
|
```python
|
|
356
405
|
editor.set_sources(
|
|
357
|
-
cfg_dir="cfg_t", # modules dir: *.json with struct/enum/typedef defs
|
|
358
406
|
flow_file="abc.json", # pipeline definition file
|
|
407
|
+
cfg_dir="cfg_t", # modules dir: *.json with struct/enum/typedef defs
|
|
359
408
|
elf_file="fw.elf", # optional ELF for .bin layout verification
|
|
360
409
|
)
|
|
361
410
|
```
|
|
362
411
|
|
|
363
412
|
| `set_sources` argument | Description |
|
|
364
413
|
| --- | --- |
|
|
365
|
-
| `cfg_dir` | Modules directory holding `*.json` (struct / enum / typedef definitions) |
|
|
366
414
|
| `flow_file` | Path to the pipeline JSON file (pipeline definition) |
|
|
415
|
+
| `cfg_dir` | Modules directory holding `*.json` (struct / enum / typedef definitions); setting it checks the Modules row |
|
|
416
|
+
| `modules_enabled` | Override the Modules row's checkbox state, independent of whether a path is set |
|
|
367
417
|
| `elf_file` | Path to an ELF for `.bin` layout verification; setting it enables verification (toggle later via the Settings checkbox, which keeps the path) |
|
|
368
418
|
| `elf_enabled` | Override whether ELF verification runs, independent of whether a path is set |
|
|
369
419
|
| `reload` | Rebuild schema / flow / UI from the new sources, defaults to `True` |
|
|
370
420
|
| `async_load` | Run that reload on a background thread (defaults to `False`). See [Async Loading](#async-loading) |
|
|
371
421
|
|
|
422
|
+
Explicitly passed paths and checkbox states are applied after the pipeline
|
|
423
|
+
note's overrides, so they always win: a note can only uncheck a row that this
|
|
424
|
+
call left untouched. See [Source overrides via `note`](#source-overrides-via-note)
|
|
425
|
+
for the full priority rules.
|
|
426
|
+
|
|
372
427
|
Toolbar orientation is set with `set_flow_orientation('horizontal' | 'vertical')`.
|
|
373
428
|
|
|
374
429
|
#### Async Loading
|
|
@@ -387,8 +442,8 @@ older one.
|
|
|
387
442
|
```python
|
|
388
443
|
editor.show()
|
|
389
444
|
editor.set_sources(
|
|
390
|
-
cfg_dir="cfg_t",
|
|
391
445
|
flow_file="abc.json",
|
|
446
|
+
cfg_dir="cfg_t",
|
|
392
447
|
elf_file="fw.elf",
|
|
393
448
|
async_load=True, # parse off the GUI thread; window stays responsive
|
|
394
449
|
)
|
|
@@ -403,7 +458,7 @@ which side they sit on (once, via the `custom_button_position` constructor arg).
|
|
|
403
458
|
|
|
404
459
|
```python
|
|
405
460
|
editor = StructEditor(custom_button_position="end")
|
|
406
|
-
editor.set_sources(
|
|
461
|
+
editor.set_sources(flow_file="abc.json", cfg_dir="cfg_t")
|
|
407
462
|
|
|
408
463
|
def on_send():
|
|
409
464
|
print(editor.current_values())
|
|
@@ -433,7 +488,7 @@ from code (e.g. wired to a custom button):
|
|
|
433
488
|
|
|
434
489
|
| Method | Description |
|
|
435
490
|
| --- | --- |
|
|
436
|
-
| `set_sources(cfg_dir=None,
|
|
491
|
+
| `set_sources(flow_file=None, cfg_dir=None, modules_enabled=None, elf_file=None, elf_enabled=None, reload=True, async_load=False)` | Point the editor at its source files after construction. See [Setting Sources](#setting-sources). |
|
|
437
492
|
| `set_flow_orientation(orientation)` | Switch the flow-button strip between `'horizontal'` (top, default) and `'vertical'` (left). Rebuilds the strip and keeps the active stage selected. |
|
|
438
493
|
| `show_section(label) -> None` | Open the stage/section named `label` in the content area (the same as clicking its flow button). Paints the error panel instead when that stage has pipeline errors; clears the content when the label is unknown. |
|
|
439
494
|
| `current_values() -> dict` | Live editor values of the active section, keyed by field name (empty dict when no parameter section is shown). |
|
|
@@ -10,6 +10,7 @@ Render C structs / JSON schemas as an **editable PySide6 UI**, and convert freel
|
|
|
10
10
|
- **Read bin back**: `import_bin` loads a raw `.bin` (e.g. read back from the chip) into the UI — the byte-for-byte inverse of the binary export.
|
|
11
11
|
- **Validation**: keyword spell-checking (with “Did you mean X?” hints), semantic audits (`min<=max`, `step>0`), and pipeline cross-validation.
|
|
12
12
|
- **ELF layout check**: optionally verify each module — and the whole pipeline against its SDK container struct — against a compiled ELF's DWARF layout, catching offset/size drift and wrong stage order.
|
|
13
|
+
- **Pipeline note sources**: a pipeline file can pin its own Modules / ELF paths (`note` → `"Modules"` / `"ELF"`) — picking one file switches the whole setup, while the UI-picked paths keep the highest priority.
|
|
13
14
|
- **Qt-binding agnostic**: built on [Qt.py](https://github.com/mottosso/Qt.py) — works with PySide6 / PyQt6 / PySide2 / PyQt5.
|
|
14
15
|
|
|
15
16
|
## Installation
|
|
@@ -38,8 +39,8 @@ app = QtWidgets.QApplication([])
|
|
|
38
39
|
|
|
39
40
|
editor = StructEditor()
|
|
40
41
|
editor.set_sources(
|
|
41
|
-
cfg_dir="cfg_t", # modules dir: *.json holding struct/enum/typedef
|
|
42
42
|
flow_file="abc.json", # pipeline definition file
|
|
43
|
+
cfg_dir="cfg_t", # modules dir: *.json holding struct/enum/typedef
|
|
43
44
|
)
|
|
44
45
|
editor.resize(480, 600)
|
|
45
46
|
editor.show()
|
|
@@ -90,7 +91,7 @@ generated from it. Files live in the **modules directory** (`cfg_dir`), one
|
|
|
90
91
|
| --- | --- | --- |
|
|
91
92
|
| `struct` | `type`, `items` (list of field specs) | `items` is required |
|
|
92
93
|
| `enum` | `type`, `items` (object `{NAME: value}`) | reads back the enumerator name |
|
|
93
|
-
| `union` | `type`, `items` (list of branch structs)
|
|
94
|
+
| `union` | `type`, `items` (list of branch structs) | tagged union; each branch is an inline `struct` selected by its `when` (see below; a legacy `branch` key is accepted but ignored) |
|
|
94
95
|
| `typedefs` | object `{alias: real_type}` | resolved before field building |
|
|
95
96
|
|
|
96
97
|
Free-form metadata keys are allowed and ignored at any level: `version`,
|
|
@@ -131,7 +132,7 @@ When omitted, the widget is inferred from `type` (and from `min/max`,
|
|
|
131
132
|
| `dial` | int | Rotary dial popup (requires `min` & `max`). |
|
|
132
133
|
| `file` | array | Path label + Browse button; loads array values from a text file. |
|
|
133
134
|
| `multiline` | array | Single-line shell that pops up a multi-line editor. |
|
|
134
|
-
| `table` | struct array |
|
|
135
|
+
| `table` | struct array | Express grid-layout intent (one column per struct member; a union member expands the branch inferred from the pipeline rows into columns — see the union section below). |
|
|
135
136
|
|
|
136
137
|
Numeric fields without an explicit `widget` become a `QSpinBox` /
|
|
137
138
|
`QDoubleSpinBox`; scalar arrays become a comma-separated line edit.
|
|
@@ -164,7 +165,7 @@ match (logical AND):
|
|
|
164
165
|
The dependency name is matched against the dotted leaf name in scope. When a
|
|
165
166
|
dependency is not found, the field stays enabled.
|
|
166
167
|
|
|
167
|
-
### `union` (tagged union)
|
|
168
|
+
### `union` (tagged union)
|
|
168
169
|
|
|
169
170
|
A `union` block declares overlapping branches, each an inline `struct` in
|
|
170
171
|
`items`. At runtime the branch whose `when` matches is the one shown / exported
|
|
@@ -180,16 +181,29 @@ and unmatched exports are zero-padded.
|
|
|
180
181
|
] }
|
|
181
182
|
```
|
|
182
183
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
184
|
+
#### Union inside a table-rendered struct array
|
|
185
|
+
|
|
186
|
+
A struct array containing a union renders as a **table** when all its rows use
|
|
187
|
+
the same union branch. The branch is **inferred from the pipeline data** —
|
|
188
|
+
nothing is pinned in the modules file (the legacy `branch` key is accepted but
|
|
189
|
+
silently ignored):
|
|
190
|
+
|
|
191
|
+
- **Uniform rows** → the inferred branch's members expand into columns. Two
|
|
192
|
+
applications can therefore share one `FilterCoeffs` and still each get a
|
|
193
|
+
table: one pipeline writes only `raw` rows, the other only `design` rows.
|
|
194
|
+
- **Mixed rows** (e.g. one `RAW` row next to `PEAKINGEQ` rows) → the array
|
|
195
|
+
falls back to the **tree** layout, where each row keeps its own branch.
|
|
196
|
+
- **No rows written** → the discriminator's schema `value` picks the branch.
|
|
197
|
+
- **Tail rows** (the pipeline wrote fewer rows than `count`) follow the first
|
|
198
|
+
written row: the discriminator continues its value (rule A) and the branch
|
|
199
|
+
members use their defaults.
|
|
200
|
+
|
|
201
|
+
The discriminator combos in the table are filtered down to the values that
|
|
202
|
+
satisfy the inferred branch's `when`, so a mixed-branch row can never be
|
|
203
|
+
created from the UI — there are no greyed-out cells and no zero-padded exports.
|
|
204
|
+
For the same reason, `widget: "table"` on a union-bearing struct array is only
|
|
205
|
+
an *intent*: the data still decides table vs. tree, and the column-count limit
|
|
206
|
+
does not apply when the intent succeeds.
|
|
193
207
|
|
|
194
208
|
### `count` expressions & multi-dimensional arrays
|
|
195
209
|
|
|
@@ -212,6 +226,9 @@ Loading runs three layers of checks, surfaced in the **load report** panel:
|
|
|
212
226
|
bounds, default is one of the choices.
|
|
213
227
|
- **Pipeline cross-validation** — values in the pipeline file are checked
|
|
214
228
|
against the schema (range, choices, enum membership).
|
|
229
|
+
- **Duplicate type definitions** — the same struct / enum / union defined in
|
|
230
|
+
two module files is an error; the first definition found wins and the
|
|
231
|
+
duplicate is reported.
|
|
215
232
|
|
|
216
233
|
## Pipeline File
|
|
217
234
|
|
|
@@ -224,6 +241,7 @@ tuning name) whose value is the group body:
|
|
|
224
241
|
```jsonc
|
|
225
242
|
{
|
|
226
243
|
"Speech Tuning": {
|
|
244
|
+
"note": { "Modules": "cfg_t", "ELF": "../elf/fw.elf" }, // optional sources
|
|
227
245
|
"flow": ["RX NS", "RX DRC", "RX EQ"], // stage order, optional
|
|
228
246
|
"container": "SpeechConfig", // optional, enables layout check
|
|
229
247
|
|
|
@@ -240,12 +258,43 @@ tuning name) whose value is the group body:
|
|
|
240
258
|
| --- | --- | --- |
|
|
241
259
|
| `flow` | no | Ordered list of stage names. The flow buttons and the export order follow it. **Omit it and the stages run in the order they appear in the JSON.** When present, every listed name must have a stage block; defined stages missing from `flow` are a warning. |
|
|
242
260
|
| `container` | no | Name of the SDK struct that holds all modules (see [Container layout check](#container-layout-check)). Omit to disable that check. |
|
|
261
|
+
| `note` | no | Free-form metadata dict. Two keys are special — `"Modules"` / `"ELF"` pin the pipeline's companion sources (see [Source overrides via `note`](#source-overrides-via-note)); everything else in it is ignored. |
|
|
243
262
|
| *stage name* | — | Any other key is a **stage block**; its name is the label shown on the flow button. |
|
|
244
263
|
|
|
245
264
|
All keys are **lowercase and case-sensitive** — write `flow`, not `Flow`. A
|
|
246
265
|
mistyped key (`Flow`, `flwo`, …) is reported with a "Did you mean `flow`?" hint.
|
|
247
|
-
Free-form metadata keys (`version`, `description`, `author`, `comment
|
|
248
|
-
|
|
266
|
+
Free-form metadata keys (`version`, `description`, `author`, `comment`) are
|
|
267
|
+
allowed and ignored.
|
|
268
|
+
|
|
269
|
+
### Source overrides via `note`
|
|
270
|
+
|
|
271
|
+
A pipeline file can pin its own companion sources, so picking **one file
|
|
272
|
+
switches the whole tuning setup** — no need to re-pick the Modules directory
|
|
273
|
+
and ELF by hand:
|
|
274
|
+
|
|
275
|
+
```jsonc
|
|
276
|
+
"note": {
|
|
277
|
+
"Send Format": "Speech Tuning", // free-form fields stay ignored
|
|
278
|
+
"Modules": "cfg_t", // modules directory
|
|
279
|
+
"ELF": "../elf/best1702_ibrt.elf" // ELF for layout verification
|
|
280
|
+
}
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
Both keys are optional and take absolute or **pipeline-file-relative** paths.
|
|
284
|
+
Selecting the pipeline applies them in Settings:
|
|
285
|
+
|
|
286
|
+
- The matching row's checkbox is **unchecked** — exactly as if the user had —
|
|
287
|
+
and the note's path feeds the slot. The checkbox stays clickable and the
|
|
288
|
+
UI-picked path is kept and still displayed, so re-checking the row switches
|
|
289
|
+
back to it at any time.
|
|
290
|
+
- **UI settings always win**: a checked row forces the UI-picked path no
|
|
291
|
+
matter what the note says. The note can only take over a row the user left
|
|
292
|
+
unchecked.
|
|
293
|
+
- Neither side providing Modules is a load error (with a hint to enable the
|
|
294
|
+
Settings row or add a note path); neither side providing an ELF simply
|
|
295
|
+
skips layout verification.
|
|
296
|
+
- Reload re-reads the note from disk, so editing it takes effect without
|
|
297
|
+
re-picking the pipeline file — but a reload never flips a checkbox.
|
|
249
298
|
|
|
250
299
|
### Stage block
|
|
251
300
|
|
|
@@ -276,7 +325,7 @@ class MyWindow(QtWidgets.QMainWindow):
|
|
|
276
325
|
def __init__(self):
|
|
277
326
|
super().__init__()
|
|
278
327
|
editor = StructEditor()
|
|
279
|
-
editor.set_sources(
|
|
328
|
+
editor.set_sources(flow_file="abc.json", cfg_dir="cfg_t")
|
|
280
329
|
self.setCentralWidget(editor)
|
|
281
330
|
```
|
|
282
331
|
|
|
@@ -301,21 +350,27 @@ Omitting an argument leaves that slot untouched.
|
|
|
301
350
|
|
|
302
351
|
```python
|
|
303
352
|
editor.set_sources(
|
|
304
|
-
cfg_dir="cfg_t", # modules dir: *.json with struct/enum/typedef defs
|
|
305
353
|
flow_file="abc.json", # pipeline definition file
|
|
354
|
+
cfg_dir="cfg_t", # modules dir: *.json with struct/enum/typedef defs
|
|
306
355
|
elf_file="fw.elf", # optional ELF for .bin layout verification
|
|
307
356
|
)
|
|
308
357
|
```
|
|
309
358
|
|
|
310
359
|
| `set_sources` argument | Description |
|
|
311
360
|
| --- | --- |
|
|
312
|
-
| `cfg_dir` | Modules directory holding `*.json` (struct / enum / typedef definitions) |
|
|
313
361
|
| `flow_file` | Path to the pipeline JSON file (pipeline definition) |
|
|
362
|
+
| `cfg_dir` | Modules directory holding `*.json` (struct / enum / typedef definitions); setting it checks the Modules row |
|
|
363
|
+
| `modules_enabled` | Override the Modules row's checkbox state, independent of whether a path is set |
|
|
314
364
|
| `elf_file` | Path to an ELF for `.bin` layout verification; setting it enables verification (toggle later via the Settings checkbox, which keeps the path) |
|
|
315
365
|
| `elf_enabled` | Override whether ELF verification runs, independent of whether a path is set |
|
|
316
366
|
| `reload` | Rebuild schema / flow / UI from the new sources, defaults to `True` |
|
|
317
367
|
| `async_load` | Run that reload on a background thread (defaults to `False`). See [Async Loading](#async-loading) |
|
|
318
368
|
|
|
369
|
+
Explicitly passed paths and checkbox states are applied after the pipeline
|
|
370
|
+
note's overrides, so they always win: a note can only uncheck a row that this
|
|
371
|
+
call left untouched. See [Source overrides via `note`](#source-overrides-via-note)
|
|
372
|
+
for the full priority rules.
|
|
373
|
+
|
|
319
374
|
Toolbar orientation is set with `set_flow_orientation('horizontal' | 'vertical')`.
|
|
320
375
|
|
|
321
376
|
#### Async Loading
|
|
@@ -334,8 +389,8 @@ older one.
|
|
|
334
389
|
```python
|
|
335
390
|
editor.show()
|
|
336
391
|
editor.set_sources(
|
|
337
|
-
cfg_dir="cfg_t",
|
|
338
392
|
flow_file="abc.json",
|
|
393
|
+
cfg_dir="cfg_t",
|
|
339
394
|
elf_file="fw.elf",
|
|
340
395
|
async_load=True, # parse off the GUI thread; window stays responsive
|
|
341
396
|
)
|
|
@@ -350,7 +405,7 @@ which side they sit on (once, via the `custom_button_position` constructor arg).
|
|
|
350
405
|
|
|
351
406
|
```python
|
|
352
407
|
editor = StructEditor(custom_button_position="end")
|
|
353
|
-
editor.set_sources(
|
|
408
|
+
editor.set_sources(flow_file="abc.json", cfg_dir="cfg_t")
|
|
354
409
|
|
|
355
410
|
def on_send():
|
|
356
411
|
print(editor.current_values())
|
|
@@ -380,7 +435,7 @@ from code (e.g. wired to a custom button):
|
|
|
380
435
|
|
|
381
436
|
| Method | Description |
|
|
382
437
|
| --- | --- |
|
|
383
|
-
| `set_sources(cfg_dir=None,
|
|
438
|
+
| `set_sources(flow_file=None, cfg_dir=None, modules_enabled=None, elf_file=None, elf_enabled=None, reload=True, async_load=False)` | Point the editor at its source files after construction. See [Setting Sources](#setting-sources). |
|
|
384
439
|
| `set_flow_orientation(orientation)` | Switch the flow-button strip between `'horizontal'` (top, default) and `'vertical'` (left). Rebuilds the strip and keeps the active stage selected. |
|
|
385
440
|
| `show_section(label) -> None` | Open the stage/section named `label` in the content area (the same as clicking its flow button). Paints the error panel instead when that stage has pipeline errors; clears the content when the label is unknown. |
|
|
386
441
|
| `current_values() -> dict` | Live editor values of the active section, keyed by field name (empty dict when no parameter section is shown). |
|