def split_by_net_role(obj): # Actor Mixer和Virtual Folder无法被放在SwitchContainer下面 if obj['type'] == 'ActorMixer' or obj['type'] == 'Folder': return original_name = obj['name'] # 拆分结构并重组到SwitchContainer下面 old_parent = WaapiTools.get_parent_objects(obj, False) new_parent = WaapiTools.create_object(original_name + '_Temp', 'SwitchContainer', old_parent, 'rename') WaapiTools.move_object(obj, new_parent) obj_2p = WaapiTools.copy_object(obj, new_parent) obj_3p = WaapiTools.copy_object(obj, new_parent) WaapiTools.rename_object(obj, original_name + '_1P') WaapiTools.rename_object(obj_2p, original_name + '_2P') WaapiTools.rename_object(obj_3p, original_name + '_3P') WaapiTools.rename_object(new_parent, original_name) # 分配bus original_bus = WaapiTools.get_object_property(obj, '@OutputBus') original_bus_name = original_bus['name'] bus_1p = WaapiTools.find_object_by_name(original_bus_name + '_1P', 'Bus') if bus_1p is None: bus_1p = WaapiTools.create_object(original_bus_name + '_1P', 'Bus', original_bus, 'replace') bus_2p = WaapiTools.find_object_by_name(original_bus_name + '_2P', 'Bus') if bus_2p is None: bus_2p = WaapiTools.create_object(original_bus_name + '_2P', 'Bus', original_bus, 'replace') bus_3p = WaapiTools.find_object_by_name(original_bus_name + '_3P', 'Bus') if bus_3p is None: bus_3p = WaapiTools.create_object(original_bus_name + '_3P', 'Bus', original_bus, 'replace') WaapiTools.set_object_property(obj, 'OverrideOutput', True) WaapiTools.set_object_reference(obj, 'OutputBus', bus_1p) WaapiTools.set_object_property(obj_2p, 'OverrideOutput', True) WaapiTools.set_object_reference(obj_2p, 'OutputBus', bus_2p) WaapiTools.set_object_property(obj_3p, 'OverrideOutput', True) WaapiTools.set_object_reference(obj_3p, 'OutputBus', bus_3p) net_role_switch_group = WaapiTools.find_object_by_name( 'Net_Role', 'SwitchGroup') if net_role_switch_group is None: return WaapiTools.set_object_reference(new_parent, 'SwitchGroupOrStateGroup', net_role_switch_group) for switch_obj in WaapiTools.get_children_objects(net_role_switch_group, False): if '1P' in switch_obj['name']: assign_switch_mapping(obj, switch_obj) WaapiTools.set_object_reference(new_parent, 'DefaultSwitchOrState', switch_obj) if '2P' in switch_obj['name']: assign_switch_mapping(obj_2p, switch_obj) if '3P' in switch_obj['name']: assign_switch_mapping(obj_3p, switch_obj)
def replace_event(self, event_obj): new_event_name = event_obj['name'].replace(self.__oldName, self.__newName).replace( '_01', '') WaapiTools.rename_object(event_obj, new_event_name) for action in WaapiTools.get_children_objects(event_obj, False): target = WaapiTools.get_object_property(action, '@Target') target_full = WaapiTools.get_full_info_from_obj_id(target['id']) new_target_path = target_full['path'].replace( self.__oldName, self.__newName) new_target = WaapiTools.get_object_from_path(new_target_path) if new_target is not None: WaapiTools.set_object_reference(action, 'Target', new_target)
def temp_tool(objects: list): for obj in objects: parent = WaapiTools.get_parent_objects(obj, False) new_obj = WaapiTools.create_object('Tail', 'SwitchContainer', parent, 'rename') WaapiTools.move_object(obj, new_obj) indoor_switch_group = WaapiTools.find_object_by_name( 'Indoor_Outdoor', 'SwitchGroup') WaapiTools.set_object_reference(new_obj, 'SwitchGroupOrStateGroup', indoor_switch_group) outdoor_switch = WaapiTools.get_children_objects( indoor_switch_group, False)[1] LogicContainerTools.assign_switch_mapping(obj, outdoor_switch) WaapiTools.set_object_reference(new_obj, 'DefaultSwitchOrState', outdoor_switch) if parent['type'] == 'SwitchContainer': loop_switch_group = WaapiTools.find_object_by_name( 'Gun_Shot_Loop_Mode', 'SwitchGroup') end_switch = WaapiTools.get_children_objects( loop_switch_group, False)[0] LogicContainerTools.assign_switch_mapping(new_obj, end_switch)