from pydantic import BaseModel, Field, field_validator import math import plant2dxf from ezdxf.math import Matrix44 class Gefaellestrecke(BaseModel): teileid: str x: float = Field(description="X-Koordinate des Foerder-Zentrums") y: float = Field(description="Y-Koordinate des Foerder-Zentrums") laenge:float = Field(description = "Länge des Förderers") h0: float = Field(description="Höhe Unten in Merkmale") h1: float = Field(description="Höhe Oben in Merkmale") drehung: float = Field(default=0.0, description="Drehung an z achse") anzahl_scanner: int = Field(default=0, description="Anzahl der Scanner") anzahl_separatoren: int = Field(default=0, description="Anzahl der Separatoren") @property def hight_zwischen(self): return ((self.h0 + self.h1) /2) @classmethod def from_merkmale(cls, teileid: str, x: float, y: float, merkmale: dict) -> 'Gefaellestrecke': h0 = float(merkmale.get("Höhe unten")) * 1000 h1 = float(merkmale.get("Höhe oben")) * 1000 laenge = float(merkmale.get("Länge in Meter")) * 1000 return cls( teileid = teileid, laenge = laenge, x = x, y = y, h0 = h0, h1 =h1, drehung = float(merkmale.get("Drehung")), anzahl_scanner = int(merkmale.get("Anzahl der Scanner")), anzahl_separatoren = int(merkmale.get("Anzahl der Separatoren")) ) def hat_motor_umlenk_station (gefaelle_objekt, gefaellestrecke_nachbarn): hat_motor_0 = None hat_motor_1 = None hat_umlenk_0 = None hat_umlenk_1 = None tefkurve_0 = None tefkurve_1 = None umlenk_gerade = False motor_gerade = False upper_hoehe_gefaehlle = gefaelle_objekt.h1 lower_hoehe_gefaehlle = gefaelle_objekt.h0 rotation = gefaelle_objekt.drehung x = gefaelle_objekt.x y = gefaelle_objekt.y if "Kurvenrichtung" in gefaellestrecke_nachbarn: vario_hoehe_0 = float(gefaellestrecke_nachbarn.get("vario_hoehe_0")) vario_hoehe_1 = float(gefaellestrecke_nachbarn.get("vario_hoehe_1")) kurvenrichtung = gefaellestrecke_nachbarn.get("Kurvenrichtung") tefkurve_0 = gefaellestrecke_nachbarn.get("Tefkurve") x_angetrieben = gefaellestrecke_nachbarn.get("X_angetrieben") y_angetrieben = gefaellestrecke_nachbarn.get("Y_angetrieben") if (kurvenrichtung == "links" and tefkurve_0 == "außen") or kurvenrichtung == "rechts" and tefkurve_0 == "innen": tefkurve_0 = "rechts" else: tefkurve_0 = "links" if upper_hoehe_gefaehlle > lower_hoehe_gefaehlle: if vario_hoehe_0 == upper_hoehe_gefaehlle or vario_hoehe_1 == upper_hoehe_gefaehlle: hat_motor_0 = True else: hat_umlenk_0 = True elif upper_hoehe_gefaehlle < lower_hoehe_gefaehlle: if vario_hoehe_0 == lower_hoehe_gefaehlle or vario_hoehe_1 == lower_hoehe_gefaehlle: hat_motor_0 = True else: hat_umlenk_0 = True else: rotation_zwischen = rotation if rotation_zwischen == 0.0: rotation_zwischen = -360.0 if (((-360.0<= rotation_zwischen< -270.0)and y > y_angetrieben) or ((-90.0< rotation< 0.0)and y > y_angetrieben) or ((-270.0< rotation_zwischen< -90.0)and y < y_angetrieben) or (rotation == -90.0 and x < x_angetrieben) or ((rotation == -270.0)and x lower_hoehe_gefaehlle: if vario_hoehe_0_1 == upper_hoehe_gefaehlle or vario_hoehe_1_1 == upper_hoehe_gefaehlle: hat_motor_1 = True else: hat_umlenk_1 = True elif upper_hoehe_gefaehlle < lower_hoehe_gefaehlle: if vario_hoehe_0_1 == lower_hoehe_gefaehlle or vario_hoehe_1_1 == lower_hoehe_gefaehlle: hat_motor_1 = True else: hat_umlenk_1 = True else: rotation_zwischen = rotation if rotation_zwischen == 0.0: rotation_zwischen = -360.0 if (((-360.0<= rotation_zwischen< -270.0)and y > y_angetrieben) or ((-90.0< rotation< 0.0)and y > y_angetrieben) or ((-270.0< rotation_zwischen< -90.0)and y < y_angetrieben) or (rotation == -90.0 and x < x_angetrieben) or ((rotation == -270.0)and x