def __init__(self): gr.top_block.__init__(self, "Dvbs2 Tx") Qt.QWidget.__init__(self) self.setWindowTitle("Dvbs2 Tx") 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", "dvbs2_tx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 5000000 self.vga2_gain = vga2_gain = 10 self.vga1_gain = vga1_gain = -8 self.tx_gain = tx_gain = 50 self.taps = taps = 100 self.samp_rate = samp_rate = symbol_rate * 2 self.rolloff = rolloff = 0.2 self.center_freq = center_freq = 1280e6 ################################################## # Blocks ################################################## self._vga2_gain_range = Range(0, 25, 1, 10, 200) self._vga2_gain_win = RangeWidget(self._vga2_gain_range, self.set_vga2_gain, "vga2_gain", "counter_slider", int) self.top_layout.addWidget(self._vga2_gain_win) self._vga1_gain_range = Range(-35, -4, 1, -8, 200) self._vga1_gain_win = RangeWidget(self._vga1_gain_range, self.set_vga1_gain, "vga1_gain", "counter_slider", int) self.top_layout.addWidget(self._vga1_gain_win) self._tx_gain_range = Range(0, 89, 1, 50, 200) self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, "tx_gain", "counter_slider", float) self.top_layout.addWidget(self._tx_gain_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype center_freq, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.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 xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + 'bladerf=0,buffers=128,buflen=32768') self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(center_freq, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(vga2_gain, 0) self.osmosdr_sink_0.set_if_gain(0, 0) self.osmosdr_sink_0.set_bb_gain(vga1_gain, 0) self.osmosdr_sink_0.set_antenna('', 0) self.osmosdr_sink_0.set_bandwidth(6000000, 0) self.fft_filter_xxx_0 = filter.fft_filter_ccc( 1, (firdes.root_raised_cosine(1.0, samp_rate, samp_rate / 2, rolloff, taps)), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.dvbs2_physical_cc_0 = dvbs2.physical_cc(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.MOD_16APSK, dvbs2.PILOTS_ON, 0) self.dvbs2_modulator_bc_0 = dvbs2.modulator_bc(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.MOD_16APSK) self.dvbs2_ldpc_bb_0 = dvbs2.ldpc_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.MOD_OTHER) self.dvbs2_interleaver_bb_0 = dvbs2.interleaver_bb( dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.MOD_16APSK) self.dvbs2_bch_bb_0 = dvbs2.bch_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10) self.dvbs2_bbscrambler_bb_0 = dvbs2.bbscrambler_bb( dvbs2.FECFRAME_NORMAL, dvbs2.C9_10) self.dvbs2_bbheader_bb_0 = dvbs2.bbheader_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.RO_0_20) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/run/shm/adv16apsk910.ts', True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.dvbs2_bbheader_bb_0, 0)) self.connect((self.dvbs2_bbheader_bb_0, 0), (self.dvbs2_bbscrambler_bb_0, 0)) self.connect((self.dvbs2_bbscrambler_bb_0, 0), (self.dvbs2_bch_bb_0, 0)) self.connect((self.dvbs2_bch_bb_0, 0), (self.dvbs2_ldpc_bb_0, 0)) self.connect((self.dvbs2_interleaver_bb_0, 0), (self.dvbs2_modulator_bc_0, 0)) self.connect((self.dvbs2_ldpc_bb_0, 0), (self.dvbs2_interleaver_bb_0, 0)) self.connect((self.dvbs2_modulator_bc_0, 0), (self.dvbs2_physical_cc_0, 0)) self.connect((self.dvbs2_physical_cc_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Dvbs2 Tx") ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 5000000 self.taps = taps = 50 self.samp_rate = samp_rate = symbol_rate * 2 self.rolloff = rolloff = 0.2 ################################################## # Blocks ################################################## self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=1280000000, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.13333, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "bladerf=0,buffers=128,buflen=32768" ) self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(1280e6, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(15, 0) self.osmosdr_sink_0.set_if_gain(0, 0) self.osmosdr_sink_0.set_bb_gain(-10, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(6000000, 0) self.fft_filter_xxx_0 = filter.fft_filter_ccc(1, (firdes.root_raised_cosine(1, samp_rate, samp_rate/2, rolloff, taps)), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.dvbs2_physical_cc_0 = dvbs2.physical_cc(dvbs2.MOD_16APSK, dvbs2.C9_10, dvbs2.PILOTS_ON, dvbs2.FECFRAME_NORMAL, 0) self.dvbs2_modulator_bc_0 = dvbs2.modulator_bc(dvbs2.MOD_16APSK, dvbs2.C9_10, dvbs2.FECFRAME_NORMAL) self.dvbs2_ldpc_bb_0 = dvbs2.ldpc_bb(dvbs2.C9_10, dvbs2.FECFRAME_NORMAL, dvbs2.MOD_OTHER) self.dvbs2_interleaver_bb_0 = dvbs2.interleaver_bb(dvbs2.MOD_16APSK, dvbs2.C_OTHER, dvbs2.FECFRAME_NORMAL) self.dvbs2_bch_bb_0 = dvbs2.bch_bb(dvbs2.C9_10, dvbs2.FECFRAME_NORMAL) self.dvbs2_bbscrambler_bb_0 = dvbs2.bbscrambler_bb(dvbs2.C9_10, dvbs2.FECFRAME_NORMAL) self.dvbs2_bbheader_bb_0 = dvbs2.bbheader_bb(dvbs2.C9_10, dvbs2.RO_0_20, dvbs2.FECFRAME_NORMAL) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/run/shm/adv16apsk910.ts", True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.dvbs2_bbheader_bb_0, 0)) self.connect((self.dvbs2_bbheader_bb_0, 0), (self.dvbs2_bbscrambler_bb_0, 0)) self.connect((self.dvbs2_bbscrambler_bb_0, 0), (self.dvbs2_bch_bb_0, 0)) self.connect((self.dvbs2_bch_bb_0, 0), (self.dvbs2_ldpc_bb_0, 0)) self.connect((self.dvbs2_ldpc_bb_0, 0), (self.dvbs2_interleaver_bb_0, 0)) self.connect((self.dvbs2_interleaver_bb_0, 0), (self.dvbs2_modulator_bc_0, 0)) self.connect((self.dvbs2_modulator_bc_0, 0), (self.dvbs2_physical_cc_0, 0)) self.connect((self.dvbs2_physical_cc_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0))
def main(args): nargs = len(args) if nargs == 1: infile = args[0] outfile = None elif nargs == 2: infile = args[0] outfile = args[1] else: sys.stderr.write("Usage: dvbs2-blade.py input_file [output_file]\n"); sys.exit(1) symbol_rate = 5000000 samp_rate = symbol_rate * 2 frame_size = dvbs2.FECFRAME_NORMAL constellation = dvbs2.MOD_16APSK code_rate = dvbs2.C9_10 pilots = dvbs2.PILOTS_ON rolloff = dvbs2.RO_0_20 gold_code = 0 rrc_taps = 50 center_freq = 1280000000 txvga1_gain = -10 txvga2_gain = 15 bandwidth = 6000000 if constellation == dvbs2.MOD_QPSK: if ( code_rate == dvbs2.C1_4 or code_rate == dvbs2.C1_3 or code_rate == dvbs2.C2_5 or code_rate == dvbs2.C1_2 or code_rate == dvbs2.C3_5 or code_rate == dvbs2.C2_3 or code_rate == dvbs2.C3_4 or code_rate == dvbs2.C4_5 or code_rate == dvbs2.C5_6 or code_rate == dvbs2.C8_9 or code_rate == dvbs2.C9_10 or code_rate == dvbs2.C13_45 or code_rate == dvbs2.C9_20 or code_rate == dvbs2.C11_20 or code_rate == dvbs2.C11_45 or code_rate == dvbs2.C4_15 or code_rate == dvbs2.C14_45 or code_rate == dvbs2.C7_15 or code_rate == dvbs2.C8_15 or code_rate == dvbs2.C32_45): pass else: sys.stderr.write("Invalid code rate for QPSK\n"); sys.exit(1) if constellation == dvbs2.MOD_8PSK: if ( code_rate == dvbs2.C3_5 or code_rate == dvbs2.C2_3 or code_rate == dvbs2.C3_4 or code_rate == dvbs2.C5_6 or code_rate == dvbs2.C8_9 or code_rate == dvbs2.C9_10 or code_rate == dvbs2.C23_36 or code_rate == dvbs2.C25_36 or code_rate == dvbs2.C13_18 or code_rate == dvbs2.C7_15 or code_rate == dvbs2.C8_15 or code_rate == dvbs2.C26_45 or code_rate == dvbs2.C32_45): pass else: sys.stderr.write("Invalid code rate for 8PSK\n"); sys.exit(1) if constellation == dvbs2.MOD_8APSK: if ( code_rate == dvbs2.C100_180 or code_rate == dvbs2.C104_180): pass else: sys.stderr.write("Invalid code rate for 8APSK\n"); sys.exit(1) if constellation == dvbs2.MOD_16APSK: if ( code_rate == dvbs2.C2_3 or code_rate == dvbs2.C3_4 or code_rate == dvbs2.C4_5 or code_rate == dvbs2.C5_6 or code_rate == dvbs2.C8_9 or code_rate == dvbs2.C9_10 or code_rate == dvbs2.C26_45 or code_rate == dvbs2.C3_5 or code_rate == dvbs2.C28_45 or code_rate == dvbs2.C23_36 or code_rate == dvbs2.C25_36 or code_rate == dvbs2.C13_18 or code_rate == dvbs2.C140_180 or code_rate == dvbs2.C154_180 or code_rate == dvbs2.C7_15 or code_rate == dvbs2.C8_15 or code_rate == dvbs2.C26_45 or code_rate == dvbs2.C3_5 or code_rate == dvbs2.C32_45): pass else: sys.stderr.write("Invalid code rate for 16APSK\n"); sys.exit(1) if constellation == dvbs2.MOD_8_8APSK: if ( code_rate == dvbs2.C90_180 or code_rate == dvbs2.C96_180 or code_rate == dvbs2.C100_180 or code_rate == dvbs2.C18_30 or code_rate == dvbs2.C20_30): pass else: sys.stderr.write("Invalid code rate for 8+8APSK\n"); sys.exit(1) if constellation == dvbs2.MOD_32APSK: if ( code_rate == dvbs2.C3_4 or code_rate == dvbs2.C4_5 or code_rate == dvbs2.C5_6 or code_rate == dvbs2.C8_9 or code_rate == dvbs2.C9_10): pass else: sys.stderr.write("Invalid code rate for 32APSK\n"); sys.exit(1) if constellation == dvbs2.MOD_4_12_16APSK: if ( code_rate == dvbs2.C2_3 or code_rate == dvbs2.C32_45): pass else: sys.stderr.write("Invalid code rate for 4+12+16rbAPSK\n"); sys.exit(1) if constellation == dvbs2.MOD_4_8_4_16APSK: if ( code_rate == dvbs2.C128_180 or code_rate == dvbs2.C132_180 or code_rate == dvbs2.C140_180): pass else: sys.stderr.write("Invalid code rate for 4+8+4+16APSK\n"); sys.exit(1) if constellation == dvbs2.MOD_64APSK: if ( code_rate == dvbs2.C128_180): pass else: sys.stderr.write("Invalid code rate for 64APSK\n"); sys.exit(1) if constellation == dvbs2.MOD_4_12_20_28APSK: if ( code_rate == dvbs2.C132_180): pass else: sys.stderr.write("Invalid code rate for 4+12+20+28APSK\n"); sys.exit(1) if constellation == dvbs2.MOD_8_16_20_20APSK: if ( code_rate == dvbs2.C7_9 or code_rate == dvbs2.C4_5 or code_rate == dvbs2.C5_6): pass else: sys.stderr.write("Invalid code rate for 8+16+20+20APSK\n"); sys.exit(1) if constellation == dvbs2.MOD_128APSK: if ( code_rate == dvbs2.C135_180 or code_rate == dvbs2.C140_180): pass else: sys.stderr.write("Invalid code rate for 128APSK\n"); sys.exit(1) if constellation == dvbs2.MOD_256APSK: if ( code_rate == dvbs2.C20_30 or code_rate == dvbs2.C22_30 or code_rate == dvbs2.C116_180 or code_rate == dvbs2.C124_180 or code_rate == dvbs2.C128_180 or code_rate == dvbs2.C135_180): pass else: sys.stderr.write("Invalid code rate for 256APSK\n"); sys.exit(1) if rolloff == dvbs2.RO_0_05: rrc_rolloff = 0.05 elif rolloff == dvbs2.RO_0_10: rrc_rolloff = 0.10 elif rolloff == dvbs2.RO_0_15: rrc_rolloff = 0.15 elif rolloff == dvbs2.RO_0_20: rrc_rolloff = 0.20 elif rolloff == dvbs2.RO_0_25: rrc_rolloff = 0.25 elif rolloff == dvbs2.RO_0_35: rrc_rolloff = 0.35 if ( code_rate == dvbs2.C3_5 or code_rate == dvbs2.C4_5 or code_rate == dvbs2.C5_6 or code_rate == dvbs2.C7_9 or code_rate == dvbs2.C13_18 or code_rate == dvbs2.C23_36 or code_rate == dvbs2.C25_36 or code_rate == dvbs2.C26_45 or code_rate == dvbs2.C28_45 or code_rate == dvbs2.C90_180 or code_rate == dvbs2.C96_180 or code_rate == dvbs2.C100_180 or code_rate == dvbs2.C116_180 or code_rate == dvbs2.C124_180 or code_rate == dvbs2.C128_180 or code_rate == dvbs2.C135_180 or code_rate == dvbs2.C140_180): code_rate_interleaver = code_rate else: code_rate_interleaver = dvbs2.C_OTHER if ( code_rate == dvbs2.C2_3 or code_rate == dvbs2.C3_4 or code_rate == dvbs2.C4_5 or code_rate == dvbs2.C5_6 or code_rate == dvbs2.C8_9 or code_rate == dvbs2.C9_10 or code_rate == dvbs2.C90_180 or code_rate == dvbs2.C96_180 or code_rate == dvbs2.C100_180 or code_rate == dvbs2.C104_180 or code_rate == dvbs2.C26_45 or code_rate == dvbs2.C18_30 or code_rate == dvbs2.C28_45 or code_rate == dvbs2.C23_36 or code_rate == dvbs2.C116_180 or code_rate == dvbs2.C20_30 or code_rate == dvbs2.C124_180 or code_rate == dvbs2.C25_36 or code_rate == dvbs2.C128_180 or code_rate == dvbs2.C13_18 or code_rate == dvbs2.C132_180 or code_rate == dvbs2.C22_30 or code_rate == dvbs2.C135_180 or code_rate == dvbs2.C140_180 or code_rate == dvbs2.C7_9 or code_rate == dvbs2.C154_180): code_rate_modulator = code_rate else: code_rate_modulator = dvbs2.C_OTHER if constellation == dvbs2.MOD_128APSK: constellation_ldpc = constellation else: constellation_ldpc = dvbs2.MOD_OTHER tb = gr.top_block() src = blocks.file_source(gr.sizeof_char, infile, True) dvbs2_bbheader = dvbs2.bbheader_bb(code_rate, rolloff, frame_size) dvbs2_bbscrambler = dvbs2.bbscrambler_bb(code_rate, frame_size) dvbs2_bch = dvbs2.bch_bb(code_rate, frame_size) dvbs2_ldpc = dvbs2.ldpc_bb(code_rate, frame_size, constellation) dvbs2_interleaver = dvbs2.interleaver_bb(constellation, code_rate_interleaver, frame_size) dvbs2_modulator = dvbs2.modulator_bc(constellation, code_rate_modulator, frame_size) dvbs2_physical = dvbs2.physical_cc(constellation, code_rate, pilots, frame_size, gold_code) fft_filter = filter.fft_filter_ccc(1, (firdes.root_raised_cosine(1, samp_rate, samp_rate/2, rrc_rolloff, rrc_taps)), 1) fft_filter.declare_sample_delay(0) out = osmosdr.sink(args="bladerf=0,buffers=128,buflen=32768") out.set_sample_rate(samp_rate) out.set_center_freq(center_freq, 0) out.set_freq_corr(0, 0) out.set_gain(txvga2_gain, 0) out.set_bb_gain(txvga1_gain, 0) out.set_bandwidth(bandwidth, 0) tb.connect(src, dvbs2_bbheader) tb.connect(dvbs2_bbheader, dvbs2_bbscrambler) tb.connect(dvbs2_bbscrambler, dvbs2_bch) tb.connect(dvbs2_bch, dvbs2_ldpc) tb.connect(dvbs2_ldpc, dvbs2_interleaver) tb.connect(dvbs2_interleaver, dvbs2_modulator) tb.connect(dvbs2_modulator, dvbs2_physical) tb.connect(dvbs2_physical, fft_filter) tb.connect(fft_filter, out) if outfile: dst = blocks.file_sink(gr.sizeof_gr_complex, outfile) tb.connect(fft_filter, dst) tb.run()
def main(args): nargs = len(args) if nargs == 1: infile = args[0] outfile = None elif nargs == 2: infile = args[0] outfile = args[1] else: sys.stderr.write("Usage: dvbs2-blade.py input_file [output_file]\n") sys.exit(1) symbol_rate = 5000000 samp_rate = symbol_rate * 2 frame_size = dvbs2.FECFRAME_NORMAL constellation = dvbs2.MOD_16APSK code_rate = dvbs2.C9_10 pilots = dvbs2.PILOTS_ON rolloff = dvbs2.RO_0_20 gold_code = 0 rrc_taps = 50 center_freq = 1280000000 txvga1_gain = -10 txvga2_gain = 15 bandwidth = 6000000 if constellation == dvbs2.MOD_QPSK: if (code_rate == dvbs2.C1_4 or code_rate == dvbs2.C1_3 or code_rate == dvbs2.C2_5 or code_rate == dvbs2.C1_2 or code_rate == dvbs2.C3_5 or code_rate == dvbs2.C2_3 or code_rate == dvbs2.C3_4 or code_rate == dvbs2.C4_5 or code_rate == dvbs2.C5_6 or code_rate == dvbs2.C8_9 or code_rate == dvbs2.C9_10 or code_rate == dvbs2.C13_45 or code_rate == dvbs2.C9_20 or code_rate == dvbs2.C11_20 or code_rate == dvbs2.C11_45 or code_rate == dvbs2.C4_15 or code_rate == dvbs2.C14_45 or code_rate == dvbs2.C7_15 or code_rate == dvbs2.C8_15 or code_rate == dvbs2.C32_45): pass else: sys.stderr.write("Invalid code rate for QPSK\n") sys.exit(1) if constellation == dvbs2.MOD_8PSK: if (code_rate == dvbs2.C3_5 or code_rate == dvbs2.C2_3 or code_rate == dvbs2.C3_4 or code_rate == dvbs2.C5_6 or code_rate == dvbs2.C8_9 or code_rate == dvbs2.C9_10 or code_rate == dvbs2.C23_36 or code_rate == dvbs2.C25_36 or code_rate == dvbs2.C13_18 or code_rate == dvbs2.C7_15 or code_rate == dvbs2.C8_15 or code_rate == dvbs2.C26_45 or code_rate == dvbs2.C32_45): pass else: sys.stderr.write("Invalid code rate for 8PSK\n") sys.exit(1) if constellation == dvbs2.MOD_8APSK: if (code_rate == dvbs2.C100_180 or code_rate == dvbs2.C104_180): pass else: sys.stderr.write("Invalid code rate for 8APSK\n") sys.exit(1) if constellation == dvbs2.MOD_16APSK: if (code_rate == dvbs2.C2_3 or code_rate == dvbs2.C3_4 or code_rate == dvbs2.C4_5 or code_rate == dvbs2.C5_6 or code_rate == dvbs2.C8_9 or code_rate == dvbs2.C9_10 or code_rate == dvbs2.C26_45 or code_rate == dvbs2.C3_5 or code_rate == dvbs2.C28_45 or code_rate == dvbs2.C23_36 or code_rate == dvbs2.C25_36 or code_rate == dvbs2.C13_18 or code_rate == dvbs2.C140_180 or code_rate == dvbs2.C154_180 or code_rate == dvbs2.C7_15 or code_rate == dvbs2.C8_15 or code_rate == dvbs2.C26_45 or code_rate == dvbs2.C3_5 or code_rate == dvbs2.C32_45): pass else: sys.stderr.write("Invalid code rate for 16APSK\n") sys.exit(1) if constellation == dvbs2.MOD_8_8APSK: if (code_rate == dvbs2.C90_180 or code_rate == dvbs2.C96_180 or code_rate == dvbs2.C100_180 or code_rate == dvbs2.C18_30 or code_rate == dvbs2.C20_30): pass else: sys.stderr.write("Invalid code rate for 8+8APSK\n") sys.exit(1) if constellation == dvbs2.MOD_32APSK: if (code_rate == dvbs2.C3_4 or code_rate == dvbs2.C4_5 or code_rate == dvbs2.C5_6 or code_rate == dvbs2.C8_9 or code_rate == dvbs2.C9_10): pass else: sys.stderr.write("Invalid code rate for 32APSK\n") sys.exit(1) if constellation == dvbs2.MOD_4_12_16APSK: if (code_rate == dvbs2.C2_3 or code_rate == dvbs2.C32_45): pass else: sys.stderr.write("Invalid code rate for 4+12+16rbAPSK\n") sys.exit(1) if constellation == dvbs2.MOD_4_8_4_16APSK: if (code_rate == dvbs2.C128_180 or code_rate == dvbs2.C132_180 or code_rate == dvbs2.C140_180): pass else: sys.stderr.write("Invalid code rate for 4+8+4+16APSK\n") sys.exit(1) if constellation == dvbs2.MOD_64APSK: if (code_rate == dvbs2.C128_180): pass else: sys.stderr.write("Invalid code rate for 64APSK\n") sys.exit(1) if constellation == dvbs2.MOD_4_12_20_28APSK: if (code_rate == dvbs2.C132_180): pass else: sys.stderr.write("Invalid code rate for 4+12+20+28APSK\n") sys.exit(1) if constellation == dvbs2.MOD_8_16_20_20APSK: if (code_rate == dvbs2.C7_9 or code_rate == dvbs2.C4_5 or code_rate == dvbs2.C5_6): pass else: sys.stderr.write("Invalid code rate for 8+16+20+20APSK\n") sys.exit(1) if constellation == dvbs2.MOD_128APSK: if (code_rate == dvbs2.C135_180 or code_rate == dvbs2.C140_180): pass else: sys.stderr.write("Invalid code rate for 128APSK\n") sys.exit(1) if constellation == dvbs2.MOD_256APSK: if (code_rate == dvbs2.C20_30 or code_rate == dvbs2.C22_30 or code_rate == dvbs2.C116_180 or code_rate == dvbs2.C124_180 or code_rate == dvbs2.C128_180 or code_rate == dvbs2.C135_180): pass else: sys.stderr.write("Invalid code rate for 256APSK\n") sys.exit(1) if rolloff == dvbs2.RO_0_05: rrc_rolloff = 0.05 elif rolloff == dvbs2.RO_0_10: rrc_rolloff = 0.10 elif rolloff == dvbs2.RO_0_15: rrc_rolloff = 0.15 elif rolloff == dvbs2.RO_0_20: rrc_rolloff = 0.20 elif rolloff == dvbs2.RO_0_25: rrc_rolloff = 0.25 elif rolloff == dvbs2.RO_0_35: rrc_rolloff = 0.35 if (code_rate == dvbs2.C3_5 or code_rate == dvbs2.C4_5 or code_rate == dvbs2.C5_6 or code_rate == dvbs2.C7_9 or code_rate == dvbs2.C13_18 or code_rate == dvbs2.C23_36 or code_rate == dvbs2.C25_36 or code_rate == dvbs2.C26_45 or code_rate == dvbs2.C28_45 or code_rate == dvbs2.C90_180 or code_rate == dvbs2.C96_180 or code_rate == dvbs2.C100_180 or code_rate == dvbs2.C116_180 or code_rate == dvbs2.C124_180 or code_rate == dvbs2.C128_180 or code_rate == dvbs2.C135_180 or code_rate == dvbs2.C140_180): code_rate_interleaver = code_rate else: code_rate_interleaver = dvbs2.C_OTHER if (code_rate == dvbs2.C2_3 or code_rate == dvbs2.C3_4 or code_rate == dvbs2.C4_5 or code_rate == dvbs2.C5_6 or code_rate == dvbs2.C8_9 or code_rate == dvbs2.C9_10 or code_rate == dvbs2.C90_180 or code_rate == dvbs2.C96_180 or code_rate == dvbs2.C100_180 or code_rate == dvbs2.C104_180 or code_rate == dvbs2.C26_45 or code_rate == dvbs2.C18_30 or code_rate == dvbs2.C28_45 or code_rate == dvbs2.C23_36 or code_rate == dvbs2.C116_180 or code_rate == dvbs2.C20_30 or code_rate == dvbs2.C124_180 or code_rate == dvbs2.C25_36 or code_rate == dvbs2.C128_180 or code_rate == dvbs2.C13_18 or code_rate == dvbs2.C132_180 or code_rate == dvbs2.C22_30 or code_rate == dvbs2.C135_180 or code_rate == dvbs2.C140_180 or code_rate == dvbs2.C7_9 or code_rate == dvbs2.C154_180): code_rate_modulator = code_rate else: code_rate_modulator = dvbs2.C_OTHER if constellation == dvbs2.MOD_128APSK: constellation_ldpc = constellation else: constellation_ldpc = dvbs2.MOD_OTHER tb = gr.top_block() src = blocks.file_source(gr.sizeof_char, infile, True) dvbs2_bbheader = dvbs2.bbheader_bb(code_rate, rolloff, frame_size) dvbs2_bbscrambler = dvbs2.bbscrambler_bb(code_rate, frame_size) dvbs2_bch = dvbs2.bch_bb(code_rate, frame_size) dvbs2_ldpc = dvbs2.ldpc_bb(code_rate, frame_size, constellation) dvbs2_interleaver = dvbs2.interleaver_bb(constellation, code_rate_interleaver, frame_size) dvbs2_modulator = dvbs2.modulator_bc(constellation, code_rate_modulator, frame_size) dvbs2_physical = dvbs2.physical_cc(constellation, code_rate, pilots, frame_size, gold_code) fft_filter = filter.fft_filter_ccc(1, (firdes.root_raised_cosine( 1, samp_rate, samp_rate / 2, rrc_rolloff, rrc_taps)), 1) fft_filter.declare_sample_delay(0) out = osmosdr.sink(args="bladerf=0,buffers=128,buflen=32768") out.set_sample_rate(samp_rate) out.set_center_freq(center_freq, 0) out.set_freq_corr(0, 0) out.set_gain(txvga2_gain, 0) out.set_bb_gain(txvga1_gain, 0) out.set_bandwidth(bandwidth, 0) tb.connect(src, dvbs2_bbheader) tb.connect(dvbs2_bbheader, dvbs2_bbscrambler) tb.connect(dvbs2_bbscrambler, dvbs2_bch) tb.connect(dvbs2_bch, dvbs2_ldpc) tb.connect(dvbs2_ldpc, dvbs2_interleaver) tb.connect(dvbs2_interleaver, dvbs2_modulator) tb.connect(dvbs2_modulator, dvbs2_physical) tb.connect(dvbs2_physical, fft_filter) tb.connect(fft_filter, out) if outfile: dst = blocks.file_sink(gr.sizeof_gr_complex, outfile) tb.connect(fft_filter, dst) tb.run()
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Dvbs2 Tx") ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 5000000 self.taps = taps = 50 self.samp_rate = samp_rate = symbol_rate * 2 self.rolloff = rolloff = 0.2 ################################################## # Blocks ################################################## self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=1280000000, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.13333, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " + "bladerf=0,buffers=128,buflen=32768") self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(1280e6, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(15, 0) self.osmosdr_sink_0.set_if_gain(0, 0) self.osmosdr_sink_0.set_bb_gain(-10, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(6000000, 0) self.fft_filter_xxx_0 = filter.fft_filter_ccc( 1, (firdes.root_raised_cosine(1, samp_rate, samp_rate / 2, rolloff, taps)), 1 ) self.fft_filter_xxx_0.declare_sample_delay(0) self.dvbs2_physical_cc_0 = dvbs2.physical_cc( dvbs2.MOD_16APSK, dvbs2.C9_10, dvbs2.PILOTS_ON, dvbs2.FECFRAME_NORMAL, 0 ) self.dvbs2_modulator_bc_0 = dvbs2.modulator_bc(dvbs2.MOD_16APSK, dvbs2.C9_10, dvbs2.FECFRAME_NORMAL) self.dvbs2_ldpc_bb_0 = dvbs2.ldpc_bb(dvbs2.C9_10, dvbs2.FECFRAME_NORMAL, dvbs2.MOD_OTHER) self.dvbs2_interleaver_bb_0 = dvbs2.interleaver_bb(dvbs2.MOD_16APSK, dvbs2.C_OTHER, dvbs2.FECFRAME_NORMAL) self.dvbs2_bch_bb_0 = dvbs2.bch_bb(dvbs2.C9_10, dvbs2.FECFRAME_NORMAL) self.dvbs2_bbscrambler_bb_0 = dvbs2.bbscrambler_bb(dvbs2.C9_10, dvbs2.FECFRAME_NORMAL) self.dvbs2_bbheader_bb_0 = dvbs2.bbheader_bb(dvbs2.C9_10, dvbs2.RO_0_20, dvbs2.FECFRAME_NORMAL) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char * 1, "/run/shm/adv16apsk910.ts", True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.dvbs2_bbheader_bb_0, 0)) self.connect((self.dvbs2_bbheader_bb_0, 0), (self.dvbs2_bbscrambler_bb_0, 0)) self.connect((self.dvbs2_bbscrambler_bb_0, 0), (self.dvbs2_bch_bb_0, 0)) self.connect((self.dvbs2_bch_bb_0, 0), (self.dvbs2_ldpc_bb_0, 0)) self.connect((self.dvbs2_ldpc_bb_0, 0), (self.dvbs2_interleaver_bb_0, 0)) self.connect((self.dvbs2_interleaver_bb_0, 0), (self.dvbs2_modulator_bc_0, 0)) self.connect((self.dvbs2_modulator_bc_0, 0), (self.dvbs2_physical_cc_0, 0)) self.connect((self.dvbs2_physical_cc_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0))
def __init__(self): gr.top_block.__init__(self, "Dvbs2 Tx") Qt.QWidget.__init__(self) self.setWindowTitle("Dvbs2 Tx") 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", "dvbs2_tx") 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)) ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 5000000 self.tx_gain = tx_gain = 0 self.taps = taps = 100 self.samp_rate = samp_rate = symbol_rate * 2 self.rolloff = rolloff = 0.2 self.qtgui_variable = qtgui_variable = '"labul' self.pilots = pilots = 0 self.noise_type = noise_type = "Gaussian" self.noise = noise = 0.1 self.code_rate_qpsk = code_rate_qpsk = "9/10" self.code_rate_8psk = code_rate_8psk = "9/10" self.code_rate_32apsk = code_rate_32apsk = "9/10" self.code_rate_16apsk = code_rate_16apsk = "9/10" self.center_freq = center_freq = 1280e6 self.browse_button = browse_button = 0 self.FEC_Frame_size = FEC_Frame_size = 'Normal' ################################################## # Blocks ################################################## self._tx_gain_range = Range(0, 89, 1, 0, 200) self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, 'TX Gain (dB)', "counter_slider", float) self.top_grid_layout.addWidget(self._tx_gain_win, 1, 0, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._rolloff_options = (0.2, 0.25, 0.35, ) self._rolloff_labels = (str(self._rolloff_options[0]), str(self._rolloff_options[1]), str(self._rolloff_options[2]), ) self._rolloff_tool_bar = Qt.QToolBar(self) self._rolloff_tool_bar.addWidget(Qt.QLabel('Rolloff'+": ")) self._rolloff_combo_box = Qt.QComboBox() self._rolloff_tool_bar.addWidget(self._rolloff_combo_box) for label in self._rolloff_labels: self._rolloff_combo_box.addItem(label) self._rolloff_callback = lambda i: Qt.QMetaObject.invokeMethod(self._rolloff_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._rolloff_options.index(i))) self._rolloff_callback(self.rolloff) self._rolloff_combo_box.currentIndexChanged.connect( lambda i: self.set_rolloff(self._rolloff_options[i])) self.top_grid_layout.addWidget(self._rolloff_tool_bar, 0, 1, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.constellation_tab = Qt.QTabWidget() self.constellation_tab_widget_0 = Qt.QWidget() self.constellation_tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.constellation_tab_widget_0) self.constellation_tab_grid_layout_0 = Qt.QGridLayout() self.constellation_tab_layout_0.addLayout(self.constellation_tab_grid_layout_0) self.constellation_tab.addTab(self.constellation_tab_widget_0, 'QPSK') self.constellation_tab_widget_1 = Qt.QWidget() self.constellation_tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.constellation_tab_widget_1) self.constellation_tab_grid_layout_1 = Qt.QGridLayout() self.constellation_tab_layout_1.addLayout(self.constellation_tab_grid_layout_1) self.constellation_tab.addTab(self.constellation_tab_widget_1, '8PSK') self.constellation_tab_widget_2 = Qt.QWidget() self.constellation_tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.constellation_tab_widget_2) self.constellation_tab_grid_layout_2 = Qt.QGridLayout() self.constellation_tab_layout_2.addLayout(self.constellation_tab_grid_layout_2) self.constellation_tab.addTab(self.constellation_tab_widget_2, '16APSK') self.constellation_tab_widget_3 = Qt.QWidget() self.constellation_tab_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.constellation_tab_widget_3) self.constellation_tab_grid_layout_3 = Qt.QGridLayout() self.constellation_tab_layout_3.addLayout(self.constellation_tab_grid_layout_3) self.constellation_tab.addTab(self.constellation_tab_widget_3, '32APSK') self.top_grid_layout.addWidget(self.constellation_tab, 2, 0, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.uhd_usrp_sink = uhd.usrp_sink( ",".join(('', '')), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink.set_samp_rate(samp_rate) self.uhd_usrp_sink.set_center_freq(center_freq, 0) self.uhd_usrp_sink.set_gain(tx_gain, 0) self._qtgui_variable_tool_bar = Qt.QToolBar(self) if None: self._qtgui_variable_formatter = None else: self._qtgui_variable_formatter = lambda x: str(x) self._qtgui_variable_tool_bar.addWidget(Qt.QLabel('label'+": ")) self._qtgui_variable_label = Qt.QLabel(str(self._qtgui_variable_formatter(self.qtgui_variable))) self._qtgui_variable_tool_bar.addWidget(self._qtgui_variable_label) self.top_grid_layout.addWidget(self._qtgui_variable_tool_bar, 3, 0, 1, 1) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype center_freq, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink.set_update_time(0.10) self.qtgui_freq_sink.set_y_axis(-140, 10) self.qtgui_freq_sink.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink.enable_autoscale(False) self.qtgui_freq_sink.enable_grid(True) self.qtgui_freq_sink.set_fft_average(0.2) self.qtgui_freq_sink.enable_axis_labels(True) self.qtgui_freq_sink.enable_control_panel(False) if not True: self.qtgui_freq_sink.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink.set_plot_pos_half(not True) labels = ['DVB-S2', '', '', '', '', '', '', '', '', ''] 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 xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink.set_line_label(i, labels[i]) self.qtgui_freq_sink.set_line_width(i, widths[i]) self.qtgui_freq_sink.set_line_color(i, colors[i]) self.qtgui_freq_sink.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_win = sip.wrapinstance(self.qtgui_freq_sink.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_win, 4, 0, 1, 1) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._pilots_options = (1, 0, ) self._pilots_labels = ("On", "Off", ) self._pilots_group_box = Qt.QGroupBox('Pilots') self._pilots_box = Qt.QVBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._pilots_button_group = variable_chooser_button_group() self._pilots_group_box.setLayout(self._pilots_box) for i, label in enumerate(self._pilots_labels): radio_button = Qt.QRadioButton(label) self._pilots_box.addWidget(radio_button) self._pilots_button_group.addButton(radio_button, i) self._pilots_callback = lambda i: Qt.QMetaObject.invokeMethod(self._pilots_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._pilots_options.index(i))) self._pilots_callback(self.pilots) self._pilots_button_group.buttonClicked[int].connect( lambda i: self.set_pilots(self._pilots_options[i])) self.top_grid_layout.addWidget(self._pilots_group_box, 3, 1, 1, 1) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._noise_type_options = ("Uniform", "Gaussian", "Laplacian", "Impulse", ) self._noise_type_labels = (str(self._noise_type_options[0]), str(self._noise_type_options[1]), str(self._noise_type_options[2]), str(self._noise_type_options[3]), ) self._noise_type_tool_bar = Qt.QToolBar(self) self._noise_type_tool_bar.addWidget(Qt.QLabel('Noise Type'+": ")) self._noise_type_combo_box = Qt.QComboBox() self._noise_type_tool_bar.addWidget(self._noise_type_combo_box) for label in self._noise_type_labels: self._noise_type_combo_box.addItem(label) self._noise_type_callback = lambda i: Qt.QMetaObject.invokeMethod(self._noise_type_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._noise_type_options.index(i))) self._noise_type_callback(self.noise_type) self._noise_type_combo_box.currentIndexChanged.connect( lambda i: self.set_noise_type(self._noise_type_options[i])) self.top_grid_layout.addWidget(self._noise_type_tool_bar, 1, 1, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.noise_source = analog.noise_source_c(analog.GR_GAUSSIAN, 0, 0) self._noise_range = Range(0, 1, 0.01, 0.1, 200) self._noise_win = RangeWidget(self._noise_range, self.set_noise, 'Noise', "counter", float) self.top_grid_layout.addWidget(self._noise_win, 2, 1, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.file_source = blocks.file_source(gr.sizeof_char*1, '/home/anisan/videos/The_Maker/900.ts', True) self.file_source.set_begin_tag(pmt.PMT_NIL) self.fft_filter = filter.fft_filter_ccc(1, (firdes.root_raised_cosine(1.0, samp_rate, samp_rate/2, rolloff, taps)), 1) self.fft_filter.declare_sample_delay(0) self.dvbs2_physical = dvbs2.physical_cc(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.MOD_16APSK, dvbs2.PILOTS_OFF, 0) self.dvbs2_modulator = dvbs2.modulator_bc(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.MOD_16APSK) self.dvbs2_ldpc = dvbs2.ldpc_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.MOD_OTHER) self.dvbs2_interleaver = dvbs2.interleaver_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.MOD_16APSK) self.dvbs2_bbscrambler = dvbs2.bbscrambler_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10) self.dvbs2_bbheader = dvbs2.bbheader_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.RO_0_20) self.dvb_bch = dtv.dvb_bch_bb(dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10) self._code_rate_qpsk_options = ["1/4", "1/3", "2/5", "1/2", "3/5", "2/3", "3/4", "4/5", "5/6", "8/9", "9/10"] self._code_rate_qpsk_labels = map(str, self._code_rate_qpsk_options) self._code_rate_qpsk_group_box = Qt.QGroupBox('Code Rate') self._code_rate_qpsk_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._code_rate_qpsk_button_group = variable_chooser_button_group() self._code_rate_qpsk_group_box.setLayout(self._code_rate_qpsk_box) for i, label in enumerate(self._code_rate_qpsk_labels): radio_button = Qt.QRadioButton(label) self._code_rate_qpsk_box.addWidget(radio_button) self._code_rate_qpsk_button_group.addButton(radio_button, i) self._code_rate_qpsk_callback = lambda i: Qt.QMetaObject.invokeMethod(self._code_rate_qpsk_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._code_rate_qpsk_options.index(i))) self._code_rate_qpsk_callback(self.code_rate_qpsk) self._code_rate_qpsk_button_group.buttonClicked[int].connect( lambda i: self.set_code_rate_qpsk(self._code_rate_qpsk_options[i])) self.constellation_tab_layout_0.addWidget(self._code_rate_qpsk_group_box) self._code_rate_8psk_options = ["3/5", "2/3", "3/4", "4/5", "5/6", "8/9", "9/10"] self._code_rate_8psk_labels = map(str, self._code_rate_8psk_options) self._code_rate_8psk_group_box = Qt.QGroupBox('Code Rate') self._code_rate_8psk_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._code_rate_8psk_button_group = variable_chooser_button_group() self._code_rate_8psk_group_box.setLayout(self._code_rate_8psk_box) for i, label in enumerate(self._code_rate_8psk_labels): radio_button = Qt.QRadioButton(label) self._code_rate_8psk_box.addWidget(radio_button) self._code_rate_8psk_button_group.addButton(radio_button, i) self._code_rate_8psk_callback = lambda i: Qt.QMetaObject.invokeMethod(self._code_rate_8psk_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._code_rate_8psk_options.index(i))) self._code_rate_8psk_callback(self.code_rate_8psk) self._code_rate_8psk_button_group.buttonClicked[int].connect( lambda i: self.set_code_rate_8psk(self._code_rate_8psk_options[i])) self.constellation_tab_layout_1.addWidget(self._code_rate_8psk_group_box) self._code_rate_32apsk_options = ["3/4", "4/5", "5/6", "8/9", "9/10"] self._code_rate_32apsk_labels = map(str, self._code_rate_32apsk_options) self._code_rate_32apsk_group_box = Qt.QGroupBox('Code Rate') self._code_rate_32apsk_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._code_rate_32apsk_button_group = variable_chooser_button_group() self._code_rate_32apsk_group_box.setLayout(self._code_rate_32apsk_box) for i, label in enumerate(self._code_rate_32apsk_labels): radio_button = Qt.QRadioButton(label) self._code_rate_32apsk_box.addWidget(radio_button) self._code_rate_32apsk_button_group.addButton(radio_button, i) self._code_rate_32apsk_callback = lambda i: Qt.QMetaObject.invokeMethod(self._code_rate_32apsk_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._code_rate_32apsk_options.index(i))) self._code_rate_32apsk_callback(self.code_rate_32apsk) self._code_rate_32apsk_button_group.buttonClicked[int].connect( lambda i: self.set_code_rate_32apsk(self._code_rate_32apsk_options[i])) self.constellation_tab_layout_3.addWidget(self._code_rate_32apsk_group_box) self._code_rate_16apsk_options = [ "2/3", "3/4", "4/5", "5/6", "8/9", "9/10"] self._code_rate_16apsk_labels = map(str, self._code_rate_16apsk_options) self._code_rate_16apsk_group_box = Qt.QGroupBox('Code Rate') self._code_rate_16apsk_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._code_rate_16apsk_button_group = variable_chooser_button_group() self._code_rate_16apsk_group_box.setLayout(self._code_rate_16apsk_box) for i, label in enumerate(self._code_rate_16apsk_labels): radio_button = Qt.QRadioButton(label) self._code_rate_16apsk_box.addWidget(radio_button) self._code_rate_16apsk_button_group.addButton(radio_button, i) self._code_rate_16apsk_callback = lambda i: Qt.QMetaObject.invokeMethod(self._code_rate_16apsk_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._code_rate_16apsk_options.index(i))) self._code_rate_16apsk_callback(self.code_rate_16apsk) self._code_rate_16apsk_button_group.buttonClicked[int].connect( lambda i: self.set_code_rate_16apsk(self._code_rate_16apsk_options[i])) self.constellation_tab_grid_layout_2.addWidget(self._code_rate_16apsk_group_box) _browse_button_push_button = Qt.QPushButton('Browse') self._browse_button_choices = {'Pressed': 1, 'Released': 0} _browse_button_push_button.pressed.connect(lambda: self.set_browse_button(self._browse_button_choices['Pressed'])) _browse_button_push_button.released.connect(lambda: self.set_browse_button(self._browse_button_choices['Released'])) self.top_grid_layout.addWidget(_browse_button_push_button, 0, 0, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.add_bloc = blocks.add_vcc(1) self._FEC_Frame_size_options = ('Normal', 'Short', ) self._FEC_Frame_size_labels = (str(self._FEC_Frame_size_options[0]), str(self._FEC_Frame_size_options[1]), ) self._FEC_Frame_size_group_box = Qt.QGroupBox('FEC Frame Size') self._FEC_Frame_size_box = Qt.QVBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._FEC_Frame_size_button_group = variable_chooser_button_group() self._FEC_Frame_size_group_box.setLayout(self._FEC_Frame_size_box) for i, label in enumerate(self._FEC_Frame_size_labels): radio_button = Qt.QRadioButton(label) self._FEC_Frame_size_box.addWidget(radio_button) self._FEC_Frame_size_button_group.addButton(radio_button, i) self._FEC_Frame_size_callback = lambda i: Qt.QMetaObject.invokeMethod(self._FEC_Frame_size_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._FEC_Frame_size_options.index(i))) self._FEC_Frame_size_callback(self.FEC_Frame_size) self._FEC_Frame_size_button_group.buttonClicked[int].connect( lambda i: self.set_FEC_Frame_size(self._FEC_Frame_size_options[i])) self.top_grid_layout.addWidget(self._FEC_Frame_size_group_box, 4, 1, 1, 1) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) ################################################## # Connections ################################################## self.connect((self.add_bloc, 0), (self.qtgui_freq_sink, 0)) self.connect((self.dvb_bch, 0), (self.dvbs2_ldpc, 0)) self.connect((self.dvbs2_bbheader, 0), (self.dvbs2_bbscrambler, 0)) self.connect((self.dvbs2_bbscrambler, 0), (self.dvb_bch, 0)) self.connect((self.dvbs2_interleaver, 0), (self.dvbs2_modulator, 0)) self.connect((self.dvbs2_ldpc, 0), (self.dvbs2_interleaver, 0)) self.connect((self.dvbs2_modulator, 0), (self.dvbs2_physical, 0)) self.connect((self.dvbs2_physical, 0), (self.fft_filter, 0)) self.connect((self.fft_filter, 0), (self.add_bloc, 0)) self.connect((self.file_source, 0), (self.dvbs2_bbheader, 0)) self.connect((self.noise_source, 0), (self.add_bloc, 1))
def __init__(self): global configPath, MP4file, frame_size, code_rate, modulation, pilots, const_rollof, rolloff gr.top_block.__init__(self, "Dvbs2 Tx") Qt.QWidget.__init__(self) self.setWindowTitle("Dvbs2 Tx") 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", "dvbs2_tx") self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray)) #### Initial Config #### if not os.path.exists(configPath): write_config() f = open(configPath, "r") lines = f.readlines() MP4file = str(lines[0]) MP4file = MP4file.rstrip() frame_size = int(lines[1]) code_rate = int(lines[2]) modulation = int(lines[3]) pilots = int(lines[4]) const_rolloff = int(lines[5]) f.close() ################################################## # Variables ################################################## self.browse_button = browse_button = 0 self.constellation_label = constellation_label = 'Current Constellation' self.symbol_rate = symbol_rate = 5000000 self.tx_gain = tx_gain = 0 self.taps = taps = 100 self.samp_rate = samp_rate = symbol_rate * 2 self.pilot = pilots self.noise_type = noise_type = "Gaussian" self.noise = noise = 0.0 self.center_freq = center_freq = 1280e6 self.FEC_Frame_size = frame_size if(const_rolloff == dvbs2.RO_0_20): rolloff = 0.2 elif(const_rolloff == dvbs2.RO_0_25): rolloff = 0.25 elif(const_rolloff == dvbs2.RO_0_35): rolloff = 0.35 self.rolloff = rolloff self.code_rate_qpsk = code_rate if (code_rate >= dvbs2.C3_5): self.code_rate_8psk = code_rate else: self.code_rate_8psk = dvbs2.C9_10 if (code_rate >= dvbs2.C2_3): self.code_rate_16apsk = code_rate else: self.code_rate_16apsk = dvbs2.C9_10 if (code_rate >= dvbs2.C3_4): self.code_rate_32apsk = code_rate else: self.code_rate_32apsk = dvbs2.C9_10 if modulation == dvbs2.MOD_QPSK: modulation_str = "QPSK" elif modulation == dvbs2.MOD_8PSK: modulation_str = "8PSK" elif modulation == dvbs2.MOD_16APSK: modulation_str = "16APSK" elif modulation == dvbs2.MOD_32APSK: modulation_str = "32APSK" ################################################## # File Handler ################################################## filePath = os.path.dirname(MP4file)+"/"+os.path.splitext(os.path.basename(MP4file))[0] if not os.path.exists(filePath): os.mkdir(filePath) fileTS = filePath+"/"+str(frame_size)+str(code_rate)+str(modulation)+str(pilots)+str(const_rolloff)+".ts" if not os.path.exists(fileTS): line = 0 if modulation == dvbs2.MOD_QPSK: line = 2+code_rate if pilots: line = line+12 elif modulation == dvbs2.MOD_8PSK: line = 22+code_rate if pilots: line = line+7 elif modulation == dvbs2.MOD_16APSK: line = 35+code_rate if pilots: line = line+7 elif modulation == dvbs2.MOD_32APSK: line = 48+code_rate if pilots: line = line+6 f = open(ratesPath, "r") lines = f.readlines() muxrate = str(int(round(float(lines[line].split()[-1])))) f.close() os.system("ffmpeg -i "+MP4file+" -c:v copy -c:a copy -muxrate "+muxrate+" -f mpegts "+fileTS) self.qtgui_variable = qtgui_variable = "Source File: "+MP4file+"\nModulation: "+modulation_str ################################################## # Blocks ################################################## self._tx_gain_range = Range(0, 89, 1, 0, 200) self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, 'TX Gain (dB)', "counter_slider", float) self.top_grid_layout.addWidget(self._tx_gain_win) self._rolloff_options = (0.2, 0.25, 0.35, ) self._rolloff_labels = ("0.20", "0.25", "0.35", ) self._rolloff_tool_bar = Qt.QToolBar(self) self._rolloff_tool_bar.addWidget(Qt.QLabel('Rolloff'+": ")) self._rolloff_combo_box = Qt.QComboBox() self._rolloff_tool_bar.addWidget(self._rolloff_combo_box) for label in self._rolloff_labels: self._rolloff_combo_box.addItem(label) self._rolloff_callback = lambda i: Qt.QMetaObject.invokeMethod(self._rolloff_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._rolloff_options.index(i))) self._rolloff_callback(self.rolloff) self._rolloff_combo_box.currentIndexChanged.connect( lambda i: self.set_rolloff(self._rolloff_options[i])) self.top_grid_layout.addWidget(self._rolloff_tool_bar) self.constellation_tab = Qt.QTabWidget() self.constellation_tab_widget_0 = Qt.QWidget() self.constellation_tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.constellation_tab_widget_0) self.constellation_tab_grid_layout_0 = Qt.QGridLayout() self.constellation_tab_layout_0.addLayout(self.constellation_tab_grid_layout_0) self.constellation_tab.addTab(self.constellation_tab_widget_0, 'QPSK') self.constellation_tab_widget_1 = Qt.QWidget() self.constellation_tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.constellation_tab_widget_1) self.constellation_tab_grid_layout_1 = Qt.QGridLayout() self.constellation_tab_layout_1.addLayout(self.constellation_tab_grid_layout_1) self.constellation_tab.addTab(self.constellation_tab_widget_1, '8PSK') self.constellation_tab_widget_2 = Qt.QWidget() self.constellation_tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.constellation_tab_widget_2) self.constellation_tab_grid_layout_2 = Qt.QGridLayout() self.constellation_tab_layout_2.addLayout(self.constellation_tab_grid_layout_2) self.constellation_tab.addTab(self.constellation_tab_widget_2, '16APSK') self.constellation_tab_widget_3 = Qt.QWidget() self.constellation_tab_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.constellation_tab_widget_3) self.constellation_tab_grid_layout_3 = Qt.QGridLayout() self.constellation_tab_layout_3.addLayout(self.constellation_tab_grid_layout_3) self.constellation_tab.addTab(self.constellation_tab_widget_3, '32APSK') self.top_grid_layout.addWidget(self.constellation_tab) self.uhd_usrp_sink = uhd.usrp_sink( ",".join(('', '')), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink.set_samp_rate(samp_rate) self.uhd_usrp_sink.set_center_freq(center_freq, 0) self.uhd_usrp_sink.set_gain(tx_gain, 0) self._qtgui_variable_tool_bar = Qt.QToolBar(self) self._qtgui_variable_formatter = lambda x: str(x) self._qtgui_variable_tool_bar.addWidget(Qt.QLabel()) self._qtgui_variable_label = Qt.QLabel(str(self._qtgui_variable_formatter(self.qtgui_variable))) self._qtgui_variable_tool_bar.addWidget(self._qtgui_variable_label) self.top_grid_layout.addWidget(self._qtgui_variable_tool_bar) self.qtgui_freq_sink = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype center_freq, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink.set_update_time(0.10) self.qtgui_freq_sink.set_y_axis(-140, 10) self.qtgui_freq_sink.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink.enable_autoscale(False) self.qtgui_freq_sink.enable_grid(True) self.qtgui_freq_sink.set_fft_average(0.2) self.qtgui_freq_sink.enable_axis_labels(True) self.qtgui_freq_sink.enable_control_panel(False) labels = ['DVB-S2', '', '', '', '', '', '', '', '', ''] 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 xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink.set_line_label(i, labels[i]) self.qtgui_freq_sink.set_line_width(i, widths[i]) self.qtgui_freq_sink.set_line_color(i, colors[i]) self.qtgui_freq_sink.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_win = sip.wrapinstance(self.qtgui_freq_sink.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_win) self._pilot_options = (1, 0, ) self._pilot_labels = ("On", "Off", ) self._pilot_group_box = Qt.QGroupBox('Pilots') self._pilot_box = Qt.QVBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._pilot_button_group = variable_chooser_button_group() self._pilot_group_box.setLayout(self._pilot_box) for i, label in enumerate(self._pilot_labels): radio_button = Qt.QRadioButton(label) self._pilot_box.addWidget(radio_button) self._pilot_button_group.addButton(radio_button, i) self._pilot_callback = lambda i: Qt.QMetaObject.invokeMethod(self._pilot_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._pilot_options.index(i))) self._pilot_callback(self.pilot) self._pilot_button_group.buttonClicked[int].connect( lambda i: self.set_pilot(self._pilot_options[i])) self.top_grid_layout.addWidget(self._pilot_group_box) self._noise_type_options = ("Uniform", "Gaussian", "Laplacian", "Impulse", ) self._noise_type_labels = ("Uniform", "Gaussian", "Laplacian", "Impulse", ) self._noise_type_tool_bar = Qt.QToolBar(self) self._noise_type_tool_bar.addWidget(Qt.QLabel('Noise Type'+": ")) self._noise_type_combo_box = Qt.QComboBox() self._noise_type_tool_bar.addWidget(self._noise_type_combo_box) for label in self._noise_type_labels: self._noise_type_combo_box.addItem(label) self._noise_type_callback = lambda i: Qt.QMetaObject.invokeMethod(self._noise_type_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._noise_type_options.index(i))) self._noise_type_callback(self.noise_type) self._noise_type_combo_box.currentIndexChanged.connect( lambda i: self.set_noise_type(self._noise_type_options[i])) self.top_grid_layout.addWidget(self._noise_type_tool_bar) self.noise_source = analog.noise_source_c(analog.GR_GAUSSIAN, noise, 0) self._noise_range = Range(0, 1, 0.01, noise, 200) self._noise_win = RangeWidget(self._noise_range, self.set_noise, 'Noise', "counter_slider", float) self.top_grid_layout.addWidget(self._noise_win) self.file_source = blocks.file_source(gr.sizeof_char*1, fileTS, True) self.file_source.set_begin_tag(pmt.PMT_NIL) self.fft_filter = filter.fft_filter_ccc(1, (firdes.root_raised_cosine(1.0, samp_rate, samp_rate/2, rolloff, taps)), 1) self.fft_filter.declare_sample_delay(0) self.dvbs2_physical = dvbs2.physical_cc(frame_size, code_rate, modulation, pilots, 0) self.dvbs2_modulator = dvbs2.modulator_bc(frame_size, code_rate, modulation) self.dvbs2_ldpc = dvbs2.ldpc_bb(frame_size, code_rate, dvbs2.MOD_OTHER) self.dvbs2_interleaver = dvbs2.interleaver_bb(frame_size, code_rate, modulation) self.dvbs2_bch = dvbs2.bch_bb(frame_size, code_rate) self.dvbs2_bbscrambler = dvbs2.bbscrambler_bb(frame_size, code_rate) self.dvbs2_bbheader = dvbs2.bbheader_bb(frame_size, code_rate, const_rolloff) self._code_rate_qpsk_options = [dvbs2.C1_4, dvbs2.C1_3, dvbs2.C2_5, dvbs2.C1_2, dvbs2.C3_5, dvbs2.C2_3, dvbs2.C3_4, dvbs2.C4_5, dvbs2.C5_6, dvbs2.C8_9, dvbs2.C9_10] self._code_rate_qpsk_labels = ["1/4", "1/3", "2/5", "1/2", "3/5", "2/3", "3/4", "4/5", "5/6", "8/9", "9/10"] self._code_rate_qpsk_group_box = Qt.QGroupBox('Code Rate') self._code_rate_qpsk_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._code_rate_qpsk_button_group = variable_chooser_button_group() self._code_rate_qpsk_group_box.setLayout(self._code_rate_qpsk_box) for i, label in enumerate(self._code_rate_qpsk_labels): radio_button = Qt.QRadioButton(label) self._code_rate_qpsk_box.addWidget(radio_button) self._code_rate_qpsk_button_group.addButton(radio_button, i) self._code_rate_qpsk_callback = lambda i: Qt.QMetaObject.invokeMethod(self._code_rate_qpsk_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._code_rate_qpsk_options.index(i))) self._code_rate_qpsk_callback(self.code_rate_qpsk) self._code_rate_qpsk_button_group.buttonClicked[int].connect( lambda i: self.set_code_rate_qpsk(self._code_rate_qpsk_options[i])) self.constellation_tab_grid_layout_0.addWidget(self._code_rate_qpsk_group_box) self._code_rate_8psk_options = [dvbs2.C3_5, dvbs2.C2_3, dvbs2.C3_4, dvbs2.C4_5, dvbs2.C5_6, dvbs2.C8_9, dvbs2.C9_10] self._code_rate_8psk_labels = ["3/5", "2/3", "3/4", "4/5", "5/6", "8/9", "9/10"] self._code_rate_8psk_group_box = Qt.QGroupBox('Code Rate') self._code_rate_8psk_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._code_rate_8psk_button_group = variable_chooser_button_group() self._code_rate_8psk_group_box.setLayout(self._code_rate_8psk_box) for i, label in enumerate(self._code_rate_8psk_labels): radio_button = Qt.QRadioButton(label) self._code_rate_8psk_box.addWidget(radio_button) self._code_rate_8psk_button_group.addButton(radio_button, i) self._code_rate_8psk_callback = lambda i: Qt.QMetaObject.invokeMethod(self._code_rate_8psk_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._code_rate_8psk_options.index(i))) self._code_rate_8psk_callback(self.code_rate_8psk) self._code_rate_8psk_button_group.buttonClicked[int].connect( lambda i: self.set_code_rate_8psk(self._code_rate_8psk_options[i])) self.constellation_tab_grid_layout_1.addWidget(self._code_rate_8psk_group_box) self._code_rate_32apsk_options = [dvbs2.C3_4, dvbs2.C4_5, dvbs2.C5_6, dvbs2.C8_9, dvbs2.C9_10] self._code_rate_32apsk_labels = ["3/4", "4/5", "5/6", "8/9", "9/10"] self._code_rate_32apsk_group_box = Qt.QGroupBox('Code Rate') self._code_rate_32apsk_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._code_rate_32apsk_button_group = variable_chooser_button_group() self._code_rate_32apsk_group_box.setLayout(self._code_rate_32apsk_box) for i, label in enumerate(self._code_rate_32apsk_labels): radio_button = Qt.QRadioButton(label) self._code_rate_32apsk_box.addWidget(radio_button) self._code_rate_32apsk_button_group.addButton(radio_button, i) self._code_rate_32apsk_callback = lambda i: Qt.QMetaObject.invokeMethod(self._code_rate_32apsk_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._code_rate_32apsk_options.index(i))) self._code_rate_32apsk_callback(self.code_rate_32apsk) self._code_rate_32apsk_button_group.buttonClicked[int].connect( lambda i: self.set_code_rate_32apsk(self._code_rate_32apsk_options[i])) self.constellation_tab_grid_layout_3.addWidget(self._code_rate_32apsk_group_box) self._code_rate_16apsk_options = [dvbs2.C2_3, dvbs2.C3_4, dvbs2.C4_5, dvbs2.C5_6, dvbs2.C8_9, dvbs2.C9_10] self._code_rate_16apsk_labels = ["2/3", "3/4", "4/5", "5/6", "8/9", "9/10"] self._code_rate_16apsk_group_box = Qt.QGroupBox('Code Rate') self._code_rate_16apsk_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._code_rate_16apsk_button_group = variable_chooser_button_group() self._code_rate_16apsk_group_box.setLayout(self._code_rate_16apsk_box) for i, label in enumerate(self._code_rate_16apsk_labels): radio_button = Qt.QRadioButton(label) self._code_rate_16apsk_box.addWidget(radio_button) self._code_rate_16apsk_button_group.addButton(radio_button, i) self._code_rate_16apsk_callback = lambda i: Qt.QMetaObject.invokeMethod(self._code_rate_16apsk_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._code_rate_16apsk_options.index(i))) self._code_rate_16apsk_callback(self.code_rate_16apsk) self._code_rate_16apsk_button_group.buttonClicked[int].connect( lambda i: self.set_code_rate_16apsk(self._code_rate_16apsk_options[i])) self.constellation_tab_grid_layout_2.addWidget(self._code_rate_16apsk_group_box) _browse_button_push_button = Qt.QPushButton('Browse') self._browse_button_choices = {'Pressed': 1, 'Released': 0} _browse_button_push_button.pressed.connect( lambda: self.set_browse_button(self._browse_button_choices['Pressed'])) _browse_button_push_button.released.connect( lambda: self.set_browse_button(self._browse_button_choices['Released'])) self.top_grid_layout.addWidget(_browse_button_push_button) self.add_bloc = blocks.add_vcc(1) self._FEC_Frame_size_options = (dvbs2.FECFRAME_SHORT, dvbs2.FECFRAME_NORMAL, ) self._FEC_Frame_size_labels = ('Normal', 'Short', ) self._FEC_Frame_size_group_box = Qt.QGroupBox('FEC Frame Size') self._FEC_Frame_size_box = Qt.QVBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._FEC_Frame_size_button_group = variable_chooser_button_group() self._FEC_Frame_size_group_box.setLayout(self._FEC_Frame_size_box) for i, label in enumerate(self._FEC_Frame_size_labels): radio_button = Qt.QRadioButton(label) self._FEC_Frame_size_box.addWidget(radio_button) self._FEC_Frame_size_button_group.addButton(radio_button, i) self._FEC_Frame_size_callback = lambda i: Qt.QMetaObject.invokeMethod(self._FEC_Frame_size_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._FEC_Frame_size_options.index(i))) self._FEC_Frame_size_callback(self.FEC_Frame_size) self._FEC_Frame_size_button_group.buttonClicked[int].connect( lambda i: self.set_FEC_Frame_size(self._FEC_Frame_size_options[i])) self.top_grid_layout.addWidget(self._FEC_Frame_size_group_box) ################################################## # Connections ################################################## self.connect((self.add_bloc, 0), (self.qtgui_freq_sink, 0)) self.connect((self.add_bloc, 0), (self.uhd_usrp_sink, 0)) self.connect((self.dvbs2_bbheader, 0), (self.dvbs2_bbscrambler, 0)) self.connect((self.dvbs2_bbscrambler, 0), (self.dvbs2_bch, 0)) self.connect((self.dvbs2_bch, 0), (self.dvbs2_ldpc, 0)) self.connect((self.dvbs2_interleaver, 0), (self.dvbs2_modulator, 0)) self.connect((self.dvbs2_ldpc, 0), (self.dvbs2_interleaver, 0)) self.connect((self.dvbs2_modulator, 0), (self.dvbs2_physical, 0)) self.connect((self.dvbs2_physical, 0), (self.fft_filter, 0)) self.connect((self.fft_filter, 0), (self.add_bloc, 0)) self.connect((self.file_source, 0), (self.dvbs2_bbheader, 0)) self.connect((self.noise_source, 0), (self.add_bloc, 1))
def __init__(self): gr.top_block.__init__(self, "Dvbs2 Tx") Qt.QWidget.__init__(self) self.setWindowTitle("Dvbs2 Tx") 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", "dvbs2_tx") self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 5000000 self.tx_gain = tx_gain = 10 self.taps = taps = 100 self.samp_rate = samp_rate = symbol_rate * 2 self.rolloff = rolloff = 0.2 self.center_freq = center_freq = 1280e6 ################################################## # Blocks ################################################## self._tx_gain_range = Range(0, 89, 1, 10, 200) self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, "tx_gain", "counter_slider", float) self.top_grid_layout.addWidget(self._tx_gain_win) self.uhd_usrp_sink_0_0 = uhd.usrp_sink( ",".join(('', "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0_0.set_center_freq(center_freq, 0) self.uhd_usrp_sink_0_0.set_gain(tx_gain, 0) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype center_freq, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.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 xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.fft_filter_xxx_0 = filter.fft_filter_ccc(1, (firdes.root_raised_cosine(1.0, samp_rate, samp_rate/2, rolloff, taps)), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.dvbs2_physical_cc_0 = dvbs2.physical_cc(dvbs2.FECFRAME_NORMAL, dvbs2.C3_4, dvbs2.MOD_8PSK, dvbs2.PILOTS_ON, 0) self.dvbs2_modulator_bc_0 = dvbs2.modulator_bc(dvbs2.FECFRAME_NORMAL, dvbs2.C3_4, dvbs2.MOD_8PSK) self.dvbs2_ldpc_bb_0 = dvbs2.ldpc_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C3_4, dvbs2.MOD_OTHER) self.dvbs2_interleaver_bb_0 = dvbs2.interleaver_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C3_4, dvbs2.MOD_8PSK) self.dvbs2_bch_bb_0 = dvbs2.bch_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C3_4) self.dvbs2_bbscrambler_bb_0 = dvbs2.bbscrambler_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C3_4) self.dtv_dvb_bbheader_bb_0 = dtv.dvb_bbheader_bb(dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C3_4, dtv.RO_0_20, dtv.INPUTMODE_NORMAL, dtv.INBAND_OFF, 168, 4000000) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, '/home/anisan/videos/toystory/700.ts', True) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.dtv_dvb_bbheader_bb_0, 0)) self.connect((self.dtv_dvb_bbheader_bb_0, 0), (self.dvbs2_bbscrambler_bb_0, 0)) self.connect((self.dvbs2_bbscrambler_bb_0, 0), (self.dvbs2_bch_bb_0, 0)) self.connect((self.dvbs2_bch_bb_0, 0), (self.dvbs2_ldpc_bb_0, 0)) self.connect((self.dvbs2_interleaver_bb_0, 0), (self.dvbs2_modulator_bc_0, 0)) self.connect((self.dvbs2_ldpc_bb_0, 0), (self.dvbs2_interleaver_bb_0, 0)) self.connect((self.dvbs2_modulator_bc_0, 0), (self.dvbs2_physical_cc_0, 0)) self.connect((self.dvbs2_physical_cc_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.uhd_usrp_sink_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Dvbs2 Tx") Qt.QWidget.__init__(self) self.setWindowTitle("Dvbs2 Tx") 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", "dvbs2_tx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 5000000 self.vga2_gain = vga2_gain = 10 self.vga1_gain = vga1_gain = -8 self.tx_gain = tx_gain = 50 self.taps = taps = 100 self.samp_rate = samp_rate = symbol_rate * 2 self.rolloff = rolloff = 0.2 self.center_freq = center_freq = 1280e6 ################################################## # Blocks ################################################## self._vga2_gain_range = Range(0, 25, 1, 10, 200) self._vga2_gain_win = RangeWidget(self._vga2_gain_range, self.set_vga2_gain, "vga2_gain", "counter_slider", int) self.top_layout.addWidget(self._vga2_gain_win) self._vga1_gain_range = Range(-35, -4, 1, -8, 200) self._vga1_gain_win = RangeWidget(self._vga1_gain_range, self.set_vga1_gain, "vga1_gain", "counter_slider", int) self.top_layout.addWidget(self._vga1_gain_win) self._tx_gain_range = Range(0, 89, 1, 50, 200) self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, "tx_gain", "counter_slider", float) self.top_layout.addWidget(self._tx_gain_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype center_freq, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.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 xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + 'bladerf=0,buffers=128,buflen=32768' ) self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(center_freq, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(vga2_gain, 0) self.osmosdr_sink_0.set_if_gain(0, 0) self.osmosdr_sink_0.set_bb_gain(vga1_gain, 0) self.osmosdr_sink_0.set_antenna('', 0) self.osmosdr_sink_0.set_bandwidth(6000000, 0) self.fft_filter_xxx_0 = filter.fft_filter_ccc(1, (firdes.root_raised_cosine(1.0, samp_rate, samp_rate/2, rolloff, taps)), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.dvbs2_physical_cc_0 = dvbs2.physical_cc(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.MOD_16APSK, dvbs2.PILOTS_ON, 0) self.dvbs2_modulator_bc_0 = dvbs2.modulator_bc(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.MOD_16APSK) self.dvbs2_ldpc_bb_0 = dvbs2.ldpc_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.MOD_OTHER) self.dvbs2_interleaver_bb_0 = dvbs2.interleaver_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.MOD_16APSK) self.dvbs2_bch_bb_0 = dvbs2.bch_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10) self.dvbs2_bbscrambler_bb_0 = dvbs2.bbscrambler_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10) self.dvbs2_bbheader_bb_0 = dvbs2.bbheader_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.RO_0_20) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, '/run/shm/adv16apsk910.ts', True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.dvbs2_bbheader_bb_0, 0)) self.connect((self.dvbs2_bbheader_bb_0, 0), (self.dvbs2_bbscrambler_bb_0, 0)) self.connect((self.dvbs2_bbscrambler_bb_0, 0), (self.dvbs2_bch_bb_0, 0)) self.connect((self.dvbs2_bch_bb_0, 0), (self.dvbs2_ldpc_bb_0, 0)) self.connect((self.dvbs2_interleaver_bb_0, 0), (self.dvbs2_modulator_bc_0, 0)) self.connect((self.dvbs2_ldpc_bb_0, 0), (self.dvbs2_interleaver_bb_0, 0)) self.connect((self.dvbs2_modulator_bc_0, 0), (self.dvbs2_physical_cc_0, 0)) self.connect((self.dvbs2_physical_cc_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0))
def test_instance(self): # FIXME: Test will fail until you pass sensible arguments to the constructor instance = interleaver_bb()