BNA8/.resources/e804f6dc7729a6add9938ee349fb3e6f861d8c045e0bcc3cf792e97d253ef8cd
Salijoghli f38f97fee0 fixes
2025-10-07 19:20:00 +04:00

94 lines
2.6 KiB
Plaintext

def deviceType(self, path, props):
try:
docked_view = "Docked-East-"
devices = []
tags = []
prop = props[0]
if "Conveyor" in path:
docked_view += "Conv"
autStand.devices.build_device_mapping(prop)
devices = autStand.devices.build_device_table(self)
elif "VFD" in path:
docked_view += "VFD"
else:
docked_view += "Device"
tags = autStand.devices.getAllTags(self, prop)
return [docked_view, tags, devices]
except Exception as e:
import traceback
msg = "Error in deviceType: {}\n{}".format(str(e), traceback.format_exc())
system.perspective.print(msg)
return None
def handleTagHighlight(view, currentValue):
tag_priority = currentValue.value
# --- CASE 1: Remove all highlights by applying CLEAR class ---
if str(tag_priority).upper() == "CLEAR":
for child in view.rootContainer.getChildren()[0].getChildren():
try:
currentClasses = child.props.style['classes'].split(" ")
filtered = [c for c in currentClasses if not c.startswith("Highlight/")]
child.props.style.classes = " ".join(filtered)
child.props.params.highlight = ""
except:
pass
return False
if "||" not in tag_priority:
return
parts = str(tag_priority).split("||")
tag = parts[0]
splitedTag = tag.split("/")
deviceName = splitedTag[-1]
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 = ""
currentClasses = child.props.style['classes'].split(" ")
# strip only highlight-related classes
filtered = [c for c in currentClasses if not c.startswith("Highlight/")]
child.props.style["classes"] = " ".join(filtered)
child.props.params.highlight = ""
tagPath = tagsList[0]
if tag == tagPath:
path = child.props.get("path")
if "Photoeye" in path:
child.props.params.highlight = priority
else:
child.props.style["classes"] += " Highlight/Pulse-" + priority
docked_view = deviceType(view, path, tagProps)
system.perspective.openDock(docked_view[0], params = {'tagProps':tagProps, 'tags': docked_view[1], 'devices':docked_view[2]})
foundMatch = True
return foundMatch