Abfrage ob es Fehler gibt bevor Fehler Worksheet erstellt werden
This commit is contained in:
+32
-29
@@ -148,42 +148,45 @@ def write_excel_from_json(plines:Polylines, outpath:str):
|
|||||||
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
|
if len(plines.errors_existing_sensors) > 0 or len(plines.errors_dists) > 0:
|
||||||
ws3 = wb.create_sheet("Not connected Equipment")
|
# Worksheet 3 - Nicht an Racks gekoppeltes Equipment
|
||||||
ws3.append(["Type", "ID", "x", "y"])
|
ws3 = wb.create_sheet("Not connected Equipment")
|
||||||
for error in plines.errors_sensors:
|
ws3.append(["Type", "ID", "x", "y"])
|
||||||
ws3.append(["Sensor / Actuator", error.name, error.coords.x, error.coords.y])
|
for error in plines.errors_sensors:
|
||||||
|
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(["Subistributor", error.name, error.coords.x, error.coords.y])
|
ws3.append(["Subistributor", error.name, error.coords.x, error.coords.y])
|
||||||
|
|
||||||
# Worksheet 4 - Fehlgeschlagenes Routing
|
|
||||||
ws4 = wb.create_sheet("Routing Errors")
|
|
||||||
ws4.append(["Subdistributor", "Sensor / Actuator", "Details"])
|
|
||||||
|
|
||||||
nicht_angebunden = set(e.name for e in plines.errors_sensors + plines.errors_dists)
|
if len(plines.errors_routing) > 0:
|
||||||
|
# Worksheet 4 - Fehlgeschlagenes Routing
|
||||||
|
ws4 = wb.create_sheet("Routing Errors")
|
||||||
|
ws4.append(["Subdistributor", "Sensor / Actuator", "Details"])
|
||||||
|
|
||||||
for routing_error in plines.errors_routing:
|
nicht_angebunden = set(e.name for e in plines.errors_sensors + plines.errors_dists)
|
||||||
uv = routing_error.unterverteiler
|
|
||||||
uv_nicht_angebunden = uv in nicht_angebunden
|
|
||||||
|
|
||||||
if uv in plines.errors_existing_dists:
|
|
||||||
ws4.append([uv,"-", "Distributor not found in given layout"])
|
|
||||||
continue
|
|
||||||
|
|
||||||
for sensor in routing_error.sensoren:
|
for routing_error in plines.errors_routing:
|
||||||
sensor_nicht_angebunden = sensor in nicht_angebunden
|
uv = routing_error.unterverteiler
|
||||||
|
uv_nicht_angebunden = uv in nicht_angebunden
|
||||||
|
|
||||||
|
if uv in plines.errors_existing_dists:
|
||||||
|
ws4.append([uv,"-", "Distributor not found in given layout"])
|
||||||
|
continue
|
||||||
|
|
||||||
if sensor_nicht_angebunden and uv_nicht_angebunden:
|
for sensor in routing_error.sensoren:
|
||||||
grund = "Subdistributor and sensor / actuator not connected to racks"
|
sensor_nicht_angebunden = sensor in nicht_angebunden
|
||||||
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)"
|
|
||||||
|
|
||||||
ws4.append([uv, sensor, grund])
|
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)"
|
||||||
|
|
||||||
|
ws4.append([uv, sensor, grund])
|
||||||
|
|
||||||
|
|
||||||
wb.save(outpath)
|
wb.save(outpath)
|
||||||
|
|||||||
Reference in New Issue
Block a user