Ejemplo n.º 1
0
 def create_attributes(self):
     self.value = Attribute(NumberMeta(description="Value"))
     self.value.meta.set_dtype('float64')
     yield 'value', self.value
     self.generator = Attribute(
         PointGeneratorMeta(description="Scan Point Generator"))
     yield "generator", self.generator
     self.axis_name = Attribute(StringMeta(description="Name of the axis"))
     yield "axis_name", self.axis_name
     self.exposure = Attribute(NumberMeta(description="Exposure time"))
     self.value.meta.set_dtype('float64')
     yield "exposure", self.exposure
 def test_create_children(self, attribute_mock, method_mock):
     # Load up items to create
     mi1, mi2 = MagicMock(), MagicMock()
     method_mock.side_effect = [mi1, mi2]
     ai1, ai2 = MagicMock(), MagicMock()
     attribute_mock.side_effect = [ai1, ai2]
     # Load up refs to get
     group_attr = Attribute()
     child_attr = self.make_grouped_attr()
     m1 = MethodMeta()
     m2 = MethodMeta()
     BlockItem.items[("endpoint", "foo")] = ai1
     self.item.ref = OrderedDict((
         ("foo", group_attr), ("c", child_attr), ("a", m1), ("b", m2)))
     self.item.create_children()
     # Check it made the right thing
     self.assertEqual(len(self.item.children), 3)
     attribute_mock.assert_any_call(("endpoint", "foo"), group_attr)
     self.assertEqual(self.item.children[0], ai1)
     attribute_mock.assert_any_call(("endpoint", "c"), child_attr)
     ai1.add_child.assert_called_once_with(ai2)
     method_mock.assert_any_call(("endpoint", "a"), m1)
     self.assertEqual(self.item.children[1], mi1)
     method_mock.assert_any_call(("endpoint", "b"), m2)
     self.assertEqual(self.item.children[2], mi2)
Ejemplo n.º 3
0
 def create_attributes(self):
     params = self.params
     if params.pv is None and params.rbv is None:
         raise ValueError('must pass pv rbv')
     if params.rbv is None:
         if params.rbv_suff is None:
             params.rbv = params.pv
         else:
             params.rbv = params.pv + params.rbv_suff
     # Meta instance
     self.name = params.name
     self.meta = self.create_meta(params.description)
     # Pv strings
     self.pv = params.pv
     self.rbv = params.rbv
     # camonitor subscription
     self.monitor = None
     self.ca_format = catools.FORMAT_CTRL
     # This will be our attr
     self.attr = None
     # The attribute we will be publishing
     self.attr = Attribute(self.meta)
     self.attr.set_put_function(self.caput)
     yield self.name, self.attr
Ejemplo n.º 4
0
 def setUp(self):
     self.data = StringMeta().create_attribute_model()
     self.data.set_notifier_path(Mock(), ["block", "attr"])
     self.controller = Mock()
     self.context = Mock()
     self.o = Attribute(self.controller, self.context, self.data)
Ejemplo n.º 5
0
 def create_attributes(self):
     self.counter = Attribute(NumberMeta(description="A counter"))
     self.counter.meta.set_dtype('uint32')
     self.counter.set_put_function(self.counter.set_value)
     self.counter.set_value(0)
     yield "counter", self.counter
 def test_grouped_children(self):
     attr = self.make_grouped_attr()
     self.item.ref = dict(c=attr, d=Attribute())
     self.assertEqual(self.item.ref_children(), 1)
 def make_grouped_attr(self):
     attr = Attribute()
     attr.set_endpoint_data("meta", MagicMock())
     attr.meta.tags = ["group:foo"]
     return attr
 def test_ref_children(self):
     self.item.ref = dict(
         a=MethodMeta(), b=MethodMeta(), c=Attribute())
     self.assertEqual(self.item.ref_children(), 3)