From be69281af51ae728107ddcdc944c55ba8801f6c2 Mon Sep 17 00:00:00 2001 From: Michael Stangl Date: Fri, 29 May 2026 13:28:08 +0200 Subject: [PATCH] =?UTF-8?q?Variof=C3=B6rderer=20Test=20in=20tests.lsp=20wi?= =?UTF-8?q?eder=20rein?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Lisp/tests.lsp | 278 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 278 insertions(+) diff --git a/Lisp/tests.lsp b/Lisp/tests.lsp index 999a433..8ca70fe 100644 --- a/Lisp/tests.lsp +++ b/Lisp/tests.lsp @@ -202,3 +202,281 @@ (defun c:EXPORTCSV () (csv:run-export "EXPORTCSV" "export_csv.py" "export.csv") ) + +;; ============================================================ +;; TEST_FOERDERER - Automatischer Test ohne Benutzereingabe +;; Erzeugt 12 Variofoerderer (6x Auf, 6x Ab) mit deltaL=7000 +;; und verschiedenen Hoehenstufen. Tabellarische Zusammenfassung. +;; ============================================================ +(defun c:TEST_FOERDERER ( / deltaL deltaH richtung ergebnis + best-winkel L_GF L_VF dateiname + y-offset hoehen-liste idx + anz-gebaut anz-nicht-gebaut + result-pfad erfolgsquote + zusammenfassung-liste + nr deltaH_val status winkel L_GF_val L_VF_val) + + ;; Bibliothek initialisieren (laedt Block-Library und extrahiert Masse) + (if (not *lib-initialized*) + (init-bibliothek) + ) + + (ssg-start "TEST_FOERDERER" '(("OSMODE") ("CECOLOR") ("ATTREQ") ("ATTDIA"))) + (setvar "OSMODE" 0) + (setvar "ATTREQ" 0) + (setvar "ATTDIA" 0) + + (setq deltaL 7000) + (setq hoehen-liste '(0 1000 2000 3000 4000 5000)) + (setq y-offset 0) + (setq idx 0) + (setq zusammenfassung-liste '()) + (setq anz-gebaut 0) + (setq anz-nicht-gebaut 0) + + (princ "\n") + (princ "\n================================================================") + (princ "\n FOERDERTEST - PRODUKTIONSPROTOKOLL") + (princ "\n================================================================") + (princ (strcat "\n Distanz dL = " (rtos deltaL 2 0) " mm")) + (princ "\n Hoehenstufen: 0, 1000, 2000, 3000, 4000, 5000 mm") + (princ "\n Richtungen: Auf + Ab") + (princ "\n================================================================") + (princ "\n Nr. Richtung dH (mm) Status Winkel L_GF (mm) L_VF (mm)") + (princ "\n================================================================") + + ;; ========================================================== + ;; TEIL 1: Aufwaerts-Tests (6 Foerderer) + ;; ========================================================== + (foreach deltaH hoehen-liste + (setq idx (1+ idx)) + (setq richtung "Auf") + + (setq ergebnis (berechne-alle-winkel deltaL deltaH richtung)) + (setq best-winkel (car ergebnis)) + (setq L_GF (cadr ergebnis)) + (setq L_VF (caddr ergebnis)) + + (if (and best-winkel L_GF L_VF (> L_GF 0) (> L_VF 0)) + (progn + (setq anz-gebaut (1+ anz-gebaut)) + (princ (strcat "\n " + (itoa idx) " " + (if (< idx 10) " " "") + "Auf " + (rtos deltaH 4 0) " " + "GEBAUT " + (itoa best-winkel) " Grad " + (rtos L_GF 2 1) " " + (rtos L_VF 2 1))) + + (foerderanlage-einfuegen deltaL deltaH richtung best-winkel + (/ L_GF 2.0) (/ L_GF 2.0) L_VF + (list 0 y-offset 0)) + + (setq zusammenfassung-liste (cons + (list idx richtung deltaH "GEBAUT" best-winkel L_GF L_VF) + zusammenfassung-liste)) + ) + (progn + (setq anz-nicht-gebaut (1+ anz-nicht-gebaut)) + (princ (strcat "\n " + (itoa idx) " " + (if (< idx 10) " " "") + "Auf " + (rtos deltaH 4 0) " " + "NICHT " + "--- " + "--- " + "---")) + + (cond + ((and (<= L_GF 0) (<= L_VF 0)) + (princ "\n -> Grund: L_GF und L_VF sind negativ (Strecke zu kurz)")) + ((<= L_GF 0) + (princ "\n -> Grund: L_GF ist negativ (Gefaellestrecke zu kurz)")) + ((<= L_VF 0) + (princ "\n -> Grund: L_VF ist negativ (keine passende Steigung moeglich)")) + ((null best-winkel) + (princ "\n -> Grund: Kein passender Winkel (Hoehendifferenz zu gross/klein)")) + (t + (princ "\n -> Grund: Unbekannter Fehler in der Berechnung")) + ) + + (setq zusammenfassung-liste (cons + (list idx richtung deltaH "NICHT_GEBAUT" nil nil nil) + zusammenfassung-liste)) + ) + ) + (setq y-offset (- y-offset 200)) + ) + + ;; ========================================================== + ;; TEIL 2: Abwaerts-Tests (6 Foerderer) + ;; ========================================================== + (foreach deltaH hoehen-liste + (setq idx (1+ idx)) + (setq richtung "Ab") + + (if (< deltaH 1) + (progn + ;; deltaH = 0 bei Abwaerts ist prinzipiell unmoeglich + (setq anz-nicht-gebaut (1+ anz-nicht-gebaut)) + (princ (strcat "\n " + (itoa idx) " " + (if (< idx 10) " " "") + "Ab " + (rtos deltaH 4 0) " " + "NICHT " + "--- " + "--- " + "---")) + (princ "\n -> Grund: Bei Richtung 'Ab' mit dH=0 ist aus geometrischen Gruenden") + (princ "\n keine Foerderanlage moeglich (immer negative Netto-Hoehe)") + + (setq zusammenfassung-liste (cons + (list idx richtung deltaH "GEOMETRISCH_UNMOEGLICH" nil nil nil) + zusammenfassung-liste)) + ) + (progn + (setq ergebnis (berechne-alle-winkel deltaL deltaH richtung)) + (setq best-winkel (car ergebnis)) + (setq L_GF (cadr ergebnis)) + (setq L_VF (caddr ergebnis)) + + (if (and best-winkel L_GF L_VF (> L_GF 0) (> L_VF 0)) + (progn + (setq anz-gebaut (1+ anz-gebaut)) + (princ (strcat "\n " + (itoa idx) " " + (if (< idx 10) " " "") + "Ab " + (rtos deltaH 4 0) " " + "GEBAUT " + (itoa best-winkel) " Grad " + (rtos L_GF 2 1) " " + (rtos L_VF 2 1))) + + (foerderanlage-einfuegen deltaL deltaH richtung best-winkel + (/ L_GF 2.0) (/ L_GF 2.0) L_VF + (list 0 y-offset 0)) + + (setq zusammenfassung-liste (cons + (list idx richtung deltaH "GEBAUT" best-winkel L_GF L_VF) + zusammenfassung-liste)) + ) + (progn + (setq anz-nicht-gebaut (1+ anz-nicht-gebaut)) + (princ (strcat "\n " + (itoa idx) " " + (if (< idx 10) " " "") + "Ab " + (rtos deltaH 4 0) " " + "NICHT " + "--- " + "--- " + "---")) + + (cond + ((and (<= L_GF 0) (<= L_VF 0)) + (princ "\n -> Grund: L_GF und L_VF sind negativ (Strecke zu kurz)")) + ((<= L_GF 0) + (princ "\n -> Grund: L_GF ist negativ (Gefaellestrecke zu kurz)")) + ((<= L_VF 0) + (princ "\n -> Grund: L_VF ist negativ (Hoehendifferenz zu klein fuer diesen Weg)")) + ((null best-winkel) + (princ "\n -> Grund: Kein passender Winkel (Hoehendifferenz zu gross)")) + (t + (princ "\n -> Grund: Unbekannter Fehler in der Berechnung")) + ) + + (setq zusammenfassung-liste (cons + (list idx richtung deltaH "NICHT_GEBAUT" nil nil nil) + zusammenfassung-liste)) + ) + ) + ) + ) + (setq y-offset (- y-offset 200)) + ) + + ;; ========================================================== + ;; TEIL 3: ZUSAMMENFASSUNG + ;; ========================================================== + (princ "\n\n================================================================================") + (princ "\n ZUSAMMENFASSUNG") + (princ (strcat "\n dL = " (rtos deltaL 2 0) " mm")) + (princ "\n================================================================================") + + (foreach item (reverse zusammenfassung-liste) + (setq nr (car item)) + (setq richtung (cadr item)) + (setq deltaH_val (caddr item)) + (setq status (cadddr item)) + (setq winkel (car (cddddr item))) + (setq L_GF_val (cadr (cddddr item))) + (setq L_VF_val (caddr (cddddr item))) + + (cond + ((= status "GEBAUT") + (princ (strcat "\n " + (itoa nr) ". " richtung + (if (= richtung "Auf") " " " ") + (rtos deltaH_val 2 0) " mm " + (itoa winkel) " Grad " + (rtos L_GF_val 2 2) " mm " + (rtos L_VF_val 2 2) " mm GEBAUT"))) + ((= status "GEOMETRISCH_UNMOEGLICH") + (princ (strcat "\n " + (itoa nr) ". " richtung + (if (= richtung "Auf") " " " ") + (rtos deltaH_val 2 0) " mm " + "--- " + "--- mm " + "--- mm GEOMETRISCH UNMOEGLICH"))) + (t + (princ (strcat "\n " + (itoa nr) ". " richtung + (if (= richtung "Auf") " " " ") + (rtos deltaH_val 2 0) " mm " + "--- " + "--- mm " + "--- mm NICHT GEBAUT"))) + ) + ) + + (princ "\n\n================================================================================") + (princ (strcat "\n Erfolgreich gebaut: " (itoa anz-gebaut) " von " (itoa idx))) + (princ (strcat "\n Erfolgsquote: " (rtos (/ (* anz-gebaut 100.0) idx) 2 1) "%")) + (princ "\n================================================================================") + + (princ "\n\n Erklaerung:") + (princ "\n ----------") + (princ "\n GEBAUT:") + (princ "\n - Auf, dH=0 -> L_VF > 0 kompensiert 3 Grad-Gefaellestrecken") + (princ "\n - Auf, dH>0 -> Normalfall") + (princ "\n - Ab, dH>=1000 -> Normalfall") + (princ "\n") + (princ "\n NICHT GEBAUT:") + (princ "\n - Ab, dH=0 -> Geometrisch unmoeglich (Netto-Hoehe immer negativ)") + (princ "\n - Auf, dH=5000 -> 48 Grad Steigung reicht nicht aus (L_VF negativ)") + (princ "\n - Ab, dH=5000 -> 48 Grad Gefaelle reicht nicht aus") + (princ "\n================================================================================") + + (ssg-end) + + ;; Datei speichern + (if (getenv "DXFM_RESULTS") + (setq result-pfad (getenv "DXFM_RESULTS")) + (setq result-pfad (strcat (getenv "DXFM_BLOCKS") "/../results")) + ) + + (setq dateiname (strcat result-pfad + "/" + (menucmd "M=$(edtime,$(getvar,date),YYYYMODD-HHmm)") + ".dxf")) + (princ (strcat "\n\nSpeichere als: " dateiname)) + (command "_.DXFOUT" dateiname "V" "2018" "16") + (princ "\n\n>>> FOERDERTEST abgeschlossen (12 Foerderer)! <<<") + (princ) +)