model.py: gemeinsames TRO-Modell; Hauptweg CSV -> tro_flow --json -> scl_skeleton
- lib/model.py (neu, pydantic): TroBase -> DerivedTro, Connection, OpenPoint, Analysis (aus tro_flow verschoben), TroDocument = TRO-JSON (Schema sps_skel-tro-v2). items/fbType werden immer ueber den Typ aus tro_catalog gelesen, nie gespeichert; abweichende Werte in einer JSON sind ein Fehler. JSON-Schluessel wie bisher (id, type, fbType ...), extra="forbid". - tro_flow: Tro/Analysis aus model.py; neuer Schalter --json schreibt <name>_tro.json (TroDocument) - scl_skeleton: liest die JSON ueber TroDocument statt per Dict-Zugriff, Bauteile ueber TroItem-Konstanten; ungueltige JSON -> Exit 1 ohne SCL, alte tro_extract-JSON (v1) mit Hinweis auf tro_flow --json - tro_annotate: nur noch Ansicht; derselbe analyse_tros-Aufruf wie tro_flow (inkl. sepliste-Gegenprobe), damit Zeichnung und JSON uebereinstimmen - tro_extract: geparkt (unveraendert) - tests/test_model.py + conftest.py, pytest in requirements.txt aktiviert - Doku: Python_Scripts.md (§6b model.py), Commandlines.md, CLAUDE.md, Aufrufkommentare in bin/ (scl_skeleton.bat zeigte tro_flow-Aufrufe) Geprueft: alle tro_flow/tro_annotate-Ausgaben (8 CSVs) bis auf Zeitstempel identisch zum vorherigen Stand; scl_skeleton alt/neu auf derselben JSON byte-identisch (export, mubea, HundM05); 10 Tests gruen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
90cafec99c
commit
97a0db6707
+29
-15
@@ -28,15 +28,19 @@ activates `.venv` if present and runs `lib/<name>.py` with all arguments passed
|
||||
through. Every tool accepts `--help`.
|
||||
|
||||
```
|
||||
CSV ─► material_flow ─► tro_flow ─► tro_annotate ─► [edit in BricsCAD] ─► tro_extract ─► scl_skeleton
|
||||
(+ DXF) (DXF only) (JSON → SCL)
|
||||
CSV ─► material_flow ─► tro_flow --json ─► <name>_tro.json ─► scl_skeleton ─► <name>_FB_Main.scl
|
||||
│ (model.py) (validates)
|
||||
└─► tro_annotate (+ DXF) ─► <name>_annotated.dxf viewer only
|
||||
|
||||
parked: tro_extract (DXF → JSON), see 2.4
|
||||
```
|
||||
|
||||
Shared conventions:
|
||||
|
||||
- Input names (`--file`, `--dxf`) are a bare filename resolved against
|
||||
`%SKEL_DATA%`, or a full path. `tro_extract`/`scl_skeleton` look up their
|
||||
input in `%SKEL_RESULTS%` instead (it is the output of the previous step).
|
||||
`%SKEL_DATA%`, or a full path. `scl_skeleton` (and the parked `tro_extract`)
|
||||
look up their input in `%SKEL_RESULTS%` instead (it is the output of the
|
||||
previous step).
|
||||
- All output goes to `%SKEL_RESULTS%`.
|
||||
- `--tosvg` needs Graphviz `dot` (`neato` with `--use-cords`) on `PATH`, or
|
||||
`GRAPHVIZ_DOT` pointing at `dot`.
|
||||
@@ -78,16 +82,20 @@ Input: CSV export. Details: [`Python_Scripts.md` §4](Python_Scripts.md#4-tro_fl
|
||||
| `--true-scale` | — | off | Only with `--use-cords`: draw to scale (default shortens empty stretches > 1500 mm). |
|
||||
| `--doc` | — | off | Write Markdown report `<name>_tro_doc.md`. |
|
||||
| `--connect` | — | off | Write TRO topology as `<name>_tro_connect.ini`. |
|
||||
| `--json` | — | off | Write the TRO-JSON `<name>_tro.json` (model `lib/model.py`) — input for `scl_skeleton`. |
|
||||
|
||||
Exit codes: `0` ok · `1` input/CLI error · `2` SVG rendering failed ·
|
||||
`3` TRO validation errors (`<name>_tro_errors.md` written).
|
||||
|
||||
```bat
|
||||
bin\tro_flow.bat --file mubea.csv --tosvg --use-cords --doc
|
||||
bin\tro_flow.bat --file mubea.csv --json
|
||||
```
|
||||
|
||||
### 2.3 `tro_annotate` — burn the TROs into a copy of the drawing
|
||||
|
||||
Viewer only: shows the same TROs as `tro_flow` in the drawing for a visual
|
||||
check; the drawing is not read back as data.
|
||||
Input: CSV export + original BricsCAD DXF. The original is never modified.
|
||||
Details: [`Python_Scripts.md` §5](Python_Scripts.md#5-tro_annotatepy--burn-the-tros-into-a-copy-of-the-cad-drawing).
|
||||
|
||||
@@ -117,6 +125,10 @@ bin\tro_annotate.bat --emit-lisp
|
||||
|
||||
### 2.4 `tro_extract` — read the TROs back out of the drawing into JSON
|
||||
|
||||
**Parked** — kept, but not part of the main path. Its JSON (schema
|
||||
`sps_skel-tro-extract-v1`) is rejected by `scl_skeleton`; use
|
||||
`tro_flow --json` instead.
|
||||
|
||||
Input: the (possibly hand-edited) annotated DXF only, never the CSV.
|
||||
Details: [`Python_Scripts.md` §5a](Python_Scripts.md#5a-tro_extractpy--read-the-tros-back-out-of-the-drawing-into-json).
|
||||
|
||||
@@ -133,8 +145,9 @@ bin\tro_extract.bat --dxf mubea_annotated.dxf
|
||||
|
||||
### 2.5 `scl_skeleton` — generate the `FB_Main` SCL skeleton
|
||||
|
||||
Input: TRO-JSON from `tro_extract`. Output is a skeleton with
|
||||
`TODO(E-Planung)` gaps, not a compilable program.
|
||||
Input: TRO-JSON from `tro_flow --json`, validated against `lib/model.py` — a
|
||||
wrong or renamed key stops the run (exit `1`) instead of producing SCL. Output
|
||||
is a skeleton with `TODO(E-Planung)` gaps, not a compilable program.
|
||||
Details: [`Python_Scripts.md` §5b](Python_Scripts.md#5b-scl_skeletonpy--generate-the-fb_main-skeleton-as-scl).
|
||||
|
||||
| Switch | Argument | Default | Effect |
|
||||
@@ -143,11 +156,11 @@ Details: [`Python_Scripts.md` §5b](Python_Scripts.md#5b-scl_skeletonpy--generat
|
||||
| `--out` | `NAME` | `<source>_FB_Main.scl` | Output SCL filename. |
|
||||
| `--start` | `TRO` | — | TRO where the REGION order begins. Only needed while the flow is a closed loop without a loading/unloading station (`SYSn`). |
|
||||
|
||||
Exit codes: `0` ok · `1` input/CLI error.
|
||||
Exit codes: `0` ok · `1` input/CLI error or JSON does not match the model.
|
||||
|
||||
```bat
|
||||
bin\scl_skeleton.bat --json mubea_annotated_tro.json
|
||||
bin\scl_skeleton.bat --json mubea_annotated_tro.json --start TRO01
|
||||
bin\scl_skeleton.bat --json mubea_tro.json
|
||||
bin\scl_skeleton.bat --json mubea_tro.json --start TRO01
|
||||
```
|
||||
|
||||
## 3. End-to-end example
|
||||
@@ -155,18 +168,19 @@ bin\scl_skeleton.bat --json mubea_annotated_tro.json --start TRO01
|
||||
```bat
|
||||
bin\activate_venv.bat
|
||||
bin\material_flow.bat --file mubea.csv --tosvg --doc
|
||||
bin\tro_flow.bat --file mubea.csv --tosvg --use-cords --doc
|
||||
bin\tro_flow.bat --file mubea.csv --tosvg --use-cords --doc --json
|
||||
bin\scl_skeleton.bat --json mubea_tro.json
|
||||
REM optional, for a visual check in BricsCAD:
|
||||
bin\tro_annotate.bat --file mubea.csv --dxf Mubea.dxf --flow --legend
|
||||
REM ... optionally review / edit results\mubea_annotated.dxf in BricsCAD ...
|
||||
bin\tro_extract.bat --dxf mubea_annotated.dxf
|
||||
bin\scl_skeleton.bat --json mubea_annotated_tro.json
|
||||
```
|
||||
|
||||
Tests: `python -m pytest tests/` (with `.venv` active).
|
||||
|
||||
## 4. Documentation tooling (not part of the pipeline)
|
||||
|
||||
| Command | Purpose |
|
||||
|---|---|
|
||||
| `py doc/TRO_Katalog/tro_graphs/gen_tro_graphs.py` | Regenerates the per-type SVGs, the edge legend and the UH01–UH05 topology graphs for `TRO_Katalog.md` from `doc/TRO_Katalog/connect.ini`. No switches, no `bin/` wrapper. Needs Graphviz `dot`. |
|
||||
|
||||
The libraries `lib/tro_catalog.py`, `lib/dxf_registration.py` and
|
||||
`lib/tro_overrides.py` have no command line of their own.
|
||||
The libraries `lib/tro_catalog.py`, `lib/model.py`, `lib/dxf_registration.py`
|
||||
and `lib/tro_overrides.py` have no command line of their own.
|
||||
|
||||
Reference in New Issue
Block a user