def __init__(self):
        grc_wxgui.top_block_gui.__init__(
            self,
            title="Complex Multiplier RX SDRstick HF1 with PBT & Variable BW")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.kHz = kHz = 0
        self.MHz = MHz = 10
        self.Hz = Hz = 0
        self.samp_rate = samp_rate = 384000
        self.pbt = pbt = 0
        self.freq = freq = MHz * 1000000 + kHz * 1000 + Hz
        self.bw = bw = 1500
        self.AF_gain = AF_gain = 2

        ##################################################
        # Blocks
        ##################################################
        _pbt_sizer = wx.BoxSizer(wx.VERTICAL)
        self._pbt_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_pbt_sizer,
            value=self.pbt,
            callback=self.set_pbt,
            label="  Passband Tuning",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._pbt_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_pbt_sizer,
            value=self.pbt,
            callback=self.set_pbt,
            minimum=-.000190,
            maximum=.000190,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_pbt_sizer)
        self._bw_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.bw,
            callback=self.set_bw,
            label="  Bandwidth",
            choices=[500, 1500, 3000, 10000],
            labels=['500', '1.5K', '3K', '10K'],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._bw_chooser)
        _AF_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._AF_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_AF_gain_sizer,
            value=self.AF_gain,
            callback=self.set_AF_gain,
            label="  Audio Gain",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._AF_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_AF_gain_sizer,
            value=self.AF_gain,
            callback=self.set_AF_gain,
            minimum=0,
            maximum=10,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_AF_gain_sizer)
        self.wxgui_fftsink2_1 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=freq,
            y_per_div=10,
            y_divs=10,
            ref_level=-30,
            ref_scale=2.0,
            sample_rate=(samp_rate),
            fft_size=4096,
            fft_rate=15,
            average=True,
            avg_alpha=.5,
            title="             LSB          Baseband Frequency kHz        USB",
            peak_hold=False,
            size=(850, 400),
        )
        self.Add(self.wxgui_fftsink2_1.win)
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            samp_rate / 48000,
            firdes.low_pass(1, samp_rate, bw / 2, 100, firdes.WIN_HAMMING,
                            6.76))
        _kHz_sizer = wx.BoxSizer(wx.VERTICAL)
        self._kHz_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_kHz_sizer,
            value=self.kHz,
            callback=self.set_kHz,
            label="kHz",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._kHz_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_kHz_sizer,
            value=self.kHz,
            callback=self.set_kHz,
            minimum=-500,
            maximum=500,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_kHz_sizer)
        self.hpsdr_hermesNB_0 = hpsdr.hermesNB(freq, freq, freq, 0, 0, 1, 1, 0,
                                               384000, "eth0", "0xF0", 0xa0, 0,
                                               0x00, 0x00, 0, 1)
        self.blocks_null_source_0 = blocks.null_source(gr.sizeof_gr_complex *
                                                       1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((1, ))
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff(
            (AF_gain, ))
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.audio_sink_0_0 = audio.sink(48000, "", True)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate / 48000, analog.GR_COS_WAVE, ((bw / 2) * pbt), .99, 0)
        self.analog_agc3_xx_0 = analog.agc3_cc(1, 1e-5, 0.5, 1.0, 1)
        self.analog_agc3_xx_0.set_max_gain(65536)
        _MHz_sizer = wx.BoxSizer(wx.VERTICAL)
        self._MHz_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_MHz_sizer,
            value=self.MHz,
            callback=self.set_MHz,
            label="MHz",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._MHz_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_MHz_sizer,
            value=self.MHz,
            callback=self.set_MHz,
            minimum=0,
            maximum=50,
            num_steps=50,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_MHz_sizer)
        _Hz_sizer = wx.BoxSizer(wx.VERTICAL)
        self._Hz_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_Hz_sizer,
            value=self.Hz,
            callback=self.set_Hz,
            label="Fine",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._Hz_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_Hz_sizer,
            value=self.Hz,
            callback=self.set_Hz,
            minimum=-1000,
            maximum=1000,
            num_steps=200,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_Hz_sizer)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc3_xx_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.audio_sink_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.wxgui_fftsink2_1, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.analog_agc3_xx_0, 0))
        self.connect((self.blocks_null_source_0, 0),
                     (self.hpsdr_hermesNB_0, 0))
        self.connect((self.hpsdr_hermesNB_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.blocks_multiply_xx_0, 0))
