aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2021-12-13 18:31:05 +0100
committerNao Pross <np@0hm.ch>2021-12-13 18:31:05 +0100
commit723103628ccb1679fc7e94022f5a97176442544d (patch)
tree96391de5e584901787ccaef9c8b2a78d2b17eb4d
parentEdit fractional delay (diff)
downloadFading-723103628ccb1679fc7e94022f5a97176442544d.tar.gz
Fading-723103628ccb1679fc7e94022f5a97176442544d.zip
Clean up GUI code, set up network constellation plots
Diffstat (limited to '')
-rw-r--r--flowgraphs/qam_sim.grc4
-rwxr-xr-xflowgraphs/qam_sim.py8
-rw-r--r--flowgraphs/qpsk_sim.grc24
-rwxr-xr-xflowgraphs/qpsk_sim.py179
-rw-r--r--src/gui/NotoSerifCJKjp-Medium.otfbin23900156 -> 0 bytes
-rw-r--r--src/gui/dpg.ini15
-rwxr-xr-xsrc/gui/gui.py328
-rwxr-xr-xsrc/gui/gui_v2.py336
-rw-r--r--src/gui/lena512color.pngbin786572 -> 474775 bytes
-rw-r--r--src/gui/logo.pngbin9317 -> 0 bytes
-rw-r--r--src/gui/net.py64
-rw-r--r--src/gui/test.py40
-rw-r--r--src/gui/test2.py22
13 files changed, 265 insertions, 755 deletions
diff --git a/flowgraphs/qam_sim.grc b/flowgraphs/qam_sim.grc
index c5f407b..b7aee4b 100644
--- a/flowgraphs/qam_sim.grc
+++ b/flowgraphs/qam_sim.grc
@@ -385,7 +385,7 @@ blocks:
bus_structure: null
coordinate: [600, 572.0]
rotation: 0
- state: disabled
+ state: enabled
- name: digital_constellation_decoder_cb_0
id: digital_constellation_decoder_cb
parameters:
@@ -534,7 +534,7 @@ blocks:
bus_structure: null
coordinate: [648, 740.0]
rotation: 0
- state: enabled
+ state: disabled
- name: fadingui_netsink_0
id: fadingui_netsink
parameters:
diff --git a/flowgraphs/qam_sim.py b/flowgraphs/qam_sim.py
index 9f22572..b450f74 100755
--- a/flowgraphs/qam_sim.py
+++ b/flowgraphs/qam_sim.py
@@ -178,7 +178,6 @@ class qam_sim(gr.top_block, Qt.QWidget):
self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win)
self.fadingui_phasecorrection_0 = fadingui.phasecorrection(frame_len)
- self.fadingui_multipath_fading_0 = fadingui.multipath_fading(amplitudes=[0.12], delays=[1.8], los =True)
self.fadingui_ber_0 = fadingui.ber(vgl=testvec + list(np.zeros(4)), vlen=frame_len)
self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 2 * np.pi / 100, rrc_taps, 32, 16, 1.5, 1)
self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc(2, 5e-3, 1, qam_const)
@@ -192,6 +191,7 @@ class qam_sim(gr.top_block, Qt.QWidget):
verbose=False,
log=False)
self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(qam_const)
+ self.channels_selective_fading_model_0 = channels.selective_fading_model( 8, ((4*carrier_freq)/(3*10e8))/samp_rate, False, 4.0, 21, (0,1.8), (1,0.12), 8 )
self.channels_channel_model_0 = channels.channel_model(
noise_voltage=100e-3,
frequency_offset=0,
@@ -223,7 +223,8 @@ class qam_sim(gr.top_block, Qt.QWidget):
self.connect((self.blocks_tagged_stream_align_0, 0), (self.blocks_repack_bits_bb_0, 0))
self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0))
self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_mux_0, 0))
- self.connect((self.channels_channel_model_0, 0), (self.fadingui_multipath_fading_0, 0))
+ self.connect((self.channels_channel_model_0, 0), (self.channels_selective_fading_model_0, 0))
+ self.connect((self.channels_selective_fading_model_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))
self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_tagged_stream_align_0, 0))
self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_throttle_0, 0))
self.connect((self.digital_corr_est_cc_0, 1), (self.blocks_complex_to_mag_0, 0))
@@ -232,7 +233,6 @@ class qam_sim(gr.top_block, Qt.QWidget):
self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.qtgui_const_sink_x_0, 1))
self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_lms_dd_equalizer_cc_0, 0))
self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_const_sink_x_0, 0))
- self.connect((self.fadingui_multipath_fading_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))
self.connect((self.fadingui_phasecorrection_0, 0), (self.digital_constellation_decoder_cb_0, 0))
self.connect((self.fadingui_phasecorrection_0, 0), (self.qtgui_const_sink_x_0, 2))
@@ -278,6 +278,7 @@ class qam_sim(gr.top_block, Qt.QWidget):
def set_samp_rate(self, samp_rate):
self.samp_rate = samp_rate
self.blocks_throttle_0.set_sample_rate(self.samp_rate)
+ self.channels_selective_fading_model_0.set_fDTs(((4*self.carrier_freq)/(3*10e8))/self.samp_rate)
self.qtgui_time_sink_x_0.set_samp_rate(self.samp_rate / self.sps)
def get_rrc_taps(self):
@@ -304,6 +305,7 @@ class qam_sim(gr.top_block, Qt.QWidget):
def set_carrier_freq(self, carrier_freq):
self.carrier_freq = carrier_freq
+ self.channels_selective_fading_model_0.set_fDTs(((4*self.carrier_freq)/(3*10e8))/self.samp_rate)
def get_access_code_symbols(self):
return self.access_code_symbols
diff --git a/flowgraphs/qpsk_sim.grc b/flowgraphs/qpsk_sim.grc
index a6afefa..e5078ea 100644
--- a/flowgraphs/qpsk_sim.grc
+++ b/flowgraphs/qpsk_sim.grc
@@ -8,7 +8,7 @@ options:
description: ''
gen_cmake: 'On'
gen_linking: dynamic
- generate_options: qt_gui
+ generate_options: no_gui
hier_block_src_path: '.:'
id: qpsk_sim
max_nouts: '0'
@@ -210,7 +210,7 @@ blocks:
bus_structure: null
coordinate: [1064, 1080.0]
rotation: 0
- state: true
+ state: disabled
- name: blocks_repack_bits_bb_0
id: blocks_repack_bits_bb
parameters:
@@ -521,7 +521,7 @@ blocks:
- name: fadingui_netsink_0
id: fadingui_netsink
parameters:
- address: udp://localhost:31415
+ address: udp://localhost:31416
affinity: ''
alias: ''
comment: ''
@@ -533,11 +533,11 @@ blocks:
bus_structure: null
coordinate: [704, 316.0]
rotation: 0
- state: disabled
+ state: enabled
- name: fadingui_netsink_1
id: fadingui_netsink
parameters:
- address: udp://localhost:31415
+ address: udp://localhost:31418
affinity: ''
alias: ''
comment: ''
@@ -549,11 +549,11 @@ blocks:
bus_structure: null
coordinate: [768, 916.0]
rotation: 0
- state: disabled
+ state: enabled
- name: fadingui_netsink_3
id: fadingui_netsink
parameters:
- address: udp://localhost:31415
+ address: udp://localhost:31419
affinity: ''
alias: ''
comment: ''
@@ -565,11 +565,11 @@ blocks:
bus_structure: null
coordinate: [1280, 916.0]
rotation: 0
- state: disabled
+ state: enabled
- name: fadingui_netsink_4
id: fadingui_netsink
parameters:
- address: udp://localhost:31415
+ address: udp://localhost:31417
affinity: ''
alias: ''
comment: ''
@@ -581,7 +581,7 @@ blocks:
bus_structure: null
coordinate: [528, 916.0]
rotation: 0
- state: disabled
+ state: enabled
- name: fadingui_phasecorrection_0
id: fadingui_phasecorrection
parameters:
@@ -702,7 +702,7 @@ blocks:
bus_structure: null
coordinate: [1240, 828.0]
rotation: 0
- state: true
+ state: disabled
- name: qtgui_time_sink_x_0
id: qtgui_time_sink_x
parameters:
@@ -799,7 +799,7 @@ blocks:
bus_structure: null
coordinate: [1248, 1060.0]
rotation: 0
- state: true
+ state: disabled
- name: virtual_sink_0
id: virtual_sink
parameters:
diff --git a/flowgraphs/qpsk_sim.py b/flowgraphs/qpsk_sim.py
index 12a4894..2d135f0 100755
--- a/flowgraphs/qpsk_sim.py
+++ b/flowgraphs/qpsk_sim.py
@@ -9,25 +9,10 @@
# Author: Naoki Sean Pross, Sara Cinzia Halter
# GNU Radio version: 3.8.2.0
-from distutils.version import StrictVersion
-
-if __name__ == '__main__':
- import ctypes
- import sys
- if sys.platform.startswith('linux'):
- try:
- x11 = ctypes.cdll.LoadLibrary('libX11.so')
- x11.XInitThreads()
- except:
- print("Warning: failed to XInitThreads()")
-
-from PyQt5 import Qt
-from gnuradio import qtgui
-from gnuradio.filter import firdes
-import sip
from gnuradio import blocks
import numpy
from gnuradio import channels
+from gnuradio.filter import firdes
from gnuradio import digital
from gnuradio import gr
import sys
@@ -38,40 +23,11 @@ from gnuradio import eng_notation
import fadingui
import numpy as np
-from gnuradio import qtgui
-class qpsk_sim(gr.top_block, Qt.QWidget):
+class qpsk_sim(gr.top_block):
def __init__(self):
gr.top_block.__init__(self, "QPSK Sim")
- Qt.QWidget.__init__(self)
- self.setWindowTitle("QPSK Sim")
- 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", "qpsk_sim")
-
- try:
- if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
- self.restoreGeometry(self.settings.value("geometry").toByteArray())
- else:
- self.restoreGeometry(self.settings.value("geometry"))
- except:
- pass
##################################################
# Variables
@@ -90,94 +46,11 @@ class qpsk_sim(gr.top_block, Qt.QWidget):
##################################################
# Blocks
##################################################
- self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
- 1024, #size
- samp_rate / sps, #samp_rate
- "", #name
- 1 #number of inputs
- )
- self.qtgui_time_sink_x_0.set_update_time(0.10)
- self.qtgui_time_sink_x_0.set_y_axis(0, 10)
-
- self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")
-
- self.qtgui_time_sink_x_0.enable_tags(True)
- self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
- self.qtgui_time_sink_x_0.enable_autoscale(False)
- self.qtgui_time_sink_x_0.enable_grid(False)
- self.qtgui_time_sink_x_0.enable_axis_labels(True)
- self.qtgui_time_sink_x_0.enable_control_panel(False)
- self.qtgui_time_sink_x_0.enable_stem_plot(False)
-
-
- labels = ['Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5',
- 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10']
- widths = [1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1]
- colors = ['blue', 'red', 'green', 'black', 'cyan',
- 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue']
- alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
- 1.0, 1.0, 1.0, 1.0, 1.0]
- styles = [1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1]
- markers = [-1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1]
-
-
- for i in range(1):
- if len(labels[i]) == 0:
- self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i))
- else:
- self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
- self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
- self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
- self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
- self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
- self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])
-
- self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
- self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win)
- self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
- 1024, #size
- "", #name
- 1 #number of inputs
- )
- self.qtgui_const_sink_x_0.set_update_time(0.10)
- self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
- self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
- self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
- self.qtgui_const_sink_x_0.enable_autoscale(False)
- self.qtgui_const_sink_x_0.enable_grid(False)
- self.qtgui_const_sink_x_0.enable_axis_labels(True)
-
-
- labels = ['', '', '', '', '',
- '', '', '', '', '']
- widths = [1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1]
- colors = ["blue", "red", "red", "red", "red",
- "red", "red", "red", "red", "red"]
- styles = [0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0]
- markers = [0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0]
- alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
- 1.0, 1.0, 1.0, 1.0, 1.0]
-
- for i in range(1):
- if len(labels[i]) == 0:
- self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i))
- else:
- self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
- self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
- self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
- self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
- self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
- self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])
-
- self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
- self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win)
self.fadingui_phasecorrection_0 = fadingui.phasecorrection(frame_len)
+ self.fadingui_netsink_4 = fadingui.netsink(address='udp://localhost:31417', dtype="complex", vlen=1)
+ self.fadingui_netsink_3 = fadingui.netsink(address='udp://localhost:31419', dtype="complex", vlen=1)
+ self.fadingui_netsink_1 = fadingui.netsink(address='udp://localhost:31418', dtype="complex", vlen=1)
+ self.fadingui_netsink_0 = fadingui.netsink(address='udp://localhost:31416', dtype="complex", vlen=1)
self.fadingui_multipath_fading_0 = fadingui.multipath_fading(amplitudes=[0.12], delays=[1.8], los =True)
self.fadingui_ber_0 = fadingui.ber(vgl=testvec + list(np.zeros(4)), vlen=frame_len)
self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 2 * np.pi / 100, rrc_taps, 32, 16, 1.5, 1)
@@ -205,7 +78,6 @@ class qpsk_sim(gr.top_block, Qt.QWidget):
self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_char*1, frame_len)
self.blocks_stream_mux_0 = blocks.stream_mux(gr.sizeof_char*1, [len(testvec), 4])
self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(2, 8, "", False, gr.GR_LSB_FIRST)
- self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
self.analog_random_source_x_0 = blocks.vector_source_b(list(map(int, numpy.random.randint(0, 255, 400))), True)
@@ -214,7 +86,6 @@ class qpsk_sim(gr.top_block, Qt.QWidget):
# Connections
##################################################
self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_mux_0, 1))
- self.connect((self.blocks_complex_to_mag_0, 0), (self.qtgui_time_sink_x_0, 0))
self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_stream_to_vector_0, 0))
self.connect((self.blocks_stream_mux_0, 0), (self.digital_constellation_modulator_0, 0))
self.connect((self.blocks_stream_to_vector_0, 0), (self.fadingui_ber_0, 0))
@@ -223,21 +94,18 @@ class qpsk_sim(gr.top_block, Qt.QWidget):
self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_mux_0, 0))
self.connect((self.channels_channel_model_0, 0), (self.fadingui_multipath_fading_0, 0))
self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_corr_est_cc_0, 0))
+ self.connect((self.digital_cma_equalizer_cc_0, 0), (self.fadingui_netsink_1, 0))
self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_tagged_stream_align_0, 0))
self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_throttle_0, 0))
- self.connect((self.digital_corr_est_cc_0, 1), (self.blocks_complex_to_mag_0, 0))
+ self.connect((self.digital_constellation_modulator_0, 0), (self.fadingui_netsink_0, 0))
self.connect((self.digital_corr_est_cc_0, 0), (self.fadingui_phasecorrection_0, 0))
self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0))
+ self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.fadingui_netsink_4, 0))
self.connect((self.fadingui_multipath_fading_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))
self.connect((self.fadingui_phasecorrection_0, 0), (self.digital_constellation_decoder_cb_0, 0))
- self.connect((self.fadingui_phasecorrection_0, 0), (self.qtgui_const_sink_x_0, 0))
+ self.connect((self.fadingui_phasecorrection_0, 0), (self.fadingui_netsink_3, 0))
- def closeEvent(self, event):
- self.settings = Qt.QSettings("GNU Radio", "qpsk_sim")
- self.settings.setValue("geometry", self.saveGeometry())
- event.accept()
-
def get_testvec(self):
return self.testvec
@@ -252,7 +120,6 @@ class qpsk_sim(gr.top_block, Qt.QWidget):
def set_sps(self, sps):
self.sps = sps
self.set_rrc_taps(firdes.root_raised_cosine(self.nfilts, self.nfilts, 1.0/float(self.sps), self.excess_bw, 45*self.nfilts))
- self.qtgui_time_sink_x_0.set_samp_rate(self.samp_rate / self.sps)
def get_nfilts(self):
return self.nfilts
@@ -274,7 +141,6 @@ class qpsk_sim(gr.top_block, Qt.QWidget):
def set_samp_rate(self, samp_rate):
self.samp_rate = samp_rate
self.blocks_throttle_0.set_sample_rate(self.samp_rate)
- self.qtgui_time_sink_x_0.set_samp_rate(self.samp_rate / self.sps)
def get_rrc_taps(self):
return self.rrc_taps
@@ -315,34 +181,21 @@ class qpsk_sim(gr.top_block, Qt.QWidget):
def main(top_block_cls=qpsk_sim, options=None):
if gr.enable_realtime_scheduling() != gr.RT_OK:
print("Error: failed to enable real-time scheduling.")
-
- if StrictVersion("4.5.0") <= StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
- style = gr.prefs().get_string('qtgui', 'style', 'raster')
- Qt.QApplication.setGraphicsSystem(style)
- qapp = Qt.QApplication(sys.argv)
-
tb = top_block_cls()
- tb.start()
-
- tb.show()
-
def sig_handler(sig=None, frame=None):
- Qt.QApplication.quit()
+ tb.stop()
+ tb.wait()
+
+ sys.exit(0)
signal.signal(signal.SIGINT, sig_handler)
signal.signal(signal.SIGTERM, sig_handler)
- timer = Qt.QTimer()
- timer.start(500)
- timer.timeout.connect(lambda: None)
+ tb.start()
- def quitting():
- tb.stop()
- tb.wait()
+ tb.wait()
- qapp.aboutToQuit.connect(quitting)
- qapp.exec_()
if __name__ == '__main__':
main()
diff --git a/src/gui/NotoSerifCJKjp-Medium.otf b/src/gui/NotoSerifCJKjp-Medium.otf
deleted file mode 100644
index 1a37d19..0000000
--- a/src/gui/NotoSerifCJKjp-Medium.otf
+++ /dev/null
Binary files differ
diff --git a/src/gui/dpg.ini b/src/gui/dpg.ini
deleted file mode 100644
index 8fd9e9b..0000000
--- a/src/gui/dpg.ini
+++ /dev/null
@@ -1,15 +0,0 @@
-[Window][Debug##Default]
-Pos=60,60
-Size=400,400
-Collapsed=0
-
-[Window][###21]
-Pos=60,60
-Size=129,100
-Collapsed=0
-
-[Window][###23]
-Pos=258,161
-Size=100,100
-Collapsed=0
-
diff --git a/src/gui/gui.py b/src/gui/gui.py
index 3f5b986..d3ada9c 100755
--- a/src/gui/gui.py
+++ b/src/gui/gui.py
@@ -30,21 +30,38 @@ logger = logging.getLogger(__name__)
#================================================
# Initialize DearPyGUI
-
-
create_context()
-create_viewport(title="Fading Demonstrator")
+create_viewport(title="Fading Demonstrator",width=1920, height=1200)
setup_dearpygui()
-
# Show demo for dev
show_demo()
-show_documentation()
+show_debug()
+
+#================================================
+# Set up theme and looks
+
+# Font
+# with font_registry():
+# # first argument ids the path to the .ttf or .otf file
+# default_font = add_font("NotoSerifCJKjp-Medium.otf", 20)
+# second_font = add_font("NotoSerifCJKjp-Medium.otf", 10)
+# test = add_font("NotoSerifCJKjp-Medium.otf", 30)
+
+# Constellation diagrams
+with theme(tag="constellation_series_theme"):
+ with theme_component(mvScatterSeries):
+ # add_theme_style(mvPlotStyleVar_Marker, mvPlotMarker_Asterisk, category=mvThemeCat_Plots)
+ add_theme_style(mvPlotStyleVar_MarkerSize, 3, category=mvThemeCat_Plots)
#================================================
# GUI Callback functions
+# Menu Bar
+def exit(sender, data):
+ stop_dearpygui()
+
# Flow graph window
def on_rx_node_link(sender, app_data):
link_id_1, link_id_2 = app_data
@@ -52,193 +69,202 @@ def on_rx_node_link(sender, app_data):
def on_rx_node_delink(sender, app_data):
link_id = app_data
- delete_item(link_id)
+ # do nothing
+ # delete_item(link_id)
-#================================================
-#Setting Window Test
-# with window(label="Dear", width=800, height=800, on_close=_on_demo_close, pos=(100, 100)):
-
- with menu_bar():
- with menu(label="Settings"):
- add_menu_item(label="Option 1", callback=_log)
- add_menu_item(label="Option 2", check=True, callback=_log)
- add_menu_item(label="Option 3", check=True, default_value=True, callback=_log)
+# add and load images
+def add_and_load_image(image_path):
+ width, height, channels, data = load_image(image_path)
+ with texture_registry() as reg_id:
+ texture_id = add_static_texture(width, height, data, parent=reg_id)
+ return add_image(texture_id)
+#================================================
+# Primary Window
-# Settings Window
-def exit(sender, data):
- stop_dearpygui()
+with window(tag="primary_window"):
+ # Grössere Schrifftart/ Grösse für das ganze Dokument definiert
+ # bind_font(default_font)
-# def _hsv_to_rgb(h, s, v):
-# if s == 0.0: return (v, v, v)
-# i = int(h*6.) # XXX assume int() truncates!
-# f = (h*6.)-i; p,q,t = v*(1.-s), v*(1.-s*f), v*(1.-s*(1.-f)); i%=6
-# if i == 0: return (255*v, 255*t, 255*p)
-# if i == 1: return (255*q, 255*v, 255*p)
-# if i == 2: return (255*p, 255*v, 255*t)
-# if i == 3: return (255*p, 255*q, 255*v)
-# if i == 4: return (255*t, 255*p, 255*v)
-# if i == 5: return (255*v, 255*p, 255*q)
-
-with window(label="Settings", width=200, height=400, pos=(25, 25), tag="sim_win",
- no_close=True,no_background= True):
with menu_bar():
with menu(label="Settings"):
- add_menu_item(label="Option 1")
- add_menu_item(label="Option 2", check=True)
- add_menu_item(label="Option 3", check=True, default_value=True)
+ add_menu_item(label="Toggle Fullscreen",callback=toggle_viewport_fullscreen)
+ add_menu_item(label="Minimize",callback=minimize_viewport)
+ add_menu_item(label="Close", callback=exit)
- #Farbwahl in schleife und mit def?
- with theme(tag= "button_window"):
- with theme_component(mvButton):
- add_theme_color(mvThemeCol_Button,(135, 206, 255))#Blau
- add_theme_color(mvThemeCol_Text,(0,0,0))#Schwarz
- add_theme_style(mvStyleVar_FrameRounding, 5)
+ with theme(tag="close"):
+ with theme_component():
+ add_theme_color(mvThemeCol_Text,(255, 64, 64))
+ add_theme_style(mvStyleVar_Alpha, 5)
+ bind_item_theme(last_item(),"close")
- add_button(label="Toggle Fullscreen", height=50, width=150,callback= toggle_viewport_fullscreen)
- bind_item_theme(last_item(),"button_window")
-
- with theme(tag= "button_minimize"):
- with theme_component(mvButton):
- #add_theme_color(mvThemeCol_Button,(135, 206, 255))#Blau
- #add_theme_color(mvThemeCol_Text,(0,0,0))#Schwarz
- add_theme_style(mvStyleVar_FrameRounding, 5)
- add_button(label="Minimize",height=50, width=150, callback= minimize_viewport)
- bind_item_theme(last_item(),"button_minimize")
-
- #with child_window(autosize_x=True, height=100)as close:
- add_button(label="Maximize",height=50, width=150, callback= maximize_viewport) #Befehl nötig ?
-
- with theme(tag= "button_close"):
- with theme_component(mvButton):
- add_theme_color(mvThemeCol_Button,(255, 64, 64))#Rot
- add_theme_color(mvThemeCol_Text,(0,0,0))#Schwarz
- add_theme_style(mvStyleVar_FrameRounding, 5)
-
- add_button(label="Close", height=50, width=150, callback= exit)
- bind_item_theme(last_item(),"button_close")
-
-
-
-
-# #================================================
-# # Flow Graph Window
-
-# with window(label="RX DSP Flow Graph", width=800, height=400, pos=(25,25), tag="rx_win"):
-# with node_editor(callback=on_rx_node_link, delink_callback=on_rx_node_delink):
-# with node(label="USRP Source", pos=(20,100)):
-# with node_attribute(tag="src_out", attribute_type=mvNode_Attr_Output):
-# add_text("Signal from antenna")
-
-# with node(label="Clock Sync", pos=(200,200)):
-# with node_attribute(tag="clksync_in", attribute_type=mvNode_Attr_Input):
-# add_text("Input")
-
-# with node_attribute(tag="clksync_out", attribute_type=mvNode_Attr_Output):
-# add_text("Synchronized")
+#================================================
+# Flow Graph Window
-# with node(label="Equalizer", pos=(350,100)):
-# with node_attribute(tag="eq_in", attribute_type=mvNode_Attr_Input):
-# add_text("Input")
+with window(label="RX DSP Flow Graph", width=800, height=400, pos=(0,25), tag="rx_win"):
+ with node_editor(callback=on_rx_node_link, delink_callback=on_rx_node_delink):
+ with node(label="USRP Source", pos=(20,100)):
+ with node_attribute(tag="src_out", attribute_type=mvNode_Attr_Output):
+ add_text("Signal from antenna")
-# with node_attribute(attribute_type=mvNode_Attr_Static):
-# add_knob_float(label="Gain")
+ with node(label="Clock Sync", pos=(200,200)):
+ with node_attribute(tag="clksync_in", attribute_type=mvNode_Attr_Input):
+ add_text("Input")
-# with node_attribute(tag="eq_out", attribute_type=mvNode_Attr_Output):
-# add_text("Equalized")
+ with node_attribute(tag="clksync_out", attribute_type=mvNode_Attr_Output):
+ add_text("Synchronized")
-# with node(label="Phase Locked Loop", pos=(600, 200)):
-# with node_attribute(tag="pll_in", attribute_type=mvNode_Attr_Input):
-# add_text("Input")
+ with node(label="Equalizer", pos=(350,100)):
+ with node_attribute(tag="eq_in", attribute_type=mvNode_Attr_Input):
+ add_text("Input")
-# with node_attribute(tag="pll_out", attribute_type=mvNode_Attr_Output):
-# add_text("Locked")
-# add_knob_float(label="Loop BW")
+ with node_attribute(tag="eq_out", attribute_type=mvNode_Attr_Output):
+ add_text("Equalized")
+ with node(label="Phase Locked Loop", pos=(600, 200)):
+ with node_attribute(tag="pll_in", attribute_type=mvNode_Attr_Input):
+ add_text("Input")
-# add_node_link(get_alias_id("src_out"), get_alias_id("clksync_in"))
-# add_node_link(get_alias_id("clksync_out"), get_alias_id("eq_in"))
-# add_node_link(get_alias_id("eq_out"), get_alias_id("pll_in"))
+ with node_attribute(tag="pll_out", attribute_type=mvNode_Attr_Output):
+ add_text("Locked")
-# #================================================
-# Network plots Window
-recv_plot = net.network_plot(url="udp://localhost:31415", dtype=float, nsamples=100, \
- label="Test", height=300, width=800)
+ add_node_link(get_alias_id("src_out"), get_alias_id("clksync_in"))
+ add_node_link(get_alias_id("clksync_out"), get_alias_id("eq_in"))
+ add_node_link(get_alias_id("eq_out"), get_alias_id("pll_in"))
-plots = {
- # recv_plot: "plt_ampl"
+#================================================
+# Network plots
+
+time_plot = net.network_plot(url="udp://localhost:31415", dtype=float, \
+ nsamples=100, tag="time_plot", label="Time plot")
+channel_plot = net.network_constellation_plot(url="udp://localhost:31416", \
+ nsamples=80, tag="channel_plot", label="Channel")
+synchronized_plot = net.network_constellation_plot(url="udp://localhost:31417", \
+ nsamples=100, tag="synchronized_plot", label="Synchronized")
+equalized_plot = net.network_constellation_plot(url="udp://localhost:31418", \
+ nsamples=100, tag="equalized_plot", label="Equalized")
+locked_plot = net.network_constellation_plot(url="udp://localhost:31419", \
+ nsamples=100, tag="locked_plot", label="Locked")
+
+network_plots = {
+ time_plot: "time_plot_series",
+ channel_plot: "channel_plot_series",
+ synchronized_plot: "synchronized_plot_series",
+ equalized_plot: "equalized_plot_series",
+ locked_plot: "locked_plot_series",
}
-with window(label="Time domain plots", width=800, height=350, pos=(25,450)):
- with recv_plot:
- add_plot_axis(mvXAxis, label="Time")
- add_plot_axis(mvYAxis, label="Amplitude", tag="axis")
-
- add_line_series(recv_plot.xdata, recv_plot.ydata, parent="axis", tag="plt_ampl")
+with window(label="Time domain", width=800, height=350, pos=(0,425)):
+ with time_plot:
+ add_plot_axis(mvXAxis, label="Time", tag="xaxis_time")
+ add_plot_axis(mvYAxis, label="Amplitude", tag="yaxis_time")
+ add_line_series(time_plot.xdata, time_plot.ydata, parent="yaxis_time", tag=network_plots[time_plot])
+
+with window(label="Channel", width=560, height=400, pos=(800,25)):
+ with channel_plot:
+ add_plot_axis(mvXAxis, label="In-Phase", tag="inphase_channel")
+ add_plot_axis(mvYAxis, label="Quadrature", tag="quadrature_channel")
+
+ add_plot_legend()
+ set_axis_limits("inphase_channel", -2.5, 2.5)
+ set_axis_limits("quadrature_channel", -2.5, 2.5)
+
+ series_tag = network_plots[channel_plot]
+ add_scatter_series(channel_plot.xdata, channel_plot.ydata, \
+ label = "Channel", parent="inphase_channel", tag=series_tag)
+ bind_item_theme(series_tag, "constellation_series_theme")
+ # bind_colormap("channel_plot", mvPlotColormap_Spectral)
+
+with window(label="Synchronized", width=560, height=400, pos=(1360,25)):
+ with synchronized_plot:
+ add_plot_axis(mvXAxis, label="In-Phase", tag="inphase_synchronized")
+ add_plot_axis(mvYAxis, label="Quadrature", tag="quadrature_synchronized")
+
+ add_plot_legend()
+ set_axis_limits("inphase_synchronized", -2.5, 2.5)
+ set_axis_limits("quadrature_synchronized", -2.5, 2.5)
+
+ series_tag = network_plots[synchronized_plot]
+ add_scatter_series(synchronized_plot.xdata, synchronized_plot.ydata, \
+ label="Synchronized", parent="inphase_synchronized", tag=series_tag)
+ bind_item_theme(series_tag, "constellation_series_theme")
+
+with window(label="Equalized", width=560, height=400, pos=(800,425)):
+ with equalized_plot:
+ add_plot_legend()
+ add_plot_axis(mvXAxis, label="In-Phase", tag="inphase_equalized")
+ add_plot_axis(mvYAxis, label="Quadrature", tag="quadrature_equalized")
+
+ add_plot_legend()
+ set_axis_limits("inphase_equalized", -1.5, 1.5)
+ set_axis_limits("quadrature_equalized", -1.5, 1.5)
+
+ series_tag = network_plots[equalized_plot]
+ add_scatter_series(equalized_plot.xdata, equalized_plot.ydata, \
+ label="Equalized", parent="inphase_equalized", tag=series_tag)
+ bind_item_theme(series_tag, "constellation_series_theme")
+
+with window(label="Locked", width=560, height=400, pos=(1360,425)):
+ with locked_plot:
+ add_plot_legend()
+ add_plot_axis(mvXAxis, label="In-Phase", tag="inphase_locked")
+ add_plot_axis(mvYAxis, label="Quadrature", tag="quadrature_locked")
+
+ add_plot_legend()
+ set_axis_limits("inphase_locked", -1.5, 1.5)
+ set_axis_limits("quadrature_locked", -1.5, 1.5)
+
+ series_tag = network_plots[locked_plot]
+ add_scatter_series(locked_plot.xdata, locked_plot.ydata, \
+ label="Locked", parent="inphase_locked", tag=series_tag)
+ bind_item_theme(series_tag, "constellation_series_theme")
#================================================
-# Byte Error Rate Window
-#TO DO:
+# Bit Error Rate Window
-with window(label="Byte Error Rate ", width=300, height=150, pos=(850,25),tag="__ber_id",no_move=True, no_collapse= True):
- add_text("The Byte Error Rate is:")
+#TO DO:BER von GNU Radio anzeigen
+with theme(tag= "ber_window"):
+ with theme_component(mvAll):
+ add_theme_style(mvStyleVar_WindowTitleAlign, 0.5)
+ add_theme_style(mvStyleVar_WindowRounding, 5)
+ add_theme_style(mvStyleVar_WindowBorderSize, 1)#Rad ein und aus Schalten
-#================================================
-# Channel Window
-#TO DO:
-# recv_plot = net.network_plot(url="udp://localhost:31415", nsamples=100, label="Test", height=300, width=800)
-
-# plots = {
-# recv_plot: "plt_ampl"
-# }
-
-# with window(label="Channel ", width=600, height=600, pos=(850,25)):
-# with child_window(autosize_x=True, height=100):
-# add_button(label="Toggle Fullscreen", callback= toggle_viewport_fullscreen)
-# with recv_plot:
-# add_plot_axis(mvXAxis, label="In-phase")
-# add_plot_axis(mvYAxis, label="Quadrature", tag="plt_ampl")
-
-# add_scatter_series(recv_plot.x_data, recv_plot.y_data, parent="plt_ampl")
-# #================================================
-# # Synchronized Window
-# #TO DO:
-# with window(label="Synchronized ", width=600, height=600, pos=(850,25)):
-# with child_window(autosize_x=True, height=100):
-# add_button(label="Toggle Fullscreen", callback= toggle_viewport_fullscreen)
-
-# #================================================
-# # Equalized Window
-# #TO DO:
-# with window(label="Equalized ", width=600, height=600, pos=(850,25)):
-# with child_window(autosize_x=True, height=100):
-# add_button(label="Toggle Fullscreen", callback= toggle_viewport_fullscreen)
-
-# #================================================
-# # Locked Window
-# #TO DO:
-# with window(label="Locked ", width=600, height=600, pos=(850,25)):
-# with child_window(autosize_x=True, height=100):
-# add_button(label="Toggle Fullscreen", callback= toggle_viewport_fullscreen)
+with window(label="Bit Error Rate ", width=300, height=150, pos=(1200,875), no_title_bar = True, no_move=True, no_collapse= True) as ber_window :
+
+ add_text("The Bit Error Rate is:", pos=(35,10))
+ with theme(tag= "button_ber"):
+ with theme_component(mvButton):
+ add_theme_color(mvThemeCol_Button,(135, 206, 255))#Blau
+ add_theme_color(mvThemeCol_Text,(0,0,0))#Schwarz
+ add_theme_style(mvStyleVar_FrameRounding, 5)
+ add_button(label="BER", height=60, width=150,pos=(75,60))
+ bind_item_theme(last_item(),"button_ber")
+# bind_item_theme(ber_window, "ber_window")
+# bind_item_font(ber_window, test)
#================================================
+# Picture Window
+with window(label="Picture", width=400, height=300, pos=(0,825)) as picture_window :
+ add_and_load_image("lena512color.png") #TO DO Problem lösen
+#================================================
# Start GUI and main loop
# Start window and main loop
show_viewport()
+set_primary_window("primary_window", True)
# Main loop
while is_dearpygui_running():
- for plt, tag in plots.items():
+ for plt, tag in network_plots.items():
plt.refresh_series(tag)
render_dearpygui_frame()
diff --git a/src/gui/gui_v2.py b/src/gui/gui_v2.py
deleted file mode 100755
index 4513322..0000000
--- a/src/gui/gui_v2.py
+++ /dev/null
@@ -1,336 +0,0 @@
-#!/usr/bin/env python3
-
-# Python stdlib
-import sys
-
-# Grahical libraries
-
-from dearpygui.dearpygui import *
-import dearpygui._dearpygui as internal_dpg
-from dearpygui.demo import show_demo
-
-# Detect (unix) signals
-import signal
-
-# Mathematics
-import numpy as np
-
-# For debugging
-import logging
-
-# Remote resources
-import net
-
-#================================================
-# Debugging tools
-
-logging.basicConfig(format="[%(levelname)s] %(asctime)s %(message)s", level=logging.DEBUG)
-logger = logging.getLogger(__name__)
-
-#================================================
-# Initialize DearPyGUI
-
-
-create_context()
-create_viewport(title="Fading Demonstrator",width=1920, height=1200)
-setup_dearpygui()
-
-# Show demo for dev
-show_demo()
-#show_font_manager()
-
-#================================================
-# add a font registry
-with font_registry():
- # first argument ids the path to the .ttf or .otf file
- default_font = add_font("NotoSerifCJKjp-Medium.otf", 20)
- second_font = add_font("NotoSerifCJKjp-Medium.otf", 10)
- test = add_font("NotoSerifCJKjp-Medium.otf", 30)
-
-#================================================
-# GUI Callback functions
-
-# Menu Bar
-def exit(sender, data):
- stop_dearpygui()
-
-# Flow graph window
-def on_rx_node_link(sender, app_data):
- link_id_1, link_id_2 = app_data
- add_node_link(link_id_1, link_id_2, parent=sender)
-
-def on_rx_node_delink(sender, app_data):
- link_id = app_data
- delete_item(link_id)
-
-# add and load images
-def add_and_load_image(image_path):
- width, height, channels, data = load_image(image_path)
-
- with texture_registry() as reg_id:
- texture_id = add_static_texture(width, height, data, parent=reg_id)
-
- return add_image(texture_id)
-
-
-#================================================
-#Setting Primary Window
-
-with window(tag="Primary Window"):
- bind_font(default_font) # Grössere Schrifftart/ Grösse für das ganze Dokument definiert
-
-#================================================
-#Setting Window in Menu
- with menu_bar():
- with menu(label="Settings"):
-
- with theme(tag= "close"):
- with theme_component():
- add_theme_color(mvThemeCol_Text,(255, 64, 64))#Rot
- add_theme_style(mvStyleVar_Alpha, 5)
-
- add_menu_item(label="Toggle Fullscreen",callback= toggle_viewport_fullscreen)
- add_menu_item(label="Minimize",callback= minimize_viewport)
- add_menu_item(label="Close", callback= exit)
- bind_item_theme(last_item(),"close")
-
- with menu(label="Plot"):
- add_menu_item(label="unlock x limits", callback=lambda: set_axis_limits_auto("xaxis_channel"))
- add_menu_item(label="unlock y limits", callback=lambda: set_axis_limits_auto("yaxis_channel"))
-
-
-#================================================
-# Flow Graph Window
-
-with window(label="RX DSP Flow Graph", width=800, height=400, pos=(0,25), tag="rx_win",
- no_title_bar = True, no_move=True, no_collapse= True):
- with node_editor(callback=on_rx_node_link, delink_callback=on_rx_node_delink):
- with node(label="USRP Source", pos=(20,100)):
- with node_attribute(tag="src_out", attribute_type=mvNode_Attr_Output):
- add_text("Signal from antenna")
-
- with node(label="Clock Sync", pos=(200,200)):
- with node_attribute(tag="clksync_in", attribute_type=mvNode_Attr_Input):
- add_text("Input")
-
- with node_attribute(tag="clksync_out", attribute_type=mvNode_Attr_Output):
- add_text("Synchronized")
-
- with node(label="Equalizer", pos=(350,100)):
- with node_attribute(tag="eq_in", attribute_type=mvNode_Attr_Input):
- add_text("Input")
-
- with node_attribute(attribute_type=mvNode_Attr_Static):
- add_knob_float(label="Gain")
-
- with node_attribute(tag="eq_out", attribute_type=mvNode_Attr_Output):
- add_text("Equalized")
-
- with node(label="Phase Locked Loop", pos=(600, 200)):
- with node_attribute(tag="pll_in", attribute_type=mvNode_Attr_Input):
- add_text("Input")
-
- with node_attribute(tag="pll_out", attribute_type=mvNode_Attr_Output):
- add_text("Locked")
- add_knob_float(label="Loop BW")
-
-
- add_node_link(get_alias_id("src_out"), get_alias_id("clksync_in"))
- add_node_link(get_alias_id("clksync_out"), get_alias_id("eq_in"))
- add_node_link(get_alias_id("eq_out"), get_alias_id("pll_in"))
-
-#================================================
-# Network plots Window
-
-recv_plot = net.network_plot(url="udp://localhost:31415", dtype=float, nsamples=100, \
- label="Test", height=300, width=800)
-
-plots = {
- # recv_plot: "plt_ampl"
-}
-
-with window(label="Time domain plots", width=800, height=350, pos=(0,425),
- no_title_bar = True, no_move=True, no_collapse= True):
- with recv_plot:
- add_plot_axis(mvXAxis, label="Time")
- add_plot_axis(mvYAxis, label="Amplitude", tag="axis")
-
- add_line_series(recv_plot.xdata, recv_plot.ydata, parent="axis", tag="plt_ampl")
-
-#================================================
-# Byte Error Rate Window
-
-#TO DO:BER von GNU Radio anzeigen
-
-with theme(tag= "ber_window"):
- with theme_component(mvAll):
- add_theme_style(mvStyleVar_WindowTitleAlign, 0.5)
- add_theme_style(mvStyleVar_WindowRounding, 5)
- add_theme_style(mvStyleVar_WindowBorderSize, 1)#Rad ein und aus Schalten
-
-with window(label="Byte Error Rate ", width=300, height=150, pos=(1200,875)
- ,no_title_bar = True, no_move=True, no_collapse= True) as ber_window :
-
- add_text("The Byte Error Rate is:",pos=(35,10))
-
- with theme(tag= "button_ber"):
- with theme_component(mvButton):
- add_theme_color(mvThemeCol_Button,(135, 206, 255))#Blau
- add_theme_color(mvThemeCol_Text,(0,0,0))#Schwarz
- add_theme_style(mvStyleVar_FrameRounding, 5)
-
- add_button(label="BER", height=60, width=150,pos=(75,60))
- bind_item_theme(last_item(),"button_ber")
-
-bind_item_theme(ber_window,"ber_window")
-bind_item_font(ber_window,test)
-
-#================================================
-# Picture Window
-with window(label="Picture", width=400, height=300, pos=(0,825),
- no_title_bar = True, no_move=True, no_collapse= True) as picture_window :
- #with child_window(width=400, height=400):
- add_and_load_image("logo.png")
- add_text("Picture 1")
- #add_and_load_image("lena512color.png") #TO DO Problem lösen
-
-with window(label="Picture_2", width=400, height=300, pos=(400,825),
- no_title_bar = True, no_move=True, no_collapse= True) as picture_window :
- #with child_window(width=400, height=400):
- add_and_load_image("logo.png")
- add_text("Picture 2")
- #add_and_load_image("l
-
-#================================================
-# Channel Window
-# TO DO: Change Data to Real Data from the GUI
-
-# Some Data to plot
-sindatax = []
-sindatay = []
-for i in range(-2, 100):
- sindatax.append(i / 100)
- sindatay.append(0.5 + 0.5 * np.sin(50 * i / 100))
-sindatay2 = []
-for i in range(-2, 100):
- sindatay2.append(2 + 0.5 * np.sin(50 * i / 100))
-
-with window(label="Channel ", width=560, height=400, pos=(800,25),
- no_title_bar = True, no_move=True, no_collapse= True):
-
- # create a theme for the plot
- with theme(tag="plot_theme"):
- with theme_component(mvScatterSeries):
- add_theme_color(mvPlotCol_Line, (135, 206, 255), category=mvThemeCat_Plots)
- add_theme_style(mvPlotStyleVar_Marker,mvPlotMarker_Asterisk, category=mvThemeCat_Plots) #TO DO: change to mvPlotMarker_Circle
- add_theme_style(mvPlotStyleVar_MarkerSize, 3, category=mvThemeCat_Plots)
-
- # Plot
- with plot(tag="plot", label="Channel", height=-1, width=-1):
-
- # optionally create legend
- add_plot_legend()
-
- # REQUIRED: create x and y axes
- add_plot_axis(mvXAxis, label="In-phase",tag="xaxis_channel")
- set_axis_limits("xaxis_channel", -2, 2)
-
- add_plot_axis(mvYAxis, label= "Quadrature", tag="yaxis_channel")
- set_axis_limits("yaxis_channel", -2, 2)
-
- # series belong to a y axis
- add_scatter_series(sindatax, sindatay2, label="Some Data", parent="yaxis_channel", tag="series_data2")
- #add_button(label="Delete Series 1", parent=last_item(), callback=lambda: delete_item("series_data2"))
-
- # apply theme to series
- bind_item_theme("series_data2", "plot_theme")
-
-
-
-#================================================
-# Synchronized Window
-with window(label="Synchronized", width=560, height=400, pos=(1360,25),
- no_title_bar = True, no_move=True, no_collapse= True):
- add_text("TO DO Synchronized")
-
- # with child_window(autosize_x=True, height=100):
- # add_button(label="Toggle Fullscreen", callback= toggle_viewport_fullscreen)
-# #================================================
-# # Equalized Window
-with window(label="Equalized", width=560, height=400, pos=(800,425),
- no_title_bar = True, no_move=True, no_collapse= True):
- add_text("TO DO Equalized")
-
-#================================================
-# Locked Window
-# TO DO: Change Data to Real Data from the GUI
-
-# Some Data to plot
-sindatax = []
-sindatay = []
-for i in range(-2, 100):
- sindatax.append(i / 100)
- sindatay.append(0.5 + 0.5 * np.sin(50 * i / 100))
-sindatay2 = []
-for i in range(-2, 100):
- sindatay2.append(2 + 0.5 * np.sin(50 * i / 100))
-
-with window(label="Locked ", width=560, height=400, pos=(1360,425),
- no_title_bar = True, no_move=True, no_collapse= True):
-
- # create a theme for the plot
- with theme(tag="plot_theme_locked"):
- with theme_component(mvScatterSeries):
- add_theme_color(mvPlotCol_Line, (135, 206, 255), category=mvThemeCat_Plots)
- add_theme_style(mvPlotStyleVar_Marker,mvPlotMarker_Asterisk, category=mvThemeCat_Plots) #TO DO: change to mvPlotMarker_Circle
- add_theme_style(mvPlotStyleVar_MarkerSize, 3, category=mvThemeCat_Plots)
-
- # Plot
- with plot(tag="plot_locked", label="Locked", height=-1, width=-1):
-
- # optionally create legend
- add_plot_legend()
-
- # REQUIRED: create x and y axes
- add_plot_axis(mvXAxis, label="In-phase",tag="xaxis_locked")
- set_axis_limits("xaxis_locked", -2, 2)
-
- add_plot_axis(mvYAxis, label= "Quadrature", tag="yaxis_locked")
- set_axis_limits("yaxis_locked", -2, 2)
-
- # series belong to a y axis
- add_scatter_series(sindatax, sindatay2, label="Some Data", parent="yaxis_locked", tag="series_data2_locked")
- #add_button(label="Delete Series 1", parent=last_item(), callback=lambda: delete_item("series_data2"))
-
- # apply theme to series
- bind_item_theme("series_data2_locked", "plot_theme_locked")
-
-#TO DO: find a better way to do that
- with group(horizontal=True):
- add_button(label="unlock x limits", callback=lambda: set_axis_limits_auto("xaxis_locked"))
- add_button(label="unlock y limits", callback=lambda: set_axis_limits_auto("yaxis_locked"))
-
-
-
-
-
-#================================================
-
-# Start GUI and main loop
-
-# Start window and main loop
-show_viewport()
-set_primary_window("Primary Window", True)
-
-# Main loop
-while is_dearpygui_running():
- for plt, tag in plots.items():
- plt.refresh_series(tag)
-
- render_dearpygui_frame()
-
-#================================================
-# Close everything
-
-# clean up gui
-destroy_context()
diff --git a/src/gui/lena512color.png b/src/gui/lena512color.png
index ffe5c83..7d364e0 100644
--- a/src/gui/lena512color.png
+++ b/src/gui/lena512color.png
Binary files differ
diff --git a/src/gui/logo.png b/src/gui/logo.png
deleted file mode 100644
index f972f98..0000000
--- a/src/gui/logo.png
+++ /dev/null
Binary files differ
diff --git a/src/gui/net.py b/src/gui/net.py
index c7008cd..264c9d8 100644
--- a/src/gui/net.py
+++ b/src/gui/net.py
@@ -12,10 +12,11 @@ class udpsource:
"""
Creates an UDP listening socket
"""
- def __init__(self, url, dtype):
+ def __init__(self, url, dtype, timeout=0.05):
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.url = urlparse(url)
self.dtype = dtype
+ self.timeout = timeout
def __del__(self):
self.sock.close()
@@ -26,7 +27,8 @@ class udpsource:
# self.sock.listen()
def read(self, nblocks):
- ready, _, _ = select.select([self.sock], [], [])
+ # TODO: run in a separate thread (it will be painful to implement)
+ ready, _w, _x = select.select([self.sock], [], [], self.timeout)
if not ready:
return None
@@ -40,7 +42,10 @@ class udpsource:
def chunk_to_samples(chunk):
samples = chunk.split(",")
if samples:
- return list(map(self.dtype, samples))
+ try:
+ return list(map(self.dtype, samples))
+ except ValueError:
+ return []
# convert each chunk into a list of samples
chunk_values = map(chunk_to_samples, chunks)
@@ -51,18 +56,29 @@ class udpsource:
return values
class network_plot(udpsource):
- def __init__(self, url, dtype, nsamples, **kwargs):
+ """
+ Wraps a udpsource while at the same time intefacing with DearPyGUI as a plot element.
+ """
+ def __init__(self, url, dtype, nsamples , **kwargs):
udpsource.__init__(self, url, dtype)
+ self.nsamples = nsamples
+
+ self._init_buffers()
+ self._init_dpg_plot(**kwargs)
+
+ # listen for connections
+ self.bind()
+ def _init_buffers(self):
# create buffers for x and y values
- self.nsamples = nsamples
- self.xvalues = np.arange(0, self.nsamples)
- self.yvalues = RingBuffer(capacity=self.nsamples, dtype=np.dtype(dtype))
+ self.xvalues = RingBuffer(capacity=self.nsamples, dtype=np.dtype(self.dtype))
+ self.yvalues = RingBuffer(capacity=self.nsamples, dtype=np.dtype(self.dtype))
+
+ self.xvalues.extend(np.arange(0, self.nsamples))
self.yvalues.extend(np.zeros(self.nsamples))
- # create a plot
+ def _init_dpg_plot(self, **kwargs):
self.plot = dpg.plot(**kwargs)
- self.bind()
# Map `with' expressions to the underlying plot
def __enter__(self):
@@ -73,15 +89,41 @@ class network_plot(udpsource):
@property
def xdata(self):
- return self.xvalues
+ # unwrap ringbuffer
+ return np.array(self.xvalues)
@property
def ydata(self):
+ # unwrap ringbuffer
return np.array(self.yvalues)
def refresh_series(self, tag):
- new_values = self.read(1)
+ new_values = self.read(10)
if new_values:
self.yvalues.extendleft(new_values)
dpg.set_value(tag, [self.xdata, self.ydata])
+
+
+class network_constellation_plot(network_plot):
+ """
+ Special case of a plot, where complex numbers are drawn into a scatter plot
+ """
+ def __init__(self, url, nsamples, **kwargs):
+ network_plot.__init__(self, url, np.complex64, nsamples)
+
+ def _init_buffers(self):
+ self.xvalues = RingBuffer(capacity=self.nsamples, dtype=np.float32)
+ self.yvalues = RingBuffer(capacity=self.nsamples, dtype=np.float32)
+
+ self.xvalues.extend(np.zeros(self.nsamples))
+ self.yvalues.extend(np.zeros(self.nsamples))
+
+ def refresh_series(self, tag):
+ new_values = self.read(1)
+
+ if new_values:
+ self.xvalues.extendleft(np.real(new_values))
+ self.yvalues.extendleft(np.imag(new_values))
+
+ dpg.set_value(tag, [self.xdata, self.ydata])
diff --git a/src/gui/test.py b/src/gui/test.py
deleted file mode 100644
index f3accf3..0000000
--- a/src/gui/test.py
+++ /dev/null
@@ -1,40 +0,0 @@
-import dearpygui.dearpygui as dpg
-
-# Callbacks
-def cb_nextpic(sender, app_data, user_data):
- dpg.set_value(texture_id, user_data['textures'][user_data['next_key']])
-
- # Set key for next Image. Rotate back to 1 when last image has been shown
- if user_data['next_key'] < 11:
- user_data['next_key'] = user_data['next_key']+1
- else:
- user_data['next_key'] = 1
-
-
-# Load in the Logo and add it to the texture_registry
-# TODO: Find out, what that thing is actually doing. It is not really clear atm.
-width, height, channels, data = dpg.load_image("logo.png")
-with dpg.texture_registry():
- texture_id = dpg.add_dynamic_texture(width, height, data)
-
-# Next, load in the rest of the pictures
-# Important: We are only interested in the data part here!
-# Important: All the images must have the same size, because they are
-# displayed on the image that will be created from the
-# texture_id of the registry
-img_dict = {}
-for a in range(11):
- width, height, channels, data = dpg.load_image(f"resources\img{a+1}.png")
- img_dict[a+1] = data
-
-img_handler_dict = {
- 'next_key': 1,
- 'textures': img_dict
-}
-
-with dpg.window(label="Hangman") as main_window:
- dpg.add_image(texture_id)
- dpg.add_button(label="Next IMG", callback=cb_nextpic, user_data=img_handler_dict)
-
-dpg.set_primary_window(main_window, True)
-dpg.start_dearpygui() \ No newline at end of file
diff --git a/src/gui/test2.py b/src/gui/test2.py
deleted file mode 100644
index f339af8..0000000
--- a/src/gui/test2.py
+++ /dev/null
@@ -1,22 +0,0 @@
-import dearpygui.dearpygui as dpg
-
-dpg.create_context()
-
-with dpg.window(label="about", width=400, height=400):
- dpg.add_button(label="Press me")
- dpg.draw_line((0, 10), (100, 100), color=(255, 0, 0, 255), thickness=1)
-
-# print children
-print(dpg.get_item_children(dpg.last_root()))
-
-# print children in slot 1
-print(dpg.get_item_children(dpg.last_root(), 1))
-
-# check draw_line's slot
-print(dpg.get_item_slot(dpg.last_item()))
-
-dpg.create_viewport(title='Custom Title', width=800, height=600)
-dpg.setup_dearpygui()
-dpg.show_viewport()
-dpg.start_dearpygui()
-dpg.destroy_context()