Document the planned DXF-to-JSON-to-SCL generator pipeline

Add a Roadmap section to README.md and CLAUDE.md describing the two
still-to-be-written lib/ tools (tro_export.py, scl_gen.py) that will
turn the annotated CAD drawing into a JSON layout model and then into
TIA-Portal-importable SCL, including the --skip-json shortcut.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-20 21:29:49 +02:00
parent ec009efefe
commit e630ec12d6
2 changed files with 119 additions and 38 deletions
+37 -2
View File
@@ -13,8 +13,10 @@ The repository has moved past pure analysis: `lib/` now holds working Python too
derives a material-flow graph and a TRO list from a CSV export (ILS 2.0) and can annotate a
copy of the BricsCAD drawing with the result. What does **not** exist yet is the actual
SCL-skeleton generator — the step that would emit TIA-Portal-importable SCL from a JSON
layout model. `tests/` and `examples/` are still empty scaffolding (see "Standard Programm
Template" below). What exists today is:
layout model — nor the tool that derives that JSON model from the annotated drawing; see
"Roadmap" below for the planned two-tool pipeline that closes this gap. `tests/` and
`examples/` are still empty scaffolding (see "Standard Programm Template" below). What
exists today is:
- `bin/` — environment/venv management scripts, plus one `.bat`/`.sh` wrapper pair per CLI
tool in `lib/` (see "Environment scripts" below)
@@ -137,6 +139,39 @@ local, fully-vendored SCL source (`FB_ILS_MTRO_Vario_workStation`, `FB_EmptyCarr
`doc/TRO_Katalog/scl_templates/*.scl` as **read-only reference material** for pattern
extraction, not code to execute or modify.
## Roadmap: DXF → JSON → SCL (planned, not implemented)
`tro_annotate.py` is where the current pipeline stops today: the user can keep hand-editing
the annotated DXF copy afterwards (via the BricsCAD `TRO_INSERT`/`TRO_EDIT` commands, see
`doc/HundM/BricsCAD_TRO_Symbol.md`) — moving TROs, adding new ones, or changing a type. Two
more `lib/` tools are planned to carry that drawing the rest of the way to importable SCL:
1. **`lib/tro_export.py`** (planned) — reads the (possibly hand-edited) annotated DXF plus
the CSV export and derives the JSON layout file described in
`doc/HundM/Json_Layout-Konzept.md` (`plc`, `controlUnits`, `sensors[]`, `conveyors[]`,
`tros[]`, `loadingBooms[]`, `emptyCarrBuffers[]`, `routing`, `jamAreas[]`, `scanners[]`,
`connections[]`, `destinations[]`). Per-TRO timing (`trailingTime`, `handlingTime`,
`senFree`, `senWait`, `jamTime`, ...) comes from the type-based default table in
`doc/TRO_Typen.md` unless the CAD symbol carries an `OVERRIDE_TIMING_JSON` value (see
`doc/HundM/BricsCAD_TRO_Symbol.md`), in which case the override wins. The resulting JSON
file is meant to be hand-edited afterwards — that's the intended place to tweak defaults
or individual timings before code generation.
2. **`lib/scl_gen.py`** (planned) — reads the JSON layout file and emits the `.scl` files
(`FB_Main`, `FB_CallSensors`, `FC_Direction`, `FC_Call_Jams` per controller) ready for
TIA Portal import. Takes a `--skip-json` switch for the case where no manual JSON edits
are needed: it then reads the DXF + CSV directly (running the same derivation as
`tro_export.py` internally) and emits SCL immediately, without writing or reading an
intermediate JSON file.
Both tools follow the existing `lib/` conventions once written: a `bin/<name>.bat`/`.sh`
wrapper pair (see "Environment scripts" above) and a switches/outputs section in
`doc/Python_Scripts.md`. Note this is a separate concept from the `create_skel.py` /
`guess_fbtype()` generator sketched in `doc/HundM/suggestion.md` and
`doc/HundM/Json_Layout-Konzept.md` §14.5 — that one is designed to derive its skeleton JSON
from HundM's Excel I/O-list exports (`*_TIA.xlsx`, `*_positions.json`, ...), a different
input source than this repo's CSV+DXF pipeline. The JSON *schema* it targets is the same
(`doc/HundM/Json_Layout-Konzept.md`); only the derivation source differs.
## Standard Programm Template
This project follows the user's standard Python project scaffold convention:
+82 -36
View File
@@ -23,30 +23,64 @@ erzeugt. Diese drei Werkzeuge liegen als CLI-Tools in `lib/` und sind über
`bin/`-Wrapper aufrufbar (siehe unten). Details, Domänenmodell und die
Roadmap zum Generator stehen in `doc/`, allen voran `doc/Python_Scripts.md`.
## Roadmap
`tro_annotate.py` ist aktuell die letzte Stufe: Der Nutzer kann die annotierte
DXF-Kopie danach von Hand weiterbearbeiten — TROs verschieben, ergänzen oder
deren Typ ändern (`TRO_INSERT`/`TRO_EDIT` im BricsCAD-Menü, siehe
`doc/HundM/BricsCAD_TRO_Symbol.md`). Geplant sind zwei weitere Tools, die diese
Zeichnung bis zum fertigen SCL-Code weiterführen:
1. **`tro_export.py`** (geplant) — liest die (ggf. von Hand nachbearbeitete)
annotierte DXF zusammen mit dem CSV-Export und leitet daraus die
JSON-Layout-Datei nach dem in `doc/HundM/Json_Layout-Konzept.md`
beschriebenen Schema ab (`plc`, `controlUnits`, `sensors[]`, `conveyors[]`,
`tros[]`, `loadingBooms[]`, `emptyCarrBuffers[]`, `routing`, `jamAreas[]`,
`scanners[]`, `connections[]`, `destinations[]`). Timing-Werte pro TRO
(`trailingTime`, `handlingTime`, `senFree`, `senWait`, `jamTime`, ...)
kommen dabei standardmäßig aus der typspezifischen Default-Tabelle
(`doc/TRO_Typen.md`); trägt das CAD-Symbol einen `OVERRIDE_TIMING_JSON`-Wert
(siehe `doc/HundM/BricsCAD_TRO_Symbol.md`), gewinnt der Override. Die
erzeugte JSON-Datei ist danach von Hand editierbar, um einzelne Defaults
oder Zeiten anzupassen, bevor daraus SCL generiert wird.
2. **`scl_gen.py`** (geplant) — liest die JSON-Layout-Datei und erzeugt daraus
die `.scl`-Skeleton-Dateien für den direkten TIA-Portal-Import (`FB_Main`,
`FB_CallSensors`, `FC_Direction`, `FC_Call_Jams` je Steuerung). Mit dem
Schalter `--skip-json` läuft dieser Schritt auch ohne manuell
nachbearbeitete JSON-Datei: `scl_gen.py` liest dann DXF und CSV direkt (wie
`tro_export.py`) und erzeugt sofort SCL mit den Typ-Defaults, ohne eine
Zwischen-JSON-Datei zu schreiben oder einzulesen — sinnvoll, wenn an den
Defaults nichts manuell angepasst werden muss.
Beide Tools bekommen wie üblich ein `bin/<name>.bat`/`.sh`-Wrapper-Paar und
werden in `doc/Python_Scripts.md` dokumentiert, sobald sie existieren.
## Projektstruktur
sps_skel/
bin/ Umgebungsskripte + ein .bat/.sh-Wrapper-Paar je CLI-Tool
setenv.bat/.sh Umgebungsvariablen setzen
install_py.bat/.sh venv erstellen + pip install
activate_venv.bat/.sh venv aktivieren
get_cmd.bat/.sh Shell mit Umgebung oeffnen
material_flow.bat/.sh Wrapper fuer lib/material_flow.py
tro_flow.bat/.sh Wrapper fuer lib/tro_flow.py
tro_annotate.bat/.sh Wrapper fuer lib/tro_annotate.py
cad/ generiertes BricsCAD-LISP (tro_types.lsp) fuer den TROEDIT-Dialog
cfg/ Konfigurationsdateien (INI/JSON); dxf_registration.json
data/ Eingabedaten - CSV-Exporte, DXF (nicht im Git)
doc/ Dokumentation, siehe doc/Python_Scripts.md
examples/ Beispieldateien
lib/ Python-Quellcode (CLI-Tools + Bibliotheken)
log/ Log-Dateien (nicht im Git)
results/ Ergebnisse der CLI-Tools (.dot/.svg/.md/.dxf, nicht im Git)
tests/ Unit Tests
.gitignore
LICENSE
README.md
requirements.txt
```text
sps_skel/
bin/ Umgebungsskripte + ein .bat/.sh-Wrapper-Paar je CLI-Tool
setenv.bat/.sh Umgebungsvariablen setzen
install_py.bat/.sh venv erstellen + pip install
activate_venv.bat/.sh venv aktivieren
get_cmd.bat/.sh Shell mit Umgebung oeffnen
material_flow.bat/.sh Wrapper fuer lib/material_flow.py
tro_flow.bat/.sh Wrapper fuer lib/tro_flow.py
tro_annotate.bat/.sh Wrapper fuer lib/tro_annotate.py
cad/ generiertes BricsCAD-LISP (tro_types.lsp) fuer den TROEDIT-Dialog
cfg/ Konfigurationsdateien (INI/JSON); dxf_registration.json
data/ Eingabedaten - CSV-Exporte, DXF (nicht im Git)
doc/ Dokumentation, siehe doc/Python_Scripts.md
examples/ Beispieldateien
lib/ Python-Quellcode (CLI-Tools + Bibliotheken)
log/ Log-Dateien (nicht im Git)
results/ Ergebnisse der CLI-Tools (.dot/.svg/.md/.dxf, nicht im Git)
tests/ Unit Tests
.gitignore
LICENSE
README.md
requirements.txt
```
## Umgebungsvariablen
@@ -74,28 +108,38 @@ Roadmap zum Generator stehen in `doc/`, allen voran `doc/Python_Scripts.md`.
### Setup (Windows)
bin\install_py.bat
```bat
bin\install_py.bat
```
### Setup (Linux / macOS)
bash bin/install_py.sh
```sh
bash bin/install_py.sh
```
## Nutzung
### Umgebung setzen
bin\setenv.bat # Windows
source bin/setenv.sh # Linux / macOS
```bat
bin\setenv.bat # Windows
source bin/setenv.sh # Linux / macOS
```
### Shell mit gesetzten Variablen oeffnen
bin\get_cmd.bat # Windows
source bin/get_cmd.sh # Linux / macOS
```bat
bin\get_cmd.bat # Windows
source bin/get_cmd.sh # Linux / macOS
```
### venv aktivieren
bin\activate_venv.bat # Windows
source bin/activate_venv.sh # Linux / macOS
```bat
bin\activate_venv.bat # Windows
source bin/activate_venv.sh # Linux / macOS
```
### CLI-Tools ausführen
@@ -105,14 +149,16 @@ setzt die Umgebung, aktiviert `.venv` und ruft dann das Python-Modul auf.
`%SKEL_DATA%` aufgelöst) oder einen vollen Pfad; Ausgaben landen in
`%SKEL_RESULTS%`.
REM 1) Materialfluss der mechanischen Objekte
bin\material_flow.bat --file mubea.csv --tosvg --doc
```bat
REM 1) Materialfluss der mechanischen Objekte
bin\material_flow.bat --file mubea.csv --tosvg --doc
REM 2) TRO-Liste + eigenes Flussdiagramm ableiten
bin\tro_flow.bat --file mubea.csv --tosvg --doc
REM 2) TRO-Liste + eigenes Flussdiagramm ableiten
bin\tro_flow.bat --file mubea.csv --tosvg --doc
REM 3) TROs als Marker-Symbole in eine Kopie der CAD-Zeichnung einbrennen
bin\tro_annotate.bat --file mubea.csv --dxf 500573_60_1.dxf --flow --fb --legend
REM 3) TROs als Marker-Symbole in eine Kopie der CAD-Zeichnung einbrennen
bin\tro_annotate.bat --file mubea.csv --dxf 500573_60_1.dxf --flow --fb --legend
```
Alle Switches, Ausgabedateien und Exit-Codes der drei Tools sind in
[`doc/Python_Scripts.md`](doc/Python_Scripts.md) dokumentiert; das