def __init__(self, atten=0, fd=50, fadeMode=0): gr.top_block.__init__(self, "Static RF or Single Path Rayleigh Faded RF") ################################################## # Parameters ################################################## self.atten = atten self.fd = fd self.fadeMode = fadeMode ################################################## # Variables ################################################## self.usrpRate = usrpRate = 250e3 self.fdTs = fdTs = fd * (1.0 / usrpRate) self.centreFreq = centreFreq = 1e6 self.baseband_multiplier = baseband_multiplier = 0.25 ################################################## # Blocks ################################################## self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer( ("0.0.0.0", 1234), allow_none=True) self.xmlrpc_server_0.register_instance(self) threading.Thread(target=self.xmlrpc_server_0.serve_forever).start() self.uhd_usrp_sink_0_0_0 = uhd.usrp_sink( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0_0_0.set_subdev_spec("A:AB", 0) self.uhd_usrp_sink_0_0_0.set_samp_rate(usrpRate) self.uhd_usrp_sink_0_0_0.set_center_freq(centreFreq, 0) self.uhd_usrp_sink_0_0_0.set_gain(0, 0) self.rccBlocks_channelModel_cc_0 = rccBlocks.channelModel_cc( randint(-10000, 0), fdTs, 1.0, False, bool(fadeMode)) self.rccBlocks_VNXLabBrick_0 = rccBlocks.VNXLabBrick(atten) self.const_source_x_0_0 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 1.0) self.const_source_x_0 = gr.sig_source_c(0, gr.GR_CONST_WAVE, 0, 0, 1.0 + 1j) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, usrpRate) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc( (baseband_multiplier, )) ################################################## # Connections ################################################## self.connect((self.const_source_x_0, 0), (self.rccBlocks_channelModel_cc_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.uhd_usrp_sink_0_0_0, 0)) self.connect((self.const_source_x_0_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.rccBlocks_VNXLabBrick_0, 0)) self.connect((self.rccBlocks_channelModel_cc_0, 0), (self.blocks_multiply_const_vxx_1, 0))
def __init__(self): gr.top_block.__init__(self, "Static RF or Single Path Rayleigh Faded RF") Qt.QWidget.__init__(self) self.setWindowTitle("Static RF or Single Path Rayleigh Faded RF") self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) 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) ################################################## # Variables ################################################## self.speed = speed = 50 self.carrierFreq = carrierFreq = 155e6 self.usrpRate = usrpRate = 250e3 self.rfLeveldBm = rfLeveldBm = -80 self.fd = fd = ((1.0*speed/3.6)*carrierFreq)/3e8 self.hhh = hhh = fd self.fdTs = fdTs = fd*(1.0/usrpRate) self.fadeMode = fadeMode = False self.centreFreq = centreFreq = 1e6 self.baseband_multiplier = baseband_multiplier = 0.25 self.atten = atten = abs(rfLeveldBm+65) ################################################## # Blocks ################################################## _fadeMode_check_box = Qt.QCheckBox("Fading Enabled") self._fadeMode_choices = {True: True, False: False} self._fadeMode_choices_inv = dict((v,k) for k,v in self._fadeMode_choices.iteritems()) self._fadeMode_callback = lambda i: _fadeMode_check_box.setChecked(self._fadeMode_choices_inv[i]) self._fadeMode_callback(self.fadeMode) _fadeMode_check_box.stateChanged.connect(lambda i: self.set_fadeMode(self._fadeMode_choices[bool(i)])) self.top_layout.addWidget(_fadeMode_check_box) self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(("0.0.0.0", 1234), allow_none=True) self.xmlrpc_server_0.register_instance(self) threading.Thread(target=self.xmlrpc_server_0.serve_forever).start() self.uhd_usrp_sink_0_0_0 = uhd.usrp_sink( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0_0_0.set_subdev_spec("A:AB", 0) self.uhd_usrp_sink_0_0_0.set_samp_rate(usrpRate) self.uhd_usrp_sink_0_0_0.set_center_freq(centreFreq, 0) self.uhd_usrp_sink_0_0_0.set_gain(0, 0) self._speed_tool_bar = Qt.QToolBar(self) self._speed_tool_bar.addWidget(Qt.QLabel("Vehicle Speed, Kph"+": ")) self._speed_line_edit = Qt.QLineEdit(str(self.speed)) self._speed_tool_bar.addWidget(self._speed_line_edit) self._speed_line_edit.returnPressed.connect( lambda: self.set_speed(eng_notation.str_to_num(self._speed_line_edit.text().toAscii()))) self.top_layout.addWidget(self._speed_tool_bar) self._rfLeveldBm_layout = Qt.QHBoxLayout() self._rfLeveldBm_layout.addWidget(Qt.QLabel("Unfaded RF Level, dBm"+": ")) self._rfLeveldBm_counter = Qwt.QwtCounter() self._rfLeveldBm_counter.setRange(-125, -80, 0.5) self._rfLeveldBm_counter.setNumButtons(2) self._rfLeveldBm_counter.setMinimumWidth(200) self._rfLeveldBm_counter.setValue(self.rfLeveldBm) self._rfLeveldBm_layout.addWidget(self._rfLeveldBm_counter) self._rfLeveldBm_counter.valueChanged.connect(self.set_rfLeveldBm) self.top_layout.addLayout(self._rfLeveldBm_layout) self.rccBlocks_channelModel_cc_0 = rccBlocks.channelModel_cc(randint(-10000,0), fdTs, 1.0, False, fadeMode) self.rccBlocks_VNXLabBrick_0 = rccBlocks.VNXLabBrick(atten) self._hhh_tool_bar = Qt.QToolBar(self) self._hhh_tool_bar.addWidget(Qt.QLabel("Doppler Frequency, Hz"+": ")) self._hhh_label = Qt.QLabel(str(self.hhh)) self._hhh_tool_bar.addWidget(self._hhh_label) self.top_layout.addWidget(self._hhh_tool_bar) self.const_source_x_0_0 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 1.0) self.const_source_x_0 = gr.sig_source_c(0, gr.GR_CONST_WAVE, 0, 0, 1.0+1j) self._carrierFreq_tool_bar = Qt.QToolBar(self) self._carrierFreq_tool_bar.addWidget(Qt.QLabel("RF Frequency, Hz"+": ")) self._carrierFreq_line_edit = Qt.QLineEdit(str(self.carrierFreq)) self._carrierFreq_tool_bar.addWidget(self._carrierFreq_line_edit) self._carrierFreq_line_edit.returnPressed.connect( lambda: self.set_carrierFreq(eng_notation.str_to_num(self._carrierFreq_line_edit.text().toAscii()))) self.top_layout.addWidget(self._carrierFreq_tool_bar) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, usrpRate) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((baseband_multiplier, )) ################################################## # Connections ################################################## self.connect((self.const_source_x_0, 0), (self.rccBlocks_channelModel_cc_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.uhd_usrp_sink_0_0_0, 0)) self.connect((self.const_source_x_0_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.rccBlocks_VNXLabBrick_0, 0)) self.connect((self.rccBlocks_channelModel_cc_0, 0), (self.blocks_multiply_const_vxx_1, 0))