class TestValidate(unittest.TestCase):

    def setUp(self):
        self.meta = BooleanArrayMeta("test description")

    def test_init(self):
        self.assertEqual("test description", self.meta.description)
        self.assertEqual(self.meta.label, "")
        self.assertEqual(self.meta.typeid, "malcolm:core/BooleanArrayMeta:1.0")

    def test_validate_none(self):
        self.assertEquals(self.meta.validate(None), [])

    def test_validate_array(self):
        array = ["True", "", True, False, 1, 0]
        self.assertEquals(
            [True, False, True, False, True, False],
            self.meta.validate(array))

    def test_not_iterable_raises(self):
        value = True
        self.assertRaises(ValueError, self.meta.validate, value)

    def test_null_element_raises(self):
        array = ["test", None]
        self.assertRaises(ValueError, self.meta.validate, array)
Пример #2
0
class TestValidate(unittest.TestCase):

    def setUp(self):
        self.meta = BooleanArrayMeta("test description")

    def test_init(self):
        self.assertEqual("test description", self.meta.description)
        self.assertEqual(self.meta.label, "")
        self.assertEqual(self.meta.typeid, "malcolm:core/BooleanArrayMeta:1.0")

    def test_validate_none(self):
        self.assertIsNone(self.meta.validate(None))

    def test_validate_array(self):
        array = ["True", "", True, False, 1, 0]
        self.assertEquals(
            [True, False, True, False, True, False],
            self.meta.validate(array))

    def test_not_iterable_raises(self):
        value = True
        self.assertRaises(ValueError, self.meta.validate, value)

    def test_null_element_raises(self):
        array = ["test", None]
        self.assertRaises(ValueError, self.meta.validate, array)
Пример #3
0
 def __init__(self, process, control, meta, block_name, field_name,
              writeable):
     super(PandABoxTablePart, self).__init__(
         process, control, meta, block_name, field_name, writeable)
     # Fill in the meta object with the correct headers
     columns = OrderedDict()
     self.fields = OrderedDict()
     fields = control.get_table_fields(block_name, field_name)
     for field_name, (bits_hi, bits_lo) in fields.items():
         nbits = bits_hi - bits_lo + 1
         if nbits < 1:
             raise ValueError("Bad bits %s:%s" % (bits_hi, bits_lo))
         if nbits == 1:
             column_meta = BooleanArrayMeta(field_name)
             widget_tag = widget("checkbox")
         else:
             if nbits <= 8:
                 dtype = "uint8"
             elif nbits <= 16:
                 dtype = "uint16"
             elif nbits <= 32:
                 dtype = "uint32"
             elif nbits <= 64:
                 dtype = "uint64"
             else:
                 raise ValueError("Bad bits %s:%s" % (bits_hi, bits_lo))
             column_meta = NumberArrayMeta(dtype, field_name)
             widget_tag = widget("textinput")
         label, column_name = make_label_attr_name(field_name)
         column_meta.set_label(label)
         column_meta.set_tags([widget_tag])
         columns[column_name] = column_meta
         self.fields[column_name] = (bits_hi, bits_lo)
     meta.set_elements(TableElementMap(columns))
Пример #4
0
 def create_attributes(self):
     for data in super(ManagerController, self).create_attributes():
         yield data
     # Make a table for the layout info we need
     columns = OrderedDict()
     columns["name"] = StringArrayMeta("Name of layout part")
     columns["mri"] = StringArrayMeta("Malcolm full name of child block")
     columns["x"] = NumberArrayMeta("float64", "X Coordinate of child block")
     columns["y"] = NumberArrayMeta("float64", "Y Coordinate of child block")
     columns["visible"] = BooleanArrayMeta("Whether child block is visible")
     layout_table_meta = TableMeta("Layout of child blocks", columns=columns)
     layout_table_meta.set_writeable_in(sm.EDITABLE)
     self.layout = layout_table_meta.make_attribute()
     yield "layout", self.layout, self.set_layout
     self.layout_name = ChoiceMeta(
         "Saved layout name to load", []).make_attribute()
     self.layout_name.meta.set_writeable_in(
         self.stateMachine.AFTER_RESETTING)
     yield "layoutName", self.layout_name, self.load_layout
     assert os.path.isdir(self.params.configDir), \
         "%s is not a directory" % self.params.configDir
Пример #5
0
 def setUp(self):
     self.meta = BooleanArrayMeta("test description")
 def setUp(self):
     self.meta = BooleanArrayMeta("test description")
sm = RunnableDeviceStateMachine

configure_args = [
    "generator",
    PointGeneratorMeta("Generator instance"), REQUIRED, "axes_to_move",
    StringArrayMeta("Axes that should be moved"), REQUIRED, "exposure",
    NumberMeta("float64", "How long to remain at each point"), REQUIRED
]

# Make a table for the layout info we need
columns = OrderedDict()
columns["name"] = StringArrayMeta("Name of layout part")
columns["mri"] = StringArrayMeta("Malcolm full name of child block")
columns["x"] = NumberArrayMeta("float64", "X Co-ordinate of child block")
columns["y"] = NumberArrayMeta("float64", "X Co-ordinate of child block")
columns["visible"] = BooleanArrayMeta("Whether child block is visible")
layout_table_meta = TableMeta("Layout of child blocks", columns=columns)

# Make a table for the port info we need
columns = OrderedDict()
columns["name"] = StringArrayMeta("Name of layout part")
columns["type"] = StringArrayMeta("Type of outport (e.g. bit or pos)")
columns["value"] = StringArrayMeta("Value of outport (e.g. PULSE1.OUT)")
outport_table_meta = TableMeta("List of ports on blocks", columns=columns)


@sm.insert
@method_takes()
class ManagerController(DefaultController):
    """RunnableDevice implementer that also exposes GUI for child parts"""
    # hooks