Hello Mayou.
It might be not the best solution, but a few years ago, I created a Python script similar to the one below:
#executed with jython
from connect2j import scriptContext
with scriptContext('widget', 'pvs', 'PVUtil', 'ColorFontUtil', dict=globals()):
RED = ColorFontUtil.RED
BLUE = ColorFontUtil.BLUE
GREEN = ColorFontUtil.getColorFromRGB(0, 255, 0)
node = PVUtil.getString(pvs[0])
device = PVUtil.getString(pvs[1])
if device == "rpi4":
color = GREEN
elif device == "nano2gb":
color = BLUE
elif device == "nano4gb":
color = RED
widget.setPropertyValue("traces[0].y_pv", "pva://" + device + ":NTP_client:" + node)
widget.setPropertyValue("traces[0].color", color)
widget.setPropertyValue("traces[0].name", device + " Node: " + node)
My goal was to dynamically change the colors, names, and traces in a Strip Chart to visualize data from different nodes and devices using the same chart. To achieve this, I declared two PVs, node_ID
and device_name
, and used other elements like a Combo Box to switch between them.
You can find some examples I created for that project in this link: https://github.com/EusebioAlsoliman/TFM/tree/main/Phoebus
The opi file is named "Main.bob", and the script is called "update_trace_NTP.py". I hope this helps you.
Cheers, Eusebio.