Fehler-Handling weiter angepasst. Weiterreichung von getpositions bis ans Ende und Excel Ausgabe
This commit is contained in:
Vendored
+18
-1
@@ -39,6 +39,22 @@
|
|||||||
"easy_positions.json"
|
"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",
|
"name": "getpositions with HundM.dxf",
|
||||||
"type": "debugpy",
|
"type": "debugpy",
|
||||||
@@ -136,7 +152,8 @@
|
|||||||
"--filename",
|
"--filename",
|
||||||
"HundM_coords.json",
|
"HundM_coords.json",
|
||||||
"-w",
|
"-w",
|
||||||
"HundM_cables.json"
|
"HundM_cables.json",
|
||||||
|
"-g"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -41,12 +41,15 @@ class Error_Connection:
|
|||||||
class Error_Routing:
|
class Error_Routing:
|
||||||
unterverteiler: str
|
unterverteiler: str
|
||||||
sensoren: List[str]
|
sensoren: List[str]
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Polylines:
|
class Polylines:
|
||||||
kabel: List[Polyline]
|
kabel: List[Polyline]
|
||||||
errors_routing: List[Error_Routing]
|
errors_routing: List[Error_Routing]
|
||||||
errors_sensors: List[Error_Connection]
|
errors_sensors: List[Error_Connection]
|
||||||
errors_dists: 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):
|
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:
|
for routing_error in plines.errors_routing:
|
||||||
uv = routing_error.unterverteiler
|
uv = routing_error.unterverteiler
|
||||||
uv_nicht_angebunden = uv in nicht_angebunden
|
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:
|
for sensor in routing_error.sensoren:
|
||||||
sensor_nicht_angebunden = sensor in nicht_angebunden
|
sensor_nicht_angebunden = sensor in nicht_angebunden
|
||||||
|
|
||||||
|
|||||||
@@ -268,6 +268,22 @@ def check_file_in_work(work_dir, filename):
|
|||||||
mypath = filename
|
mypath = filename
|
||||||
return (mypath, fexists)
|
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__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser(description='fetches the x/y positions from a dxf file', prog='getpositions')
|
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')
|
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))
|
print(to_json(res_rac))
|
||||||
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_pos)
|
||||||
|
output_results["not_found"] = res_not_found
|
||||||
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
-2
@@ -140,8 +140,11 @@ def prepare_data(rawdata:dict):
|
|||||||
|
|
||||||
dtunlength = rawdata["tunnels"]["length"]
|
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__":
|
if __name__ == "__main__":
|
||||||
@@ -163,7 +166,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
# Einlesen und Vorbereiten der Daten
|
# Einlesen und Vorbereiten der Daten
|
||||||
rawdata = load_json(sensors_path)
|
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 = configparser.ConfigParser(allow_no_value=True, delimiters=("="))
|
||||||
config.optionxform = lambda option: option # preserve case for letters
|
config.optionxform = lambda option: option # preserve case for letters
|
||||||
@@ -184,6 +187,8 @@ if __name__ == "__main__":
|
|||||||
# Ausgabe schreiben
|
# Ausgabe schreiben
|
||||||
if args.write:
|
if args.write:
|
||||||
basename = os.path.splitext(args.write)[0]
|
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")
|
write_results(to_json(cable_paths), work_dir, f"{basename}.json")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user