ErrorCollector standarisiert. Warnings werden von getpositions zur routing zu draw durchgereicht.
This commit is contained in:
+45
-1
@@ -762,6 +762,47 @@ def check_file_in_work(work_dir: Path, filename: Path) -> tuple[Path, bool]:
|
||||
mypath = filename
|
||||
return mypath, fexists
|
||||
|
||||
def check_rack_z_coordinates(res_racks: dict, error_collector, config) -> None:
|
||||
"""
|
||||
Prüft die z-Koordinaten aller Racks und gibt eine Warnung aus,
|
||||
wenn die Differenz zwischen min und max größer als der konfigurierte Schwellwert ist.
|
||||
|
||||
Args:
|
||||
res_racks: Dictionary mit Rack-Daten (key: rack_name, value: list of coordinates)
|
||||
error_collector: ErrorCollector Instanz zum Hinzufügen von Warnungen
|
||||
config: ConfigParser Objekt mit allgemein.cfg
|
||||
"""
|
||||
if not res_racks:
|
||||
return
|
||||
|
||||
# Lese Schwellwert aus Config (Standard: 2000.0 mm)
|
||||
max_height_diff = config.getfloat("Racks", "MaximalTotalHeightDifferences", fallback=2000.0)
|
||||
|
||||
all_z_coords = []
|
||||
|
||||
# Sammle alle z-Koordinaten aus allen Racks
|
||||
for rack_name, coordinates in res_racks.items():
|
||||
if isinstance(coordinates, list):
|
||||
for coord in coordinates:
|
||||
if isinstance(coord, (list, tuple)) and len(coord) >= 3:
|
||||
all_z_coords.append(coord[2])
|
||||
elif isinstance(coord, dict) and 'z' in coord:
|
||||
all_z_coords.append(coord['z'])
|
||||
|
||||
if not all_z_coords:
|
||||
return
|
||||
|
||||
# Berechne Min und Max
|
||||
min_z = min(all_z_coords)
|
||||
max_z = max(all_z_coords)
|
||||
diff = max_z - min_z
|
||||
|
||||
# Prüfe, ob Differenz > Schwellwert
|
||||
if diff > max_height_diff:
|
||||
warning_msg = f"The z-coordinates of the racks differ strong between each other from {min_z:.1f} to {max_z:.1f}"
|
||||
error_collector.add_warnings({"rack_z_coordinate_deviation": warning_msg})
|
||||
#print(f"WARNING: {warning_msg}")
|
||||
|
||||
def check_existance(res_mappings: dict, res_dist: dict, res_pos: dict, res_tunnel: dict) -> dict:
|
||||
ret = dict()
|
||||
|
||||
@@ -960,9 +1001,12 @@ if __name__ == '__main__':
|
||||
res_rac = get_rack_positions_iter(dxf_path)
|
||||
else:
|
||||
res_rac = get_rack_positions(msp)
|
||||
|
||||
|
||||
output_results['racks'] = res_rac
|
||||
|
||||
# Prüfe z-Koordinaten der Racks auf starke Abweichungen
|
||||
check_rack_z_coordinates(res_rac, error_collector, config)
|
||||
|
||||
if args.console:
|
||||
print(to_json(res_rac))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user