Skip to content

Update widget macro with text entry #556

@ewaagaard

Description

@ewaagaard

Hi!

In a pop-up in .bob menu from the main system called Gersemi, there is an embedded display with text update templates showing various statuses and values of a wanted device determined by the user. For this purpose, I have created a text entry where one enters the process variable name of the wanted device in the system that becomes a local variable through loc://GersemiAIdevNam. I would like the macro "AI2Macro" to be the prefix (determined from user input) that then makes the text update templates show the status, e.g. $(AI2Macro):sRdV. The problem is that when this local PV is turned into a macro, the widgets (the text updates) don't seem to notice that the user has updated this PV. In runtime mode, the embedded display has indeed a macro "AI2Macro" that is exactly equal to the user input, so that seems to work. The following attached python script below is what I use:

from org.csstudio.display.builder.runtime.script import PVUtil

GersemiAIdevNam = PVUtil.getString(pvs[0])
widget.getPropertyValue("macros").add("AI2Macro", GersemiAIdevNam)

However, the other widgets in the embedded display don't seem to notice this updated macro. In the old .opi version of the menu, this JavaScript was used:

importPackage(Packages.org.csstudio.opibuilder.scriptUtil);

var macroInput = DataUtil.createMacrosInput(true);
var GersemiAIdevNam = PVUtil.getString(pvArray[0]);

macroInput.put("AI2Macro", GersemiAIdevNam);
widgetController.setPropertyValue("macros", macroInput);

Strangly enough, the display builder in CS Studio does not seem to import packages properly in JavaScript, so that's why I used python for the .bob version. In Python, the "import DataUtil" does not seem to work either. Do you have any idea of how to make other widgets understand that there is this new updated PV from the text entry user input? Thanks in advance for your help!

Best wishes,
sailew

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions