Fehler-Handling weiter angepasst. Weiterreichung von getpositions bis ans Ende und Excel Ausgabe

This commit is contained in:
2025-06-04 11:16:00 +02:00
parent 0c9ad629c2
commit cbeb8345af
4 changed files with 51 additions and 3 deletions
+18 -1
View File
@@ -39,6 +39,22 @@
"easy_positions.json"
]
},
{
"name": "getpositions with ST-Fortna.dxf",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"args": [
"--filename",
"ST-Fortna.dxf",
"--sensors",
"--rack",
"--console",
"--write",
"ST-Fortna_positions.json"
]
},
{
"name": "getpositions with HundM.dxf",
"type": "debugpy",
@@ -136,7 +152,8 @@
"--filename",
"HundM_coords.json",
"-w",
"HundM_cables.json"
"HundM_cables.json",
"-g"
]
}
]
+8
View File
@@ -41,12 +41,15 @@ class Error_Connection:
class Error_Routing:
unterverteiler: str
sensoren: List[str]
@dataclass
class Polylines:
kabel: List[Polyline]
errors_routing: List[Error_Routing]
errors_sensors: List[Error_Connection]
errors_dists: List[Error_Connection]
errors_existing_dists: List[str]
errors_existing_sensors: List[str]
def add_polyline(msp, points:Polyline, dxf_attribs):
@@ -166,6 +169,11 @@ def write_excel_from_json(plines:Polylines, outpath:str):
for routing_error in plines.errors_routing:
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 layout"])
continue
for sensor in routing_error.sensoren:
sensor_nicht_angebunden = sensor in nicht_angebunden
+18
View File
@@ -268,6 +268,22 @@ def check_file_in_work(work_dir, filename):
mypath = filename
return (mypath, fexists)
def check_existance(res_mappings, res_dist, res_pos):
ret = dict()
ret["missing_distributors"] = list()
ret["missing_sensors"] = list()
for dname in res_mappings.keys():
if dname not in res_dist:
ret["missing_distributors"].append(dname)
for sname,lofsensors in res_mappings.items():
for s in lofsensors:
if s not in res_pos:
ret['missing_sensors'].append(s)
return ret
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='fetches the x/y positions from a dxf file', prog='getpositions')
parser.add_argument('-f', '--filename', action='store', required=True, default="ST_6300_Steuerungstestlayout1_neueBloecke.dwg", help='which file should be fetched', metavar='myfile.dxf')
@@ -336,6 +352,8 @@ if __name__ == '__main__':
print(to_json(res_rac))
if args.write:
basename = os.path.splitext(args.write)[0]
res_not_found = check_existance(res_mappings, res_dist, res_pos)
output_results["not_found"] = res_not_found
write_results(to_json(output_results), work_dir, f"{basename}.json")
else:
+7 -2
View File
@@ -139,9 +139,12 @@ def prepare_data(rawdata:dict):
dtunnels[tname] = ltemp
dtunlength = rawdata["tunnels"]["length"]
errors_dists = rawdata["not_found"]["missing_distributors"]
errors_sensors = rawdata["not_found"]["missing_sensors"]
return (dracks, dsensors, dsubdists, mapping, dtunnels, dtunlength)
return (dracks, dsensors, dsubdists, mapping, dtunnels, dtunlength, errors_dists, errors_sensors)
if __name__ == "__main__":
@@ -163,7 +166,7 @@ if __name__ == "__main__":
# Einlesen und Vorbereiten der Daten
rawdata = load_json(sensors_path)
(racks, sensors, subdists, mapping, tunnels, tunlength) = prepare_data(rawdata)
(racks, sensors, subdists, mapping, tunnels, tunlength, errors_dists, errors_sensors) = prepare_data(rawdata)
config = configparser.ConfigParser(allow_no_value=True, delimiters=("="))
config.optionxform = lambda option: option # preserve case for letters
@@ -184,6 +187,8 @@ if __name__ == "__main__":
# Ausgabe schreiben
if args.write:
basename = os.path.splitext(args.write)[0]
cable_paths["errors_existing_dists"] = errors_dists
cable_paths["errors_existing_sensors"] = errors_sensors
write_results(to_json(cable_paths), work_dir, f"{basename}.json")