BNA8/.resources/09bfaaff043146e699492584d7ec7896955f8abad43b8255989c12b1bb166d48

57 lines
1.4 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()[0].getChildren():
try:
child.props.style.classes = ""
except:
pass
return False
parts = str(tag_priority).split("||")
tag = parts[0]
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"]
components = view.rootContainer.getChildren()[0].getChildren()
priority = parts[1]
foundMatch = False
# clear all highlights and apply new one when found
for child in components:
params = child.props.get("params", {})
tagProps = params.get("tagProps", {})
tagsList = list(tagProps)
if len(tagsList) == 0:
continue
child.props.style.classes = ""
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