87 lines
2.4 KiB
Plaintext
87 lines
2.4 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])
|
|
|
|
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)
|
|
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)
|
|
|
|
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
|
|
|