def _discover_from_instrument(cls, parent: Instrument,
                                  **kwargs) -> List[Dict[Any, Any]]:
        """
        New channels need `name` and `channel` keyword arguments.
        """
        channels_str = parent.channel_catalog()
        channels_to_skip = kwargs.get("channels_to_skip", [])  # Note that
        # `channels_to_skip` is an optional kwarg for loading from instrument.
        # We test this by giving this keyword during the initialization of the
        # AutoLoadableChannelList.
        kwarg_list = []
        for channel_str in channels_str.split(","):

            if channel_str in channels_to_skip:
                continue

            channel = int(channel_str)
            greeting = parent.ask(f":INST:CHN{channel}:GRT")
            new_kwargs = {
                "name": f"channel{channel}",
                "channel": channel,
                "greeting": greeting
            }
            kwarg_list.append(new_kwargs)

        return kwarg_list
예제 #2
0
    def _get_new_instance_kwargs(cls,
                                 parent: Instrument = None,
                                 **kwargs) -> dict:
        """
        Find the smallest channel number not yet occupied. An optional keyword
        `greeting` is extracted from the kwargs. The default is "Hello"
        """
        channels_str = parent.channel_catalog()
        existing_channels = [int(i) for i in channels_str.split(",")]

        new_channel = 1
        while new_channel in existing_channels:
            new_channel += 1

        new_kwargs = {
            "name": f"channel{new_channel}",
            "channel": new_channel,
            "greeting": kwargs.get("greeting", "Hello")
        }

        return new_kwargs