diff options
Diffstat (limited to '')
-rw-r--r-- | flowgraphs/qpsk_sim.grc | 8 | ||||
-rwxr-xr-x | flowgraphs/qpsk_sim.py | 20 | ||||
-rw-r--r-- | src/gr-fadingui/python/ber.py | 10 | ||||
-rwxr-xr-x | src/gui/gui.py | 11 | ||||
-rw-r--r-- | src/gui/net.py | 24 |
5 files changed, 53 insertions, 20 deletions
diff --git a/flowgraphs/qpsk_sim.grc b/flowgraphs/qpsk_sim.grc index a8dd485..75bf3e1 100644 --- a/flowgraphs/qpsk_sim.grc +++ b/flowgraphs/qpsk_sim.grc @@ -366,9 +366,9 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [568, 548.0] + coordinate: [592, 572.0] rotation: 0 - state: disabled + state: enabled - name: digital_cma_equalizer_cc_0 id: digital_cma_equalizer_cc parameters: @@ -518,7 +518,7 @@ blocks: bus_structure: null coordinate: [648, 740.0] rotation: 0 - state: enabled + state: disabled - name: fadingui_netsink_0 id: fadingui_netsink parameters: @@ -816,7 +816,7 @@ blocks: bus_structure: null coordinate: [1248, 1060.0] rotation: 0 - state: enabled + state: disabled - name: virtual_sink_0 id: virtual_sink parameters: diff --git a/flowgraphs/qpsk_sim.py b/flowgraphs/qpsk_sim.py index 1e00180..63d8a6e 100755 --- a/flowgraphs/qpsk_sim.py +++ b/flowgraphs/qpsk_sim.py @@ -47,7 +47,11 @@ class qpsk_sim(gr.top_block): # Blocks ################################################## 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_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_0 = fadingui.netsink(address='udp://localhost:31415', dtype="float", vlen=1) + self.fadingui_netsink_0 = fadingui.netsink(address='udp://localhost:31416', dtype="complex", vlen=1) self.fadingui_ber_0 = fadingui.ber(vgl=testvec + list(np.zeros(4)), vlen=frame_len,address='udp://localhost:31420') 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_corr_est_cc_0 = digital.corr_est_cc(access_code_symbols, 1, len(access_code_symbols) // 2, 0.9, digital.THRESHOLD_ABSOLUTE) @@ -61,6 +65,7 @@ class qpsk_sim(gr.top_block): log=False) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(qpsk_const) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(15, 1, 2e-3, 1) + 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=2e-3, @@ -74,6 +79,7 @@ class qpsk_sim(gr.top_block): 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) @@ -82,20 +88,26 @@ class qpsk_sim(gr.top_block): # 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.fadingui_netsink_0_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)) 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.channels_selective_fading_model_0, 0), (self.fadingui_netsink_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_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.fadingui_multipath_fading_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) + self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.fadingui_netsink_4, 0)) self.connect((self.fadingui_phasecorrection_0, 0), (self.digital_constellation_decoder_cb_0, 0)) + self.connect((self.fadingui_phasecorrection_0, 0), (self.fadingui_netsink_3, 0)) def get_testvec(self): @@ -133,6 +145,7 @@ class qpsk_sim(gr.top_block): 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) def get_rrc_taps(self): return self.rrc_taps @@ -158,6 +171,7 @@ class qpsk_sim(gr.top_block): 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/src/gr-fadingui/python/ber.py b/src/gr-fadingui/python/ber.py index 1c5debf..664780f 100644 --- a/src/gr-fadingui/python/ber.py +++ b/src/gr-fadingui/python/ber.py @@ -43,7 +43,7 @@ class ber(gr.sync_block): self.vgl=vgl self.vlen=vlen - self.ber_samples = RingBuffer(capacity=2000, dtype=int) + self.ber_samples = RingBuffer(capacity=100, dtype=int) self.ber_samples.extend(np.zeros(self.ber_samples.maxlen)) # Create a socket and parse remote machine url @@ -84,8 +84,6 @@ class ber(gr.sync_block): log.debug(f"Length: {len(inp)}") # log.debug(f"Inp_vector:{inp}") - - for i in inp: i = np.array(i, dtype=np.uint8) v = np.array(self.vgl, dtype=np.uint8) ^ i @@ -102,11 +100,7 @@ class ber(gr.sync_block): ber_max, ber_min, ber_avg = self.ber_stats() log.debug(f"Statistics: {ber_max}, {ber_min}, {ber_avg}") - #self.send(self.encode(ber_max, ber_min, ber_avg)) - self.send(self.encode(trueber)) - self.send(self.encode(ber_max)) - self.send(self.encode(ber_min)) - self.send(self.encode(ber_avg)) + self.send(self.encode([trueber, ber_max, ber_avg])) return len(inp) #return len(input_items[0]) diff --git a/src/gui/gui.py b/src/gui/gui.py index 6091618..9ac69f7 100755 --- a/src/gui/gui.py +++ b/src/gui/gui.py @@ -253,12 +253,18 @@ with window(label="Bit Error Rate ", width=300, height=150, pos=(1200,875), no_t 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 with window(label="Picture", width=400, height=300, pos=(0,825)) as picture_window : @@ -275,6 +281,7 @@ set_primary_window("primary_window", True) while is_dearpygui_running(): 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 715e7a0..f836f42 100644 --- a/src/gui/net.py +++ b/src/gui/net.py @@ -12,11 +12,12 @@ 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 def __del__(self): self.sock.close() @@ -33,8 +34,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 +55,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. |