Exemplo n.º 1
0
class TestAttribute(unittest.TestCase):
    def setUp(self):
        self.meta = StringMeta()
        self.o = self.meta.create_attribute_model()

    def test_init(self):
        self.assertIs(self.o.meta, self.meta)
        assert self.o.value == ""
        assert self.o.typeid == "epics:nt/NTScalar:1.0"

    def test_set_value(self):
        value = "test_value"
        self.o.set_value(value)
        assert self.o.value == value

    def test_set_alarm(self):
        alarm = Alarm(AlarmSeverity.MAJOR_ALARM, AlarmStatus.DEVICE_STATUS,
                      "bad")
        self.o.set_alarm(alarm)
        assert self.o.alarm == alarm

    def test_set_timeStamp(self):
        timeStamp = TimeStamp()
        self.o.set_timeStamp(timeStamp)
        assert self.o.timeStamp == timeStamp
Exemplo n.º 2
0
 def __init__(self, value):
     # type: (Value) -> None
     super(TitlePart, self).__init__("label")
     meta = StringMeta("Label for the block")
     set_tags(meta, writeable=True)
     self.attr = meta.create_attribute_model()
     self.registrar = None  # type: PartRegistrar
     self.initial_value = value
Exemplo n.º 3
0
 def __init__(self, svg: ASvg = "") -> None:
     super().__init__("icon")
     meta = StringMeta("SVG icon for the Block")
     set_tags(meta, widget=Widget.ICON)
     try:
         with open(svg) as f:
             self.svg_text = f.read()
     except IOError:
         self.svg_text = "<svg/>"
     self.attr = meta.create_attribute_model(self.svg_text)
Exemplo n.º 4
0
 def __init__(
     self,
     help_url: AHelpUrl,
     name: APartName = "help",
     description: ADesc = "Help documentation for the Block",
 ) -> None:
     super().__init__(name)
     meta = StringMeta(description)
     set_tags(meta, widget=Widget.HELP)
     self.attr = meta.create_attribute_model(help_url)
Exemplo n.º 5
0
 def __init__(self,
              name: APartName,
              rbv: ARbv,
              group: AGroup = None) -> None:
     super().__init__(name)
     meta = StringMeta("CS Axis")
     builtin.util.set_tags(meta, group=group, sink_port=Port.MOTOR)
     self.rbv = rbv
     self.attr = meta.create_attribute_model()
     # Subscriptions
     self.monitor = None
Exemplo n.º 6
0
 def __init__(self, name, rbv, group=None):
     # type: (ca.util.APartName, ca.util.ARbv, ca.util.AGroup) -> None
     super(CompoundMotorCSPart, self).__init__(name)
     meta = StringMeta("CS Axis")
     builtin.util.set_tags(meta, group=group, sink_port=Port.MOTOR)
     self.rbv = rbv
     self.attr = meta.create_attribute_model()
     # Subscriptions
     self.monitor = None
     # Hooks
     self.register_hooked(builtin.hooks.DisableHook, self.disconnect)
     self.register_hooked((builtin.hooks.InitHook, builtin.hooks.ResetHook),
                          self.reconnect)
Exemplo n.º 7
0
 def __init__(
     self,
     name: APartName,
     description: AMetaDescription,
     writeable: AWriteable = True,
     config: AConfig = 1,
     group: AGroup = None,
     widget: AWidget = None,
     value: AValue = "",
 ) -> None:
     super().__init__(name)
     meta = StringMeta(description)
     set_tags(meta, writeable, config, group, widget, sink_port=Port.BLOCK)
     self.attr = meta.create_attribute_model(value)
     self.writeable_func = self.attr.set_value if writeable else None
Exemplo n.º 8
0
 def __init__(
         self,
         name,  # type: APartName
         description,  # type: AMetaDescription
         writeable=False,  # type: AWriteable
         config=1,  # type: AConfig
         group=None,  # type: AGroup
         widget=None,  # type: AWidget
         value="",  # type: Value
 ):
     # type: (...) -> None
     super(StringPart, self).__init__(name)
     meta = StringMeta(description)
     set_tags(meta, writeable, config, group, widget)
     self.attr = meta.create_attribute_model(value)
     self.writeable_func = self.attr.set_value if writeable else None
Exemplo n.º 9
0
 def __init__(self, value: ALabelValue = None) -> None:
     super().__init__("label")
     meta = StringMeta("Label for the block")
     set_tags(meta, writeable=True)
     self.initial_value = value
     self.attr = meta.create_attribute_model(self.initial_value)
Exemplo n.º 10
0
 def __init__(self, help_url, name="help"):
     # type: (HelpUrl, APartName) -> None
     super(HelpPart, self).__init__(name)
     meta = StringMeta("Help documentation for the Block")
     set_tags(meta, widget=Widget.HELP)
     self.attr = meta.create_attribute_model(help_url)