def test_001 (self): vlen = 10 self.rx_data = None src_data = range(vlen)*100 src = blocks.vector_source_f(src_data, False, vlen) zeromq_pub_sink = zeromq.pub_sink(gr.sizeof_float, vlen, "tcp://127.0.0.1:5555") self.tb.connect(src, zeromq_pub_sink) self.probe_manager = zeromq.probe_manager() self.probe_manager.add_socket("tcp://127.0.0.1:5555", 'float32', self.recv_data) self.tb.run() self.probe_manager.watcher() self.assertFloatTuplesAlmostEqual(self.rx_data, src_data)
def test_001(self): vlen = 10 self.rx_data = None src_data = list(range(vlen)) * 100 src = blocks.vector_source_f(src_data, False, vlen) zeromq_pub_sink = zeromq.pub_sink(gr.sizeof_float, vlen, "tcp://127.0.0.1:5555") self.tb.connect(src, zeromq_pub_sink) self.probe_manager = zeromq.probe_manager() self.probe_manager.add_socket("tcp://127.0.0.1:5555", 'float32', self.recv_data) zmq_pull_t = threading.Thread(target=self.probe_manager.watcher) zmq_pull_t.daemon = True zmq_pull_t.start() self.tb.run() zmq_pull_t.join() self.assertFloatTuplesAlmostEqual(self.rx_data, src_data)
def test_001 (self): vlen = 10 self.rx_data = None src_data = list(range(vlen))*100 src = blocks.vector_source_f(src_data, False, vlen) zeromq_pub_sink = zeromq.pub_sink(gr.sizeof_float, vlen, "tcp://127.0.0.1:0") address = zeromq_pub_sink.last_endpoint() self.tb.connect(src, zeromq_pub_sink) self.probe_manager = zeromq.probe_manager() self.probe_manager.add_socket(address, 'float32', self.recv_data) zmq_pull_t = threading.Thread(target=self.probe_manager.watcher) zmq_pull_t.daemon = True zmq_pull_t.start() self.tb.run() zmq_pull_t.join(6.0) # Check to see if we timed out self.assertFalse(zmq_pull_t.is_alive()) self.assertFloatTuplesAlmostEqual(self.rx_data, src_data)
def __init__(self, options, parent=None): QtGui.QMainWindow.__init__(self, parent) self.options = options # load and uic the file right away, no additional step necessary self.gui = uic.loadUi(os.path.join(os.path.dirname(__file__),'ofdm_tx_gui_window.ui'), self) # GUI update timer self.plot_timer = Qt.QTimer() # ZeroMQ self.probe_manager = zeromq.probe_manager() self.probe_manager.add_socket("tcp://"+self.options.tx_hostname+":4444", 'f', self.plot_powerallocation) self.probe_manager.add_socket("tcp://"+self.options.tx_hostname+":4445", 'B', self.plot_bitloading) self.rpc_mgr_tx = zeromq.rpc_manager() self.rpc_mgr_tx.set_request_socket("tcp://"+self.options.tx_hostname+":6660") # Window Title self.gui.setWindowTitle("Transmitter") #Plots self.gui.qwtPlotPowerallocation.setTitle("Subcarrier Power Allocation") self.gui.qwtPlotPowerallocation.setAxisTitle(Qwt.QwtPlot.xBottom, "Subcarrier Index") self.gui.qwtPlotPowerallocation.setAxisScale(Qwt.QwtPlot.xBottom, -99, 100) self.gui.qwtPlotPowerallocation.setAxisScale(Qwt.QwtPlot.yLeft, 0, 3) self.gui.qwtPlotPowerallocation.setCanvasBackground(Qt.Qt.white) self.grid_powerallocation = Qwt.QwtPlotGrid() self.grid_powerallocation.enableXMin(True) self.grid_powerallocation.setPen(Qt.QPen(Qt.Qt.black, 1, Qt.Qt.DotLine)) self.grid_powerallocation.attach(self.gui.qwtPlotPowerallocation) self.powerallocation_x = range(-99,101) self.powerallocation_y = [0]*len(self.powerallocation_x) self.curve_powerallocation = Qwt.QwtPlotCurve() self.curve_powerallocation.setPen(Qt.QPen(Qt.Qt.green, 1)) self.curve_powerallocation.setBrush(Qt.Qt.green) self.curve_powerallocation.setStyle(Qwt.QwtPlotCurve.Steps) self.curve_powerallocation.attach(self.gui.qwtPlotPowerallocation) self.gui.qwtPlotBitloading.setTitle("Subcarrier Bitloading") self.gui.qwtPlotBitloading.setAxisTitle(Qwt.QwtPlot.xBottom, "Subcarrier Index") self.gui.qwtPlotBitloading.setAxisScale(Qwt.QwtPlot.xBottom, -99, 100) self.gui.qwtPlotBitloading.setAxisScale(Qwt.QwtPlot.yLeft, 0, 8) self.gui.qwtPlotBitloading.setCanvasBackground(Qt.Qt.white) self.grid_bitloading = Qwt.QwtPlotGrid() self.grid_bitloading.enableXMin(True) self.grid_bitloading.setPen(Qt.QPen(Qt.Qt.black, 1, Qt.Qt.DotLine)) self.grid_bitloading.attach(self.gui.qwtPlotBitloading) self.bitloading_x = range(-99,101) self.bitloading_y = [0]*len(self.bitloading_x) self.curve_bitloading = Qwt.QwtPlotCurve() self.curve_bitloading.setPen(Qt.QPen(Qt.Qt.magenta, 1)) self.curve_bitloading.setBrush(Qt.Qt.magenta) self.curve_bitloading.setStyle(Qwt.QwtPlotCurve.Steps) self.curve_bitloading.attach(self.gui.qwtPlotBitloading) #Signals self.connect(self.plot_timer, QtCore.SIGNAL("timeout()"), self.probe_manager.watcher) self.connect(self.gui.pushButtonUpdate, QtCore.SIGNAL("clicked()"), self.update_tx_parameters) # start GUI update timer (33ms for 30 FPS) self.plot_timer.start(33)
def __init__(self, options, parent=None): QtGui.QMainWindow.__init__(self, parent) self.options = options # load and uic the file right away, no additional step necessary self.gui = uic.loadUi(os.path.join(os.path.dirname(__file__),'ofdm_rx_gui_window.ui'), self) # GUI update timer self.update_timer = Qt.QTimer() # ZeroMQ self.probe_manager = zeromq.probe_manager() self.probe_manager.add_socket("tcp://"+self.options.rx_hostname+":5555", 'float32', self.plot_snr) self.probe_manager.add_socket("tcp://"+self.options.rx_hostname+":5556", 'float32', self.plot_ber) if options.measurement: self.probe_manager.add_socket("tcp://"+self.options.rx_hostname+":5556", 'float32', self.take_measurement) self.probe_manager.add_socket("tcp://"+self.options.rx_hostname+":5557", 'float32', self.plot_freqoffset) self.probe_manager.add_socket("tcp://"+self.options.tx_hostname+":4445", 'uint8', self.plot_rate) self.probe_manager.add_socket("tcp://"+self.options.rx_hostname+":5559", 'float32', self.plot_csi) self.probe_manager.add_socket("tcp://"+self.options.rx_hostname+":5560", 'complex64', self.plot_scatter) self.rpc_mgr_tx = zeromq.rpc_manager() self.rpc_mgr_tx.set_request_socket("tcp://"+self.options.tx_hostname+":6660") self.rpc_mgr_rx = zeromq.rpc_manager() self.rpc_mgr_rx.set_request_socket("tcp://"+self.options.rx_hostname+":5550") # Window Title self.gui.setWindowTitle("Receiver") #Plots self.gui.qwtPlotSNR.setAxisTitle(Qwt.QwtPlot.yLeft, "SNR[dB]") self.gui.qwtPlotSNR.setAxisScale(Qwt.QwtPlot.xBottom, 0, 127) self.gui.qwtPlotSNR.enableAxis(Qwt.QwtPlot.xBottom, False) self.gui.qwtPlotSNR.setAxisScale(Qwt.QwtPlot.yLeft, 0, 30) self.gui.qwtPlotSNR.setCanvasBackground(Qt.Qt.white) self.grid_snr = Qwt.QwtPlotGrid() self.grid_snr.setPen(Qt.QPen(Qt.Qt.black, 1, Qt.Qt.DotLine)) self.grid_snr.attach(self.gui.qwtPlotSNR) self.snr_x = range(0,128) self.snr_y = [0.0] self.curve_snr = Qwt.QwtPlotCurve() self.curve_snr.setPen(Qt.QPen(Qt.Qt.red, 1)) self.curve_snr.setBrush(Qt.Qt.red) self.curve_snr.setStyle(Qwt.QwtPlotCurve.Steps) self.curve_snr.attach(self.gui.qwtPlotSNR) self.gui.qwtPlotBER.setAxisTitle(Qwt.QwtPlot.yLeft, "BER") self.gui.qwtPlotBER.setAxisScale(Qwt.QwtPlot.xBottom, 0, 127) self.gui.qwtPlotBER.enableAxis(Qwt.QwtPlot.xBottom, False) self.gui.qwtPlotBER.setAxisScale(Qwt.QwtPlot.yLeft, 0.0001, 0.5) self.gui.qwtPlotBER.setCanvasBackground(Qt.Qt.white) self.grid_ber = Qwt.QwtPlotGrid() self.grid_ber.setPen(Qt.QPen(Qt.Qt.black, 1, Qt.Qt.DotLine)) self.grid_ber.attach(self.gui.qwtPlotBER) scale_engine = Qwt.QwtLog10ScaleEngine() self.gui.qwtPlotBER.setAxisScaleEngine(Qwt.QwtPlot.yLeft, scale_engine) self.ber_x = range(0,128) self.ber_y = [0.0] self.curve_ber = Qwt.QwtPlotCurve() self.curve_ber.setBaseline(1e-100) self.curve_ber.setPen(Qt.QPen(Qt.Qt.green, 1)) self.curve_ber.setBrush(Qt.Qt.green) self.curve_ber.setStyle(Qwt.QwtPlotCurve.Steps) self.curve_ber.attach(self.gui.qwtPlotBER) self.gui.qwtPlotFreqoffset.setAxisTitle(Qwt.QwtPlot.yLeft, "Frequency Offset") self.gui.qwtPlotFreqoffset.setAxisScale(Qwt.QwtPlot.xBottom, 0, 127) self.gui.qwtPlotFreqoffset.enableAxis(Qwt.QwtPlot.xBottom, False) self.gui.qwtPlotFreqoffset.setAxisScale(Qwt.QwtPlot.yLeft, -1, 1) self.gui.qwtPlotFreqoffset.setCanvasBackground(Qt.Qt.white) self.grid_freqoffset = Qwt.QwtPlotGrid() self.grid_freqoffset.setPen(Qt.QPen(Qt.Qt.black, 1, Qt.Qt.DotLine)) self.grid_freqoffset.attach(self.gui.qwtPlotFreqoffset) self.freqoffset_x = range(0,128) self.freqoffset_y = [0.0] self.curve_freqoffset = Qwt.QwtPlotCurve() self.curve_freqoffset.setPen(Qt.QPen(Qt.Qt.black, 1)) self.curve_freqoffset.attach(self.gui.qwtPlotFreqoffset) self.gui.qwtPlotRate.setAxisTitle(Qwt.QwtPlot.yLeft, "Datarate[Mbits/s]") self.gui.qwtPlotRate.setAxisScale(Qwt.QwtPlot.xBottom, 0, 127) self.gui.qwtPlotRate.enableAxis(Qwt.QwtPlot.xBottom, False) self.gui.qwtPlotRate.setAxisScale(Qwt.QwtPlot.yLeft, 0, 10) self.gui.qwtPlotRate.setCanvasBackground(Qt.Qt.white) self.grid_rate = Qwt.QwtPlotGrid() self.grid_rate.setPen(Qt.QPen(Qt.Qt.black, 1, Qt.Qt.DotLine)) self.grid_rate.attach(self.gui.qwtPlotRate) self.rate_x = range(0,128) self.rate_y = [0]*len(self.rate_x) self.curve_rate = Qwt.QwtPlotCurve() self.curve_rate.setPen(Qt.QPen(Qt.Qt.lightGray, 1)) self.curve_rate.setBrush(Qt.Qt.lightGray) self.curve_rate.setStyle(Qwt.QwtPlotCurve.Steps) self.curve_rate.attach(self.gui.qwtPlotRate) self.gui.qwtPlotCSI.setTitle("Normalized Channel State Information") self.gui.qwtPlotCSI.setAxisTitle(Qwt.QwtPlot.xBottom, "Subcarrier") self.gui.qwtPlotCSI.setAxisScale(Qwt.QwtPlot.xBottom, -99, 100) self.gui.qwtPlotCSI.setAxisScale(Qwt.QwtPlot.yLeft, 0, 2) self.gui.qwtPlotCSI.setCanvasBackground(Qt.Qt.white) self.grid_csi = Qwt.QwtPlotGrid() self.grid_csi.enableXMin(True) self.grid_csi.setPen(Qt.QPen(Qt.Qt.black, 1, Qt.Qt.DotLine)) self.grid_csi.attach(self.gui.qwtPlotCSI) self.csi_x = range(-99,101) self.csi_y = [0]*len(self.csi_x) self.curve_csi = Qwt.QwtPlotCurve() self.curve_csi.setPen(Qt.QPen(Qt.Qt.blue, 1)) self.curve_csi.setBrush(Qt.Qt.blue) self.curve_csi.setStyle(Qwt.QwtPlotCurve.Steps) self.curve_csi.attach(self.gui.qwtPlotCSI) self.gui.qwtPlotScatter.setTitle("Scatterplot (Subcarrier -99)") self.gui.qwtPlotScatter.setAxisTitle(Qwt.QwtPlot.xBottom, "I") self.gui.qwtPlotScatter.setAxisTitle(Qwt.QwtPlot.yLeft, "Q") self.gui.qwtPlotScatter.setAxisScale(Qwt.QwtPlot.xBottom, -1.5, 1.5) self.gui.qwtPlotScatter.setAxisScale(Qwt.QwtPlot.yLeft, -1.5, 1.5) self.gui.qwtPlotScatter.setCanvasBackground(Qt.Qt.white) self.grid_scatter = Qwt.QwtPlotGrid() self.grid_scatter.setPen(Qt.QPen(Qt.Qt.black, 1, Qt.Qt.DotLine)) self.grid_scatter.attach(self.gui.qwtPlotScatter) self.scatter_buffer = numpy.complex64([0+0j]) self.curve_scatter = Qwt.QwtPlotCurve() self.curve_scatter.setPen(Qt.QPen(Qt.Qt.blue, 1)) self.curve_scatter.setStyle(Qwt.QwtPlotCurve.Dots) self.curve_scatter.attach(self.gui.qwtPlotScatter) self.marker = Qwt.QwtSymbol() self.marker.setStyle(Qwt.QwtSymbol.XCross) self.marker.setSize(Qt.QSize(3,3)) self.curve_scatter.setSymbol(self.marker) # plot picker self.plot_picker = Qwt.QwtPlotPicker(Qwt.QwtPlot.xBottom, Qwt.QwtPlot.yLeft, Qwt.QwtPicker.PointSelection, Qwt.QwtPlotPicker.VLineRubberBand, Qwt.QwtPicker.AlwaysOff, self.gui.qwtPlotCSI.canvas()) #Signals self.connect(self.update_timer, QtCore.SIGNAL("timeout()"), self.probe_manager.watcher) self.connect(self.gui.pushButtonMeasure, QtCore.SIGNAL("clicked()"), self.measure_average) #self.connect(self.gui.pushButtonUpdate, QtCore.SIGNAL("clicked()"), self.update_modulation) self.connect(self.gui.horizontalSliderAmplitude, QtCore.SIGNAL("valueChanged(int)"), self.slide_amplitude) self.connect(self.gui.lineEditAmplitude, QtCore.SIGNAL("editingFinished()"), self.edit_amplitude) self.connect(self.gui.horizontalSliderOffset, QtCore.SIGNAL("valueChanged(int)"), self.slide_freq_offset) self.connect(self.gui.lineEditOffset, QtCore.SIGNAL("editingFinished()"), self.edit_freq_offset) self.connect(self.plot_picker, QtCore.SIGNAL("selected(const QwtDoublePoint &)"), self.subcarrier_selected) self.connect(self.gui.comboBoxChannelModel, QtCore.SIGNAL("currentIndexChanged(QString)"), self.set_channel_profile) self.connect(self.gui.horizontalSliderTxGain, QtCore.SIGNAL("valueChanged(int)"), self.slide_tx_gain) self.connect(self.gui.horizontalSliderRxGain, QtCore.SIGNAL("valueChanged(int)"), self.slide_rx_gain) self.connect(self.gui.comboBoxScheme, QtCore.SIGNAL("currentIndexChanged(QString)"), self.set_allocation_scheme) self.connect(self.gui.horizontalSliderDataRate, QtCore.SIGNAL("valueChanged(int)"), self.slide_data_rate) self.connect(self.gui.lineEditDataRate, QtCore.SIGNAL("editingFinished()"), self.edit_data_rate) self.connect(self.gui.horizontalSliderGap, QtCore.SIGNAL("valueChanged(int)"), self.slide_target_ber) self.connect(self.gui.lineEditGap, QtCore.SIGNAL("editingFinished()"), self.edit_target_ber) self.connect(self.gui.horizontalSliderResourceBlockSize, QtCore.SIGNAL("valueChanged(int)"), self.slide_resource_block_size) self.connect(self.gui.lineEditResourceBlockSize, QtCore.SIGNAL("editingFinished()"), self.edit_resource_block_size) self.connect(self.gui.comboBoxResourceBlocksScheme, QtCore.SIGNAL("currentIndexChanged(QString)"), self.set_resource_block_scheme) self.connect(self.gui.comboBoxModulation, QtCore.SIGNAL("currentIndexChanged(QString)"), self.set_modulation_scheme) if options.measurement: self.rpc_mgr_tx.request("set_amplitude",[0.018]) self.rpc_mgr_tx.request("set_amplitude_ideal",[0.018]) self.i = 0 self.ii = 0 self.iii = 1 self.ber=0.0 self.snr=0.0 self.snrsum=0.0 self.datarate=0.0 self.ratesum=0.0 self.dirname = "Simulation_"+strftime("%Y_%m_%d_%H_%M_%S",gmtime())+"/" print self.dirname if not os.path.isdir("./" + self.dirname): os.mkdir("./" + self.dirname + "/") self.iter_points = 60 self.snr_points = 30 amp_min_log = numpy.log10(0.018**2) amp_max_log = numpy.log10(0.7**2) self.txpow_range = numpy.logspace(amp_min_log,amp_max_log,self.snr_points) self.meas_ber = 0.5 self.change_mod = 1 # start GUI update timer (33ms for 30 FPS) self.update_timer.start(33) # get transmitter settings self.update_tx_params()
def __init__(self, window_name, options, parent=None): QtGui.QMainWindow.__init__(self, parent) # give Ctrl+C back to system signal.signal(signal.SIGINT, signal.SIG_DFL) self.gui = uic.loadUi( os.path.join(os.path.dirname(__file__), 'main_window.ui'), self) self.update_timer = Qt.QTimer() # socket addresses rpc_adr_server = "tcp://" + options.servername + ":6666" rpc_adr_client = "tcp://" + options.clientname + ":6667" probe_adr_server = "tcp://" + options.servername + ":5556" probe_adr_client = "tcp://" + options.clientname + ":5557" # ZeroMQ self.probe_manager = zeromq.probe_manager() self.probe_manager.add_socket(probe_adr_server, 'float32', self.plot_data_server) self.probe_manager.add_socket(probe_adr_client, 'float32', self.plot_data_client) self.rpc_mgr_server = zeromq.rpc_manager() self.rpc_mgr_server.set_request_socket(rpc_adr_server) self.rpc_mgr_client = zeromq.rpc_manager() self.rpc_mgr_client.set_request_socket(rpc_adr_client) self.gui.setWindowTitle(window_name) self.gui.qwtPlotServer.setTitle("Signal Scope") self.gui.qwtPlotServer.setAxisTitle(Qwt.QwtPlot.xBottom, "Samples") self.gui.qwtPlotServer.setAxisTitle(Qwt.QwtPlot.yLeft, "Amplitude") self.gui.qwtPlotServer.setAxisScale(Qwt.QwtPlot.xBottom, 0, 100) self.gui.qwtPlotServer.setAxisScale(Qwt.QwtPlot.yLeft, -2, 2) self.gui.qwtPlotClient.setTitle("Signal Scope") self.gui.qwtPlotClient.setAxisTitle(Qwt.QwtPlot.xBottom, "Samples") self.gui.qwtPlotClient.setAxisTitle(Qwt.QwtPlot.yLeft, "Amplitude") self.gui.qwtPlotClient.setAxisScale(Qwt.QwtPlot.xBottom, 0, 100) self.gui.qwtPlotClient.setAxisScale(Qwt.QwtPlot.yLeft, -2, 2) # Grid pen = Qt.QPen(Qt.Qt.DotLine) pen.setColor(Qt.Qt.black) pen.setWidth(0) grid_server = Qwt.QwtPlotGrid() grid_client = Qwt.QwtPlotGrid() grid_server.setPen(pen) grid_client.setPen(pen) grid_server.attach(self.gui.qwtPlotServer) grid_client.attach(self.gui.qwtPlotClient) #Signals self.connect(self.update_timer, QtCore.SIGNAL("timeout()"), self.probe_manager.watcher) self.connect(self.gui.pushButtonRunServer, QtCore.SIGNAL("clicked()"), self.start_fg_server) self.connect(self.gui.pushButtonStopServer, QtCore.SIGNAL("clicked()"), self.stop_fg_server) self.connect(self.gui.pushButtonRunClient, QtCore.SIGNAL("clicked()"), self.start_fg_client) self.connect(self.gui.pushButtonStopClient, QtCore.SIGNAL("clicked()"), self.stop_fg_client) self.connect(self.gui.comboBox, QtCore.SIGNAL("currentIndexChanged(QString)"), self.set_waveform) self.connect(self.gui.spinBox, QtCore.SIGNAL("valueChanged(int)"), self.set_gain) self.shortcut_start = QtGui.QShortcut(Qt.QKeySequence("Ctrl+S"), self.gui) self.shortcut_stop = QtGui.QShortcut(Qt.QKeySequence("Ctrl+C"), self.gui) self.shortcut_exit = QtGui.QShortcut(Qt.QKeySequence("Ctrl+D"), self.gui) self.connect(self.shortcut_exit, QtCore.SIGNAL("activated()"), self.gui.close) # start update timer self.update_timer.start(30)
def __init__(self, options, parent=None): QtGui.QMainWindow.__init__(self, parent) self.options = options # load and uic the file right away, no additional step necessary self.gui = uic.loadUi(os.path.join(os.path.dirname(__file__),'ofdm_mrrc_rx_gui_window.ui'), self) # GUI update timer self.update_timer = Qt.QTimer() # ZeroMQ self.probe_manager = zeromq.probe_manager() self.probe_manager.add_socket("tcp://"+self.options.rx_hostname+":5555", 'float32', self.plot_snr) self.probe_manager.add_socket("tcp://"+self.options.rx_hostname+":5554", 'float32', self.plot_snr2) self.probe_manager.add_socket("tcp://"+self.options.rx_hostname+":5556", 'float32', self.plot_ber) self.probe_manager.add_socket("tcp://"+self.options.rx_hostname+":5557", 'float32', self.plot_freqoffset) self.probe_manager.add_socket("tcp://"+self.options.rx_hostname+":5553", 'float32', self.plot_freqoffset2) self.probe_manager.add_socket("tcp://"+self.options.tx_hostname+":4445", 'uint8', self.plot_rate) self.probe_manager.add_socket("tcp://"+self.options.rx_hostname+":5559", 'float32', self.plot_csi) self.probe_manager.add_socket("tcp://"+self.options.rx_hostname+":5558", 'float32', self.plot_csi2) self.probe_manager.add_socket("tcp://"+self.options.rx_hostname+":5560", 'complex64', self.plot_scatter) self.rpc_mgr_tx = zeromq.rpc_manager() self.rpc_mgr_tx.set_request_socket("tcp://"+self.options.tx_hostname+":6660") self.rpc_mgr_rx = zeromq.rpc_manager() self.rpc_mgr_rx.set_request_socket("tcp://"+self.options.rx_hostname+":5550") # Window Title self.gui.setWindowTitle("Receiver") #Plots self.gui.qwtPlotSNR.setAxisTitle(Qwt.QwtPlot.yLeft, "Rx 1 SNR[dB]") self.gui.qwtPlotSNR.setAxisScale(Qwt.QwtPlot.xBottom, 0, 127) self.gui.qwtPlotSNR.enableAxis(Qwt.QwtPlot.xBottom, False) self.gui.qwtPlotSNR.setAxisScale(Qwt.QwtPlot.yLeft, 0, 30) self.snr_x = range(0,128) self.snr_y = [0.0] self.curve_snr = Qwt.QwtPlotCurve() self.curve_snr.setPen(Qt.QPen(Qt.Qt.red, 1)) self.curve_snr.setBrush(Qt.Qt.red) self.curve_snr.setStyle(Qwt.QwtPlotCurve.Steps) self.curve_snr.attach(self.gui.qwtPlotSNR) #Plots self.gui.qwtPlotSNR2.setAxisTitle(Qwt.QwtPlot.yLeft, "Rx 2 SNR[dB]") self.gui.qwtPlotSNR2.setAxisScale(Qwt.QwtPlot.xBottom, 0, 127) self.gui.qwtPlotSNR2.enableAxis(Qwt.QwtPlot.xBottom, False) self.gui.qwtPlotSNR2.setAxisScale(Qwt.QwtPlot.yLeft, 0, 30) self.snr2_x = range(0,128) self.snr2_y = [0.0] self.curve_snr2 = Qwt.QwtPlotCurve() self.curve_snr2.setPen(Qt.QPen(Qt.Qt.red, 1)) self.curve_snr2.setBrush(Qt.Qt.red) self.curve_snr2.setStyle(Qwt.QwtPlotCurve.Steps) self.curve_snr2.attach(self.gui.qwtPlotSNR2) self.gui.qwtPlotBER.setAxisTitle(Qwt.QwtPlot.yLeft, "BER") self.gui.qwtPlotBER.setAxisScale(Qwt.QwtPlot.xBottom, 0, 127) self.gui.qwtPlotBER.enableAxis(Qwt.QwtPlot.xBottom, False) self.gui.qwtPlotBER.setAxisScale(Qwt.QwtPlot.yLeft, 0.0001, 0.5) scale_engine = Qwt.QwtLog10ScaleEngine() self.gui.qwtPlotBER.setAxisScaleEngine(Qwt.QwtPlot.yLeft, scale_engine) self.ber_x = range(0,128) self.ber_y = [0.0] self.curve_ber = Qwt.QwtPlotCurve() self.curve_ber.setBaseline(1e-100) self.curve_ber.setPen(Qt.QPen(Qt.Qt.green, 1)) self.curve_ber.setBrush(Qt.Qt.green) self.curve_ber.setStyle(Qwt.QwtPlotCurve.Steps) self.curve_ber.attach(self.gui.qwtPlotBER) self.gui.qwtPlotFreqoffset.setAxisTitle(Qwt.QwtPlot.yLeft, "RX 1 Frequency Offset") self.gui.qwtPlotFreqoffset.setAxisScale(Qwt.QwtPlot.xBottom, 0, 127) self.gui.qwtPlotFreqoffset.enableAxis(Qwt.QwtPlot.xBottom, False) self.gui.qwtPlotFreqoffset.setAxisScale(Qwt.QwtPlot.yLeft, -1, 1) self.freqoffset_x = range(0,128) self.freqoffset_y = [0.0] self.curve_freqoffset = Qwt.QwtPlotCurve() self.curve_freqoffset.setPen(Qt.QPen(Qt.Qt.black, 1)) self.curve_freqoffset.attach(self.gui.qwtPlotFreqoffset) self.gui.qwtPlotFreqoffset2.setAxisTitle(Qwt.QwtPlot.yLeft, "RX 2 Frequency Offset") self.gui.qwtPlotFreqoffset2.setAxisScale(Qwt.QwtPlot.xBottom, 0, 127) self.gui.qwtPlotFreqoffset2.enableAxis(Qwt.QwtPlot.xBottom, False) self.gui.qwtPlotFreqoffset2.setAxisScale(Qwt.QwtPlot.yLeft, -1, 1) self.freqoffset2_x = range(0,128) self.freqoffset2_y = [0.0] self.curve_freqoffset2 = Qwt.QwtPlotCurve() self.curve_freqoffset2.setPen(Qt.QPen(Qt.Qt.black, 1)) self.curve_freqoffset2.attach(self.gui.qwtPlotFreqoffset2) self.gui.qwtPlotRate.setAxisTitle(Qwt.QwtPlot.yLeft, "Datarate[Mbits/s]") self.gui.qwtPlotRate.setAxisScale(Qwt.QwtPlot.xBottom, 0, 127) self.gui.qwtPlotRate.enableAxis(Qwt.QwtPlot.xBottom, False) self.gui.qwtPlotRate.setAxisScale(Qwt.QwtPlot.yLeft, 0, 10) self.rate_x = range(0,128) self.rate_y = [0]*len(self.rate_x) self.curve_rate = Qwt.QwtPlotCurve() self.curve_rate.setPen(Qt.QPen(Qt.Qt.lightGray, 1)) self.curve_rate.setBrush(Qt.Qt.lightGray) self.curve_rate.setStyle(Qwt.QwtPlotCurve.Steps) self.curve_rate.attach(self.gui.qwtPlotRate) self.gui.qwtPlotCSI.setTitle("Rx 1 Normalized CTF") self.gui.qwtPlotCSI.setAxisTitle(Qwt.QwtPlot.xBottom, "Subcarrier") self.gui.qwtPlotCSI.setAxisScale(Qwt.QwtPlot.xBottom, -99, 100) self.gui.qwtPlotCSI.setAxisScale(Qwt.QwtPlot.yLeft, 0, 2) self.csi_x = range(-99,101) self.csi_y = [0]*len(self.csi_x) self.curve_csi = Qwt.QwtPlotCurve() self.curve_csi.setPen(Qt.QPen(Qt.Qt.blue, 1)) self.curve_csi.setBrush(Qt.Qt.blue) self.curve_csi.setStyle(Qwt.QwtPlotCurve.Steps) self.curve_csi.attach(self.gui.qwtPlotCSI) self.gui.qwtPlotCSI2.setTitle("Rx 2 Normalized CTF") self.gui.qwtPlotCSI2.setAxisTitle(Qwt.QwtPlot.xBottom, "Subcarrier") self.gui.qwtPlotCSI2.setAxisScale(Qwt.QwtPlot.xBottom, -99, 100) self.gui.qwtPlotCSI2.setAxisScale(Qwt.QwtPlot.yLeft, 0, 2) #self.csi_x = range(-99,101) #self.csi_y = [0]*len(self.csi_x) self.curve_csi2 = Qwt.QwtPlotCurve() self.curve_csi2.setPen(Qt.QPen(Qt.Qt.blue, 1)) self.curve_csi2.setBrush(Qt.Qt.blue) self.curve_csi2.setStyle(Qwt.QwtPlotCurve.Steps) self.curve_csi2.attach(self.gui.qwtPlotCSI2) self.gui.qwtPlotScatter.setTitle("Scatterplot (Subcarrier -99)") self.gui.qwtPlotScatter.setAxisTitle(Qwt.QwtPlot.xBottom, "I") self.gui.qwtPlotScatter.setAxisTitle(Qwt.QwtPlot.yLeft, "Q") self.gui.qwtPlotScatter.setAxisScale(Qwt.QwtPlot.xBottom, -1.5, 1.5) self.gui.qwtPlotScatter.setAxisScale(Qwt.QwtPlot.yLeft, -1.5, 1.5) self.scatter_buffer = numpy.complex64([0+0j]) self.curve_scatter = Qwt.QwtPlotCurve() self.curve_scatter.setPen(Qt.QPen(Qt.Qt.blue, 1)) self.curve_scatter.setStyle(Qwt.QwtPlotCurve.Dots) self.curve_scatter.attach(self.gui.qwtPlotScatter) self.marker = Qwt.QwtSymbol() self.marker.setStyle(Qwt.QwtSymbol.XCross) self.marker.setSize(Qt.QSize(3,3)) self.curve_scatter.setSymbol(self.marker) # plot picker self.plot_picker = Qwt.QwtPlotPicker(Qwt.QwtPlot.xBottom, Qwt.QwtPlot.yLeft, Qwt.QwtPicker.PointSelection, Qwt.QwtPlotPicker.VLineRubberBand, Qwt.QwtPicker.AlwaysOff, self.gui.qwtPlotCSI.canvas(), #self.gui.qwtPlotCSI2.canvas() ) #Signals self.connect(self.update_timer, QtCore.SIGNAL("timeout()"), self.probe_manager.watcher) self.connect(self.gui.pushButtonMeasure, QtCore.SIGNAL("clicked()"), self.measure_average) self.connect(self.gui.pushButtonUpdate, QtCore.SIGNAL("clicked()"), self.update_modulation) self.connect(self.gui.horizontalSliderAmplitude, QtCore.SIGNAL("valueChanged(int)"), self.slide_amplitude) self.connect(self.gui.lineEditAmplitude, QtCore.SIGNAL("editingFinished()"), self.edit_amplitude) self.connect(self.gui.horizontalSliderOffset, QtCore.SIGNAL("valueChanged(int)"), self.slide_freq_offset) self.connect(self.gui.lineEditOffset, QtCore.SIGNAL("editingFinished()"), self.edit_freq_offset) self.connect(self.plot_picker, QtCore.SIGNAL("selected(const QwtDoublePoint &)"), self.subcarrier_selected) self.connect(self.gui.comboBoxChannelModel, QtCore.SIGNAL("currentIndexChanged(QString)"), self.set_channel_profile) # start GUI update timer self.update_timer.start(33) # get transmitter settings self.update_tx_params()
def __init__(self, window_name, options, parent=None): QtGui.QMainWindow.__init__(self, parent) # give Ctrl+C back to system signal.signal(signal.SIGINT, signal.SIG_DFL) self.gui = uic.loadUi(os.path.join(os.path.dirname(__file__),'main_window.ui'), self) self.update_timer = Qt.QTimer() # socket addresses rpc_adr_server = "tcp://"+options.servername+":6666" rpc_adr_client = "tcp://"+options.clientname+":6667" probe_adr_server = "tcp://"+options.servername+":5556" probe_adr_client = "tcp://"+options.clientname+":5557" # ZeroMQ self.probe_manager = zeromq.probe_manager() self.probe_manager.add_socket(probe_adr_server, 'float32', self.plot_data_server) self.probe_manager.add_socket(probe_adr_client, 'float32', self.plot_data_client) self.rpc_mgr_server = zeromq.rpc_manager() self.rpc_mgr_server.set_request_socket(rpc_adr_server) self.rpc_mgr_client = zeromq.rpc_manager() self.rpc_mgr_client.set_request_socket(rpc_adr_client) self.gui.setWindowTitle(window_name) self.gui.qwtPlotServer.setTitle("Signal Scope") self.gui.qwtPlotServer.setAxisTitle(Qwt.QwtPlot.xBottom, "Samples") self.gui.qwtPlotServer.setAxisTitle(Qwt.QwtPlot.yLeft, "Amplitude") self.gui.qwtPlotServer.setAxisScale(Qwt.QwtPlot.xBottom, 0, 100) self.gui.qwtPlotServer.setAxisScale(Qwt.QwtPlot.yLeft, -2, 2) self.gui.qwtPlotClient.setTitle("Signal Scope") self.gui.qwtPlotClient.setAxisTitle(Qwt.QwtPlot.xBottom, "Samples") self.gui.qwtPlotClient.setAxisTitle(Qwt.QwtPlot.yLeft, "Amplitude") self.gui.qwtPlotClient.setAxisScale(Qwt.QwtPlot.xBottom, 0, 100) self.gui.qwtPlotClient.setAxisScale(Qwt.QwtPlot.yLeft, -2, 2) # Grid pen = Qt.QPen(Qt.Qt.DotLine) pen.setColor(Qt.Qt.black) pen.setWidth(0) grid_server = Qwt.QwtPlotGrid() grid_client = Qwt.QwtPlotGrid() grid_server.setPen(pen) grid_client.setPen(pen) grid_server.attach(self.gui.qwtPlotServer) grid_client.attach(self.gui.qwtPlotClient) #Signals self.connect(self.update_timer, QtCore.SIGNAL("timeout()"), self.probe_manager.watcher) self.connect(self.gui.pushButtonRunServer, QtCore.SIGNAL("clicked()"), self.start_fg_server) self.connect(self.gui.pushButtonStopServer, QtCore.SIGNAL("clicked()"), self.stop_fg_server) self.connect(self.gui.pushButtonRunClient, QtCore.SIGNAL("clicked()"), self.start_fg_client) self.connect(self.gui.pushButtonStopClient, QtCore.SIGNAL("clicked()"), self.stop_fg_client) self.connect(self.gui.comboBox, QtCore.SIGNAL("currentIndexChanged(QString)"), self.set_waveform) self.connect(self.gui.spinBox, QtCore.SIGNAL("valueChanged(int)"), self.set_gain) self.shortcut_start = QtGui.QShortcut(Qt.QKeySequence("Ctrl+S"), self.gui) self.shortcut_stop = QtGui.QShortcut(Qt.QKeySequence("Ctrl+C"), self.gui) self.shortcut_exit = QtGui.QShortcut(Qt.QKeySequence("Ctrl+D"), self.gui) self.connect(self.shortcut_exit, QtCore.SIGNAL("activated()"), self.gui.close) # start update timer self.update_timer.start(30)
def __init__(self, options, parent=None): QtGui.QMainWindow.__init__(self, parent) self.options = options # load and uic the file right away, no additional step necessary self.gui = uic.loadUi( os.path.join(os.path.dirname(__file__), 'ofdm_rx_gui_window.ui'), self) # GUI update timer self.update_timer = Qt.QTimer() # ZeroMQ self.probe_manager = zeromq.probe_manager() self.probe_manager.add_socket( "tcp://" + self.options.rx_hostname + ":5555", 'float32', self.plot_snr) self.probe_manager.add_socket( "tcp://" + self.options.rx_hostname + ":5556", 'float32', self.plot_ber) if options.measurement: self.probe_manager.add_socket( "tcp://" + self.options.rx_hostname + ":5556", 'float32', self.take_measurement) self.probe_manager.add_socket( "tcp://" + self.options.rx_hostname + ":5557", 'float32', self.plot_freqoffset) self.probe_manager.add_socket( "tcp://" + self.options.tx_hostname + ":4445", 'uint8', self.plot_rate) self.probe_manager.add_socket( "tcp://" + self.options.rx_hostname + ":5559", 'float32', self.plot_csi) self.probe_manager.add_socket( "tcp://" + self.options.rx_hostname + ":5560", 'complex64', self.plot_scatter) self.rpc_mgr_tx = zeromq.rpc_manager() self.rpc_mgr_tx.set_request_socket("tcp://" + self.options.tx_hostname + ":6660") self.rpc_mgr_rx = zeromq.rpc_manager() self.rpc_mgr_rx.set_request_socket("tcp://" + self.options.rx_hostname + ":5550") # Window Title self.gui.setWindowTitle("Receiver") #Plots self.gui.qwtPlotSNR.setAxisTitle(Qwt.QwtPlot.yLeft, "SNR[dB]") self.gui.qwtPlotSNR.setAxisScale(Qwt.QwtPlot.xBottom, 0, 127) self.gui.qwtPlotSNR.enableAxis(Qwt.QwtPlot.xBottom, False) self.gui.qwtPlotSNR.setAxisScale(Qwt.QwtPlot.yLeft, 0, 30) self.snr_x = range(0, 128) self.snr_y = [0.0] self.curve_snr = Qwt.QwtPlotCurve() self.curve_snr.setPen(Qt.QPen(Qt.Qt.red, 1)) self.curve_snr.setBrush(Qt.Qt.red) self.curve_snr.setStyle(Qwt.QwtPlotCurve.Steps) self.curve_snr.attach(self.gui.qwtPlotSNR) self.gui.qwtPlotBER.setAxisTitle(Qwt.QwtPlot.yLeft, "BER") self.gui.qwtPlotBER.setAxisScale(Qwt.QwtPlot.xBottom, 0, 127) self.gui.qwtPlotBER.enableAxis(Qwt.QwtPlot.xBottom, False) self.gui.qwtPlotBER.setAxisScale(Qwt.QwtPlot.yLeft, 0.0001, 0.5) scale_engine = Qwt.QwtLog10ScaleEngine() self.gui.qwtPlotBER.setAxisScaleEngine(Qwt.QwtPlot.yLeft, scale_engine) self.ber_x = range(0, 128) self.ber_y = [0.0] self.curve_ber = Qwt.QwtPlotCurve() self.curve_ber.setBaseline(1e-100) self.curve_ber.setPen(Qt.QPen(Qt.Qt.green, 1)) self.curve_ber.setBrush(Qt.Qt.green) self.curve_ber.setStyle(Qwt.QwtPlotCurve.Steps) self.curve_ber.attach(self.gui.qwtPlotBER) self.gui.qwtPlotFreqoffset.setAxisTitle(Qwt.QwtPlot.yLeft, "Frequency Offset") self.gui.qwtPlotFreqoffset.setAxisScale(Qwt.QwtPlot.xBottom, 0, 127) self.gui.qwtPlotFreqoffset.enableAxis(Qwt.QwtPlot.xBottom, False) self.gui.qwtPlotFreqoffset.setAxisScale(Qwt.QwtPlot.yLeft, -1, 1) self.freqoffset_x = range(0, 128) self.freqoffset_y = [0.0] self.curve_freqoffset = Qwt.QwtPlotCurve() self.curve_freqoffset.setPen(Qt.QPen(Qt.Qt.black, 1)) self.curve_freqoffset.attach(self.gui.qwtPlotFreqoffset) self.gui.qwtPlotRate.setAxisTitle(Qwt.QwtPlot.yLeft, "Datarate[Mbits/s]") self.gui.qwtPlotRate.setAxisScale(Qwt.QwtPlot.xBottom, 0, 127) self.gui.qwtPlotRate.enableAxis(Qwt.QwtPlot.xBottom, False) self.gui.qwtPlotRate.setAxisScale(Qwt.QwtPlot.yLeft, 0, 10) self.rate_x = range(0, 128) self.rate_y = [0] * len(self.rate_x) self.curve_rate = Qwt.QwtPlotCurve() self.curve_rate.setPen(Qt.QPen(Qt.Qt.lightGray, 1)) self.curve_rate.setBrush(Qt.Qt.lightGray) self.curve_rate.setStyle(Qwt.QwtPlotCurve.Steps) self.curve_rate.attach(self.gui.qwtPlotRate) self.gui.qwtPlotCSI.setTitle("Normalized Channel State Information") self.gui.qwtPlotCSI.setAxisTitle(Qwt.QwtPlot.xBottom, "Subcarrier") self.gui.qwtPlotCSI.setAxisScale(Qwt.QwtPlot.xBottom, -99, 100) self.gui.qwtPlotCSI.setAxisScale(Qwt.QwtPlot.yLeft, 0, 2) self.csi_x = range(-99, 101) self.csi_y = [0] * len(self.csi_x) self.curve_csi = Qwt.QwtPlotCurve() self.curve_csi.setPen(Qt.QPen(Qt.Qt.blue, 1)) self.curve_csi.setBrush(Qt.Qt.blue) self.curve_csi.setStyle(Qwt.QwtPlotCurve.Steps) self.curve_csi.attach(self.gui.qwtPlotCSI) self.gui.qwtPlotScatter.setTitle("Scatterplot (Subcarrier -99)") self.gui.qwtPlotScatter.setAxisTitle(Qwt.QwtPlot.xBottom, "I") self.gui.qwtPlotScatter.setAxisTitle(Qwt.QwtPlot.yLeft, "Q") self.gui.qwtPlotScatter.setAxisScale(Qwt.QwtPlot.xBottom, -1.5, 1.5) self.gui.qwtPlotScatter.setAxisScale(Qwt.QwtPlot.yLeft, -1.5, 1.5) self.scatter_buffer = numpy.complex64([0 + 0j]) self.curve_scatter = Qwt.QwtPlotCurve() self.curve_scatter.setPen(Qt.QPen(Qt.Qt.blue, 1)) self.curve_scatter.setStyle(Qwt.QwtPlotCurve.Dots) self.curve_scatter.attach(self.gui.qwtPlotScatter) self.marker = Qwt.QwtSymbol() self.marker.setStyle(Qwt.QwtSymbol.XCross) self.marker.setSize(Qt.QSize(3, 3)) self.curve_scatter.setSymbol(self.marker) # plot picker self.plot_picker = Qwt.QwtPlotPicker(Qwt.QwtPlot.xBottom, Qwt.QwtPlot.yLeft, Qwt.QwtPicker.PointSelection, Qwt.QwtPlotPicker.VLineRubberBand, Qwt.QwtPicker.AlwaysOff, self.gui.qwtPlotCSI.canvas()) #Signals self.connect(self.update_timer, QtCore.SIGNAL("timeout()"), self.probe_manager.watcher) self.connect(self.gui.pushButtonMeasure, QtCore.SIGNAL("clicked()"), self.measure_average) #self.connect(self.gui.pushButtonUpdate, QtCore.SIGNAL("clicked()"), self.update_modulation) self.connect(self.gui.horizontalSliderAmplitude, QtCore.SIGNAL("valueChanged(int)"), self.slide_amplitude) self.connect(self.gui.lineEditAmplitude, QtCore.SIGNAL("editingFinished()"), self.edit_amplitude) self.connect(self.gui.horizontalSliderOffset, QtCore.SIGNAL("valueChanged(int)"), self.slide_freq_offset) self.connect(self.gui.lineEditOffset, QtCore.SIGNAL("editingFinished()"), self.edit_freq_offset) self.connect(self.plot_picker, QtCore.SIGNAL("selected(const QwtDoublePoint &)"), self.subcarrier_selected) self.connect(self.gui.comboBoxChannelModel, QtCore.SIGNAL("currentIndexChanged(QString)"), self.set_channel_profile) self.connect(self.gui.horizontalSliderTxGain, QtCore.SIGNAL("valueChanged(int)"), self.slide_tx_gain) self.connect(self.gui.horizontalSliderRxGain, QtCore.SIGNAL("valueChanged(int)"), self.slide_rx_gain) self.connect(self.gui.comboBoxScheme, QtCore.SIGNAL("currentIndexChanged(QString)"), self.set_allocation_scheme) self.connect(self.gui.horizontalSliderDataRate, QtCore.SIGNAL("valueChanged(int)"), self.slide_data_rate) self.connect(self.gui.lineEditDataRate, QtCore.SIGNAL("editingFinished()"), self.edit_data_rate) self.connect(self.gui.horizontalSliderGap, QtCore.SIGNAL("valueChanged(int)"), self.slide_gap) self.connect(self.gui.lineEditGap, QtCore.SIGNAL("editingFinished()"), self.edit_gap) self.connect(self.gui.horizontalSliderResourceBlockSize, QtCore.SIGNAL("valueChanged(int)"), self.slide_resource_block_size) self.connect(self.gui.lineEditResourceBlockSize, QtCore.SIGNAL("editingFinished()"), self.edit_resource_block_size) self.connect(self.gui.comboBoxResourceBlocksScheme, QtCore.SIGNAL("currentIndexChanged(QString)"), self.set_resource_block_scheme) self.connect(self.gui.comboBoxModulation, QtCore.SIGNAL("currentIndexChanged(QString)"), self.set_modulation_scheme) if options.measurement: self.rpc_mgr_tx.request("set_amplitude", [0.018]) self.rpc_mgr_tx.request("set_amplitude_ideal", [0.018]) self.i = 0 self.ii = 0 self.iii = 1 self.ber = 0.0 self.snr = 0.0 self.snrsum = 0.0 self.datarate = 0.0 self.ratesum = 0.0 self.dirname = "Simulation_" + strftime("%Y_%m_%d_%H_%M_%S", gmtime()) + "/" print self.dirname if not os.path.isdir("./" + self.dirname): os.mkdir("./" + self.dirname + "/") self.iter_points = 60 self.snr_points = 30 amp_min_log = numpy.log10(0.018**2) amp_max_log = numpy.log10(0.7**2) self.txpow_range = numpy.logspace(amp_min_log, amp_max_log, self.snr_points) self.meas_ber = 0.5 self.change_mod = 1 # start GUI update timer (33ms for 30 FPS) self.update_timer.start(33) # get transmitter settings self.update_tx_params()