diff options
-rw-r--r-- | gnuradio-core/src/lib/io/gr_file_sink.cc | 3 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_file_sink_base.cc | 6 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_file_sink_base.h | 7 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_file_sink_base.i | 5 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_oscope_guts.cc | 69 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_trigger_mode.h | 1 | ||||
-rwxr-xr-x | gr-utils/src/python/create-gnuradio-out-of-tree-project | 4 | ||||
-rw-r--r-- | gr-wxgui/src/python/common.py | 12 | ||||
-rw-r--r-- | gr-wxgui/src/python/scope_window.py | 10 | ||||
-rw-r--r-- | gr-wxgui/src/python/scopesink_gl.py | 2 | ||||
-rw-r--r-- | gr-wxgui/src/python/scopesink_nongl.py | 14 | ||||
-rw-r--r-- | gr-wxgui/src/python/waterfall_window.py | 7 | ||||
-rw-r--r-- | grc/blocks/gr_file_sink.xml | 19 | ||||
-rw-r--r-- | grc/blocks/wxgui_scopesink2.xml | 22 |
14 files changed, 141 insertions, 40 deletions
diff --git a/gnuradio-core/src/lib/io/gr_file_sink.cc b/gnuradio-core/src/lib/io/gr_file_sink.cc index d40235fab..d2c43aac7 100644 --- a/gnuradio-core/src/lib/io/gr_file_sink.cc +++ b/gnuradio-core/src/lib/io/gr_file_sink.cc @@ -70,5 +70,8 @@ gr_file_sink::work (int noutput_items, nwritten += count; inbuf += count * d_itemsize; } + if (d_unbuffered) + fflush (d_fp); + return nwritten; } diff --git a/gnuradio-core/src/lib/io/gr_file_sink_base.cc b/gnuradio-core/src/lib/io/gr_file_sink_base.cc index 5ddeeb4d5..c43304b0d 100644 --- a/gnuradio-core/src/lib/io/gr_file_sink_base.cc +++ b/gnuradio-core/src/lib/io/gr_file_sink_base.cc @@ -118,3 +118,9 @@ gr_file_sink_base::do_update() d_updated = false; } } + +void +gr_file_sink_base::set_unbuffered(bool unbuffered) +{ + d_unbuffered = unbuffered; +} diff --git a/gnuradio-core/src/lib/io/gr_file_sink_base.h b/gnuradio-core/src/lib/io/gr_file_sink_base.h index 0c028d7fd..7b96cdb7f 100644 --- a/gnuradio-core/src/lib/io/gr_file_sink_base.h +++ b/gnuradio-core/src/lib/io/gr_file_sink_base.h @@ -37,6 +37,7 @@ class gr_file_sink_base bool d_updated; // is there a new FILE pointer? bool d_is_binary; boost::mutex d_mutex; + bool d_unbuffered; protected: gr_file_sink_base(const char *filename, bool is_binary); @@ -61,6 +62,12 @@ class gr_file_sink_base * \brief if we've had an update, do it now. */ void do_update(); + + + /*! + * \brief turn on unbuffered writes for slower outputs + */ + void set_unbuffered(bool unbuffered); }; diff --git a/gnuradio-core/src/lib/io/gr_file_sink_base.i b/gnuradio-core/src/lib/io/gr_file_sink_base.i index 05a3353bb..ed4342482 100644 --- a/gnuradio-core/src/lib/io/gr_file_sink_base.i +++ b/gnuradio-core/src/lib/io/gr_file_sink_base.i @@ -43,4 +43,9 @@ class gr_file_sink_base * \brief if we've had an update, do it now. */ void do_update(); + + /*! + *\brief turn on unbuffered mode for slow outputs + */ + void set_unbuffered(bool unbuffered); }; diff --git a/gnuradio-core/src/lib/io/gr_oscope_guts.cc b/gnuradio-core/src/lib/io/gr_oscope_guts.cc index 80f78240d..ce7feca13 100644 --- a/gnuradio-core/src/lib/io/gr_oscope_guts.cc +++ b/gnuradio-core/src/lib/io/gr_oscope_guts.cc @@ -104,34 +104,49 @@ gr_oscope_guts::process_sample (const float *channel_data) d_decimator_count = d_decimator_count_init; - for (int i = 0; i < d_nchannels; i++) - d_buffer[i][d_obi] = channel_data[i]; // copy data into buffer - - switch (d_state){ - case HOLD_OFF: - d_hold_off_count--; - if (d_hold_off_count <= 0) - enter_look_for_trigger (); - break; - - case LOOK_FOR_TRIGGER: - if (found_trigger ()) - enter_post_trigger (); - break; - - case POST_TRIGGER: - d_post_trigger_count--; - if (d_post_trigger_count <= 0){ - write_output_records (); - enter_hold_off (); - } - break; - - default: - assert (0); + if (d_trigger_mode != gr_TRIG_MODE_STRIPCHART) + { + for (int i = 0; i < d_nchannels; i++) + d_buffer[i][d_obi] = channel_data[i]; // copy data into buffer + + switch (d_state){ + case HOLD_OFF: + d_hold_off_count--; + if (d_hold_off_count <= 0) + enter_look_for_trigger (); + break; + + case LOOK_FOR_TRIGGER: + if (found_trigger ()) + enter_post_trigger (); + break; + + case POST_TRIGGER: + d_post_trigger_count--; + if (d_post_trigger_count <= 0){ + write_output_records (); + enter_hold_off (); + } + break; + + default: + assert (0); + } + + d_obi = incr_bi (d_obi); + } + else + { + for (int i = 0; i < d_nchannels; i++) + { + for (int j = OUTPUT_RECORD_SIZE-1; j >= 0; j--) + { + d_buffer[i][j] = d_buffer[i][j-1]; + } + d_buffer[i][0] = channel_data[i]; + } + write_output_records(); } - - d_obi = incr_bi (d_obi); } /* diff --git a/gnuradio-core/src/lib/io/gr_trigger_mode.h b/gnuradio-core/src/lib/io/gr_trigger_mode.h index 63f6b1c98..8e1222856 100644 --- a/gnuradio-core/src/lib/io/gr_trigger_mode.h +++ b/gnuradio-core/src/lib/io/gr_trigger_mode.h @@ -27,6 +27,7 @@ enum gr_trigger_mode { gr_TRIG_MODE_FREE, gr_TRIG_MODE_AUTO, gr_TRIG_MODE_NORM, + gr_TRIG_MODE_STRIPCHART, }; enum gr_trigger_slope { diff --git a/gr-utils/src/python/create-gnuradio-out-of-tree-project b/gr-utils/src/python/create-gnuradio-out-of-tree-project index 1f512b219..d5e32c92b 100755 --- a/gr-utils/src/python/create-gnuradio-out-of-tree-project +++ b/gr-utils/src/python/create-gnuradio-out-of-tree-project @@ -52,8 +52,8 @@ def main(): # rename file contents upper_module_name = module_name.upper() - sed_cmd = 'sed -i -e "s/howto/%s/g" -e "s/HOWTO/%s/g"' % (module_name, - upper_module_name) + sed_cmd = 'sed -i -e "s/howto-write-a-block/%s/g" -e "s/howto/%s/g" -e "s/HOWTO/%s/g"' % (module_name, module_name, \ + upper_module_name) os.system('find . -type f -print0 | xargs -0 ' + sed_cmd) sys.stdout.write(""" diff --git a/gr-wxgui/src/python/common.py b/gr-wxgui/src/python/common.py index 17a7dc0de..3641ae644 100644 --- a/gr-wxgui/src/python/common.py +++ b/gr-wxgui/src/python/common.py @@ -25,6 +25,8 @@ import wx from gnuradio import gr +RUN_ALWAYS = gr.prefs().get_bool ('wxgui', 'run_always', False) + class wxgui_hb(object): """ The wxgui hier block helper/wrapper class: @@ -47,7 +49,10 @@ class wxgui_hb(object): assert points[0] == self or points[0][0] == self copy = gr.copy(self._hb.input_signature().sizeof_stream_item(0)) handler = self._handler_factory(copy.set_enabled) - handler(False) #initially disable the copy block + if RUN_ALWAYS == False: + handler(False) #initially disable the copy block + else: + handler(True) #initially enable the copy block self._bind_to_visible_event(win=self.win, handler=handler) points = list(points) points.insert(1, copy) #insert the copy block into the chain @@ -67,7 +72,10 @@ class wxgui_hb(object): if cache[0] == visible: return cache[0] = visible #print visible, handler - handler(visible) + if RUN_ALWAYS == False: + handler(visible) + else: + handler(True) return callback @staticmethod diff --git a/gr-wxgui/src/python/scope_window.py b/gr-wxgui/src/python/scope_window.py index c03b71f1e..a9917782f 100644 --- a/gr-wxgui/src/python/scope_window.py +++ b/gr-wxgui/src/python/scope_window.py @@ -38,6 +38,7 @@ import forms DEFAULT_FRAME_RATE = gr.prefs().get_long('wxgui', 'scope_rate', 30) PERSIST_ALPHA_MIN_EXP, PERSIST_ALPHA_MAX_EXP = -2, 0 SLIDER_STEPS = 100 +DEFAULT_TRIG_MODE = gr.prefs().get_long('wxgui', 'trig_mode', gr.gr_TRIG_MODE_AUTO) DEFAULT_WIN_SIZE = (600, 300) COUPLING_MODES = ( ('DC', False), @@ -47,6 +48,7 @@ TRIGGER_MODES = ( ('Freerun', gr.gr_TRIG_MODE_FREE), ('Auto', gr.gr_TRIG_MODE_AUTO), ('Normal', gr.gr_TRIG_MODE_NORM), + ('Stripchart', gr.gr_TRIG_MODE_STRIPCHART), ) TRIGGER_SLOPES = ( ('Pos +', gr.gr_TRIG_SLOPE_POS), @@ -432,6 +434,7 @@ class scope_window(wx.Panel, pubsub.pubsub): msg_key, use_persistence, persist_alpha, + trig_mode, ): pubsub.pubsub.__init__(self) #check num inputs @@ -471,11 +474,16 @@ class scope_window(wx.Panel, pubsub.pubsub): self[FRAME_RATE_KEY] = frame_rate self[TRIGGER_LEVEL_KEY] = 0 self[TRIGGER_CHANNEL_KEY] = 0 - self[TRIGGER_MODE_KEY] = gr.gr_TRIG_MODE_AUTO + self[TRIGGER_MODE_KEY] = trig_mode + self[TRIGGER_SLOPE_KEY] = gr.gr_TRIG_SLOPE_POS self[T_FRAC_OFF_KEY] = 0.5 self[USE_PERSISTENCE_KEY] = use_persistence self[PERSIST_ALPHA_KEY] = persist_alpha + + if self[TRIGGER_MODE_KEY] == gr.gr_TRIG_MODE_STRIPCHART: + self[T_FRAC_OFF_KEY] = 0.0 + for i in range(num_inputs): self.proxy(common.index_key(AC_COUPLE_KEY, i), controller, common.index_key(ac_couple_key, i)) #init panel and plot diff --git a/gr-wxgui/src/python/scopesink_gl.py b/gr-wxgui/src/python/scopesink_gl.py index ebf9b2939..15be23d5a 100644 --- a/gr-wxgui/src/python/scopesink_gl.py +++ b/gr-wxgui/src/python/scopesink_gl.py @@ -76,6 +76,7 @@ class _scope_sink_base(gr.hier_block2, common.wxgui_hb): xy_mode=False, ac_couple=False, num_inputs=1, + trig_mode=scope_window.DEFAULT_TRIG_MODE, frame_rate=scope_window.DEFAULT_FRAME_RATE, use_persistence=False, persist_alpha=None, @@ -132,6 +133,7 @@ class _scope_sink_base(gr.hier_block2, common.wxgui_hb): v_scale=v_scale, v_offset=v_offset, xy_mode=xy_mode, + trig_mode=trig_mode, ac_couple_key=AC_COUPLE_KEY, trigger_level_key=TRIGGER_LEVEL_KEY, trigger_mode_key=TRIGGER_MODE_KEY, diff --git a/gr-wxgui/src/python/scopesink_nongl.py b/gr-wxgui/src/python/scopesink_nongl.py index 5c1379ee6..bf2c50917 100644 --- a/gr-wxgui/src/python/scopesink_nongl.py +++ b/gr-wxgui/src/python/scopesink_nongl.py @@ -217,13 +217,13 @@ class input_watcher (gru.msgq_runner): chan_data = s[start:start+bytes_per_chan] rec = numpy.fromstring (chan_data, numpy.float32) records.append (rec) - - # print "nrecords = %d, reclen = %d" % (len (records),nsamples) - - de = DataEvent (records) - wx.PostEvent (self.event_receiver, de) - records = [] - del de + + # print "nrecords = %d, reclen = %d" % (len (records),nsamples) + + de = DataEvent (records) + wx.PostEvent (self.event_receiver, de) + records = [] + del de self.iscan -= 1 diff --git a/gr-wxgui/src/python/waterfall_window.py b/gr-wxgui/src/python/waterfall_window.py index b7904e4d9..6536ada10 100644 --- a/gr-wxgui/src/python/waterfall_window.py +++ b/gr-wxgui/src/python/waterfall_window.py @@ -38,6 +38,7 @@ import forms SLIDER_STEPS = 100 AVG_ALPHA_MIN_EXP, AVG_ALPHA_MAX_EXP = -3, 0 DEFAULT_FRAME_RATE = gr.prefs().get_long('wxgui', 'waterfall_rate', 30) +DEFAULT_COLOR_MODE = gr.prefs().get_string('wxgui', 'waterfall_color', 'rgb1') DEFAULT_WIN_SIZE = (600, 300) DIV_LEVELS = (1, 2, 5, 10, 20) MIN_DYNAMIC_RANGE, MAX_DYNAMIC_RANGE = 10, 200 @@ -156,6 +157,9 @@ class control_panel(wx.Panel): def _on_incr_time_scale(self, event): old_rate = self.parent[FRAME_RATE_KEY] self.parent[FRAME_RATE_KEY] *= 0.75 + if self.parent[FRAME_RATE_KEY] < 1.0: + self.parent[FRAME_RATE_KEY] = 1.0 + if self.parent[FRAME_RATE_KEY] == old_rate: self.parent[DECIMATION_KEY] += 1 def _on_decr_time_scale(self, event): @@ -217,6 +221,7 @@ class waterfall_window(wx.Panel, pubsub.pubsub): self[REF_LEVEL_KEY] = ref_level self[BASEBAND_FREQ_KEY] = baseband_freq self[COLOR_MODE_KEY] = COLOR_MODES[0][1] + self[COLOR_MODE_KEY] = DEFAULT_COLOR_MODE self[RUNNING_KEY] = True #setup the box with plot and controls self.control_panel = control_panel(self) @@ -280,6 +285,8 @@ class waterfall_window(wx.Panel, pubsub.pubsub): #grid parameters sample_rate = self[SAMPLE_RATE_KEY] frame_rate = self[FRAME_RATE_KEY] + if frame_rate < 1.0 : + frame_rate = 1.0 baseband_freq = self[BASEBAND_FREQ_KEY] num_lines = self[NUM_LINES_KEY] y_divs = self[Y_DIVS_KEY] diff --git a/grc/blocks/gr_file_sink.xml b/grc/blocks/gr_file_sink.xml index 880dc2759..0081c93f8 100644 --- a/grc/blocks/gr_file_sink.xml +++ b/grc/blocks/gr_file_sink.xml @@ -8,7 +8,9 @@ <name>File Sink</name> <key>gr_file_sink</key> <import>from gnuradio import gr</import> - <make>gr.file_sink($type.size*$vlen, $file)</make> + <make>gr.file_sink($type.size*$vlen, $file) +self.$(id).set_unbuffered($unbuffered)</make> + <callback>set_unbuffered($unbuffered)</callback> <param> <name>File</name> <key>file</key> @@ -51,6 +53,21 @@ <value>1</value> <type>int</type> </param> + <param> + <name>Unbuffered</name> + <key>unbuffered</key> + <value>False</value> + <type>bool</type> + <option> + <name>Off</name> + <key>False</key> + </option> + <option> + <name>On</name> + <key>True</key> + </option> + </param> + <check>$vlen > 0</check> <sink> <name>in</name> diff --git a/grc/blocks/wxgui_scopesink2.xml b/grc/blocks/wxgui_scopesink2.xml index eba45f489..50cd977be 100644 --- a/grc/blocks/wxgui_scopesink2.xml +++ b/grc/blocks/wxgui_scopesink2.xml @@ -20,6 +20,7 @@ scopesink2.$(type.fcn)( ac_couple=$ac_couple, xy_mode=$xy_mode, num_inputs=$num_inputs, + trig_mode=$trig_mode, #if $win_size() size=$win_size, #end if @@ -134,6 +135,27 @@ $(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos())))) <value></value> <type>notebook</type> </param> + <param> + <name>Trigger Mode</name> + <key>trig_mode</key> + <type>enum</type> + <option> + <name>Auto</name> + <key>gr.gr_TRIG_MODE_AUTO</key> + </option> + <option> + <name>Normal</name> + <key>gr.gr_TRIG_MODE_NORM</key> + </option> + <option> + <name>Freerun</name> + <key>gr.gr_TRIG_MODE_FREE</key> + </option> + <option> + <name>Stripchart</name> + <key>gr.gr_TRIG_MODE_STRIPCHART</key> + </option> + </param> <check>not $win_size or len($win_size) == 2</check> <check>not $xy_mode or '$type' == 'complex' or $num_inputs != 1</check> <sink> |