Oberfläche für Standard von Varioförder und Gefällestrecke bauen lassen

This commit is contained in:
2026-07-20 15:39:17 +02:00
parent 27ab8b4875
commit 5c28db9e91
14 changed files with 1285 additions and 143 deletions
+84 -21
View File
@@ -25,8 +25,12 @@
;; --- Ergebnis eines Testfalls als JSON-String erzeugen ---
(defun gefaellestrecke:test-json (test-id modus hz deltaL winkel h-von h-bis d-h status /
;; as-winkel/es-winkel: "30" oder "90" (Element-Variante); default "90"
(defun gefaellestrecke:test-json (test-id modus hz deltaL winkel h-von h-bis d-h status
as-winkel es-winkel /
json)
(if (null as-winkel) (setq as-winkel "90"))
(if (null es-winkel) (setq es-winkel "90"))
(setq json
(strcat " {\n"
" \"test_id\": \"" test-id "\",\n"
@@ -34,6 +38,8 @@
" \"hz_grad\": " (rtos (float hz) 2 1) ",\n"
" \"deltaL_mm\": " (rtos (float deltaL) 2 0) ",\n"
" \"winkel_grad\": " (rtos (float winkel) 2 3) ",\n"
" \"as_winkel\": \"" as-winkel "\",\n"
" \"es_winkel\": \"" es-winkel "\",\n"
" \"hoehe_von_mm\": " (rtos (float h-von) 2 0) ",\n"
" \"hoehe_bis_mm\": " (rtos (float h-bis) 2 0) ",\n"
" \"delta_h_mm\": " (rtos (float d-h) 2 0) ",\n"
@@ -296,6 +302,7 @@
m2-start m2-deltaH m2-deltaL
m3-start m3-end m3-line-vla
m3b-start m3b-end m3b-e1 m3b-e2 m3b-e3 m3b-objliste
w30-rad w30-sepx w30-lstau
lbl-layer lbl-h lbl-h2)
;; Block-Bibliothek initialisieren (setzt aus-dx, ein-dx, aus-dz, ein-dz usw.)
@@ -376,7 +383,7 @@
(setq gf-ins
(car (gefaellestrecke-einfuegen
test-L_stau test-winkel (list 0 0 test-z-start)
"links" "links" 0.0 test-deltaL)))
"links" "links" 0.0 test-deltaL "90" "90")))
(if gf-ins
(progn
(setq attribs (ssg-attrib-read gf-ins))
@@ -388,13 +395,13 @@
" dH=" (itoa d-h) " mm W=" w-str " OK"))
(setq results-list
(cons (gefaellestrecke:test-json "M1_hz000" 1 0.0 test-deltaL
(atof w-str) h-von h-bis d-h "GEBAUT")
(atof w-str) h-von h-bis d-h "GEBAUT" "90" "90")
results-list)))
(progn
(princ " FEHLER")
(setq results-list
(cons (gefaellestrecke:test-json "M1_hz000" 1 0.0 test-deltaL
0.0 0 0 0 "FEHLER")
0.0 0 0 0 "FEHLER" "90" "90")
results-list))))
;; --- M1: hz=90 Grad (Nord), Start (15000, 0, 5000) ---
@@ -408,7 +415,7 @@
(setq gf-ins
(car (gefaellestrecke-einfuegen
test-L_stau test-winkel (list 15000 0 test-z-start)
"links" "links" 90.0 test-deltaL)))
"links" "links" 90.0 test-deltaL "90" "90")))
(if gf-ins
(progn
(setq attribs (ssg-attrib-read gf-ins))
@@ -420,13 +427,13 @@
" dH=" (itoa d-h) " mm W=" w-str " OK"))
(setq results-list
(cons (gefaellestrecke:test-json "M1_hz090" 1 90.0 test-deltaL
(atof w-str) h-von h-bis d-h "GEBAUT")
(atof w-str) h-von h-bis d-h "GEBAUT" "90" "90")
results-list)))
(progn
(princ " FEHLER")
(setq results-list
(cons (gefaellestrecke:test-json "M1_hz090" 1 90.0 test-deltaL
0.0 0 0 0 "FEHLER")
0.0 0 0 0 "FEHLER" "90" "90")
results-list))))
;; --- M1: hz=180 Grad (West), Start (0, -15000, 5000) ---
@@ -440,7 +447,7 @@
(setq gf-ins
(car (gefaellestrecke-einfuegen
test-L_stau test-winkel (list 0 -15000 test-z-start)
"links" "links" 180.0 test-deltaL)))
"links" "links" 180.0 test-deltaL "90" "90")))
(if gf-ins
(progn
(setq attribs (ssg-attrib-read gf-ins))
@@ -452,13 +459,13 @@
" dH=" (itoa d-h) " mm W=" w-str " OK"))
(setq results-list
(cons (gefaellestrecke:test-json "M1_hz180" 1 180.0 test-deltaL
(atof w-str) h-von h-bis d-h "GEBAUT")
(atof w-str) h-von h-bis d-h "GEBAUT" "90" "90")
results-list)))
(progn
(princ " FEHLER")
(setq results-list
(cons (gefaellestrecke:test-json "M1_hz180" 1 180.0 test-deltaL
0.0 0 0 0 "FEHLER")
0.0 0 0 0 "FEHLER" "90" "90")
results-list))))
;; --- M1: hz=270 Grad (Sued), Start (15000, -15000, 5000) ---
@@ -472,7 +479,7 @@
(setq gf-ins
(car (gefaellestrecke-einfuegen
test-L_stau test-winkel (list 15000 -15000 test-z-start)
"links" "links" 270.0 test-deltaL)))
"links" "links" 270.0 test-deltaL "90" "90")))
(if gf-ins
(progn
(setq attribs (ssg-attrib-read gf-ins))
@@ -484,13 +491,13 @@
" dH=" (itoa d-h) " mm W=" w-str " OK"))
(setq results-list
(cons (gefaellestrecke:test-json "M1_hz270" 1 270.0 test-deltaL
(atof w-str) h-von h-bis d-h "GEBAUT")
(atof w-str) h-von h-bis d-h "GEBAUT" "90" "90")
results-list)))
(progn
(princ " FEHLER")
(setq results-list
(cons (gefaellestrecke:test-json "M1_hz270" 1 270.0 test-deltaL
0.0 0 0 0 "FEHLER")
0.0 0 0 0 "FEHLER" "90" "90")
results-list))))
;; ============================================================
@@ -522,7 +529,7 @@
(princ (strcat "\n\n M2_hz000: Start=(0,-35000," (rtos test-z-start 2 0) ") ..."))
(setq ergebnis
(gefaellestrecke-einfuegen
test-L_stau test-winkel m2-start "links" "links" 0.0 test-deltaL))
test-L_stau test-winkel m2-start "links" "links" 0.0 test-deltaL "90" "90"))
(setq gf-ins (car ergebnis))
(if gf-ins
(progn
@@ -541,7 +548,7 @@
" mm W=" w-str " OK"))
(setq results-list
(cons (gefaellestrecke:test-json "M2_hz000" 2 0.0 test-deltaL
(atof w-str) h-von h-bis m2-deltaH "GEBAUT")
(atof w-str) h-von h-bis m2-deltaH "GEBAUT" "90" "90")
results-list)))
(progn
;; Fallback: sin(3deg) * 10000 ≈ 523mm
@@ -550,7 +557,7 @@
(princ (strcat " FEHLER (Fallback " delta-sym "H=" (rtos m2-deltaH 2 3) ")"))
(setq results-list
(cons (gefaellestrecke:test-json "M2_hz000" 2 0.0 test-deltaL
0.0 0 0 0 "FEHLER")
0.0 0 0 0 "FEHLER" "90" "90")
results-list))))
;; ============================================================
@@ -618,20 +625,20 @@
" W=" w-str " OK"))
(setq results-list
(cons (gefaellestrecke:test-json "M3_hz270" 3 270.0 test-deltaL
(atof w-str) h-von h-bis d-h "GEBAUT")
(atof w-str) h-von h-bis d-h "GEBAUT" "90" "90")
results-list)))
(progn
(princ "\n -> FEHLER (modus3-einfuegen)")
(setq results-list
(cons (gefaellestrecke:test-json "M3_hz270" 3 270.0 test-deltaL
0.0 0 0 0 "FEHLER")
0.0 0 0 0 "FEHLER" "90" "90")
results-list)))))
;; 3D-Linie konnte nicht erzeugt werden
(progn
(princ "\n FEHLER: 3D-Linie nicht erzeugbar!")
(setq results-list
(cons (gefaellestrecke:test-json "M3_hz270" 3 270.0 test-deltaL
0.0 0 0 0 "FEHLER_LINIE")
0.0 0 0 0 "FEHLER_LINIE" "90" "90")
results-list))))
;; ============================================================
@@ -688,15 +695,71 @@
" " delta-sym "H-Soll=200 mm W=" w-str " OK"))
(setq results-list
(cons (gefaellestrecke:test-json "M3_Bogen" 3 0.0 14785.0
(atof w-str) h-von h-bis d-h "GEBAUT")
(atof w-str) h-von h-bis d-h "GEBAUT" "90" "90")
results-list)))
(progn
(princ "\n -> FEHLER (modus3-einfuegen mit Bogen)")
(setq results-list
(cons (gefaellestrecke:test-json "M3_Bogen" 3 0.0 14785.0
0.0 0 0 0 "FEHLER")
0.0 0 0 0 "FEHLER" "90" "90")
results-list))))
;; ============================================================
;; MODUS 1 - 30-Grad AUS-/EIN-Elemente (statt 90 Grad)
;; Prueft die per DCL-Dialog waehlbare Element-Variante 30 Grad.
;; hz=0, Start (30000, 0, 5000). Eigene L_stau-Berechnung, da die
;; 30-Grad-Elemente andere aus-dx/ein-dx-Masse besitzen.
;; ============================================================
(princ "\n\n================================================================")
(princ "\n MODUS 1 - 30-Grad Elemente (M1_w30)")
(princ "\n================================================================")
(entmake (list '(0 . "TEXT")
(cons 10 (list 30000 1200.0 test-z-start))
(cons 11 (list 30000 1200.0 test-z-start))
(cons 40 lbl-h)
(cons 1 (strcat "M1 | hz=0" grad-zeichen " | AS/ES=30" grad-zeichen
" | " delta-sym "L=10000 | W=3" grad-zeichen))
'(7 . "Standard") (cons 8 lbl-layer) '(72 . 1) '(73 . 2)))
;; 30-Grad-Element-Masse setzen und L_stau dafuer berechnen
(vf-set-as-masse "30" "links")
(vf-set-es-masse "30" "links")
(setq w30-rad (* test-winkel (/ pi 180.0)))
(setq w30-sepx (* 300.0 (cos w30-rad)))
(setq w30-lstau
(/ (- test-deltaL (float aus-dx) (float ein-dx) w30-sepx) (cos w30-rad)))
(princ (strcat "\n\n M1_w30: AS/ES=30 Grad, aus-dx=" (rtos (float aus-dx) 2 1)
" ein-dx=" (rtos (float ein-dx) 2 1)
" L_stau=" (rtos w30-lstau 2 1) " ..."))
(setq gf-ins
(car (gefaellestrecke-einfuegen
w30-lstau test-winkel (list 30000 0 test-z-start)
"links" "links" 0.0 test-deltaL "30" "30")))
(if gf-ins
(progn
(setq attribs (ssg-attrib-read gf-ins))
(setq h-von (atoi (cdr (assoc "HOEHE_VON_mm" attribs))))
(setq h-bis (atoi (cdr (assoc "HOEHE_BIS_mm" attribs))))
(setq d-h (abs (- h-von h-bis)))
(setq w-str (cdr (assoc "GF_WINKEL" attribs)))
(princ (strcat " von=" (itoa h-von) " bis=" (itoa h-bis)
" dH=" (itoa d-h) " mm W=" w-str " OK"))
(setq results-list
(cons (gefaellestrecke:test-json "M1_w30" 1 0.0 test-deltaL
(atof w-str) h-von h-bis d-h "GEBAUT" "30" "30")
results-list)))
(progn
(princ " FEHLER")
(setq results-list
(cons (gefaellestrecke:test-json "M1_w30" 1 0.0 test-deltaL
0.0 0 0 0 "FEHLER" "30" "30")
results-list))))
;; Element-Masse wieder auf 90 Grad zuruecksetzen (fuer Folgelaeufe)
(vf-set-as-masse "90" "links")
(vf-set-es-masse "90" "links")
;; ============================================================
;; Zusammenfassung und Export
;; ============================================================
+23 -5
View File
@@ -82,14 +82,30 @@ class TestGefaellestreckeStatus:
)
def test_alle_modus1_gebaut(self):
"""Alle vier Modus-1-Richtungen (hz=0/90/180/270) muessen GEBAUT sein."""
"""Alle Modus-1-Testfaelle (Richtungs-Sweep + 30-Grad-Variante) muessen GEBAUT sein."""
erwartet = [t["test_id"] for t in self.tests if t["modus"] == 1]
modus1 = [r for r in self.results if r["modus"] == 1]
assert len(modus1) == 4, f"Erwartet 4 Modus-1-Testfaelle, gefunden {len(modus1)}"
assert len(modus1) == len(erwartet), (
f"Erwartet {len(erwartet)} Modus-1-Testfaelle, gefunden {len(modus1)}"
)
for r in modus1:
assert r["status"] == "GEBAUT", (
f'{r["test_id"]}: erwartet GEBAUT, ist "{r["status"]}"'
)
def test_modus1_30grad_gebaut(self):
"""Die per Dialog waehlbare 30-Grad-Element-Variante (M1_w30) muss GEBAUT sein."""
r = self.results_by_id.get("M1_w30")
if r is None:
pytest.skip("M1_w30 nicht in Ergebnissen (aeltere Testdaten?)")
assert r["status"] == "GEBAUT", (
f'M1_w30: erwartet GEBAUT, ist "{r["status"]}"'
)
assert r.get("as_winkel") == "30" and r.get("es_winkel") == "30", (
f'M1_w30: Element-Winkel sollten 30 sein, sind '
f'AS={r.get("as_winkel")} ES={r.get("es_winkel")}'
)
def test_modus2_und_modus3_gebaut(self):
"""Modus 2 und Modus 3 muessen GEBAUT sein."""
for test_id in ("M2_hz000", "M3_hz270"):
@@ -179,10 +195,12 @@ class TestGefaellestreckeModusKonsistenz:
self.tests_by_id = {t["test_id"]: t for t in self.testdata if "test_id" in t}
def test_modus1_richtungsunabhaengig(self):
"""Alle vier Modus-1-Richtungen muessen dieselbe Hoehe/Winkel liefern,
da nur die Fahrtrichtung (hz), nicht die Geometrie variiert."""
"""Die vier Modus-1-Richtungen (90-Grad-Elemente) muessen dieselbe Hoehe/Winkel
liefern, da nur die Fahrtrichtung (hz), nicht die Geometrie variiert. Die
30-Grad-Variante (M1_w30) ist bewusst ausgenommen (andere Element-Masse)."""
modus1 = [r for r in self.results
if r["modus"] == 1 and r["status"] == "GEBAUT"]
if r["modus"] == 1 and r["status"] == "GEBAUT"
and r.get("as_winkel", "90") == "90"]
assert len(modus1) >= 2, "Zu wenige Modus-1-Ergebnisse fuer Vergleich"
referenz = modus1[0]
for r in modus1[1:]:
+32 -7
View File
@@ -10,7 +10,9 @@
"hz_grad": 0.0,
"start_mm": [0, 0, 5000],
"as_seite": "links",
"es_seite": "links"
"es_seite": "links",
"as_winkel": "90",
"es_winkel": "90"
},
{
"test_id": "M1_hz090",
@@ -18,7 +20,9 @@
"hz_grad": 90.0,
"start_mm": [15000, 0, 5000],
"as_seite": "links",
"es_seite": "links"
"es_seite": "links",
"as_winkel": "90",
"es_winkel": "90"
},
{
"test_id": "M1_hz180",
@@ -26,7 +30,9 @@
"hz_grad": 180.0,
"start_mm": [0, -15000, 5000],
"as_seite": "links",
"es_seite": "links"
"es_seite": "links",
"as_winkel": "90",
"es_winkel": "90"
},
{
"test_id": "M1_hz270",
@@ -34,7 +40,20 @@
"hz_grad": 270.0,
"start_mm": [15000, -15000, 5000],
"as_seite": "links",
"es_seite": "links"
"es_seite": "links",
"as_winkel": "90",
"es_winkel": "90"
},
{
"test_id": "M1_w30",
"modus": 1,
"hz_grad": 0.0,
"start_mm": [30000, 0, 5000],
"as_seite": "links",
"es_seite": "links",
"as_winkel": "30",
"es_winkel": "30",
"beschreibung": "Modus 1 mit 30-Grad AUS-/EIN-Elementen (statt 90 Grad)"
},
{
"test_id": "M2_hz000",
@@ -44,7 +63,9 @@
"linie_start_mm": [0, -35000, 0],
"linie_ende_mm": [10000, -35000, 0],
"as_seite": "links",
"es_seite": "links"
"es_seite": "links",
"as_winkel": "90",
"es_winkel": "90"
},
{
"test_id": "M3_hz270",
@@ -54,7 +75,9 @@
"deltaH_quelle": "M2_hz000",
"deltaL_quelle": "M2_hz000",
"as_seite": "links",
"es_seite": "links"
"es_seite": "links",
"as_winkel": "90",
"es_winkel": "90"
},
{
"test_id": "M3_Bogen",
@@ -64,6 +87,8 @@
"ende_mm": [38500, -43500, 1800],
"bogen": {"winkel_grad": 90, "radius_mm": 500, "seite": "links"},
"as_seite": "links",
"es_seite": "links"
"es_seite": "links",
"as_winkel": "90",
"es_winkel": "90"
}
]