diff --git a/lib/getpositions.py b/lib/getpositions.py index 1ff3be9..a705f45 100644 --- a/lib/getpositions.py +++ b/lib/getpositions.py @@ -246,6 +246,8 @@ def extract_input_positions(insert_iterable) -> tuple[dict, dict, dict, dict]: # Die Funktion sucht die übereinanderliegenen Elemente und baut ein Dict daraus allocate_blocks_together(all_sensors, wp) + set_single_frames_with_unique_sps(all_schaltschrank, wp) + # die noch übrigen Blöcke melden missing_attribs, double_ids = get_errors_double_and_attributes(wp) @@ -280,6 +282,20 @@ def get_errors_double_and_attributes(wp: CompareBuffer) -> tuple[dict, dict]: double_ids[id_].append(block['pos']) return missing_attribs, double_ids +def set_single_frames_with_unique_sps(all_sensors: dict, wp: CompareBuffer): + all_sensors_ids = wp.get_block_ids() + for id_ in all_sensors_ids: + blks_sps = wp.get_all_sps_blocks(id_) + + for block_with_sps in blks_sps: + # schaue ob es keinen Konflikt zu bestehenden Angaben + if "IO" in block_with_sps and "SPS" in block_with_sps: + sps_praefix = block_with_sps["SPS"] + new_id = f"{id_}@{sps_praefix}" + + all_sensors[new_id] = block_with_sps + wp.remove_block(id_, block_with_sps) + def allocate_blocks_together(all_sensors: dict, wp: CompareBuffer) -> None: """ Merge sensor blocks with the same ID that are split across multiple DXF blocks.