diff --git a/lib/drawdxf.py b/lib/drawdxf.py index b473cb2..2201121 100644 --- a/lib/drawdxf.py +++ b/lib/drawdxf.py @@ -411,9 +411,44 @@ def _create_cable_summary_sheet(ws, processed_data): def _create_error_sheets(wb, plines): """Erstellt die Arbeitsblätter für alle aufgetretenen Fehler.""" - # (Diese Funktion bleibt unverändert, da sie keine der umbenannten Variablen verwendet) - # ... (Code wie zuvor) - pass # Platzhalter, der Code hier bleibt gleich + # Sheet: ERR-Equipment-Connection + if plines.errors_sensors or plines.errors_dists: + ws = wb.create_sheet("ERR-Equipment-Connection") + ws.append(["Type", "ID", "x", "y"]) + ws.column_dimensions['A'].width = 20 + for error in plines.errors_sensors: + ws.append(["Sensor / Actuator", error.name, int(error.coords.x), int(error.coords.y)]) + for error in plines.errors_dists: + ws.append(["Subistributor", error.name, int(error.coords.x), int(error.coords.y)]) + + # Sheet: ERR-Routing + if plines.errors_routing: + ws = wb.create_sheet("ERR-Routing") + ws.append(["Subdistributor", "Sensor / Actuator", "Details"]) + ws.column_dimensions['A'].width = 20 + ws.column_dimensions['B'].width = 20 + ws.column_dimensions['C'].width = 50 + nicht_angebunden = {e.name for e in plines.errors_sensors + plines.errors_dists} + for error in plines.errors_routing: + uv, uv_nicht_angebunden = error.unterverteiler, error.unterverteiler in nicht_angebunden + if uv in plines.errors_dists_not_in_layout: + ws.append([uv, "-", "Distributor not found in given layout."]) + continue + for sensor in error.sensoren: + sensor_nicht_angebunden = sensor in nicht_angebunden + if sensor_nicht_angebunden and uv_nicht_angebunden: grund = "Subdistributor and sensor / actuator not connected to racks" + elif sensor_nicht_angebunden: grund = "Sensor / actuator not connected to racks" + elif uv_nicht_angebunden: grund = "Subdistributor not connected to racks" + else: grund = "Failed routing (not caused by missing connection)" + ws.append([uv, sensor, grund]) + + # Sheet: ERR-Attributes + if plines.errors_missing_attributes: + ws = wb.create_sheet("ERR-Attributes") + ws.append(["ID", "Error Detail"]) + ws.column_dimensions['B'].width = 35 + for sname, err_msg in plines.errors_missing_attributes.items(): + ws.append([sname, err_msg]) def _create_bom_workbook(outpath, processed_data, bezeichner_cfg): """Erstellt eine separate Excel-Arbeitsmappe für die Stückliste (BOM)."""