diff options
author | sara <sara.halter@gmx.ch> | 2021-11-27 16:02:47 +0100 |
---|---|---|
committer | sara <sara.halter@gmx.ch> | 2021-11-27 16:02:47 +0100 |
commit | 789501e7a17d4be4d62b13a21640378ba5c0645f (patch) | |
tree | b2a158c8c5158d7a3819394e8496b9f99716113d /src | |
parent | Test FIR filter implemenatation / eigener FIR Block Gnur radio (diff) | |
parent | Very small rewording (diff) | |
download | Fading-789501e7a17d4be4d62b13a21640378ba5c0645f.tar.gz Fading-789501e7a17d4be4d62b13a21640378ba5c0645f.zip |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to '')
-rwxr-xr-x | src/gui.py | 42 | ||||
-rw-r--r-- | src/net.py | 35 | ||||
-rw-r--r-- | src/nix/numpy-ringbuffer.nix | 12 | ||||
-rw-r--r-- | src/shell.nix | 10 |
4 files changed, 58 insertions, 41 deletions
@@ -13,7 +13,6 @@ import signal # Mathematics import numpy as np -from numpy_ringbuffer import RingBuffer # For debugging import logging @@ -37,42 +36,6 @@ setup_dearpygui() # Show demo for dev show_demo() -#================================================ -# Network classes - -class network_plot(net.udpsource): - def __init__(self, url, nsamples, **kwargs): - net.udpsource.__init__(self, url) - - self.nsamples = nsamples - self.plot = plot(**kwargs) - - # create buffer and fill with zeroes - self.buffer = RingBuffer(capacity=nsamples, dtype=(np.float, 2)) - for i in range(nsamples): - # TODO: remove random data used for testing - self.buffer.append(np.array([i, 1 + np.random.rand() / 5])) - - self.bind() - - def __enter__(self): - return self.plot.__enter__() - - def __exit__(self, t, val, tb): - self.plot.__exit__(t, val, tb) - - @property - def x_data(self): - return np.array(self.buffer[:,0]) - - @property - def y_data(self): - return np.array(self.buffer[:,1]) - - def refresh(self, series_tag): - # set_value(series_tag, [self.x_data, self.y_data]) - pass - #================================================ # GUI Callback functions @@ -135,8 +98,7 @@ with window(label="RX DSP Flow Graph", width=800, height=400, pos=(25,25), tag=" #================================================ # Network plots Window -recv_plot = network_plot(url="udp://localhost:31415", nsamples=100, label="Test", height=300, width=800) - +recv_plot = net.network_plot(url="udp://localhost:31415", nsamples=100, label="Test", height=300, width=800) plots = { recv_plot: "plt_ampl" @@ -158,7 +120,7 @@ show_viewport() # Main loop while is_dearpygui_running(): for plt, tag in plots.items(): - plt.refresh(tag) + plt.refresh_series(tag) render_dearpygui_frame() @@ -3,6 +3,8 @@ import socket from urllib.parse import urlparse import numpy as np +from numpy_ringbuffer import RingBuffer +import dearpygui.dearpygui as dpg class udpsource: @@ -31,3 +33,36 @@ class udpsource: else: return None + +class network_plot(udpsource): + def __init__(self, url, nsamples, **kwargs): + udpsource.__init__(self, url) + + self.nsamples = nsamples + self.plot = dpg.plot(**kwargs) + + # create buffer and fill with zeroes + self.buffer = RingBuffer(capacity=nsamples, dtype=(float, 2)) + for i in range(nsamples): + # TODO: remove random data used for testing + self.buffer.append(np.array([i, 1 + np.random.rand() / 5])) + + self.bind() + + def __enter__(self): + return self.plot.__enter__() + + def __exit__(self, t, val, tb): + self.plot.__exit__(t, val, tb) + + @property + def x_data(self): + return np.array(self.buffer[:,0]) + + @property + def y_data(self): + return np.array(self.buffer[:,1]) + + def refresh_series(self, tag): + dpg.set_value(tag, [self.x_data, self.y_data]) + pass diff --git a/src/nix/numpy-ringbuffer.nix b/src/nix/numpy-ringbuffer.nix new file mode 100644 index 0000000..b97b01a --- /dev/null +++ b/src/nix/numpy-ringbuffer.nix @@ -0,0 +1,12 @@ +{ lib, pkgs, buildPythonPackage, fetchPypi, isPy38, autoPatchelfHook }: + +buildPythonPackage rec { + pname = "numpy_ringbuffer"; + version = "0.2.1"; + src = fetchPypi { + inherit pname version; + sha256 = "1vrw38jb3cy9m0c1xxvkk5sf1hpgv58x649a2nnqi9ljdl5wcydc"; + }; + + buildInputs = (with pkgs.python3Packages; [ numpy ]); +} diff --git a/src/shell.nix b/src/shell.nix index 666bab3..22771e2 100644 --- a/src/shell.nix +++ b/src/shell.nix @@ -7,10 +7,18 @@ let isPy38 = pkgs.python38Packages.isPy38; }; + numpy-ringbuffer = callPackage ./nix/numpy-ringbuffer.nix { + buildPythonPackage = pkgs.python38Packages.buildPythonPackage; + fetchPypi = pkgs.python38Packages.fetchPypi; + isPy38 = pkgs.python38Packages.isPy38; + }; + in mkShell { - buildInputs = [ dearpygui ] ++ (with pkgs; [ + buildInputs = [ dearpygui numpy-ringbuffer ] ++ (with pkgs; [ gnuradio python38Packages.setuptools + python38Packages.matplotlib + python38Packages.numpy # gnuradio block dev dependencies cmake ninja pkg-config log4cpp mpir boost175 gmp volk doxygen python38Packages.pybind11 |