BNA8/.resources/0101f46f26c0425f4f6470af0c2b90d2adfb7ee8ecd2b5f77dd49d5530ac7ca1
2025-09-19 17:47:58 +04:00

55 lines
1.7 KiB
Plaintext

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[-1]
Docked_East_Map = {
"VFD": "Docked-East-VFD",
"MCM": "Docked-East-MCM"
}
Docked_East_View = Docked_East_Map["VFD"]
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