Пример #2
0
    def __init__(self):
        global outstem

        gr.top_block.__init__(self, "Top Block")  # necessary for all cases

        def _setupGUI(self):

            Qt.QWidget.__init__(self)
            self.setWindowTitle("Top Block")
            try:
                self.setWindowIcon(Qt.QIcon.fromTheme("gnuradio-grc"))
            except:
                pass
            self.top_scroll_layout = Qt.QVBoxLayout()
            self.setLayout(self.top_scroll_layout)
            self.top_scroll = Qt.QScrollArea()
            self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
            self.top_scroll_layout.addWidget(self.top_scroll)
            self.top_scroll.setWidgetResizable(True)
            self.top_widget = Qt.QWidget()
            self.top_scroll.setWidget(self.top_widget)
            self.top_layout = Qt.QVBoxLayout(self.top_widget)
            self.top_grid_layout = Qt.QGridLayout()
            self.top_layout.addLayout(self.top_grid_layout)

            self.settings = Qt.QSettings("GNU Radio", "top_block")
            self.restoreGeometry(self.settings.value("geometry").toByteArray())
            # %% FFT display
            self.fsink0 = qtgui.freq_sink_c(
                1024,  # size
                firdes.WIN_BLACKMAN_hARRIS,  # wintype
                Fsink0,  # fc
                Fs,  # bw
                "",  # name
                1,  # number of inputs
            )
            self.fsink0.set_update_time(0.10)
            self.fsink0.set_y_axis(-140, -10)
            # self.fsink0.set_y_label('RX Level', 'dB')
            self.fsink0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
            self.fsink0.enable_autoscale(False)
            self.fsink0.enable_grid(True)
            self.fsink0.set_fft_average(1.0)
            # self.fsink0.enable_axis_labels(True)
            self.fsink0.enable_control_panel(True)

            if not True:
                self.fsink0.disable_legend()

            if "complex" == "float" or "complex" == "msg_float":
                self.fsink0.set_plot_pos_half(not True)

            #            labels = ['', '', '', '', '',
            #                      '', '', '', '', '']
            #            widths = [1, 1, 1, 1, 1,
            #                      1, 1, 1, 1, 1]
            #            colors = ["blue", "red", "green", "black", "cyan",
            #                      "magenta", "yellow", "dark red", "dark green", "dark blue"]
            #            alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
            #                      1.0, 1.0, 1.0, 1.0, 1.0]

            #       for i in range(2):
            #          if len(labels[i]) == 0:
            #              self.fsink0.set_line_label(i, "Data {0}".format(i))
            #          else:
            #              self.fsink0.set_line_label(i, labels[i])
            #         self.fsink0.set_line_width(i, widths[i])
            #          self.fsink0.set_line_color(i, colors[i])
            #          self.fsink0.set_line_alpha(i, alphas[i])

            self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.fsink0.pyqwidget(), Qt.QWidget)
            self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)

        if GUI:
            _setupGUI()
        # %% Non-gui
        # for gr-hpsdr < 1.2
        self.hpsdr_hermesNB_0 = hpsdr.hermesNB(
            RxFreq0=F[0],
            RxFreq1=F[1],
            # for gr-hpsdr >= 1.2,
            # self.hpsdr_hermesNB_0 = hpsdr.hermesNB(F[0], F[1], F[2], F[3], F[4], F[5], F[6], F[7],
            TxFreq=FTX,
            RxPre=False,
            PTTModeSel=0,
            PTTTxMute=True,
            PTTRxMute=True,
            TxDr=0,
            RxSmp=Fs,
            Intfc=IF,
            ClkS="0xF8",
            AlexRA=0,
            AlexTA=0,
            AlexHPF=0x00,
            AlexLPF=0x00,
            Verbose=0,
            NumRx=NRX,
            MACAddr="*",
        )

        self.dummytx = analog.sig_source_c(0, analog.GR_CONST_WAVE, 0, 0, 0)

        # %% write file
        now = datetime.now().isoformat(timespec="seconds")
        outstem += now

        ofn0 = outstem + "_{}MHz.bin".format(F[0] / 1e6)
        print("writing", ofn0)
        self.file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1, ofn0, False)
        self.file_sink_0.set_unbuffered(False)

        ofn1 = outstem + "_{}MHz.bin".format(F[1] / 1e6)
        print("writing", ofn1)
        self.file_sink_1 = blocks.file_sink(gr.sizeof_gr_complex * 1, ofn1, False)
        self.file_sink_1.set_unbuffered(False)

        # %% Connections
        self.connect((self.dummytx, 0), (self.hpsdr_hermesNB_0, 0))
        if ofn0 is not None:
            self.connect((self.hpsdr_hermesNB_0, 0), (self.file_sink_0, 0))
        if ofn1 is not None:
            self.connect((self.hpsdr_hermesNB_0, 1), (self.file_sink_1, 0))

        if GUI:
            self.connect((self.hpsdr_hermesNB_0, 0), (self.fsink0, 0))
