Unterverteiler werden aus Konfig geladen und erkannt.
This commit is contained in:
+3
-3
@@ -28,9 +28,9 @@ QA
|
||||
|
||||
|
||||
[Cabinet-Pattern]
|
||||
A\d\d+UH00
|
||||
A\d\d+UC\d\d\d
|
||||
UC\d\d\d\d
|
||||
A\d\d\+(UH00)
|
||||
A\d\d\+(UC\d\d\d)
|
||||
\+(UC\d\d\d\d)
|
||||
|
||||
|
||||
|
||||
|
||||
+16
-10
@@ -48,18 +48,21 @@ def get_type_of_name_cfg(name: str) -> str:
|
||||
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"""
|
||||
if not config_BMK.has_section("Cabinet-Pattern"):
|
||||
return False
|
||||
return (False, "")
|
||||
|
||||
patterns = [pattern for pattern, _ in config_BMK.items("Cabinet-Pattern")]
|
||||
|
||||
for pattern in patterns:
|
||||
if re.match(pattern, name):
|
||||
return True
|
||||
|
||||
m = re.search(pattern, name)
|
||||
if m:
|
||||
res = m.group(1)
|
||||
return (True, res)
|
||||
|
||||
return False
|
||||
return (False, "")
|
||||
|
||||
|
||||
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)
|
||||
|
||||
# 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
|
||||
|
||||
if f"-{id_}" in dist2sensors or f"+{id_}" in dist2sensors:
|
||||
# Fix: use ld["pos"] instead of undefined insert_point
|
||||
if res in dist2sensors:
|
||||
ret[id_] = ld["pos"]
|
||||
|
||||
return ret
|
||||
@@ -813,8 +816,11 @@ if __name__ == '__main__':
|
||||
entities = iterdxf.modelspace(dxf_path)
|
||||
else:
|
||||
entities = msp.query('MTEXT')
|
||||
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 Texten (alter Stil)
|
||||
res_dist = get_subdistributor_positions_from_entities(entities, 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
|
||||
if args.console:
|
||||
print(to_json(res_dist))
|
||||
|
||||
Reference in New Issue
Block a user