Search in sources :

Example 1 with ImageWidget

use of org.csstudio.display.builder.model.widgets.plots.ImageWidget in project org.csstudio.display.builder by kasemir.

the class RulesTest method testValueAsExpression.

/**
 * Rules that uses the value of a PV within an expression
 */
@Test
public void testValueAsExpression() throws Exception {
    final Widget widget = new ImageWidget();
    final RuleInfo rule = new RuleInfo("WidthFromPV", "data_width", true, Arrays.asList(new RuleInfo.ExprInfoString("true", "pv0")), Arrays.asList(new ScriptPV("XSize")));
    System.out.println(rule);
    final String script = RuleToScript.generatePy(widget, rule);
    System.out.println(script);
    // Script must read the PV
    assertThat(script, containsString("PVUtil.get"));
}
Also used : ImageWidget(org.csstudio.display.builder.model.widgets.plots.ImageWidget) LabelWidget(org.csstudio.display.builder.model.widgets.LabelWidget) Widget(org.csstudio.display.builder.model.Widget) ImageWidget(org.csstudio.display.builder.model.widgets.plots.ImageWidget) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) RuleInfo(org.csstudio.display.builder.model.rules.RuleInfo) ScriptPV(org.csstudio.display.builder.model.properties.ScriptPV) Test(org.junit.Test)

Example 2 with ImageWidget

use of org.csstudio.display.builder.model.widgets.plots.ImageWidget in project org.csstudio.display.builder by kasemir.

the class RulesTest method testValueForCondition.

/**
 * Rule that checks pv0>10 and picks a certain value for that
 */
@Test
public void testValueForCondition() throws Exception {
    final ImageWidget widget = new ImageWidget();
    final WidgetProperty<Integer> width = widget.propDataWidth().clone();
    width.setValue(47);
    final RuleInfo rule = new RuleInfo("WidthBasedOnPV", "data_width", false, Arrays.asList(new RuleInfo.ExprInfoValue<Integer>("pv0>10", width)), Arrays.asList(new ScriptPV("XSize")));
    System.out.println(rule);
    final String script = RuleToScript.generatePy(widget, rule);
    System.out.println(script);
    // Script must read the PV
    assertThat(script, containsString("pv0 = PVUtil.getDouble(pvs[0])"));
}
Also used : ImageWidget(org.csstudio.display.builder.model.widgets.plots.ImageWidget) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) RuleInfo(org.csstudio.display.builder.model.rules.RuleInfo) ScriptPV(org.csstudio.display.builder.model.properties.ScriptPV) Test(org.junit.Test)

Aggregations

ScriptPV (org.csstudio.display.builder.model.properties.ScriptPV)2 RuleInfo (org.csstudio.display.builder.model.rules.RuleInfo)2 ImageWidget (org.csstudio.display.builder.model.widgets.plots.ImageWidget)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 Test (org.junit.Test)2 Widget (org.csstudio.display.builder.model.Widget)1 LabelWidget (org.csstudio.display.builder.model.widgets.LabelWidget)1