Example #1
0
    def test_layout(self):
        b = self.p.block_view("mainBlock")

        new_layout = LayoutTable(
            name=["partchild1", "partchild2", "partchild3"],
            mri=["part1", "part2", "part3"],
            x=[10, 11, 12],
            y=[20, 21, 22],
            visible=[True, True, True],
        )
        b.layout.put_value(new_layout)
        assert self.c.parts["partchild1"].x == 10
        assert self.c.parts["partchild1"].y == 20
        assert self.c.parts["partchild1"].visible == AVisibleArray(True)
        assert self.c.parts["partchild2"].x == 11
        assert self.c.parts["partchild2"].y == 21
        assert self.c.parts["partchild2"].visible == AVisibleArray(True)
        assert self.c.parts["partchild3"].x == 12
        assert self.c.parts["partchild3"].y == 22
        assert self.c.parts["partchild3"].visible == AVisibleArray(True)

        new_layout.visible = [True, False, True]
        b.layout.put_value(new_layout)
        assert self.c.parts["partchild1"].visible == AVisibleArray(True)
        assert self.c.parts["partchild2"].visible == AVisibleArray(False)
        assert self.c.parts["partchild3"].visible == AVisibleArray(True)
Example #2
0
 def test_adding_faulty_non_default_works(self):
     t = LayoutTable.from_rows([["BAD2", "faulty", 0, 0, True]])
     self.b.layout.put_value(t)
     assert list(self.b.configure.meta.defaults["detectors"].rows()) == [
         [True, "FAST", "fast", 0.0, 1],
         [True, "SLOW", "slow", 0.0, 1],
         [False, "BAD2", "faulty", 0.0, 1],
     ]
     self.b.configure(self.make_generator(), self.tmpdir)
Example #3
0
 def test_adding_faulty_fails(self):
     t = LayoutTable.from_rows([["BAD", "faulty", 0, 0, True]])
     self.b.layout.put_value(t)
     assert list(self.b.configure.meta.defaults["detectors"].rows()) == [
         [True, "FAST", "fast", 0.0, 1],
         [True, "SLOW", "slow", 0.0, 1],
         [True, "BAD", "faulty", 0.0, 1],
     ]
     with self.assertRaises(BadValueError) as cm:
         self.b.configure(self.make_generator(), self.tmpdir)
     assert str(cm.exception) == (
         "Detector BAD was faulty at init and is unusable. "
         "If the detector is now working please restart Malcolm"
     )
     self.b.configure(
         self.make_generator(),
         self.tmpdir,
         detectors=DetectorTable.from_rows([(False, "BAD", "faulty", 0.0, 1)]),
     )
     self.b.reset()
     t = LayoutTable.from_rows([["BAD", "faulty", 0, 0, False]])
     self.b.layout.put_value(t)
     self.test_init()
     self.b.configure(self.make_generator(), self.tmpdir)
    def test_set_and_load_layout(self):
        new_layout = LayoutTable(
            name=["part2"], mri=["anything"], x=[10], y=[20], visible=[False]
        )
        self.c.set_layout(new_layout)
        assert self.c.parts["part2"].x == 10
        assert self.c.parts["part2"].y == 20
        assert self.c.parts["part2"].visible is False
        assert self.c.modified.value is True
        assert self.c.modified.alarm.message == "layout changed"

        # save the layout, modify and restore it
        self.b.save(designName="testSaveLayout")
        assert self.c.modified.value is False
        self.check_expected_save(10.0, 20.0, "false")
        self.c.parts["part2"].x = 30
        self.c.set_design("testSaveLayout")
        assert self.c.parts["part2"].x == 10
Example #5
0
 def test_pcap_visible(self):
     t = LayoutTable.from_rows([["PCAP", "", 0, 0, True]])
     block = self.process.block_view("P")
     assert "attributesToCapture" not in block
     block.layout.put_value(t)
     assert block.attributesToCapture.meta.tags == ["widget:table"]