aboutsummaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rwxr-xr-xsrc/gui/gui.py37
-rw-r--r--src/gui/net.py46
-rw-r--r--src/gui/res/pic/lena512color.png (renamed from src/gui/lena512color.png)bin474775 -> 474775 bytes
-rw-r--r--src/gui/res/pic/lena512color.tiff (renamed from src/gui/lena512color.tiff)bin786572 -> 786572 bytes
-rw-r--r--src/gui/res/ttf/Hack-Bold.ttfbin0 -> 317628 bytes
-rw-r--r--src/gui/res/ttf/Hack-BoldItalic.ttfbin0 -> 322288 bytes
-rw-r--r--src/gui/res/ttf/Hack-Italic.ttfbin0 -> 316156 bytes
-rw-r--r--src/gui/res/ttf/Hack-Regular.ttfbin0 -> 309408 bytes
8 files changed, 63 insertions, 20 deletions
diff --git a/src/gui/gui.py b/src/gui/gui.py
index 5d86de1..7e2357b 100755
--- a/src/gui/gui.py
+++ b/src/gui/gui.py
@@ -45,13 +45,13 @@ show_debug()
time_plot = net.network_plot(url="udp://localhost:31415", dtype=float, \
nsamples=500, tag="time_plot", label="Time plot")
channel_plot = net.network_constellation_plot(url="udp://localhost:31416", \
- nsamples=200, tag="channel_plot", label="Channel")
+ nsamples=512, tag="channel_plot", label="Channel")
synchronized_plot = net.network_constellation_plot(url="udp://localhost:31417", \
- nsamples=200, tag="synchronized_plot", label="Synchronized")
+ nsamples=512, tag="synchronized_plot", label="Synchronized")
equalized_plot = net.network_constellation_plot(url="udp://localhost:31418", \
- nsamples=200, tag="equalized_plot", label="Equalized")
+ nsamples=512, tag="equalized_plot", label="Equalized")
locked_plot = net.network_constellation_plot(url="udp://localhost:31419", \
- nsamples=200, tag="locked_plot", label="Locked")
+ nsamples=512, tag="locked_plot", label="Locked")
constellation_plots = [channel_plot, synchronized_plot, equalized_plot, locked_plot]
network_plots = [time_plot] + constellation_plots
@@ -88,11 +88,11 @@ plots_locked = True
# 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)
+with font_registry():
+ # first argument ids the path to the .ttf or .otf file
+ default_font = add_font("res/ttf/Hack-Regular.ttf", 20)
+ # second_font = add_font("NotoSerifCJKjp-Medium.otf", 10)
+ # test = add_font("NotoSerifCJKjp-Medium.otf", 30)
# Constellation diagrams
with theme(tag="constellation_series_theme"):
@@ -113,7 +113,7 @@ def exit(sender, data):
with window(tag="primary_window"):
# Grössere Schrifftart/ Grösse für das ganze Dokument definiert
- # bind_font(default_font)
+ bind_font(default_font)
with menu_bar():
with menu(label="Settings"):
@@ -195,7 +195,7 @@ with window(label="RX DSP Flow Graph", width=800, height=400, pos=(0,25), tag="r
# Network plots
def make_constellation_plot_window(plot, label):
- with window(label=label, no_collapse=True,
+ with window(label=label, no_collapse=True, no_close=True, \
width=plot_window_sizes[plot][0], \
height=plot_window_sizes[plot][1], \
pos=plot_window_positions[plot], \
@@ -249,12 +249,18 @@ with window(label="Bit Error Rate ", width=300, height=150, pos=(200,875)) as be
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")
+ add_button(label="BER", height=60, width=-1, tag="ber_value")
+ bind_item_theme(last_item(), "button_ber")
# bind_item_theme(ber_window, "ber_window")
# bind_item_font(ber_window, test)
+def set_ber(values):
+ ber_curr, ber_max, ber_avg = values
+ configure_item("ber_value", label=f"Current: {ber_curr}, Max: {ber_max}, Avg: {ber_avg}")
+
+ber_value = net.network_value(url="udp://localhost:31420", dtype=float, refresh_func=set_ber)
+
#================================================
# Picture Window
@@ -278,8 +284,9 @@ set_primary_window("primary_window", True)
# Main loop
while is_dearpygui_running():
- for plt in network_plots:
- plt.refresh_series(plt.series_tag)
+ for plt, tag in network_plots.items():
+ plt.refresh_series(tag)
+ ber_value.refresh()
render_dearpygui_frame()
diff --git a/src/gui/net.py b/src/gui/net.py
index 121cc76..820bc84 100644
--- a/src/gui/net.py
+++ b/src/gui/net.py
@@ -1,3 +1,4 @@
+import os
import select
import socket
from urllib.parse import urlparse
@@ -12,19 +13,37 @@ class udpsource:
"""
Creates an UDP listening socket
"""
- def __init__(self, url, dtype, timeout=0.05):
+ def __init__(self, url, dtype, timeout=0.05, blocksize=1024):
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.url = urlparse(url)
self.dtype = dtype
self.timeout = timeout
+ self.blocksize = blocksize
+
+ if self.url.scheme == "udp":
+ self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+ elif self.url.scheme == "file":
+ try:
+ os.unlink(self.url.path)
+ except OSError:
+ if os.path.exists(self.url.path):
+ raise
+
+ self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
+ else:
+ raise NotImplemented
def __del__(self):
self.sock.close()
def bind(self):
self.sock.setblocking(False)
- self.sock.bind((self.url.hostname, self.url.port))
- # self.sock.listen()
+ if self.url.scheme == "udp":
+ self.sock.bind((self.url.hostname, self.url.port))
+ elif self.url.scheme == "file":
+ self.sock.bind(self.url.path)
+
+ # self.sock.listen(1)
def read(self, nblocks):
# TODO: run in a separate thread (it will be painful to implement)
@@ -33,8 +52,7 @@ class udpsource:
return None
# read from socket
- blocksize = 1024 * 4
- string = ready[0].recv(nblocks * blocksize).decode("ascii")
+ string = ready[0].recv(nblocks * self.blocksize).decode("ascii")
# decode string, remove empty values
chunks = filter(None, re.split(r"\[(.+?)\]", string))
@@ -55,6 +73,24 @@ class udpsource:
return values
+class network_value(udpsource):
+ def __init__(self, url, dtype, refresh_func):
+ udpsource.__init__(self, url, dtype, blocksize=16)
+
+ self._refresh = refresh_func
+ self.value = None
+
+ self.bind()
+
+ def read(self):
+ return udpsource.read(self, 1)
+
+ def refresh(self):
+ self.value = self.read()
+ if self.value:
+ self._refresh(self.value)
+
+
class network_plot(udpsource):
"""
Wraps a udpsource while at the same time intefacing with DearPyGUI as a plot element.
diff --git a/src/gui/lena512color.png b/src/gui/res/pic/lena512color.png
index 7d364e0..7d364e0 100644
--- a/src/gui/lena512color.png
+++ b/src/gui/res/pic/lena512color.png
Binary files differ
diff --git a/src/gui/lena512color.tiff b/src/gui/res/pic/lena512color.tiff
index ffe5c83..ffe5c83 100644
--- a/src/gui/lena512color.tiff
+++ b/src/gui/res/pic/lena512color.tiff
Binary files differ
diff --git a/src/gui/res/ttf/Hack-Bold.ttf b/src/gui/res/ttf/Hack-Bold.ttf
new file mode 100644
index 0000000..7ff4975
--- /dev/null
+++ b/src/gui/res/ttf/Hack-Bold.ttf
Binary files differ
diff --git a/src/gui/res/ttf/Hack-BoldItalic.ttf b/src/gui/res/ttf/Hack-BoldItalic.ttf
new file mode 100644
index 0000000..3b137d9
--- /dev/null
+++ b/src/gui/res/ttf/Hack-BoldItalic.ttf
Binary files differ
diff --git a/src/gui/res/ttf/Hack-Italic.ttf b/src/gui/res/ttf/Hack-Italic.ttf
new file mode 100644
index 0000000..d26198a
--- /dev/null
+++ b/src/gui/res/ttf/Hack-Italic.ttf
Binary files differ
diff --git a/src/gui/res/ttf/Hack-Regular.ttf b/src/gui/res/ttf/Hack-Regular.ttf
new file mode 100644
index 0000000..92a90cb
--- /dev/null
+++ b/src/gui/res/ttf/Hack-Regular.ttf
Binary files differ