def test_processed_signal(self): nb_samples = 10 tb = self.tb expected_result1 = [1.0] * nb_samples expected_result2 = [3.0] * nb_samples src1 = m2k.analog_in_source('ip:192.168.2.1', 0x4000, [1, 1], [0, 0], 10000, 1, 4, False, True, [0, 0], [0, 0], 0, 0, [0, 0]) op1 = blocks.head(gr.sizeof_float, nb_samples) op2 = blocks.head(gr.sizeof_float, nb_samples) msg = blocks.message_debug() dst1 = blocks.vector_sink_f() dst2 = blocks.vector_sink_f() tb.connect((src1, 0), op1) tb.connect((src1, 1), op2) tb.connect(op1, dst1) tb.connect(op2, dst2) tb.start() dst_data1 = dst1.data() dst_data2 = dst2.data() map(lambda x, y: self.assertAlmostEqual(x, y, 0.1), expected_result1, dst_data1) map(lambda x, y: self.assertAlmostEqual(x, y, 0.1), expected_result2, dst_data2)
def test_raw_signal(self): analog_in = self.ctx.getAnalogIn() nb_samples = 10 tb = self.tb expected_result1 = [1.0] * nb_samples expected_result2 = [3.0] * nb_samples src1 = m2k.analog_in_source('ip:192.168.2.1', 1024, [1, 1], [0, 0], 10000, 1, 4, False, False, [0, 0], [0, 0], 0, 0, [0, 0]) op1 = blocks.head(gr.sizeof_short, nb_samples) op2 = blocks.head(gr.sizeof_short, nb_samples) dst1 = blocks.vector_sink_s() dst2 = blocks.vector_sink_s() tb.connect((src1, 0), op1) tb.connect((src1, 1), op2) tb.connect(op1, dst1) tb.connect(op2, dst2) tb.start() dst_data1 = dst1.data() dst_data2 = dst2.data() map( lambda x, y: self.assertAlmostEqual( x, analog_in.convertRawToVolts(0, y), 0.1), expected_result1, dst_data1) map( lambda x, y: self.assertAlmostEqual( x, analog_in.convertRawToVolts(1, y), 0.1), expected_result2, dst_data2)
def __init__(self): gr.top_block.__init__(self, "Not titled yet") Qt.QWidget.__init__(self) self.setWindowTitle("Not titled yet") 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", "m2k_am_if_to_fm_pluto_tx") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.tx_samp_rate = tx_samp_rate = 600000 self.tx_freq = tx_freq = 90e6 self.samp_rate = samp_rate = 10000000 self.rr_interp = rr_interp = 8 self.rr_decim = rr_decim = 5 self.osr = osr = 5 self.lp_decim = lp_decim = 10 self.if_freq = if_freq = 475000 self.fx_decim = fx_decim = 10 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=rr_interp, decimation=rr_decim, taps=[128], fractional_bw=0.8) self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f( 4096, #size samp_rate / (osr * fx_decim), #samp_rate "Demodulated Baseband", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_1.set_update_time(0.10) self.qtgui_time_sink_x_0_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_1.enable_tags(True) self.qtgui_time_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_1.enable_autoscale(True) self.qtgui_time_sink_x_0_1.enable_grid(True) self.qtgui_time_sink_x_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_0_1.enable_control_panel(True) self.qtgui_time_sink_x_0_1.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] 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] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_1_win = sip.wrapinstance( self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c( 4096, #size samp_rate / (osr * fx_decim), #samp_rate "Translated I.F.", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(True) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] 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] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.m2k_analog_in_source_0 = m2k.analog_in_source( 'ip:192.168.3.1', 16384, [True, False], [0, 0], samp_rate, osr, 4, True, True, [2, 0], [0, 0], 0, 0, [0, 0]) self.low_pass_filter_0 = filter.fir_filter_fff( lp_decim, firdes.low_pass(1, samp_rate / (osr * fx_decim), 3000, 500, firdes.WIN_HAMMING, 6.76)) self.iio_pluto_sink_0 = iio.pluto_sink('ip:192.168.2.1', int(tx_freq), tx_samp_rate, 200000, 32768, False, 0, '', True) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_fcc( fx_decim, firdes.low_pass(1, (samp_rate / osr), (samp_rate / osr) / (2 * fx_decim), 20000), if_freq, samp_rate / osr) self.dc_blocker_xx_0 = filter.dc_blocker_ff(32, True) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(1) self.blocks_complex_to_mag_1 = blocks.complex_to_mag(1) self.audio_sink_0 = audio.sink(32000, '', False) self.analog_wfm_tx_0 = analog.wfm_tx( audio_rate=int(samp_rate / (osr * fx_decim * lp_decim)), quad_rate=tx_samp_rate, tau=75e-6, max_dev=150e3, fh=-1.0, ) ################################################## # Connections ################################################## self.connect((self.analog_wfm_tx_0, 0), (self.iio_pluto_sink_0, 0)) self.connect((self.blocks_complex_to_mag_1, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.blocks_complex_to_mag_1, 0), (self.qtgui_time_sink_x_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 1)) self.connect((self.dc_blocker_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_complex_to_mag_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_tx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.m2k_analog_in_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Not titled yet") Qt.QWidget.__init__(self) self.setWindowTitle("Not titled yet") 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", "first_m2k") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.samp_rate = samp_rate = 100000 self.m2k_ctx = m2k_ctx = "ip:192.168.3.1" ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] 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] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) self.m2k_analog_in_source_0 = m2k.analog_in_source( m2k_ctx, 8192, [True, True], [0, 0], samp_rate, 1, 4, True, True, [0, 0], [0, 0], 0, 0, [0, 0]) ################################################## # Connections ################################################## self.connect((self.m2k_analog_in_source_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.m2k_analog_in_source_0, 1), (self.qtgui_time_sink_x_0, 1))