BNA8/.resources/d26380ed8a71f34321c8c37c8b29c25fb8460ab2bdfcc3ebb6def1e1733c8e4f
2025-09-25 17:07:07 +04:00

83 lines
2.2 KiB
Plaintext

def deviceType(self, path, props):
try:
docked_view = "Docked-East-"
devices = []
tags = []
if "Conveyor" in path:
docked_view += "Conv"
devices = autStand.devices.build_device_table(self)
system.perspective.print(devices)
elif "VFD" in path:
docked_view += "VFD"
else:
docked_view += "Device"
tags = autStand.devices.getAllTags(self, props[0])
system.perspective.print(tags)
# return 1
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
if not "||" in tag_priority:
return
# --- 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]
system.perspective.print(tag)
splitedTag = tag.split("/")
deviceName = splitedTag[-1]
components = view.rootContainer.getChildren()[0].getChildren()
priority = parts[1]
system.perspective.print(priority)
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
path = child.props.get("path")
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