Changeset 8962
- Timestamp:
- 07/21/08 14:23:01
- Files:
-
- gnuradio/branches/features/experimental-gui/const_controller.py (modified) (1 diff)
- gnuradio/branches/features/experimental-gui/const_gui.py (modified) (2 diffs)
- gnuradio/branches/features/experimental-gui/const_streamer.py (modified) (4 diffs)
- gnuradio/branches/features/experimental-gui/const_top_block.py (modified) (2 diffs)
- gnuradio/branches/features/experimental-gui/fft_controller.py (modified) (1 diff)
- gnuradio/branches/features/experimental-gui/grc_constsink_test.py (modified) (3 diffs)
- gnuradio/branches/features/experimental-gui/plotter.py (modified) (4 diffs)
- gnuradio/branches/features/experimental-gui/usrp_const.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gnuradio/branches/features/experimental-gui/const_controller.py
r8932 r8962 83 83 # caller, result in the correct top block methods being invoked. 84 84 self.add_listener('decim', self.set_decim) 85 self.add_listener('gain', lambda x: self._tb.set_gain(x))86 self.add_listener('freq', lambda x: self._tb.set_freq(x))87 self.add_listener('costas_alpha', lambda x: self._tb.set_costas_alpha(x))88 self.add_listener('costas_max', lambda x: self._tb.set_costas_max(x))85 self.add_listener('gain', self._tb.set_gain) 86 self.add_listener('freq', self._tb.set_freq) 87 #self.add_listener('costas_alpha', self._tb.set_costas_alpha) 88 #self.add_listener('costas_max', self._tb.set_costas_max) 89 89 90 90 # Set providers for application properties 91 self.set_provider('sample_rate', lambda: self._tb.sample_rate()) 91 self.set_provider('sample_rate', self._tb.sample_rate) 92 93 #temp!!! 94 self['costas_alpha'] = .5 95 self['costas_beta'] = .5 92 96 93 97 # The controller is a thread. This is not required but convenient here. gnuradio/branches/features/experimental-gui/const_gui.py
r8932 r8962 20 20 # 21 21 22 # This requires GRC installed (temporary for demo purposes)23 22 from wxgui_app import wxgui_app 24 23 from const_window import const_window … … 35 34 36 35 self._win = const_window(parent=self.GetWin(), 37 controller=controller, 38 size=(600, 300), 39 title=title) 40 36 controller=controller, 37 size=(600, 300), 38 title=title, 39 msg_key='const', 40 alpha_key='costas_alpha', 41 beta_key='costas_beta', 42 gain_mu_key='costas_alpha', 43 gain_omega_key='costas_beta', 44 ) 45 41 46 self.Add(self._win) 42 47 gnuradio/branches/features/experimental-gui/const_streamer.py
r8932 r8962 30 30 """ 31 31 def __init__(self, 32 sample_rate,32 sample_rate, 33 33 bit_rate, 34 order=2,34 order=2, 35 35 frame_size=1024, 36 frame_rate=30,37 costas_alpha=0.1,36 frame_rate=30, 37 costas_alpha=0.1, 38 38 costas_max=0.05, 39 39 mm_alpha=0.005, 40 40 mm_max=0.05): 41 """!41 """! 42 42 Create a const_streamer. 43 @param sample_rate Incoming sample rate43 @param sample_rate Incoming sample rate 44 44 @param bit_rate Modulated bit rate/sec 45 @param orderConstellation order (BPSK=2, QPSK=4, default is 2)45 @param order Constellation order (BPSK=2, QPSK=4, default is 2) 46 46 @param frame_size Number of constellation points to plot at a time 47 47 @param frame_rate Number of frames/sec to create (default is 30) … … 52 52 """ 53 53 54 gr.hier_block2.__init__(self, "const_streamer",55 gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature56 gr.io_signature(1, 1, gr.sizeof_gr_complex*frame_size)) # Output signature54 gr.hier_block2.__init__(self, "const_streamer", 55 gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature 56 gr.io_signature(1, 1, gr.sizeof_gr_complex*frame_size)) # Output signature 57 57 58 # Costas frequency/phase recovery loop58 # Costas frequency/phase recovery loop 59 59 # Critically damped 2nd order PLL 60 60 costas_beta = 0.25*costas_alpha*costas_alpha 61 61 costas_min = -costas_max 62 self._costas = gr.costas_loop_cc(costas_alpha,62 self._costas = gr.costas_loop_cc(costas_alpha, 63 63 costas_beta, 64 64 costas_max, … … 69 69 # Critically damped 2nd order DLL 70 70 mm_freq = float(sample_rate)/bit_rate 71 mm_beta = 0.25*mm_alpha*mm_alpha71 mm_beta = 0.25*mm_alpha*mm_alpha 72 72 mu=0.5 # Center of bit 73 self._retime = gr.clock_recovery_mm_cc(mm_freq, # omega,73 self._retime = gr.clock_recovery_mm_cc(mm_freq, # omega, 74 74 mm_beta, # gain_omega 75 75 mu, … … 77 77 mm_max) # omega_limit 78 78 79 # Scale to unity power80 self._agc = gr.agc_cc(1e-6);79 # Scale to unity power 80 self._agc = gr.agc_cc(1e-6); 81 81 82 self._decim = blks2.stream_to_vector_decimator(item_size=gr.sizeof_gr_complex,83 sample_rate=bit_rate,84 vec_rate=frame_rate,85 vec_len=frame_size)86 87 self.connect(self, self._costas, self._retime, self._agc, self._decim, self)82 self._decim = blks2.stream_to_vector_decimator(item_size=gr.sizeof_gr_complex, 83 sample_rate=bit_rate, 84 vec_rate=frame_rate, 85 vec_len=frame_size) 86 87 self.connect(self, self._costas, self._retime, self._agc, self._decim, self) gnuradio/branches/features/experimental-gui/const_top_block.py
r8933 r8962 32 32 """ 33 33 def __init__(self, 34 order=2,34 order=2, 35 35 frame_size=1024, 36 frame_rate=30,37 which=0,38 decim=16,39 width_8=False,40 no_hb=False,41 subdev_spec=None,42 gain=None,43 freq=None,44 antenna=None,36 frame_rate=30, 37 which=0, 38 decim=16, 39 width_8=False, 40 no_hb=False, 41 subdev_spec=None, 42 gain=None, 43 freq=None, 44 antenna=None, 45 45 bit_rate=None, 46 costas_alpha=0.1,46 costas_alpha=0.1, 47 47 costas_max=0.05, 48 48 mm_alpha=0.005, 49 49 mm_max=0.05 50 50 ): 51 """!51 """! 52 52 Create a const_top_block. 53 53 54 @param orderConstellation order (BPSK=2, QPSK=4, default is 2)54 @param order Constellation order (BPSK=2, QPSK=4, default is 2) 55 55 @param frame_size Number of constellation points to plot at a time 56 56 @param frame_rate Number of frames/sec to create (default is 30) 57 @param which USRP # on USB bus (default is 0)58 @param decim Receive sample rate decimation (default is 16)59 @param width_8 Use 8-bit instead of 16-bit samples (default is False)60 @param no_hb Don't use half-band filter (default is False)57 @param which USRP # on USB bus (default is 0) 58 @param decim Receive sample rate decimation (default is 16) 59 @param width_8 Use 8-bit instead of 16-bit samples (default is False) 60 @param no_hb Don't use half-band filter (default is False) 61 61 @param subdev_spec Daughterboard selection (default is first found) 62 @param gain Daughterboard RX gain (default is mid-range)63 @param freq Daughterboard RX frequency (default is mid-range)64 @param antenna Daughterboard RX antenna (default is board-default)62 @param gain Daughterboard RX gain (default is mid-range) 63 @param freq Daughterboard RX frequency (default is mid-range) 64 @param antenna Daughterboard RX antenna (default is board-default) 65 65 @param bit_rate Modulated bit rate/sec (default equivalent to 2 samples/bit) 66 66 @param costas_alpha Costas loop 1st order gain constant (default is 0.1) … … 70 70 """ 71 71 72 gr.top_block.__init__(self, "const_top_block")72 gr.top_block.__init__(self, "const_top_block") 73 73 74 # Source of samples75 self._u = simple_usrp.source_c(which=which,76 decim=decim,77 width_8=width_8,78 no_hb=no_hb,79 subdev_spec=subdev_spec,80 gain=gain,81 freq=freq,82 antenna=antenna)74 # Source of samples 75 self._u = simple_usrp.source_c(which=which, 76 decim=decim, 77 width_8=width_8, 78 no_hb=no_hb, 79 subdev_spec=subdev_spec, 80 gain=gain, 81 freq=freq, 82 antenna=antenna) 83 83 84 # TODO: make this a configuration matched filter85 # for now assume square pulses86 self._filt = gr.fir_filter_ccf(1, [1.0,]*int(self._u.sample_rate()/bit_rate))84 # TODO: make this a configuration matched filter 85 # for now assume square pulses 86 self._filt = gr.fir_filter_ccf(1, [1.0,]*int(self._u.sample_rate()/bit_rate)) 87 87 88 self._const = const_streamer.const_streamer(sample_rate=self._u.sample_rate(),89 bit_rate=bit_rate,90 order=order,91 frame_size=frame_size,92 frame_rate=frame_rate,93 costas_alpha=costas_alpha,94 costas_max=costas_max,95 mm_alpha=mm_alpha,96 mm_max=mm_max)88 self._const = const_streamer.const_streamer(sample_rate=self._u.sample_rate(), 89 bit_rate=bit_rate, 90 order=order, 91 frame_size=frame_size, 92 frame_rate=frame_rate, 93 costas_alpha=costas_alpha, 94 costas_max=costas_max, 95 mm_alpha=mm_alpha, 96 mm_max=mm_max) 97 97 98 self._msgq = gr.msg_queue(2)99 self._sink = gr.message_sink(gr.sizeof_gr_complex*frame_size, self._msgq, True)100 101 self.connect(self._u, self._filt, self._const, self._sink)98 self._msgq = gr.msg_queue(2) 99 self._sink = gr.message_sink(gr.sizeof_gr_complex*frame_size, self._msgq, True) 100 101 self.connect(self._u, self._filt, self._const, self._sink) 102 102 103 103 # "Setters", which are called externally to affect flowgraph operation 104 104 def set_gain(self, gain): 105 return self._u.set_gain(gain)106 105 return self._u.set_gain(gain) 106 107 107 def set_freq(self, freq): 108 return self._u.set_freq(freq)109 108 return self._u.set_freq(freq) 109 110 110 def set_decim(self, decim): 111 self._u.set_decim(decim)112 self._const.set_sample_rate(self._u.sample_rate())111 self._u.set_decim(decim) 112 self._const.set_sample_rate(self._u.sample_rate()) 113 113 114 114 # Getters, which are called externally to get information about the flowgraph 115 115 def queue(self): 116 return self._msgq116 return self._msgq 117 117 118 118 def sample_rate(self): gnuradio/branches/features/experimental-gui/fft_controller.py
r8893 r8962 77 77 # caller, result in the correct top block methods being invoked. 78 78 self.add_listener('decim', self.set_decim) 79 self.add_listener('gain', lambda x: self._tb.set_gain(x))80 self.add_listener('freq', lambda x: self._tb.set_freq(x))81 self.add_listener('avg_alpha', lambda x: self._tb.set_avg_alpha(x))82 self.add_listener('average', lambda x: self._tb.set_average(x))79 self.add_listener('gain', self._tb.set_gain) 80 self.add_listener('freq', self._tb.set_freq) 81 self.add_listener('avg_alpha', self._tb.set_avg_alpha) 82 self.add_listener('average', self._tb.set_average) 83 83 84 84 # Set providers for application properties 85 self.set_provider('sample_rate', lambda: self._tb.sample_rate())86 self.set_provider('average', lambda: self._tb.average())87 self.set_provider('avg_alpha', lambda: self._tb.avg_alpha())85 self.set_provider('sample_rate', self._tb.sample_rate) 86 self.set_provider('average', self._tb.average) 87 self.set_provider('avg_alpha', self._tb.avg_alpha) 88 88 89 89 # The controller is a thread. This is not required but convenient here. gnuradio/branches/features/experimental-gui/grc_constsink_test.py
r8906 r8962 70 70 ) 71 71 self.gr_chunks_to_symbols_xx = gr.chunks_to_symbols_bc(const, 1) 72 self.gr_interp_fir_filter_xxx = gr.interp_fir_filter_ccc(samples_per_symbol, ([1]*samples_per_symbol)) 72 self.gr_fir_filter_xxx = gr.fir_filter_ccc(1, ([1]*samples_per_symbol)) 73 self.gr_repeat = gr.repeat(gr.sizeof_gr_complex*1, samples_per_symbol) 73 74 self.gr_throttle = gr.throttle(gr.sizeof_gr_complex*1, samp_rate) 74 75 self.random_source_x = gr.vector_source_b(numpy.random.randint(0, 4, 1000), True) … … 95 96 self.connect((self.random_source_x, 0), (self.gr_chunks_to_symbols_xx, 0)) 96 97 self.connect((self.gr_chunks_to_symbols_xx, 0), (self.gr_throttle, 0)) 97 self.connect((self.gr_interp_fir_filter_xxx, 0), (self.blks2_channel_model, 0))98 98 self.connect((self.blks2_channel_model, 0), (self.wxgui_constellationsink2, 0)) 99 self.connect((self.gr_throttle, 0), (self.gr_interp_fir_filter_xxx, 0)) 99 self.connect((self.gr_throttle, 0), (self.gr_repeat, 0)) 100 self.connect((self.gr_repeat, 0), (self.gr_fir_filter_xxx, 0)) 101 self.connect((self.gr_fir_filter_xxx, 0), (self.blks2_channel_model, 0)) 102 103 def set_const(self, const): 104 self.const = const 100 105 101 106 def set_freq_off(self, freq_off): … … 114 119 def set_samples_per_symbol(self, samples_per_symbol): 115 120 self.samples_per_symbol = samples_per_symbol 116 self.gr_ interp_fir_filter_xxx.set_taps(([1]*self.samples_per_symbol))121 self.gr_fir_filter_xxx.set_taps(([1]*self.samples_per_symbol)) 117 122 118 123 if __name__ == '__main__': gnuradio/branches/features/experimental-gui/plotter.py
r8814 r8962 73 73 if not self._gl_init_flag: 74 74 glClearColor(*BACKGROUND_COLOR_SPEC) 75 glEnableClientState(GL_VERTEX_ARRAY)75 self._gl_init() 76 76 self._gl_init_flag = True 77 77 #check for a change in window size … … 97 97 """ 98 98 self.semaphore = threading.Semaphore(1) 99 self.grid_compiled_list_id = wx.NewId()100 99 self.channels = dict() 101 100 #store title and unit strings … … 110 109 self.set_y_grid(-1, 1, 1) 111 110 _plotter_base.__init__(self, parent) 111 112 def _gl_init(self): 113 """! 114 Run gl initialization tasks. 115 """ 116 glEnableClientState(GL_VERTEX_ARRAY) 117 self.grid_compiled_list_id = glGenLists(1) 112 118 113 119 def set_legend(self, legend): … … 241 247 points_4 = numpy.array(zip(points, points, points, points)) 242 248 points_4 = points_4 + .01*numpy.array([ 243 ( (self.x_max-self.x_min), 0),244 ( -(self.x_max-self.x_min), 0),245 (0, (self.y_max-self.y_min)),246 (0, -(self.y_max-self.y_min)),249 (self.x_max-self.x_min, 0), 250 (self.x_min-self.x_max, 0), 251 (0, self.y_max-self.y_min), 252 (0, self.y_min-self.y_max), 247 253 ] 248 254 ) gnuradio/branches/features/experimental-gui/usrp_const.py
r8932 r8962 110 110 # do with the controller properties. 111 111 # 112 #gui = const_gui(controller)113 #gui.run()112 gui = const_gui(controller) 113 gui.run() 114 114 115 115 # TEMPORARY 116 f = open('const.dat', 'wb')117 def writer(frame):118 f.write(frame)119 controller.add_listener('const', writer)116 #f = open('const.dat', 'wb') 117 #def writer(frame): 118 # f.write(frame) 119 #controller.add_listener('const', writer) 120 120 121 controller.on_init()122 try:123 raw_input("Press return to stop.")124 except KeyboardInterrupt:125 pass121 #controller.on_init() 122 #try: 123 #raw_input("Press return to stop.") 124 #except KeyboardInterrupt: 125 #pass 126 126 127 controller.on_exit()127 #controller.on_exit()
