Varioförderer refactored mit Claude. Unittests dazu gebaut.
This commit is contained in:
+315
-117
@@ -11,48 +11,61 @@ 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")
|
||||
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)
|
||||
return (self.h0 + self.h1) / 2
|
||||
|
||||
@classmethod
|
||||
def from_merkmale(cls, teileid: str, x: float, y: float, merkmale: dict) -> 'Gefaellestrecke':
|
||||
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"))
|
||||
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 erstehlung_von_gefalle_ohne_aussnahmen(msp, x, y, upper_hoehe_gefaelle, lower_hoehe_gefaelle, halbe_laenge, winkel):
|
||||
dx = halbe_laenge *math.sin(winkel * -1)
|
||||
|
||||
def erstehlung_von_gefalle_ohne_aussnahmen(
|
||||
msp, x, y, upper_hoehe_gefaelle, lower_hoehe_gefaelle, halbe_laenge, winkel
|
||||
):
|
||||
dx = halbe_laenge * math.sin(winkel * -1)
|
||||
dy = halbe_laenge * math.cos(winkel)
|
||||
start = x +dx, y + dy,upper_hoehe_gefaelle
|
||||
ende = x -dx, y - dy,lower_hoehe_gefaelle
|
||||
line =msp.add_line(start,ende)
|
||||
start = x + dx, y + dy, upper_hoehe_gefaelle
|
||||
ende = x - dx, y - dy, lower_hoehe_gefaelle
|
||||
line = msp.add_line(start, ende)
|
||||
line.dxf.layer = "6-SP"
|
||||
def rotation_mit_zwei_verbunden(gefaellestrecke_nachbarn,richtung2, richtung0, am_kreisel, kreisel_verbunden, hight_position):
|
||||
drehung0 =gefaellestrecke_nachbarn.get("Drehung0")
|
||||
|
||||
def rotation_mit_zwei_verbunden(
|
||||
gefaellestrecke_nachbarn,
|
||||
richtung2,
|
||||
richtung0,
|
||||
am_kreisel,
|
||||
kreisel_verbunden,
|
||||
hight_position,
|
||||
):
|
||||
drehung0 = gefaellestrecke_nachbarn.get("Drehung0")
|
||||
drehung1 = gefaellestrecke_nachbarn.get("Drehung1")
|
||||
x0_kreisel = float(gefaellestrecke_nachbarn.get("x0"))
|
||||
y0_kreisel = float(gefaellestrecke_nachbarn.get("y0"))
|
||||
x1_kreisel = float(gefaellestrecke_nachbarn.get("x1"))
|
||||
y1_kreisel = float(gefaellestrecke_nachbarn.get("y1"))
|
||||
|
||||
|
||||
if richtung2 == "DEFAULT":
|
||||
if richtung0 == "Vertikal":
|
||||
if x0_kreisel < x1_kreisel:
|
||||
@@ -71,26 +84,35 @@ class Gefaellestrecke(BaseModel):
|
||||
else:
|
||||
gefaelle = "rechts"
|
||||
elif richtung0 == "Horizontal":
|
||||
if position == "lower_lower" or position == "higher_higher":
|
||||
gefaelle = "oben"
|
||||
else:
|
||||
gefaelle = "unten"
|
||||
# vertausch der drehung und der höhe für die namens gebung des blockes
|
||||
if (position == "higher_rechts" or position == "lower_rechts" or position=="higher_lower" or position== "lower_lower") and drehung0 != drehung1 and am_kreisel == 0:
|
||||
if position == "lower_lower" or position == "higher_higher":
|
||||
gefaelle = "oben"
|
||||
else:
|
||||
gefaelle = "unten"
|
||||
# vertausch der drehung und der höhe für die namens gebung des blockes
|
||||
if (
|
||||
(
|
||||
position == "higher_rechts"
|
||||
or position == "lower_rechts"
|
||||
or position == "higher_lower"
|
||||
or position == "lower_lower"
|
||||
)
|
||||
and drehung0 != drehung1
|
||||
and am_kreisel == 0
|
||||
):
|
||||
drehung_2 = drehung0
|
||||
drehung0 = drehung1
|
||||
drehung1= drehung_2
|
||||
drehung1 = drehung_2
|
||||
if hight_position == "higher":
|
||||
hight_position = "lower"
|
||||
else:
|
||||
hight_position = "higher"
|
||||
|
||||
# austausch der werte damit immer davon ausgehen dass der 1 kreisel in unserer Liste am Kreisel verbuden ist
|
||||
if kreisel_verbunden == 1 and am_kreisel ==2:
|
||||
if kreisel_verbunden == 1 and am_kreisel == 2:
|
||||
am_kreisel == 1
|
||||
drehung_2 = drehung0
|
||||
drehung0 = drehung1
|
||||
drehung1= drehung_2
|
||||
drehung1 = drehung_2
|
||||
if hight_position == "higher":
|
||||
hight_position = "lower"
|
||||
else:
|
||||
@@ -113,103 +135,249 @@ class Gefaellestrecke(BaseModel):
|
||||
else:
|
||||
gefaelle = "rechts"
|
||||
elif richtung2 == "Horizontal":
|
||||
if position == "lower_lower" or position == "higher_higher":
|
||||
gefaelle = "oben"
|
||||
else:
|
||||
gefaelle = "unten"
|
||||
# austausch der werte damit immer davon ausgehen dass der 1 kreisel in unserer Liste am Kreisel verbuden ist
|
||||
if position == "lower_lower" or position == "higher_higher":
|
||||
gefaelle = "oben"
|
||||
else:
|
||||
gefaelle = "unten"
|
||||
# austausch der werte damit immer davon ausgehen dass der 1 kreisel in unserer Liste am Kreisel verbuden ist
|
||||
if am_kreisel == 2:
|
||||
am_kreisel = 1
|
||||
drehung_2 = drehung0
|
||||
drehung0 = drehung1
|
||||
drehung1= drehung_2
|
||||
drehung1 = drehung_2
|
||||
if hight_position == "higher":
|
||||
hight_position = "lower"
|
||||
else:
|
||||
hight_position = "higher"
|
||||
# Erstellung der Rotation
|
||||
# Erstellung der Rotation
|
||||
if gefaelle == "oben":
|
||||
rotation = 0
|
||||
elif gefaelle == "unten" :
|
||||
elif gefaelle == "unten":
|
||||
rotation = 180
|
||||
elif gefaelle == "links" :
|
||||
elif gefaelle == "links":
|
||||
rotation = 90
|
||||
elif gefaelle == "rechts" :
|
||||
elif gefaelle == "rechts":
|
||||
rotation = 270
|
||||
return rotation,drehung0,drehung1,hight_position
|
||||
def ein_motor_oder_eine_umlenk(x, y,start,ende, doc, lib_doc, hoehe_gefaelle, block_Vario_Umlenkstation_500mm, block_Vario_Motorstation_500mm, blockname_motor_links, blockname_umlenk_links, hat_motor_0, hat_umlenk_0, tefkurve_0, block,umlenk_gerade,motor_gerade):
|
||||
return rotation, drehung0, drehung1, hight_position
|
||||
|
||||
block_Vario_Bogen_auf = (f"Vario_Bogen_auf_3°")
|
||||
block_Vario_Bogen_ab = (f"Vario_Bogen_ab_3°")
|
||||
def ein_motor_oder_eine_umlenk(
|
||||
x,
|
||||
y,
|
||||
start,
|
||||
ende,
|
||||
doc,
|
||||
lib_doc,
|
||||
hoehe_gefaelle,
|
||||
block_Vario_Umlenkstation_500mm,
|
||||
block_Vario_Motorstation_500mm,
|
||||
blockname_motor_links,
|
||||
blockname_umlenk_links,
|
||||
hat_motor_0,
|
||||
hat_umlenk_0,
|
||||
tefkurve_0,
|
||||
block,
|
||||
umlenk_gerade,
|
||||
motor_gerade,
|
||||
):
|
||||
|
||||
block_Vario_Bogen_auf = f"Vario_Bogen_auf_3°"
|
||||
block_Vario_Bogen_ab = f"Vario_Bogen_ab_3°"
|
||||
block_Vario_Bogen_auf_links = (f"Vario_Bogen_auf_3°") + "_links"
|
||||
block_Vario_Bogen_ab_links = (f"Vario_Bogen_ab_3°") + "_links"
|
||||
auf_attrib = block_methoden.import_block(block_Vario_Bogen_auf,lib_doc,doc)
|
||||
ab_attrib = block_methoden.import_block(block_Vario_Bogen_ab,lib_doc,doc)
|
||||
Vario_Bogen_auf_Delta_SP_0 = list(float(att)for att in re.split(r"[;,]", auf_attrib["DELTA_SP_0"]))
|
||||
Vario_Bogen_auf_Delta_SP_1 = list(float(att) for att in re.split(r"[;,]", auf_attrib["DELTA_SP_1"]))
|
||||
Vario_Bogen_ab_Delta_SP_0 = list(float(att) for att in re.split(r"[;,]", ab_attrib["DELTA_SP_0"]))
|
||||
Vario_Bogen_ab_Delta_SP_1 = list(float(att) for att in re.split(r"[;,]", ab_attrib["DELTA_SP_1"]))
|
||||
for i, wert in enumerate(Vario_Bogen_auf_Delta_SP_0):
|
||||
if wert < 0:
|
||||
Vario_Bogen_auf_Delta_SP_0[i] = abs(wert)
|
||||
auf_attrib = block_methoden.import_block(block_Vario_Bogen_auf, lib_doc, doc)
|
||||
ab_attrib = block_methoden.import_block(block_Vario_Bogen_ab, lib_doc, doc)
|
||||
Vario_Bogen_auf_Delta_SP_0 = list(
|
||||
float(att) for att in re.split(r"[;,]", auf_attrib["DELTA_SP_0"])
|
||||
)
|
||||
Vario_Bogen_auf_Delta_SP_1 = list(
|
||||
float(att) for att in re.split(r"[;,]", auf_attrib["DELTA_SP_1"])
|
||||
)
|
||||
Vario_Bogen_ab_Delta_SP_0 = list(
|
||||
float(att) for att in re.split(r"[;,]", ab_attrib["DELTA_SP_0"])
|
||||
)
|
||||
Vario_Bogen_ab_Delta_SP_1 = list(
|
||||
float(att) for att in re.split(r"[;,]", ab_attrib["DELTA_SP_1"])
|
||||
)
|
||||
for i, wert in enumerate(Vario_Bogen_auf_Delta_SP_0):
|
||||
if wert < 0:
|
||||
Vario_Bogen_auf_Delta_SP_0[i] = abs(wert)
|
||||
for i, wert in enumerate(Vario_Bogen_auf_Delta_SP_1):
|
||||
if wert< 0:
|
||||
Vario_Bogen_auf_Delta_SP_1[i] = abs(wert)
|
||||
if wert < 0:
|
||||
Vario_Bogen_auf_Delta_SP_1[i] = abs(wert)
|
||||
for i, wert in enumerate(Vario_Bogen_ab_Delta_SP_0):
|
||||
if wert< 0:
|
||||
if wert < 0:
|
||||
Vario_Bogen_ab_Delta_SP_0[i] = abs(wert)
|
||||
for i, wert in enumerate(Vario_Bogen_ab_Delta_SP_1):
|
||||
if wert< 0:
|
||||
if wert < 0:
|
||||
Vario_Bogen_ab_Delta_SP_1[i] = abs(wert)
|
||||
block_methoden.turn_two_blocks_left(doc, block_Vario_Bogen_auf, block_Vario_Bogen_ab, block_Vario_Bogen_ab_links, block_Vario_Bogen_auf_links)
|
||||
block_methoden.turn_two_blocks_left(
|
||||
doc,
|
||||
block_Vario_Bogen_auf,
|
||||
block_Vario_Bogen_ab,
|
||||
block_Vario_Bogen_ab_links,
|
||||
block_Vario_Bogen_auf_links,
|
||||
)
|
||||
if hat_motor_0 == True:
|
||||
if tefkurve_0 == "links":
|
||||
if motor_gerade == False:
|
||||
block.add_blockref(block_Vario_Bogen_ab_links,(start[0]-x,start[1]-Vario_Bogen_ab_Delta_SP_0[0]-y,start[2]- Vario_Bogen_ab_Delta_SP_0[2]-hoehe_gefaelle),dxfattribs={"rotation": 270})
|
||||
start = [start[0],start[1]-Vario_Bogen_ab_Delta_SP_0[0]- Vario_Bogen_ab_Delta_SP_1[0],start[2]-Vario_Bogen_ab_Delta_SP_0[2]- Vario_Bogen_ab_Delta_SP_1[2]]
|
||||
block.add_blockref(blockname_motor_links, (start[0]-x,start[1] - 250* math.cos(math.radians(3))-y,start[2] - 250* math.sin(math.radians(3))-hoehe_gefaelle),dxfattribs={"rotation": 270})
|
||||
start[1]= start[1] - 500* math.cos(math.radians(3))
|
||||
start[2] = start[2] - 500* math.sin(math.radians(3))
|
||||
if tefkurve_0 == "links":
|
||||
if motor_gerade == False:
|
||||
block.add_blockref(
|
||||
block_Vario_Bogen_ab_links,
|
||||
(
|
||||
start[0] - x,
|
||||
start[1] - Vario_Bogen_ab_Delta_SP_0[0] - y,
|
||||
start[2] - Vario_Bogen_ab_Delta_SP_0[2] - hoehe_gefaelle,
|
||||
),
|
||||
dxfattribs={"rotation": 270},
|
||||
)
|
||||
start = [
|
||||
start[0],
|
||||
start[1]
|
||||
- Vario_Bogen_ab_Delta_SP_0[0]
|
||||
- Vario_Bogen_ab_Delta_SP_1[0],
|
||||
start[2]
|
||||
- Vario_Bogen_ab_Delta_SP_0[2]
|
||||
- Vario_Bogen_ab_Delta_SP_1[2],
|
||||
]
|
||||
block.add_blockref(
|
||||
blockname_motor_links,
|
||||
(
|
||||
start[0] - x,
|
||||
start[1] - 250 * math.cos(math.radians(3)) - y,
|
||||
start[2] - 250 * math.sin(math.radians(3)) - hoehe_gefaelle,
|
||||
),
|
||||
dxfattribs={"rotation": 270},
|
||||
)
|
||||
start[1] = start[1] - 500 * math.cos(math.radians(3))
|
||||
start[2] = start[2] - 500 * math.sin(math.radians(3))
|
||||
else:
|
||||
block.add_blockref("Vario_Motorstation_500mm_links", (start[0]-x,start[1] -250 -y,start[2] -hoehe_gefaelle),dxfattribs={"rotation": 270})
|
||||
start[1]= start[1] - 500
|
||||
block.add_blockref(
|
||||
"Vario_Motorstation_500mm_links",
|
||||
(start[0] - x, start[1] - 250 - y, start[2] - hoehe_gefaelle),
|
||||
dxfattribs={"rotation": 270},
|
||||
)
|
||||
start[1] = start[1] - 500
|
||||
|
||||
else:
|
||||
if motor_gerade == False:
|
||||
block.add_blockref(block_Vario_Bogen_ab,(start[0]-x,start[1]-Vario_Bogen_ab_Delta_SP_0[0]-y,start[2]- Vario_Bogen_ab_Delta_SP_0[2]-hoehe_gefaelle),dxfattribs={"rotation": 270})
|
||||
start = [start[0],start[1]-Vario_Bogen_ab_Delta_SP_0[0]- Vario_Bogen_ab_Delta_SP_1[0],start[2]-Vario_Bogen_ab_Delta_SP_0[2]- Vario_Bogen_ab_Delta_SP_1[2]]
|
||||
block.add_blockref(block_Vario_Motorstation_500mm, (start[0]-x,start[1] - 250* math.cos(math.radians(3))-y,start[2] - 250* math.sin(math.radians(3))-hoehe_gefaelle),dxfattribs={"rotation": 270})
|
||||
start[1]= start[1] - 500* math.cos(math.radians(3))
|
||||
start[2] = start[2] - 500* math.sin(math.radians(3))
|
||||
if motor_gerade == False:
|
||||
block.add_blockref(
|
||||
block_Vario_Bogen_ab,
|
||||
(
|
||||
start[0] - x,
|
||||
start[1] - Vario_Bogen_ab_Delta_SP_0[0] - y,
|
||||
start[2] - Vario_Bogen_ab_Delta_SP_0[2] - hoehe_gefaelle,
|
||||
),
|
||||
dxfattribs={"rotation": 270},
|
||||
)
|
||||
start = [
|
||||
start[0],
|
||||
start[1]
|
||||
- Vario_Bogen_ab_Delta_SP_0[0]
|
||||
- Vario_Bogen_ab_Delta_SP_1[0],
|
||||
start[2]
|
||||
- Vario_Bogen_ab_Delta_SP_0[2]
|
||||
- Vario_Bogen_ab_Delta_SP_1[2],
|
||||
]
|
||||
block.add_blockref(
|
||||
block_Vario_Motorstation_500mm,
|
||||
(
|
||||
start[0] - x,
|
||||
start[1] - 250 * math.cos(math.radians(3)) - y,
|
||||
start[2] - 250 * math.sin(math.radians(3)) - hoehe_gefaelle,
|
||||
),
|
||||
dxfattribs={"rotation": 270},
|
||||
)
|
||||
start[1] = start[1] - 500 * math.cos(math.radians(3))
|
||||
start[2] = start[2] - 500 * math.sin(math.radians(3))
|
||||
else:
|
||||
block.add_blockref("Vario_Motorstation_500mm", (start[0]-x,start[1]- 250 -y,start[2] -hoehe_gefaelle),dxfattribs={"rotation": 270})
|
||||
start[1]= start[1] - 500
|
||||
block.add_blockref(
|
||||
"Vario_Motorstation_500mm",
|
||||
(start[0] - x, start[1] - 250 - y, start[2] - hoehe_gefaelle),
|
||||
dxfattribs={"rotation": 270},
|
||||
)
|
||||
start[1] = start[1] - 500
|
||||
|
||||
if hat_umlenk_0 == True:
|
||||
if tefkurve_0 == "links":
|
||||
if umlenk_gerade == False:
|
||||
block.add_blockref(block_Vario_Bogen_auf,(ende[0]-x,ende[1]+Vario_Bogen_auf_Delta_SP_0[0]-y,ende[2] + Vario_Bogen_auf_Delta_SP_0[2]-hoehe_gefaelle),dxfattribs={"rotation": 90})
|
||||
ende = [ende[0],ende[1]+ Vario_Bogen_auf_Delta_SP_0[0]+ Vario_Bogen_auf_Delta_SP_1[0],ende[2]+Vario_Bogen_auf_Delta_SP_0[2]+ Vario_Bogen_auf_Delta_SP_1[2]]
|
||||
block.add_blockref(blockname_umlenk_links, (ende[0]-x,ende[1] + 250* math.cos(math.radians(3))-y,ende[2] + 250* math.sin(math.radians(3))-hoehe_gefaelle),dxfattribs={"rotation": 270})
|
||||
block.add_blockref(
|
||||
block_Vario_Bogen_auf,
|
||||
(
|
||||
ende[0] - x,
|
||||
ende[1] + Vario_Bogen_auf_Delta_SP_0[0] - y,
|
||||
ende[2] + Vario_Bogen_auf_Delta_SP_0[2] - hoehe_gefaelle,
|
||||
),
|
||||
dxfattribs={"rotation": 90},
|
||||
)
|
||||
ende = [
|
||||
ende[0],
|
||||
ende[1]
|
||||
+ Vario_Bogen_auf_Delta_SP_0[0]
|
||||
+ Vario_Bogen_auf_Delta_SP_1[0],
|
||||
ende[2]
|
||||
+ Vario_Bogen_auf_Delta_SP_0[2]
|
||||
+ Vario_Bogen_auf_Delta_SP_1[2],
|
||||
]
|
||||
block.add_blockref(
|
||||
blockname_umlenk_links,
|
||||
(
|
||||
ende[0] - x,
|
||||
ende[1] + 250 * math.cos(math.radians(3)) - y,
|
||||
ende[2] + 250 * math.sin(math.radians(3)) - hoehe_gefaelle,
|
||||
),
|
||||
dxfattribs={"rotation": 270},
|
||||
)
|
||||
|
||||
ende [1]= ende[1] + 500* math.cos(math.radians(3))
|
||||
ende[2] = ende[2] + 500* math.sin(math.radians(3))
|
||||
ende[1] = ende[1] + 500 * math.cos(math.radians(3))
|
||||
ende[2] = ende[2] + 500 * math.sin(math.radians(3))
|
||||
else:
|
||||
block.add_blockref("Vario_Umlenkstation_500mm_links", (ende[0]-x,ende[1] + 250-y,ende[2] -hoehe_gefaelle),dxfattribs={"rotation": 270})
|
||||
ende [1]= ende[1] + 500
|
||||
block.add_blockref(
|
||||
"Vario_Umlenkstation_500mm_links",
|
||||
(ende[0] - x, ende[1] + 250 - y, ende[2] - hoehe_gefaelle),
|
||||
dxfattribs={"rotation": 270},
|
||||
)
|
||||
ende[1] = ende[1] + 500
|
||||
|
||||
else:
|
||||
if umlenk_gerade == False:
|
||||
block.add_blockref(block_Vario_Bogen_auf_links,(ende[0]-x,ende[1]+Vario_Bogen_auf_Delta_SP_0[0]-y,ende[2] + Vario_Bogen_auf_Delta_SP_0[2]-hoehe_gefaelle),dxfattribs={"rotation": 90})
|
||||
ende = [ende[0],ende[1]+ Vario_Bogen_auf_Delta_SP_0[0]+ Vario_Bogen_auf_Delta_SP_1[0],ende[2]+Vario_Bogen_auf_Delta_SP_0[2]+ Vario_Bogen_auf_Delta_SP_1[2]]
|
||||
block.add_blockref(block_Vario_Umlenkstation_500mm, (ende[0]-x,ende[1] + 250* math.cos(math.radians(3))-y,ende[2] + 250* math.sin(math.radians(3))-hoehe_gefaelle),dxfattribs={"rotation": 270})
|
||||
ende [1]= ende[1] + 500* math.cos(math.radians(3))
|
||||
ende[2] = ende[2] + 500* math.sin(math.radians(3))
|
||||
block.add_blockref(
|
||||
block_Vario_Bogen_auf_links,
|
||||
(
|
||||
ende[0] - x,
|
||||
ende[1] + Vario_Bogen_auf_Delta_SP_0[0] - y,
|
||||
ende[2] + Vario_Bogen_auf_Delta_SP_0[2] - hoehe_gefaelle,
|
||||
),
|
||||
dxfattribs={"rotation": 90},
|
||||
)
|
||||
ende = [
|
||||
ende[0],
|
||||
ende[1]
|
||||
+ Vario_Bogen_auf_Delta_SP_0[0]
|
||||
+ Vario_Bogen_auf_Delta_SP_1[0],
|
||||
ende[2]
|
||||
+ Vario_Bogen_auf_Delta_SP_0[2]
|
||||
+ Vario_Bogen_auf_Delta_SP_1[2],
|
||||
]
|
||||
block.add_blockref(
|
||||
block_Vario_Umlenkstation_500mm,
|
||||
(
|
||||
ende[0] - x,
|
||||
ende[1] + 250 * math.cos(math.radians(3)) - y,
|
||||
ende[2] + 250 * math.sin(math.radians(3)) - hoehe_gefaelle,
|
||||
),
|
||||
dxfattribs={"rotation": 270},
|
||||
)
|
||||
ende[1] = ende[1] + 500 * math.cos(math.radians(3))
|
||||
ende[2] = ende[2] + 500 * math.sin(math.radians(3))
|
||||
else:
|
||||
block.add_blockref("Vario_Umlenkstation_500mm", (ende[0]-x,ende[1] + 250-y,ende[2] -hoehe_gefaelle),dxfattribs={"rotation": 270})
|
||||
ende [1]= ende[1] + 500
|
||||
return start,ende
|
||||
def hat_motor_umlenk_station (gefaelle_objekt, gefaellestrecke_nachbarn):
|
||||
block.add_blockref(
|
||||
"Vario_Umlenkstation_500mm",
|
||||
(ende[0] - x, ende[1] + 250 - y, ende[2] - hoehe_gefaelle),
|
||||
dxfattribs={"rotation": 270},
|
||||
)
|
||||
ende[1] = ende[1] + 500
|
||||
return start, ende
|
||||
|
||||
def hat_motor_umlenk_station(gefaelle_objekt, gefaellestrecke_nachbarn):
|
||||
hat_motor_0 = None
|
||||
hat_motor_1 = None
|
||||
hat_umlenk_0 = None
|
||||
@@ -223,28 +391,38 @@ class Gefaellestrecke(BaseModel):
|
||||
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"))
|
||||
vario_hoehe_1 = float(gefaellestrecke_nachbarn.get("vario_hoehe_1"))
|
||||
kurvenrichtung = gefaellestrecke_nachbarn.get("Kurvenrichtung")
|
||||
tefkurve_0 = gefaellestrecke_nachbarn.get("Tefkurve")
|
||||
tefkurve_0 = gefaellestrecke_nachbarn.get("Tefkurve")
|
||||
x_angetrieben = gefaellestrecke_nachbarn.get("X_angetrieben")
|
||||
y_angetrieben = gefaellestrecke_nachbarn.get("Y_angetrieben")
|
||||
x_angetrieben_1 = gefaellestrecke_nachbarn.get("X_angetrieben_1")
|
||||
y_angetrieben_1 = gefaellestrecke_nachbarn.get("Y_angetrieben_1")
|
||||
if (kurvenrichtung == "links" and tefkurve_0 == "außen") or kurvenrichtung == "rechts" and tefkurve_0 == "innen":
|
||||
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_gefaelle > lower_hoehe_gefaelle:
|
||||
if vario_hoehe_0 == upper_hoehe_gefaelle or vario_hoehe_1 == upper_hoehe_gefaelle:
|
||||
|
||||
if upper_hoehe_gefaelle > lower_hoehe_gefaelle:
|
||||
if (
|
||||
vario_hoehe_0 == upper_hoehe_gefaelle
|
||||
or vario_hoehe_1 == upper_hoehe_gefaelle
|
||||
):
|
||||
hat_motor_0 = True
|
||||
else:
|
||||
hat_umlenk_0 = True
|
||||
elif upper_hoehe_gefaelle < lower_hoehe_gefaelle:
|
||||
if vario_hoehe_0 == lower_hoehe_gefaelle or vario_hoehe_1 == lower_hoehe_gefaelle:
|
||||
elif upper_hoehe_gefaelle < lower_hoehe_gefaelle:
|
||||
if (
|
||||
vario_hoehe_0 == lower_hoehe_gefaelle
|
||||
or vario_hoehe_1 == lower_hoehe_gefaelle
|
||||
):
|
||||
hat_motor_0 = True
|
||||
else:
|
||||
hat_umlenk_0 = True
|
||||
@@ -252,31 +430,45 @@ class Gefaellestrecke(BaseModel):
|
||||
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<x_angetrieben)):
|
||||
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 < x_angetrieben)
|
||||
):
|
||||
hat_umlenk_0 = True
|
||||
umlenk_gerade = True
|
||||
else:
|
||||
hat_motor_0 = True
|
||||
motor_gerade = True
|
||||
|
||||
|
||||
if "Kurvenrichtung_1" in gefaellestrecke_nachbarn:
|
||||
vario_hoehe_0_1 = float(gefaellestrecke_nachbarn.get("vario_hoehe_0_1"))
|
||||
vario_hoehe_1_1 = float(gefaellestrecke_nachbarn.get("vario_hoehe_1_1"))
|
||||
vario_hoehe_1_1 = float(gefaellestrecke_nachbarn.get("vario_hoehe_1_1"))
|
||||
kurvenrichtung_1 = gefaellestrecke_nachbarn.get("Kurvenrichtung_1")
|
||||
tefkurve_1 = gefaellestrecke_nachbarn.get("Tefkurve_1")
|
||||
if (kurvenrichtung_1 == "links" and tefkurve_1 == "außen") or kurvenrichtung_1 == "rechts" and tefkurve_1 == "innen":
|
||||
tefkurve_1 = gefaellestrecke_nachbarn.get("Tefkurve_1")
|
||||
if (
|
||||
(kurvenrichtung_1 == "links" and tefkurve_1 == "außen")
|
||||
or kurvenrichtung_1 == "rechts"
|
||||
and tefkurve_1 == "innen"
|
||||
):
|
||||
tefkurve_1 = "rechts"
|
||||
else:
|
||||
tefkurve_1 = "links"
|
||||
if upper_hoehe_gefaelle > lower_hoehe_gefaelle:
|
||||
if vario_hoehe_0_1 == upper_hoehe_gefaelle or vario_hoehe_1_1 == upper_hoehe_gefaelle:
|
||||
tefkurve_1 = "links"
|
||||
if upper_hoehe_gefaelle > lower_hoehe_gefaelle:
|
||||
if (
|
||||
vario_hoehe_0_1 == upper_hoehe_gefaelle
|
||||
or vario_hoehe_1_1 == upper_hoehe_gefaelle
|
||||
):
|
||||
hat_motor_1 = True
|
||||
else:
|
||||
hat_umlenk_1 = True
|
||||
elif upper_hoehe_gefaelle < lower_hoehe_gefaelle:
|
||||
if vario_hoehe_0_1 == lower_hoehe_gefaelle or vario_hoehe_1_1 == lower_hoehe_gefaelle:
|
||||
elif upper_hoehe_gefaelle < lower_hoehe_gefaelle:
|
||||
if (
|
||||
vario_hoehe_0_1 == lower_hoehe_gefaelle
|
||||
or vario_hoehe_1_1 == lower_hoehe_gefaelle
|
||||
):
|
||||
hat_motor_1 = True
|
||||
else:
|
||||
hat_umlenk_1 = True
|
||||
@@ -284,15 +476,21 @@ class Gefaellestrecke(BaseModel):
|
||||
rotation_zwischen = rotation
|
||||
if rotation_zwischen == 0.0:
|
||||
rotation_zwischen = -360.0
|
||||
if (((-360.0<= rotation_zwischen< -270.0)and y > y_angetrieben_1) or ((-90.0< rotation< 0.0)and y > y_angetrieben_1) or
|
||||
((-270.0< rotation_zwischen< -90.0)and y < y_angetrieben_1) or
|
||||
(rotation == -90.0 and x < x_angetrieben_1) or ((rotation == -270.0)and x<x_angetrieben_1)):
|
||||
if (
|
||||
((-360.0 <= rotation_zwischen < -270.0) and y > y_angetrieben_1)
|
||||
or ((-90.0 < rotation < 0.0) and y > y_angetrieben_1)
|
||||
or (
|
||||
(-270.0 < rotation_zwischen < -90.0) and y < y_angetrieben_1
|
||||
)
|
||||
or (rotation == -90.0 and x < x_angetrieben_1)
|
||||
or ((rotation == -270.0) and x < x_angetrieben_1)
|
||||
):
|
||||
hat_umlenk_1 = True
|
||||
umlenk_gerade = True
|
||||
else:
|
||||
hat_motor_1 = True
|
||||
motor_gerade = True
|
||||
hat_zusatz ={}
|
||||
hat_zusatz = {}
|
||||
hat_zusatz["hat_motor_0"] = hat_motor_0
|
||||
hat_zusatz["hat_motor_1"] = hat_motor_1
|
||||
hat_zusatz["hat_umlenk_0"] = hat_umlenk_0
|
||||
@@ -301,4 +499,4 @@ class Gefaellestrecke(BaseModel):
|
||||
hat_zusatz["tefkurve_1"] = tefkurve_1
|
||||
hat_zusatz["umlenk_gerade"] = umlenk_gerade
|
||||
hat_zusatz["motor_gerade"] = motor_gerade
|
||||
return hat_zusatz
|
||||
return hat_zusatz
|
||||
|
||||
+1134
-1540
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,284 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Unit-Tests für VarioFoerderer (Refactored)
|
||||
|
||||
Diese Tests können direkt in der Library-Methode verwendet werden
|
||||
oder als separate Test-Datei ausgeführt werden.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
import math
|
||||
from unittest.mock import Mock, MagicMock
|
||||
from VarioFoerderer import (
|
||||
VarioFoerderer,
|
||||
Foerderrichtung,
|
||||
MotorUmlenkConfig,
|
||||
BogenDeltas,
|
||||
OffsetResult,
|
||||
_parse_delta_attribute,
|
||||
_calculate_offset_with_rotation,
|
||||
_is_es_as_element,
|
||||
horizontale_ausrichtung,
|
||||
)
|
||||
|
||||
|
||||
class TestMotorUmlenkConfig(unittest.TestCase):
|
||||
"""Tests für MotorUmlenkConfig Dataclass"""
|
||||
|
||||
def test_motor_offset_berechnung(self):
|
||||
"""Test: Motor-Offset-Berechnung"""
|
||||
config = MotorUmlenkConfig(
|
||||
winkel_motor=45.0,
|
||||
winkel_umlenk=30.0,
|
||||
umlenk_laenge=(100.0, 50.0),
|
||||
motor_laenge=(80.0, 40.0),
|
||||
vario_abstand=25.0
|
||||
)
|
||||
|
||||
# Motor-Offsets
|
||||
expected_motor_x = 100.0 * math.cos(math.radians(45.0))
|
||||
expected_motor_z = 100.0 * math.sin(math.radians(45.0))
|
||||
|
||||
self.assertAlmostEqual(config.motor_offset_x, expected_motor_x, places=5)
|
||||
self.assertAlmostEqual(config.motor_offset_z, expected_motor_z, places=5)
|
||||
|
||||
def test_umlenk_offset_berechnung(self):
|
||||
"""Test: Umlenk-Offset-Berechnung"""
|
||||
config = MotorUmlenkConfig(
|
||||
winkel_motor=45.0,
|
||||
winkel_umlenk=30.0,
|
||||
umlenk_laenge=(100.0, 50.0),
|
||||
motor_laenge=(80.0, 40.0),
|
||||
vario_abstand=25.0
|
||||
)
|
||||
|
||||
# Umlenk-Offsets
|
||||
expected_umlenk_x = 80.0 * math.cos(math.radians(30.0))
|
||||
expected_umlenk_z = 80.0 * math.sin(math.radians(30.0))
|
||||
|
||||
self.assertAlmostEqual(config.umlenk_offset_x, expected_umlenk_x, places=5)
|
||||
self.assertAlmostEqual(config.umlenk_offset_z, expected_umlenk_z, places=5)
|
||||
|
||||
|
||||
class TestBogenDeltas(unittest.TestCase):
|
||||
"""Tests für BogenDeltas Dataclass"""
|
||||
|
||||
def test_normalize_negative_values(self):
|
||||
"""Test: Normalisierung negativer Werte"""
|
||||
deltas = BogenDeltas(
|
||||
SP_0=[-10.0, -20.0, 5.0],
|
||||
SP_1=[15.0, -25.0, 10.0],
|
||||
VP_0=[-5.0, 8.0, -3.0],
|
||||
VP_1=[12.0, -15.0, 7.0]
|
||||
)
|
||||
|
||||
deltas.normalize_negative_values()
|
||||
|
||||
# X und Y (Index 0 und 1) sollen positiv sein, Z (Index 2) unverändert
|
||||
self.assertEqual(deltas.SP_0, [10.0, 20.0, 5.0])
|
||||
self.assertEqual(deltas.SP_1, [15.0, 25.0, 10.0])
|
||||
self.assertEqual(deltas.VP_0, [5.0, 8.0, -3.0])
|
||||
self.assertEqual(deltas.VP_1, [12.0, 15.0, 7.0])
|
||||
|
||||
|
||||
class TestVarioFoerderer(unittest.TestCase):
|
||||
"""Tests für VarioFoerderer Modell"""
|
||||
|
||||
def test_from_merkmale(self):
|
||||
"""Test: VarioFoerderer aus Merkmale-Dict erstellen"""
|
||||
merkmale = {
|
||||
"Höhe Anfang": "1.5",
|
||||
"Höhe Ende": "2.0",
|
||||
"Länge in Meter": "5.0",
|
||||
"Winkel": "6",
|
||||
"Motorstation_hinten": True,
|
||||
"Spannstation_vorn": False,
|
||||
"Drehung": "-90",
|
||||
"Förderrichtung": "Auf",
|
||||
"Anzahl der Scanner": "2",
|
||||
"Anzahl der Separatoren": "3",
|
||||
}
|
||||
|
||||
foerderer = VarioFoerderer.from_merkmale("TEST-001", 100.0, 200.0, merkmale)
|
||||
|
||||
self.assertEqual(foerderer.teileid, "TEST-001")
|
||||
self.assertEqual(foerderer.x, 100.0)
|
||||
self.assertEqual(foerderer.y, 200.0)
|
||||
self.assertEqual(foerderer.h0, 1500.0) # 1.5 * 1000
|
||||
self.assertEqual(foerderer.h1, 2000.0) # 2.0 * 1000
|
||||
self.assertEqual(foerderer.laenge, 5000.0) # 5.0 * 1000
|
||||
self.assertEqual(foerderer.winkel, 6.0)
|
||||
self.assertTrue(foerderer.hat_motor)
|
||||
self.assertFalse(foerderer.hat_umlenk)
|
||||
self.assertEqual(foerderer.drehung, -90.0)
|
||||
self.assertEqual(foerderer.foerderer_richtung, "Auf")
|
||||
self.assertEqual(foerderer.anzahl_scanner, 2)
|
||||
self.assertEqual(foerderer.anzahl_separatoren, 3)
|
||||
|
||||
def test_hight_zwischen(self):
|
||||
"""Test: Berechnung der mittleren Höhe"""
|
||||
merkmale = {
|
||||
"Höhe Anfang": "1.0",
|
||||
"Höhe Ende": "3.0",
|
||||
"Länge in Meter": "1.0",
|
||||
"Winkel": "3",
|
||||
"Motorstation_hinten": False,
|
||||
"Spannstation_vorn": False,
|
||||
"Drehung": "0",
|
||||
"Förderrichtung": "Auf",
|
||||
"Anzahl der Scanner": "0",
|
||||
"Anzahl der Separatoren": "0",
|
||||
}
|
||||
|
||||
foerderer = VarioFoerderer.from_merkmale("TEST-002", 0, 0, merkmale)
|
||||
expected_height = (1000.0 + 3000.0) / 2 # (h0 + h1) / 2
|
||||
|
||||
self.assertEqual(foerderer.hight_zwischen, expected_height)
|
||||
|
||||
|
||||
class TestHilfsfunktionen(unittest.TestCase):
|
||||
"""Tests für generische Hilfsfunktionen"""
|
||||
|
||||
def test_parse_delta_attribute(self):
|
||||
"""Test: Delta-Attribut parsen"""
|
||||
attrib_dict = {
|
||||
"DELTA_SP_0": "10.5;20.3;-5.7",
|
||||
"DELTA_VP_1": "15.2,25.8,-8.1"
|
||||
}
|
||||
|
||||
result_sp = _parse_delta_attribute(attrib_dict, "DELTA_SP_0")
|
||||
result_vp = _parse_delta_attribute(attrib_dict, "DELTA_VP_1")
|
||||
|
||||
self.assertEqual(result_sp, [10.5, 20.3, -5.7])
|
||||
self.assertEqual(result_vp, [15.2, 25.8, -8.1])
|
||||
|
||||
def test_calculate_offset_with_rotation(self):
|
||||
"""Test: Offset-Berechnung mit Rotation"""
|
||||
SP = [10.0, 5.0, 8.0]
|
||||
VP = [2.0, 5.0, 3.0]
|
||||
winkel = 45.0
|
||||
|
||||
result = _calculate_offset_with_rotation(SP, VP, winkel)
|
||||
|
||||
# Erwartete Werte berechnen
|
||||
rad = math.radians(45.0)
|
||||
expected_x = (SP[0] - VP[0]) * math.cos(rad) + (SP[2] - VP[2]) * math.sin(rad)
|
||||
expected_y = VP[1]
|
||||
expected_z = -(SP[0] - VP[0]) * math.sin(rad) + (SP[2] - VP[2]) * math.cos(rad)
|
||||
|
||||
self.assertAlmostEqual(result[0], expected_x, places=5)
|
||||
self.assertAlmostEqual(result[1], expected_y, places=5)
|
||||
self.assertAlmostEqual(result[2], expected_z, places=5)
|
||||
|
||||
def test_is_es_as_element_true(self):
|
||||
"""Test: ES/AS-Element erkennen"""
|
||||
entity = Mock()
|
||||
entity.dxftype.return_value = "INSERT"
|
||||
entity.dxf.name = "200000146_ES-Element_90_rechts_modified"
|
||||
|
||||
self.assertTrue(_is_es_as_element(entity))
|
||||
|
||||
def test_is_es_as_element_false(self):
|
||||
"""Test: Kein ES/AS-Element"""
|
||||
entity = Mock()
|
||||
entity.dxftype.return_value = "INSERT"
|
||||
entity.dxf.name = "Vario_Bogen_auf_12°"
|
||||
|
||||
self.assertFalse(_is_es_as_element(entity))
|
||||
|
||||
def test_is_es_as_element_not_insert(self):
|
||||
"""Test: Kein INSERT-Entity"""
|
||||
entity = Mock()
|
||||
entity.dxftype.return_value = "LINE"
|
||||
|
||||
self.assertFalse(_is_es_as_element(entity))
|
||||
|
||||
|
||||
class TestHorizontaleAusrichtung(unittest.TestCase):
|
||||
"""Tests für horizontale_ausrichtung Funktion"""
|
||||
|
||||
def test_horizontal_rotation_0(self):
|
||||
"""Test: Horizontale Ausrichtung bei Rotation 0°"""
|
||||
merkmale = {
|
||||
"Höhe Anfang": "1.0",
|
||||
"Höhe Ende": "1.0",
|
||||
"Länge in Meter": "1.0",
|
||||
"Winkel": "3",
|
||||
"Motorstation_hinten": False,
|
||||
"Spannstation_vorn": False,
|
||||
"Drehung": "0",
|
||||
"Förderrichtung": "Horizontal",
|
||||
"Anzahl der Scanner": "0",
|
||||
"Anzahl der Separatoren": "0",
|
||||
}
|
||||
|
||||
foerderer = VarioFoerderer.from_merkmale("TEST", 100.0, 200.0, merkmale)
|
||||
|
||||
# Förderer ist über Kreisel (y > y_kreisel)
|
||||
result = horizontale_ausrichtung(foerderer, 100.0, 100.0)
|
||||
self.assertEqual(result, "unten_drehung_0_or_-90")
|
||||
|
||||
# Förderer ist unter Kreisel (y < y_kreisel)
|
||||
result = horizontale_ausrichtung(foerderer, 100.0, 300.0)
|
||||
self.assertEqual(result, "oben_drehung_0_or_-90")
|
||||
|
||||
def test_nicht_horizontal(self):
|
||||
"""Test: Nicht-horizontale Förderer geben 'None' zurück"""
|
||||
merkmale = {
|
||||
"Höhe Anfang": "1.0",
|
||||
"Höhe Ende": "2.0",
|
||||
"Länge in Meter": "1.0",
|
||||
"Winkel": "6",
|
||||
"Motorstation_hinten": False,
|
||||
"Spannstation_vorn": False,
|
||||
"Drehung": "0",
|
||||
"Förderrichtung": "Auf",
|
||||
"Anzahl der Scanner": "0",
|
||||
"Anzahl der Separatoren": "0",
|
||||
}
|
||||
|
||||
foerderer = VarioFoerderer.from_merkmale("TEST", 100.0, 200.0, merkmale)
|
||||
result = horizontale_ausrichtung(foerderer, 100.0, 100.0)
|
||||
|
||||
self.assertEqual(result, "None")
|
||||
|
||||
|
||||
class TestFoerderrichtungEnum(unittest.TestCase):
|
||||
"""Tests für Foerderrichtung Enum"""
|
||||
|
||||
def test_enum_werte(self):
|
||||
"""Test: Enum-Werte sind korrekt"""
|
||||
self.assertEqual(Foerderrichtung.AUF.value, "Auf")
|
||||
self.assertEqual(Foerderrichtung.AB.value, "Ab")
|
||||
self.assertEqual(Foerderrichtung.HORIZONTAL.value, "Horizontal")
|
||||
|
||||
def test_enum_vergleich(self):
|
||||
"""Test: Enum-Vergleich funktioniert"""
|
||||
richtung = "Auf"
|
||||
self.assertEqual(richtung, Foerderrichtung.AUF.value)
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# Test-Runner
|
||||
# ============================================================================
|
||||
|
||||
def run_tests():
|
||||
"""Führt alle Unit-Tests aus"""
|
||||
loader = unittest.TestLoader()
|
||||
suite = loader.loadTestsFromModule(__import__(__name__))
|
||||
runner = unittest.TextTestRunner(verbosity=2)
|
||||
result = runner.run(suite)
|
||||
|
||||
print("\n" + "="*70)
|
||||
print(f"Tests durchgeführt: {result.testsRun}")
|
||||
print(f"Erfolgreich: {result.testsRun - len(result.failures) - len(result.errors)}")
|
||||
print(f"Fehlgeschlagen: {len(result.failures)}")
|
||||
print(f"Errors: {len(result.errors)}")
|
||||
print("="*70)
|
||||
|
||||
return result.wasSuccessful()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
success = run_tests()
|
||||
exit(0 if success else 1)
|
||||
Reference in New Issue
Block a user