def handleTagHighlight(view, currentValue): tag_priority = currentValue.value # --- CASE 1: Remove all highlights by applying CLEAR class --- if not tag_priority or str(tag_priority).upper() == "CLEAR": for child in view.rootContainer.getChildren(): try: child.props.style.classes = "Highlight/Pulse-Clear" except: pass return False # --- CASE 2: Highlight as normal --- parts = str(tag_priority).split("||") tag = parts[0] priority = parts[1] if len(parts) > 1 else "1" splitedTag = tag.split("/") deviceName = splitedTag[-2] # second-to-last part # Map device keywords to Docked-East views Docked_East_Map = { "VFD": "Docked-East-VFD", "MCM": "Docked-East-MCM", "EXTENDO": "Docked-East-EX", "DPM": "Docked-East-DS", "FIO": "Docked-East-DS", "SIO": "Docked-East-DS", "HUB": "Docked-East-DS", "EPC": "Docked-East-EPC", "JR": "Docked-East-BTN", "Chute_JR": "Docked-East-BTN", "S_PB": "Docked-East-BTN", "SS_PB": "Docked-East-BTN", "Chute": "Docked-East-SNP", "FL_CHUTE": "Docked-East-SNP", "PalletBuild": "Docked-East-SNP", "D2C": "Docked-East-SNP", "NC": "Docked-East-SNP", } Docked_East_View = Docked_East_Map.get(deviceName, "Docked-East-VFD") # fallback # Special handling for PE devices if "PE" in deviceName: tag = "/".join(splitedTag[:2]) + "/Conveyor/" + deviceName[:-3] + "VFD1" if "MCM" in deviceName: Docked_East_View = Docked_East_Map["MCM"] # Clear old highlights (set to Clear class) components = view.rootContainer.getChildren() for child in components: child.props.style.classes = "Highlight/Pulse-Clear" # Apply highlight if found foundMatch = False for child in components: params = child.props.get("params", {}) tagProps = params.get("tagProps", {}) tagsList = list(tagProps) if len(tagsList) == 0: continue tagPath = tagsList[0] if tag == tagPath: child.props.style.classes = "Highlight/Pulse-" + priority system.perspective.openDock(Docked_East_View, params={'tagProps': tagProps}) foundMatch = True return foundMatch