wenn nur ein Tunnel oder zu viele gleichlautende Tunnel definiert wurden, dann Fehler werfen

This commit is contained in:
2025-08-14 17:09:16 +02:00
parent 76ae8ed22a
commit ec6d903515
2 changed files with 24 additions and 8 deletions
+17 -3
View File
@@ -621,10 +621,11 @@ def check_file_in_work(work_dir: Path, filename: Path) -> tuple[Path, bool]:
mypath = filename mypath = filename
return mypath, fexists return mypath, fexists
def check_existance(res_mappings: dict, res_dist: dict, res_pos: dict) -> dict: def check_existance(res_mappings: dict, res_dist: dict, res_pos: dict, res_tunnel: dict) -> dict:
ret = dict() ret = dict()
ret["missing_distributors"] = list() ret["missing_distributors"] = list()
ret["missing_sensors"] = list() ret["missing_sensors"] = list()
ret["missing_tunnel"] = list()
for dname in res_mappings.keys(): for dname in res_mappings.keys():
if dname not in res_dist: if dname not in res_dist:
ret["missing_distributors"].append(dname) ret["missing_distributors"].append(dname)
@@ -632,7 +633,13 @@ def check_existance(res_mappings: dict, res_dist: dict, res_pos: dict) -> dict:
for s in lofsensors: for s in lofsensors:
if s not in res_pos: if s not in res_pos:
ret['missing_sensors'].append(s) ret['missing_sensors'].append(s)
for tname in res_tunnel.keys():
if len(res_tunnel[tname]) < 2 :
ret["missing_tunnel"].append(tname)
if len(res_tunnel[tname]) > 2 :
if "overdefined_tunnel" not in ret:
ret["overdefined_tunnel"] = list()
ret["overdefined_tunnel"].append(tname)
return ret return ret
def dxf_is_binary(dxf_path: Path) -> bool: def dxf_is_binary(dxf_path: Path) -> bool:
@@ -810,11 +817,18 @@ if __name__ == '__main__':
if args.write: if args.write:
basename = os.path.splitext(args.write)[0] basename = os.path.splitext(args.write)[0]
res_not_found = check_existance(res_mappings, res_dist, res_sens) res_not_found = check_existance(res_mappings, res_dist, res_sens, res_tunnel)
if args.errors and "overdefined_tunnel" in res_not_found:
print("unorrect tunnels found. Writing errors-file.")
err_ids = list(res_not_found["overdefined_tunnel"])
write_results(to_json(list(err_ids)), work_dir, args.errors)
added_warnings = merge_two_dicts(warnings, missing_attribs) added_warnings = merge_two_dicts(warnings, missing_attribs)
res_not_found["missing_attributes"] = added_warnings res_not_found["missing_attributes"] = added_warnings
output_results["not_found"] = res_not_found output_results["not_found"] = res_not_found
output_results["double_ids"] = res_double output_results["double_ids"] = res_double
write_results(to_json(output_results), work_dir, f"{basename}.json") write_results(to_json(output_results), work_dir, f"{basename}.json")
else: else:
+7 -5
View File
@@ -434,11 +434,13 @@ class Anlage():
die Rückage enthält ein Tuple, welche Tunnel keinem Rack zugeordnet werden konnten die Rückage enthält ein Tuple, welche Tunnel keinem Rack zugeordnet werden konnten
''' '''
for tname, pos in self._tunnels.items(): for tname, pos in self._tunnels.items():
tunbeg = pos[0] if len(pos) == 2:
tunend = pos[1] tunbeg = pos[0]
trackname = f"t-Rack-{tname}" tunend = pos[1]
self._racks.add_rack(tunbeg, tunend, trackname) trackname = f"t-Rack-{tname}"
self._racks.add_rack(tunbeg, tunend, trackname)
else:
raise Exception("Tunnel has more than one begin and end/ just one begin")
errors = list() errors = list()
for name, pos in self._tunnels.items(): for name, pos in self._tunnels.items():
p1 = self._tunnels[name][0] p1 = self._tunnels[name][0]