Exemple #1
0
def set_tags(
    meta: VMeta,
    writeable: AWriteable = False,
    config: AConfig = 1,
    group: AGroup = None,
    widget: AWidget = None,
    sink_port: ASinkPort = None,
    port_badge: APortBadge = None,
) -> None:
    tags = []
    meta.set_writeable(writeable)
    if widget is None:
        widget = meta.default_widget()
    if widget is not Widget.NONE:
        tags.append(widget.tag())
    if config and writeable:
        # We only allow config tags on writeable functions
        tags.append(config_tag(config))
    if group:
        # If we have a group then add the tag
        tags.append(group_tag(group))
    if sink_port:
        tags.append(sink_port.sink_port_tag(disconnected_value=""))
        if port_badge:
            tags.append(port_badge)
    meta.set_tags(tags)
Exemple #2
0
 def __init__(
     self,
     meta: VMeta,
     datatype: Any,
     writeable: bool,
     min_delta: AMinDelta = 0.05,
     timeout: ATimeout = DEFAULT_TIMEOUT,
     sink_port: ASinkPort = None,
     widget: AWidget = None,
     group: AGroup = None,
     config: AConfig = 1,
     on_connect: Callable[[Any], None] = None,
     throw: AThrow = True,
     callback: Callable[[Any], None] = None,
     port_badge: APortBadge = None,
 ) -> None:
     self.writeable = writeable
     builtin.util.set_tags(
         meta, writeable, config, group, widget, sink_port, port_badge
     )
     self.throw = throw
     self.datatype = datatype
     self.min_delta = min_delta
     self.timeout = timeout
     self.on_connect = on_connect
     self.attr = meta.create_attribute_model()
     # Camonitor subscription
     self.monitor = None
     self._update_after = 0
     self._local_value: Optional[CATable] = None
     self._user_callback = callback
Exemple #3
0
 def setUp(self):
     self.meta = VMeta("test description")
     self.serialized = OrderedDict()
     self.serialized["typeid"] = "filled_in_by_subclass"
     self.serialized["description"] = "desc"
     self.serialized["tags"] = []
     self.serialized["writeable"] = True
     self.serialized["label"] = "my label"
Exemple #4
0
 def create_info(cls, configure_func: Callable) -> ConfigureParamsInfo:
     """Create a `ConfigureParamsInfo` describing the extra parameters
     that should be passed at configure"""
     call_types: Dict[str, Anno] = getattr(configure_func, "call_types", {})
     metas = OrderedDict()
     required = []
     defaults = OrderedDict()
     for k, anno in call_types.items():
         if k not in cls.call_types:
             scls = VMeta.lookup_annotype_converter(anno)
             metas[k] = scls.from_annotype(anno, writeable=True)
             if anno.default is NO_DEFAULT:
                 required.append(k)
             elif anno.default is not None:
                 defaults[k] = anno.default
     return ConfigureParamsInfo(metas, required, defaults)
Exemple #5
0
 def test_to_dict(self):
     m = VMeta("desc", writeable=True, label="my label")
     m.typeid = "filled_in_by_subclass"
     assert m.to_dict() == self.serialized