Unterverteiler werden aus Konfig geladen und erkannt.
This commit is contained in:
+3
-3
@@ -28,9 +28,9 @@ QA
|
|||||||
|
|
||||||
|
|
||||||
[Cabinet-Pattern]
|
[Cabinet-Pattern]
|
||||||
A\d\d+UH00
|
A\d\d\+(UH00)
|
||||||
A\d\d+UC\d\d\d
|
A\d\d\+(UC\d\d\d)
|
||||||
UC\d\d\d\d
|
\+(UC\d\d\d\d)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+15
-9
@@ -48,18 +48,21 @@ def get_type_of_name_cfg(name: str) -> str:
|
|||||||
return "unknown"
|
return "unknown"
|
||||||
|
|
||||||
|
|
||||||
def matches_cabinet_pattern(name: str) -> bool:
|
def matches_cabinet_pattern(name: str) -> [bool, str]:
|
||||||
"""Check if the given name matches any Cabinet-Pattern from BMK.cfg"""
|
"""Check if the given name matches any Cabinet-Pattern from BMK.cfg"""
|
||||||
if not config_BMK.has_section("Cabinet-Pattern"):
|
if not config_BMK.has_section("Cabinet-Pattern"):
|
||||||
return False
|
return (False, "")
|
||||||
|
|
||||||
patterns = [pattern for pattern, _ in config_BMK.items("Cabinet-Pattern")]
|
patterns = [pattern for pattern, _ in config_BMK.items("Cabinet-Pattern")]
|
||||||
|
|
||||||
for pattern in patterns:
|
for pattern in patterns:
|
||||||
if re.match(pattern, name):
|
|
||||||
return True
|
|
||||||
|
|
||||||
return False
|
m = re.search(pattern, name)
|
||||||
|
if m:
|
||||||
|
res = m.group(1)
|
||||||
|
return (True, res)
|
||||||
|
|
||||||
|
return (False, "")
|
||||||
|
|
||||||
|
|
||||||
def get_attributes_of_insert(d_insert: dict, d_pos: dict) -> tuple[dict, str, str]:
|
def get_attributes_of_insert(d_insert: dict, d_pos: dict) -> tuple[dict, str, str]:
|
||||||
@@ -459,11 +462,11 @@ def get_subdistributor_positions_from_symbols(all_inserts:list, all_positions:li
|
|||||||
ld, id_ = get_subdistributor_position_of_symbol(insert, pos)
|
ld, id_ = get_subdistributor_position_of_symbol(insert, pos)
|
||||||
|
|
||||||
# Check if id_ matches Cabinet-Pattern from BMK.cfg
|
# Check if id_ matches Cabinet-Pattern from BMK.cfg
|
||||||
if not matches_cabinet_pattern(id_):
|
(matches, res) = matches_cabinet_pattern(id_)
|
||||||
|
if not matches:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if f"-{id_}" in dist2sensors or f"+{id_}" in dist2sensors:
|
if res in dist2sensors:
|
||||||
# Fix: use ld["pos"] instead of undefined insert_point
|
|
||||||
ret[id_] = ld["pos"]
|
ret[id_] = ld["pos"]
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
@@ -813,8 +816,11 @@ if __name__ == '__main__':
|
|||||||
entities = iterdxf.modelspace(dxf_path)
|
entities = iterdxf.modelspace(dxf_path)
|
||||||
else:
|
else:
|
||||||
entities = msp.query('MTEXT')
|
entities = msp.query('MTEXT')
|
||||||
|
# die Infos aus den Texten (alter Stil)
|
||||||
res_dist = get_subdistributor_positions_from_entities(entities, res_mappings)
|
res_dist = get_subdistributor_positions_from_entities(entities, res_mappings)
|
||||||
new_res_dist = get_subdistributor_positions_from_symbols(all_inserts, all_positions, res_mappings)
|
# die Infos aus den Blöcken
|
||||||
|
symbol_dists = get_subdistributor_positions_from_symbols(all_inserts, all_positions, res_mappings)
|
||||||
|
res_dist = merge_two_dicts(res_dist, symbol_dists)
|
||||||
output_results['distributors'] = res_dist
|
output_results['distributors'] = res_dist
|
||||||
if args.console:
|
if args.console:
|
||||||
print(to_json(res_dist))
|
print(to_json(res_dist))
|
||||||
|
|||||||
Reference in New Issue
Block a user