2 # Copyright 2009 Free Software Foundation, Inc.
4 # This file is part of GNU Radio
6 # GNU Radio is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3, or (at your option)
11 # GNU Radio is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with GNU Radio; see the file COPYING. If not, write to
18 # the Free Software Foundation, Inc., 51 Franklin Street,
19 # Boston, MA 02110-1301, USA.
22 ##################################################
24 ##################################################
27 from gnuradio import gr, blks2
28 from pubsub import pubsub
29 from constants import *
31 ##################################################
32 # histo sink block (wrapper for old wxgui)
33 ##################################################
34 class histo_sink_f(gr.hier_block2):
36 A histogram block and a gui window.
42 size=histo_window.DEFAULT_WIN_SIZE,
48 gr.hier_block2.__init__(
51 gr.io_signature(1, 1, gr.sizeof_float),
52 gr.io_signature(0, 0, 0),
55 msgq = gr.msg_queue(2)
56 histo = gr.histo_sink_f(msgq)
57 histo.set_num_bins(num_bins)
58 histo.set_frame_size(frame_size)
60 self.connect(self, histo)
62 self.controller = pubsub()
63 self.controller.subscribe(NUM_BINS_KEY, histo.set_num_bins)
64 self.controller.publish(NUM_BINS_KEY, histo.get_num_bins)
65 self.controller.subscribe(FRAME_SIZE_KEY, histo.set_frame_size)
66 self.controller.publish(FRAME_SIZE_KEY, histo.get_frame_size)
68 common.input_watcher(msgq, self.controller, MSG_KEY, arg1_key=MINIMUM_KEY, arg2_key=MAXIMUM_KEY)
70 self.win = histo_window.histo_window(
72 controller=self.controller,
75 maximum_key=MAXIMUM_KEY,
76 minimum_key=MINIMUM_KEY,
77 num_bins_key=NUM_BINS_KEY,
78 frame_size_key=FRAME_SIZE_KEY,
81 common.register_access_methods(self, self.win)
83 # ----------------------------------------------------------------
85 # ----------------------------------------------------------------
88 from gnuradio.wxgui import stdgui2
90 class test_app_block (stdgui2.std_top_block):
91 def __init__(self, frame, panel, vbox, argv):
92 stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv)
94 # build our flow graph
97 src2 = gr.sig_source_f (input_rate, gr.GR_SIN_WAVE, 2e3, 1)
98 #src2 = gr.sig_source_f (input_rate, gr.GR_CONST_WAVE, 5.75e3, 1)
99 thr2 = gr.throttle(gr.sizeof_float, input_rate)
100 sink2 = histo_sink_f (panel, title="Data", num_bins=31, frame_size=1000)
101 vbox.Add (sink2.win, 1, wx.EXPAND)
103 self.connect(src2, thr2, sink2)
106 app = stdgui2.stdapp (test_app_block, "Histo Sink Test App")
109 if __name__ == '__main__':