예제 #1
0
    def __init__(self, max_items_group):
        """
        CTOR.
        @param device     RadioDevice instance.
        @param detector   A SS detector. 
        @param max_items_group Number of ouputs to group.
        @return A tuple with 3 elements: (final decision, energy, avg energy)
        """

        #
        self._detector = SimpleRankingDetector(512, 5, 0.3)

        # Group items
        self._grouper = GroupInN(max_items_group=max_items_group, callback=None, n_inputs=2)

        UHDSSArch.__init__(
            self,
            name="ranking_arch",
            input_signature=gr.io_signature(1, 1, gr.sizeof_gr_complex),
            output_signature=gr.io_signature(0, 0, 0),
        )
예제 #2
0
class RankingArch(UHDSSArch):
    """
    Ranking architecture.
    Construct the ranking architecture.
    """

    def __init__(self, max_items_group):
        """
        CTOR.
        @param device     RadioDevice instance.
        @param detector   A SS detector. 
        @param max_items_group Number of ouputs to group.
        @return A tuple with 3 elements: (final decision, energy, avg energy)
        """

        #
        self._detector = SimpleRankingDetector(512, 5, 0.3)

        # Group items
        self._grouper = GroupInN(max_items_group=max_items_group, callback=None, n_inputs=2)

        UHDSSArch.__init__(
            self,
            name="ranking_arch",
            input_signature=gr.io_signature(1, 1, gr.sizeof_gr_complex),
            output_signature=gr.io_signature(0, 0, 0),
        )

    def _build(self, input_signature, output_signature):
        """
        """

        self._add_connections([(self._detector, 0), (self._grouper, 0)])
        self._add_connections([(self._detector, 1), (self._grouper, 1)])

        return self._detector

        # no outputs

    def _get_sensing_data(self, the_channel, sensing_time):
        """
        Configure the device to sense the given frequency.
        @param the_channel Channel object instance. Channel to sense.
        @param sensing_time Duration of sensing.
        @return SS information of channel.
        """

        # Configure device center frequency
        # ::TRICK:: self._device  can be a DeviceChannelModel object
        #           If is the case, then check the DeviceChannelModel::center_freq method
        self.radio.set_center_freq(the_channel)

        self._grouper.set_enable(True)
        time.sleep(sensing_time)
        self._grouper.set_enable(False)

        return self._grouper.get_items()

    def sense_channel(self, the_channel, sensing_time):
        """
        ## SS on a single channel
        # Reimplement from UHDSSArch::sense_channel
        # @param the_channel Channel to be sensed.
        # @param sensing_time Sensing duration on channel.
        """
        return self._get_sensing_data(the_channel, sensing_time)

    def sense_channel_list(self, the_list, sensing_time):
        """
        @param the_list
        @param sensing_time
        """
        res = []

        for channel in the_list:
            x = self.sense_channel(channel, sensing_time)

            res.append((channel.get_channel(), x))

        return res