Fehlermeldungen, Hinweise, etc... auf englisch übersetzt

This commit is contained in:
2025-06-04 14:17:29 +02:00
parent 3e7f2c0a38
commit c0f8025a92
2 changed files with 24 additions and 27 deletions
+19 -22
View File
@@ -12,9 +12,6 @@ from collections import defaultdict
import configparser import configparser
@dataclass @dataclass
class Point: class Point:
x: float x: float
@@ -60,7 +57,7 @@ def add_polyline(msp, points:Polyline, dxf_attribs):
def new_dxf(plines, out_path): def new_dxf(plines, out_path):
""" creates a new dxf file with a polyline inside which is created by the given json file """ creates a new dxf file with a polyline inside which is created by the given json file
""" """
print("creating dxf ..") print("creating new .dxf ..")
doc = ezdxf.new('R2018', setup=True) doc = ezdxf.new('R2018', setup=True)
create_cables(plines, doc) create_cables(plines, doc)
@@ -72,7 +69,7 @@ def new_dxf(plines, out_path):
def modify_original_dxf(plines, originaldxf): def modify_original_dxf(plines, originaldxf):
""" adds new layer to original .dxf-file that contains cables """ adds new layer to original .dxf-file that contains cables
""" """
print("adding cables to original .dxf ..") print("adding cables into original .dxf ..")
doc = ezdxf.readfile(originaldxf) doc = ezdxf.readfile(originaldxf)
create_cables(plines, doc) create_cables(plines, doc)
@@ -84,7 +81,7 @@ def modify_original_dxf(plines, originaldxf):
def copy_layers_into_new(originaldxf, outpath, plines): def copy_layers_into_new(originaldxf, outpath, plines):
""" creates a new dxf file with a racks, sensors, subdists from original file including cable paths """ creates a new dxf file with a racks, sensors, subdists from original file including cable paths
""" """
print("copying layers from original .dxf into new .dxf ..") print("copying layers (Racks, Subdistributors, ...) from original .dxf into new .dxf ..")
quelle = ezdxf.readfile(originaldxf) quelle = ezdxf.readfile(originaldxf)
ziel = ezdxf.new('R2018', setup=True) ziel = ezdxf.new('R2018', setup=True)
@@ -123,7 +120,7 @@ def model_from_json(json_file):
def export_excel(json_file, out_path): def export_excel(json_file, out_path):
# Hier für Excel Export # Hier für Excel Export
print("creating excel file ..") print("creating excel file with cable information ..")
plines = model_from_json(json_file) plines = model_from_json(json_file)
write_excel_from_json(plines, out_path) write_excel_from_json(plines, out_path)
print("done") print("done")
@@ -135,8 +132,8 @@ def write_excel_from_json(plines:Polylines, outpath:str):
#Worksheet 1 - Kabellängen #Worksheet 1 - Kabellängen
ws1 = wb.active ws1 = wb.active
ws1.title = "Kabellängen" ws1.title = "Length by ID"
ws1.append(["Kabel-ID", "Länge aus Json (m)", "Gerundete Länge (m)"]) ws1.append(["Cable-ID", "True Length (m)", "Rounded Length (m)"])
for pl in plines.kabel: for pl in plines.kabel:
length = pl.length /1000 # Umrechnung von mm in m length = pl.length /1000 # Umrechnung von mm in m
@@ -145,24 +142,24 @@ def write_excel_from_json(plines:Polylines, outpath:str):
ws1.append([pl.id, length, int(rounded_len)]) ws1.append([pl.id, length, int(rounded_len)])
# Worksheet 2 - Zusammengefasste Längen # Worksheet 2 - Zusammengefasste Längen
ws2 = wb.create_sheet("Längenübersicht") ws2 = wb.create_sheet("Length Summary")
ws2.append(["Gerundete Länge (m)", "Anzahl Kabel"]) ws2.append(["Rounded Length (m)", "Number of Cables"])
for rlength in sorted(length_summary): for rlength in sorted(length_summary):
ws2.append([int(rlength), length_summary[rlength]]) ws2.append([int(rlength), length_summary[rlength]])
# Worksheet 3 - Nicht an Racks gekoppeltes Equipment # Worksheet 3 - Nicht an Racks gekoppeltes Equipment
ws3 = wb.create_sheet("Equipment nicht angebunden") ws3 = wb.create_sheet("Not connected Equipment")
ws3.append(["Typ", "Name", "x", "y"]) ws3.append(["Type", "ID", "x", "y"])
for error in plines.errors_sensors: for error in plines.errors_sensors:
ws3.append(["Sensor / Aktor", error.name, error.coords.x, error.coords.y]) ws3.append(["Sensor / Actuator", error.name, error.coords.x, error.coords.y])
for error in plines.errors_dists: for error in plines.errors_dists:
ws3.append(["Unterverteiler", error.name, error.coords.x, error.coords.y]) ws3.append(["Subistributor", error.name, error.coords.x, error.coords.y])
# Worksheet 4 - Fehlgeschlagenes Routing # Worksheet 4 - Fehlgeschlagenes Routing
ws4 = wb.create_sheet("Routingfehler") ws4 = wb.create_sheet("Routing Errors")
ws4.append(["Unterverteiler", "Sensor- / Aktorname", "Grund"]) ws4.append(["Subdistributor", "Sensor / Actuator", "Details"])
nicht_angebunden = set(e.name for e in plines.errors_sensors + plines.errors_dists) nicht_angebunden = set(e.name for e in plines.errors_sensors + plines.errors_dists)
@@ -171,20 +168,20 @@ def write_excel_from_json(plines:Polylines, outpath:str):
uv_nicht_angebunden = uv in nicht_angebunden uv_nicht_angebunden = uv in nicht_angebunden
if uv in plines.errors_existing_dists: if uv in plines.errors_existing_dists:
ws4.append([uv,"-", "Distributor not found in layout"]) ws4.append([uv,"-", "Distributor not found in given layout"])
continue continue
for sensor in routing_error.sensoren: for sensor in routing_error.sensoren:
sensor_nicht_angebunden = sensor in nicht_angebunden sensor_nicht_angebunden = sensor in nicht_angebunden
if sensor_nicht_angebunden and uv_nicht_angebunden: if sensor_nicht_angebunden and uv_nicht_angebunden:
grund = "Sensor und Unterverteiler nicht angebunden" grund = "Subdistributor and sensor / actuator not connected to racks"
elif sensor_nicht_angebunden: elif sensor_nicht_angebunden:
grund = "Sensor / Aktor nicht angebunden" grund = "Sensor / actuator not connected to racks"
elif uv_nicht_angebunden: elif uv_nicht_angebunden:
grund = "Unterverteiler nicht angebunden" grund = "Subdistributor not connected to racks"
else: else:
grund = "Fehlgeschlagenes Routing trotz Anbindung" grund = "Failed routing (not caused by missing connection)"
ws4.append([uv, sensor, grund]) ws4.append([uv, sensor, grund])
+5 -5
View File
@@ -148,11 +148,11 @@ def prepare_data(rawdata:dict):
if __name__ == "__main__": if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Berechne Wege von Sensoren zu Verteilern über Kabeltrassen') parser = argparse.ArgumentParser(description='Calculate cable-routing from Subdistributors zu sensors / actuators alon cable-racks')
parser.add_argument('-f', '--filename', action='store', required=True, default="easy_position.json", help='file with all informations about positions gathered from getpositions', metavar='my_positions.json') parser.add_argument('-f', '--filename', action='store', required=True, default="file_positions.json", help='file with all informations about positions gathered from getpositions', metavar='my_positions.json')
parser.add_argument('-c', '--console', action='store_true', help='Ausgabe auf Konsole') parser.add_argument('-c', '--console', action='store_true', help='print to console')
parser.add_argument('-g', '--graph', action='store_true', help='Zeichnet den Graphen der Anlage') parser.add_argument('-g', '--graph', action='store_true', help='draw and show generated graph')
parser.add_argument('-w', '--write', action='store', help='erstellt Ausgabe-file für das Zeichnen von Kabeln in drawdxf') parser.add_argument('-w', '--write', action='store', help='create .json file to pass into drawing module to visualize results')
args = parser.parse_args() args = parser.parse_args()