Пример #3
0
    def __init__(self):
        gr.top_block.__init__(self, "HPSDR MultiRX")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("HPSDR MultiRX")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "hpsdr_multirx")

        if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
            self.restoreGeometry(self.settings.value("geometry").toByteArray())
        else:
            self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Blocks
        ##################################################
        
        for rx_id,rx_dct in enumerate(rxs):
            self.add_waterfall(rx_id)

        self.add_frequency_display()

        freqs = [int(10e6)]*7
        for rx_id,rx_dct in enumerate(rxs):
            freqs[rx_id]  = int(rx_dct['frequency'])

        self.hpsdr_hermesNB_0 = hpsdr.hermesNB(freqs[0],freqs[1],freqs[2],freqs[3],freqs[4],freqs[5],freqs[6],
                10000000, 10000000, 0, 0, 1, 1, 0, rx_samp_rate, "enp2s0", "0xF0", 0xa0, 0, 0x00, 0x10, 0, len(rxs), "*")

        channels    = ['']*len(rxs)
        for rx_id,rx_dct in enumerate(rxs):
            channels[rx_id] = rx_dct['label']

        self.gr_digital_rf_digital_rf_sink_0 = \
            gr_digital_rf.digital_rf_sink(
                data_dir,
                channels=channels,
                dtype=np.complex64,
                subdir_cadence_secs=3600,
                file_cadence_millisecs=1000,
                sample_rate_numerator=int(rx_samp_rate),
                sample_rate_denominator=1,
                start="nowish", ignore_tags=False,
                is_complex=True, num_subchannels=1,
                uuid_str=None if ''=='' else '',
#                center_frequencies=None if () is () else (),
                center_frequencies=freqs[:len(rxs)],
                metadata=metadata,
                is_continuous=True, compression_level=0,
                checksum=False, marching_periods=True,
                stop_on_skipped=False, debug=False,
                min_chunksize=None if 0==0 else 0,
            )

        self.analog_sig_source_x_1 = analog.sig_source_c(rx_samp_rate, analog.GR_COS_WAVE, -1000, 0.95, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_1, 0), (self.hpsdr_hermesNB_0, 0))

        for rx_id,rx_dct in enumerate(rxs):
            self.connect((self.hpsdr_hermesNB_0, rx_id), (self.gr_digital_rf_digital_rf_sink_0, rx_id))

        for rx_id,rx_dct in enumerate(rxs):
            self.connect((self.hpsdr_hermesNB_0, rx_id), (self.qtgui_freq_sink_x_0, rx_id))

        for rx_id,rx_dct in enumerate(rxs):
            self.connect((self.hpsdr_hermesNB_0, rx_id), (rx_dct['qtgui_waterfall'], 0))
Пример #4
0
    def __init__(self):
        global outstem

        gr.top_block.__init__(self, "Top Block") #necessary for all cases

        def _setupGUI(self):

            Qt.QWidget.__init__(self)
            self.setWindowTitle("Top Block")
            try:
                self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
            except:
                pass
            self.top_scroll_layout = Qt.QVBoxLayout()
            self.setLayout(self.top_scroll_layout)
            self.top_scroll = Qt.QScrollArea()
            self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
            self.top_scroll_layout.addWidget(self.top_scroll)
            self.top_scroll.setWidgetResizable(True)
            self.top_widget = Qt.QWidget()
            self.top_scroll.setWidget(self.top_widget)
            self.top_layout = Qt.QVBoxLayout(self.top_widget)
            self.top_grid_layout = Qt.QGridLayout()
            self.top_layout.addLayout(self.top_grid_layout)

            self.settings = Qt.QSettings("GNU Radio", "top_block")
            self.restoreGeometry(self.settings.value("geometry").toByteArray())
