Esempio n. 1
0
def test_greater_than_rule_default_name(widget, get_renderer):
    widget.add_rule(rules.GreaterThanRule('vis', 'dummy_pv', '0'))
    renderer = get_renderer(widget)
    renderer.assemble()
    rule_element = renderer.get_node().find('./rules/rule')
    assert rule_element.attrib['prop_id'] == 'vis'
    assert rule_element.attrib['name'] == 'GreaterThanRule'
Esempio n. 2
0
def test_greater_than_rule(widget, get_renderer):
    widget.rules = []
    widget.rules.append(rules.GreaterThanRule('vis', 'dummy_pv', '0'))
    renderer = get_renderer(widget)
    renderer.assemble()
    rule_element = renderer.get_node().find('./rules/rule')
    assert rule_element.find('./pv').text == 'dummy_pv'
    assert rule_element.find('./pv').attrib['trig'] == 'true'
    exp_elements = rule_element.findall('./exp')
    assert len(exp_elements) == 2
    assert exp_elements[0].attrib['bool_exp'] == 'pv0 > 0'
    value_element = exp_elements[0].find('./value')
    assert value_element.text == 'true'
    assert exp_elements[1].attrib['bool_exp'] == 'true'
Esempio n. 3
0
def test_greater_than_rule_sets_val(widget, get_renderer):
    widget.add_rule(
        rules.GreaterThanRule('image_index', 'dummy_pv', '1', val=99))
    renderer = get_renderer(widget)
    renderer.assemble()
    rule_element = renderer.get_node().find('./rules/rule')
    assert rule_element.attrib['prop_id'] == 'image_index'
    assert rule_element.attrib['name'] == 'GreaterThanRule'

    exp_elements = rule_element.findall('./exp')
    assert len(exp_elements) == 2
    assert exp_elements[0].attrib['bool_exp'] == 'pv0 > 1'
    value_element = exp_elements[0].find('./value')
    assert value_element.text == '99'
Esempio n. 4
0
# Add a rectangle.
w = widgets.Rectangle(0, 0, 10, 10)
w.set_fg_color(colors.YELLOW_LED_OFF)
d.add_child(w)

# Add a grouping container.
group = widgets.GroupingContainer(30, 30, 90, 90)

# Add two action buttons to the grouping container.
ab = widgets.ActionButton(30, 30, 30, 30, 'hello')
ab.add_write_pv('hello', 'bye')
group.add_child(ab)
ab2 = widgets.ActionButton(60, 60, 60, 60, 'ls')
ab2.add_shell_command('ls')
group.add_child(ab2)

# Add a rule to the grouping container.
group.rules = []
group.rules.append(
    rules.GreaterThanRule('visible', 'SR-CS-FILL-01:COUNTDOWN', 300))
d.add_child(group)

# Add a label with fonts and colour from the config files
l = widgets.Label(100, 100, 200, 20, "test_label")
l.set_font(fonts.FINE_PRINT)
d.add_child(l)

# Write the OPI file.
o = render.get_opi_renderer(d)
o.write_to_file("cssgen_example.opi")