# %% FFT display
            self.fsink0 = qtgui.freq_sink_c(
            	1024, #size
            	firdes.WIN_BLACKMAN_hARRIS, #wintype
            	Fsink0, #fc
            	Fs, #bw
            	"", #name
            	1 #number of inputs
            )
            self.fsink0.set_update_time(0.10)
            self.fsink0.set_y_axis(-140, -10)
            #self.fsink0.set_y_label('RX Level', 'dB')
            self.fsink0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
            self.fsink0.enable_autoscale(False)
            self.fsink0.enable_grid(True)
            self.fsink0.set_fft_average(1.0)
            #self.fsink0.enable_axis_labels(True)
            self.fsink0.enable_control_panel(True)

            if not True:
              self.fsink0.disable_legend()

            if "complex" == "float" or "complex" == "msg_float":
              self.fsink0.set_plot_pos_half(not True)

#            labels = ['', '', '', '', '',
#                      '', '', '', '', '']
#            widths = [1, 1, 1, 1, 1,
#                      1, 1, 1, 1, 1]
#            colors = ["blue", "red", "green", "black", "cyan",
#                      "magenta", "yellow", "dark red", "dark green", "dark blue"]
#            alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
#                      1.0, 1.0, 1.0, 1.0, 1.0]

     #       for i in range(2):
      #          if len(labels[i]) == 0:
      #              self.fsink0.set_line_label(i, "Data {0}".format(i))
      #          else:
      #              self.fsink0.set_line_label(i, labels[i])
       #         self.fsink0.set_line_width(i, widths[i])
      #          self.fsink0.set_line_color(i, colors[i])
      #          self.fsink0.set_line_alpha(i, alphas[i])

            self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.fsink0.pyqwidget(), Qt.QWidget)
            self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)

        if GUI:
            _setupGUI()
# %% Non-gui
        # for gr-hpsdr < 1.2
        self.hpsdr_hermesNB_0 = hpsdr.hermesNB(RxFreq0=F[0], RxFreq1=F[1],
        # for gr-hpsdr >= 1.2,
        #self.hpsdr_hermesNB_0 = hpsdr.hermesNB(F[0], F[1], F[2], F[3], F[4], F[5], F[6], F[7],
                                               TxFreq=FTX,
                                               RxPre=False, PTTModeSel=0, PTTTxMute=True, PTTRxMute=True, TxDr=0,
                                               RxSmp=Fs, Intfc=IF, ClkS="0xF8",
                                               AlexRA=0, AlexTA=0, AlexHPF=0x00, AlexLPF=0x00, Verbose=0,
                                               NumRx=NRX,MACAddr="*")

        self.dummytx = analog.sig_source_c(0, analog.GR_CONST_WAVE, 0, 0, 0)

# %% write file
        now = datetime.now().isoformat(timespec='seconds')
        outstem += now

        ofn0 = outstem + '_{}MHz.bin'.format(F[0]/1e6)
        print('writing',ofn0)
        self.file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, ofn0, False)
        self.file_sink_0.set_unbuffered(False)

        ofn1 = outstem + '_{}MHz.bin'.format(F[1]/1e6)
        print('writing',ofn1)
        self.file_sink_1 = blocks.file_sink(gr.sizeof_gr_complex*1, ofn1, False)
        self.file_sink_1.set_unbuffered(False)


# %% Connections
        self.connect((self.dummytx, 0), (self.hpsdr_hermesNB_0, 0))
        if ofn0 is not None:
             self.connect((self.hpsdr_hermesNB_0, 0), (self.file_sink_0, 0))
        if ofn1 is not None:
             self.connect((self.hpsdr_hermesNB_0, 1), (self.file_sink_1, 0))

        if GUI:
            self.connect((self.hpsdr_hermesNB_0, 0), (self.fsink0, 0))