[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r10468 - in gnuradio/branches/developers/jblum/gui_gut
From: |
jblum |
Subject: |
[Commit-gnuradio] r10468 - in gnuradio/branches/developers/jblum/gui_guts: gnuradio-core/src/lib/io gr-wxgui/src/python |
Date: |
Thu, 19 Feb 2009 15:49:51 -0700 (MST) |
Author: jblum
Date: 2009-02-19 15:49:49 -0700 (Thu, 19 Feb 2009)
New Revision: 10468
Modified:
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_guts.cc
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_guts.h
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink_f.cc
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink_f.h
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink_x.cc
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink_x.h
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_trigger_mode.h
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scope_window.py
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scopesink_gl.py
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scopesink_nongl.py
Log:
Attempts with trigger modes: freerun, automatic, pos, neg. WIP!!!
freerun->always trigger
auto->try to trigger, if we cant find a trigger, then freerun
pos/neg->trigger only
Fixed segfault issue when setting scope guts params on init.
the gr_oscope_sink_f now creates the guts in init
the number of channels are set by check_topology
Modified:
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_guts.cc
===================================================================
---
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_guts.cc
2009-02-19 07:32:42 UTC (rev 10467)
+++
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_guts.cc
2009-02-19 22:49:49 UTC (rev 10468)
@@ -51,8 +51,8 @@
return wrap_bi (buffer_index - 1);
}
-gr_oscope_guts::gr_oscope_guts (int nchannels, double sample_rate,
gr_msg_queue_sptr msgq)
- : d_nchannels (nchannels),
+gr_oscope_guts::gr_oscope_guts (double sample_rate, gr_msg_queue_sptr msgq)
+ : d_nchannels (1),
d_msgq (msgq),
d_trigger_mode (gr_TRIG_AUTO),
d_trigger_channel (0),
@@ -69,15 +69,10 @@
d_post_trigger_count (0),
d_post_trigger_count_init (OUTPUT_RECORD_SIZE/2)
{
- if (d_nchannels > MAX_CHANNELS){
- fprintf (stderr, "gr_oscope_guts: too many channels. MAX_CHANNELS =
%d\n", MAX_CHANNELS);
- throw std::runtime_error ("too many channels");
- }
-
for (int i = 0; i < MAX_CHANNELS; i++)
d_buffer[i] = 0;
- for (int i = 0; i < d_nchannels; i++){
+ for (int i = 0; i < MAX_CHANNELS; i++){
d_buffer[i] = new float [OUTPUT_RECORD_SIZE];
for (int j = 0; j < OUTPUT_RECORD_SIZE; j++)
d_buffer[i][j] = 0.0;
@@ -120,8 +115,8 @@
case LOOK_FOR_TRIGGER:
d_pre_trigger_count++;
- //found a trigger or too many samples without a trigger
- if (found_trigger () || d_pre_trigger_count > OUTPUT_RECORD_SIZE/2)
+ //found a trigger or too many samples without a trigger in auto mode
+ if (found_trigger () || (d_trigger_mode == gr_TRIG_AUTO &&
d_pre_trigger_count > OUTPUT_RECORD_SIZE/2))
enter_post_trigger ();
break;
@@ -180,11 +175,11 @@
switch (d_trigger_mode){
- case gr_TRIG_NONE:
+ case gr_TRIG_FREE: //free run mode, always trigger
d_trigger_off = 0;
return true;
- case gr_TRIG_AUTO: //not really automatic, just do pos slope
+ case gr_TRIG_AUTO: //not really automatic, just do pos slope, auto handled
in process sample
case gr_TRIG_POS_SLOPE:
trig = prev_sample < d_trigger_level && new_sample >= d_trigger_level;
break;
@@ -287,16 +282,9 @@
bool
gr_oscope_guts::set_trigger_mode (gr_trigger_mode mode)
{
- switch (mode){
- case gr_TRIG_POS_SLOPE:
- case gr_TRIG_NEG_SLOPE:
- case gr_TRIG_NONE:
- case gr_TRIG_AUTO:
- d_trigger_mode = mode;
- trigger_changed ();
- return true;
- }
- return false;
+ d_trigger_mode = mode;
+ trigger_changed ();
+ return true;
}
bool
@@ -322,6 +310,17 @@
return set_trigger_level((min_v + max_v) * 0.5);
}
+bool
+gr_oscope_guts::set_num_channels(int nchannels)
+{
+ if (nchannels > 0 && nchannels <= MAX_CHANNELS){
+ d_nchannels = nchannels;
+ return true;
+ }
+ return false;
+}
+
+
void
gr_oscope_guts::trigger_changed ()
{
Modified:
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_guts.h
===================================================================
---
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_guts.h
2009-02-19 07:32:42 UTC (rev 10467)
+++
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_guts.h
2009-02-19 22:49:49 UTC (rev 10468)
@@ -41,8 +41,9 @@
*/
class gr_oscope_guts {
+public:
+ static const int MAX_CHANNELS = 8;
private:
- static const int MAX_CHANNELS = 16;
enum scope_state { HOLD_OFF, LOOK_FOR_TRIGGER, POST_TRIGGER };
int d_nchannels; // how many channels
@@ -81,7 +82,7 @@
public:
// CREATORS
- gr_oscope_guts (int nchannels, double sample_rate, gr_msg_queue_sptr msgq);
+ gr_oscope_guts (double sample_rate, gr_msg_queue_sptr msgq);
~gr_oscope_guts ();
// MANIPULATORS
@@ -99,6 +100,7 @@
bool set_trigger_level (double trigger_level);
bool set_trigger_level_auto (); // set to 50%
level
bool set_sample_rate(double sample_rate);
+ bool set_num_channels(int nchannels);
// ACCESSORS
Modified:
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink_f.cc
===================================================================
---
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink_f.cc
2009-02-19 07:32:42 UTC (rev 10467)
+++
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink_f.cc
2009-02-19 22:49:49 UTC (rev 10468)
@@ -38,20 +38,18 @@
gr_oscope_sink_f::gr_oscope_sink_f (double sampling_rate, gr_msg_queue_sptr
msgq)
: gr_oscope_sink_x ("oscope_sink_f",
- gr_make_io_signature (1, MAX_CHANNELS, sizeof (float)),
+ gr_make_io_signature (1, gr_oscope_guts::MAX_CHANNELS,
sizeof (float)),
sampling_rate),
d_msgq(msgq)
{
+ d_guts = new gr_oscope_guts (d_sampling_rate, d_msgq);
}
bool
gr_oscope_sink_f::check_topology (int ninputs, int noutputs)
{
- delete d_guts;
- d_guts = 0;
- d_guts = new gr_oscope_guts (ninputs, d_sampling_rate, d_msgq);
- return true;
+ return d_guts->set_num_channels(ninputs);
}
@@ -65,7 +63,7 @@
gr_vector_void_star &output_items)
{
int ni = input_items.size ();
- float tmp[MAX_CHANNELS];
+ float tmp[gr_oscope_guts::MAX_CHANNELS];
for (int i = 0; i < noutput_items; i++){
Modified:
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink_f.h
===================================================================
---
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink_f.h
2009-02-19 07:32:42 UTC (rev 10467)
+++
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink_f.h
2009-02-19 22:49:49 UTC (rev 10468)
@@ -36,13 +36,10 @@
* \brief Building block for python oscilloscope module.
* \ingroup sink
*
- * Accepts 1 to 16 float streams.
+ * Accepts multiple float streams.
*/
class gr_oscope_sink_f : public gr_oscope_sink_x
{
-public:
- static const int MAX_CHANNELS = 16;
-
private:
friend gr_oscope_sink_f_sptr
gr_make_oscope_sink_f (double sampling_rate, gr_msg_queue_sptr msgq);
Modified:
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink_x.cc
===================================================================
---
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink_x.cc
2009-02-19 07:32:42 UTC (rev 10467)
+++
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink_x.cc
2009-02-19 22:49:49 UTC (rev 10468)
@@ -87,6 +87,12 @@
return d_guts->set_sample_rate (sample_rate);
}
+bool
+gr_oscope_sink_x::set_num_channels (int nchannels)
+{
+ return d_guts->set_num_channels (nchannels);
+}
+
// ACCESSORS
int
Modified:
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink_x.h
===================================================================
---
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink_x.h
2009-02-19 07:32:42 UTC (rev 10467)
+++
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink_x.h
2009-02-19 22:49:49 UTC (rev 10468)
@@ -54,6 +54,7 @@
bool set_trigger_level (double trigger_level);
bool set_trigger_level_auto (); // set to 50%
level
bool set_sample_rate(double sample_rate);
+ bool set_num_channels (int nchannels);
// ACCESSORS
Modified:
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_trigger_mode.h
===================================================================
---
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_trigger_mode.h
2009-02-19 07:32:42 UTC (rev 10467)
+++
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_trigger_mode.h
2009-02-19 22:49:49 UTC (rev 10468)
@@ -24,9 +24,9 @@
#define INCLUDED_GR_TRIGGER_MODE_H
enum gr_trigger_mode {
- gr_TRIG_NONE, // no triggering
+ gr_TRIG_FREE, // freerun
gr_TRIG_AUTO, // auto trigger
- gr_TRIG_POS_SLOPE, // trigger on positive slope across trigger
level
+ gr_TRIG_POS_SLOPE, // trigger on positive slope across trigger level
gr_TRIG_NEG_SLOPE // trigger on negative slope across trigger
level
};
Modified:
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scope_window.py
===================================================================
---
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scope_window.py
2009-02-19 07:32:42 UTC (rev 10467)
+++
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scope_window.py
2009-02-19 22:49:49 UTC (rev 10468)
@@ -38,7 +38,7 @@
DEFAULT_WIN_SIZE = (600, 300)
DEFAULT_V_SCALE = 1000
TRIGGER_MODES = (
- ('Off', gr.gr_TRIG_NONE),
+ ('Freerun', gr.gr_TRIG_FREE),
('Auto', gr.gr_TRIG_AUTO),
('Neg', gr.gr_TRIG_NEG_SLOPE),
('Pos', gr.gr_TRIG_POS_SLOPE),
@@ -88,16 +88,16 @@
control_box.Add(common.LabelText(self, 'Trigger Options'), 0,
wx.ALIGN_CENTER)
control_box.AddSpacer(2)
#trigger mode
- self.trigger_mode_chooser = common.DropDownController(self,
'Mode', TRIGGER_MODES, parent, TRIGGER_MODE_KEY)
+ self.trigger_mode_chooser = common.DropDownController(self,
'Mode', TRIGGER_MODES, parent.ext_controller, parent.trigger_mode_key)
control_box.Add(self.trigger_mode_chooser, 0, wx.EXPAND)
#trigger level
self.trigger_level_chooser = common.DropDownController(self,
'Level', TRIGGER_LEVELS, parent, TRIGGER_LEVEL_KEY)
- parent.subscribe(TRIGGER_MODE_KEY, lambda x:
self.trigger_level_chooser.Disable(x==gr.gr_TRIG_NONE))
+ parent.subscribe(parent.trigger_mode_key, lambda x:
self.trigger_level_chooser.Disable(x==gr.gr_TRIG_FREE))
control_box.Add(self.trigger_level_chooser, 0, wx.EXPAND)
#trigger channel
choices = [('Ch%d'%(i+1), i) for i in range(parent.num_inputs)]
- self.trigger_channel_chooser = common.DropDownController(self,
'Channel', choices, parent, TRIGGER_CHANNEL_KEY)
- parent.subscribe(TRIGGER_MODE_KEY, lambda x:
self.trigger_channel_chooser.Disable(x==gr.gr_TRIG_NONE))
+ self.trigger_channel_chooser = common.DropDownController(self,
'Channel', choices, parent.ext_controller, parent.trigger_channel_key)
+ parent.subscribe(parent.trigger_mode_key, lambda x:
self.trigger_channel_chooser.Disable(x==gr.gr_TRIG_FREE))
control_box.Add(self.trigger_channel_chooser, 0, wx.EXPAND)
#axes options
SPACING = 15
@@ -262,9 +262,10 @@
v_scale,
ac_couple,
xy_mode,
- scope_trigger_level_key,
- scope_trigger_mode_key,
- scope_trigger_channel_key,
+ trigger_level_key,
+ trigger_mode_key,
+ trigger_channel_key,
+ decimation_key,
msg_key,
):
pubsub.pubsub.__init__(self)
@@ -280,9 +281,10 @@
if v_scale is None: v_scale = 1
self.frame_rate_ts = 0
#scope keys
- self.scope_trigger_level_key = scope_trigger_level_key
- self.scope_trigger_mode_key = scope_trigger_mode_key
- self.scope_trigger_channel_key = scope_trigger_channel_key
+ self.trigger_level_key = trigger_level_key
+ self.trigger_mode_key = trigger_mode_key
+ self.trigger_channel_key = trigger_channel_key
+ self.decimation_key = decimation_key
#init panel and plot
wx.Panel.__init__(self, parent, -1, style=wx.SIMPLE_BORDER)
self.plotter = plotter.channel_plotter(self)
@@ -313,10 +315,14 @@
self._register_set_prop(self, SCOPE_X_CHANNEL_KEY, 0)
self._register_set_prop(self, SCOPE_Y_CHANNEL_KEY, num_inputs-1)
self._register_set_prop(self, FRAME_RATE_KEY, frame_rate)
- self._register_set_prop(self, TRIGGER_CHANNEL_KEY, 0)
- self._register_set_prop(self, TRIGGER_MODE_KEY, gr.gr_TRIG_AUTO)
+ #REMOVE self._register_set_prop(self, TRIGGER_CHANNEL_KEY, 0)
+ #REMOVE self._register_set_prop(self, TRIGGER_MODE_KEY,
gr.gr_TRIG_AUTO)
self._register_set_prop(self, TRIGGER_LEVEL_KEY, None)
self._register_set_prop(self, MARKER_KEY, DEFAULT_MARKER_TYPE)
+
+ self.ext_controller[self.trigger_channel_key] = 0
+ self.ext_controller[self.trigger_mode_key] = gr.gr_TRIG_AUTO
+
#register events
self.ext_controller.subscribe(msg_key, self.handle_msg)
for key in (
@@ -361,14 +367,14 @@
"""
if not self.sampleses: return
sampleses = self.sampleses
- #trigger level (must do before ac coupling)
- self.ext_controller[self.scope_trigger_channel_key] =
self[TRIGGER_CHANNEL_KEY]
- self.ext_controller[self.scope_trigger_mode_key] =
self[TRIGGER_MODE_KEY]
+ #REMOVE #trigger level (must do before ac coupling)
+ #REMOVE self.ext_controller[self.trigger_channel_key] =
self[TRIGGER_CHANNEL_KEY]
+ #REMOVE self.ext_controller[self.trigger_mode_key] =
self[TRIGGER_MODE_KEY]
trigger_level = self[TRIGGER_LEVEL_KEY]
- if trigger_level is None:
self.ext_controller[self.scope_trigger_level_key] = ''
+ if trigger_level is None:
self.ext_controller[self.trigger_level_key] = ''
else:
samples = sampleses[self[TRIGGER_CHANNEL_KEY]]
- self.ext_controller[self.scope_trigger_level_key] = \
+ self.ext_controller[self.trigger_level_key] = \
trigger_level*(numpy.max(samples)-numpy.min(samples))/2 + numpy.average(samples)
#ac coupling
if self[AC_COUPLE_KEY]:
@@ -420,19 +426,20 @@
y_off =
y_per_div*round((y_max+y_min)/2/y_per_div)
if y_off != self[Y_OFF_KEY]:
self.set_y_off(y_off)
self.autorange_ts = time.time()
- #plot each waveform
- for i, samples in enumerate(sampleses):
- #number of samples to scale to the screen
- num_samps =
int(self[T_PER_DIV_KEY]*self[T_DIVS_KEY]*self.ext_controller[self.sample_rate_key])
- #handle num samps out of bounds
- if num_samps > len(samples):
- self.set_t_per_div(
-
common.get_clean_decr(self[T_PER_DIV_KEY]))
- elif num_samps < 2:
- self.set_t_per_div(
-
common.get_clean_incr(self[T_PER_DIV_KEY]))
- num_samps = 0
- else:
+ #number of samples to scale to the screen
+ actual_rate =
self.ext_controller[self.sample_rate_key]/self.ext_controller[self.decimation_key]
+ time_span = self[T_PER_DIV_KEY]*self[T_DIVS_KEY]
+ num_samps = int(round(time_span*actual_rate))
+ #adjust the decim so that we use about half the samps
+ self.ext_controller[self.decimation_key] = int(round(
+
time_span*self.ext_controller[self.sample_rate_key]/(0.5*len(sampleses[0]))
+ )
+ )
+ #num samps too small, auto increment the time
+ if num_samps < 2:
self.set_t_per_div(common.get_clean_incr(self[T_PER_DIV_KEY]))
+ #num samps in bounds, plot each waveform
+ elif num_samps <= len(sampleses[0]):
+ for i, samples in enumerate(sampleses):
#plot samples
self.plotter.set_waveform(
channel='Ch%d'%(i+1),
Modified:
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scopesink_gl.py
===================================================================
---
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scopesink_gl.py
2009-02-19 07:32:42 UTC (rev 10467)
+++
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scopesink_gl.py
2009-02-19 22:49:49 UTC (rev 10468)
@@ -75,14 +75,17 @@
#controller
self.controller = pubsub()
self.controller.subscribe(SAMPLE_RATE_KEY,
scope.set_sample_rate)
- self.controller.subscribe(SAMPLE_RATE_KEY,
scope.set_update_rate)
self.controller.publish(SAMPLE_RATE_KEY, scope.sample_rate)
+ self.controller.subscribe(DECIMATION_KEY,
scope.set_decimation_count)
+ self.controller.publish(DECIMATION_KEY,
scope.get_decimation_count)
def set_trigger_level(level):
if level == '': scope.set_trigger_level_auto()
else: scope.set_trigger_level(level)
self.controller.subscribe(SCOPE_TRIGGER_LEVEL_KEY,
set_trigger_level)
self.controller.subscribe(SCOPE_TRIGGER_MODE_KEY,
scope.set_trigger_mode)
+ self.controller.publish(SCOPE_TRIGGER_MODE_KEY,
scope.get_trigger_mode)
self.controller.subscribe(SCOPE_TRIGGER_CHANNEL_KEY,
scope.set_trigger_channel)
+ self.controller.publish(SCOPE_TRIGGER_CHANNEL_KEY,
scope.set_trigger_channel)
#start input watcher
def setter(p, k, x): # lambdas can't have assignments :(
p[k] = x
@@ -100,9 +103,10 @@
v_scale=v_scale,
ac_couple=ac_couple,
xy_mode=xy_mode,
- scope_trigger_level_key=SCOPE_TRIGGER_LEVEL_KEY,
- scope_trigger_mode_key=SCOPE_TRIGGER_MODE_KEY,
- scope_trigger_channel_key=SCOPE_TRIGGER_CHANNEL_KEY,
+ trigger_level_key=SCOPE_TRIGGER_LEVEL_KEY,
+ trigger_mode_key=SCOPE_TRIGGER_MODE_KEY,
+ trigger_channel_key=SCOPE_TRIGGER_CHANNEL_KEY,
+ decimation_key=DECIMATION_KEY,
msg_key=MSG_KEY,
)
#register callbacks from window for external use
Modified:
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scopesink_nongl.py
===================================================================
---
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scopesink_nongl.py
2009-02-19 07:32:42 UTC (rev 10467)
+++
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scopesink_nongl.py
2009-02-19 22:49:49 UTC (rev 10468)
@@ -320,7 +320,7 @@
ctrlbox.Add (self.trig_chan_choice, 0, wx.ALIGN_CENTER)
self.trig_mode_choice = wx.Choice (self, 1005,
- choices = ['None', 'Auto', 'Pos',
'Neg'])
+ choices = ['Free', 'Auto', 'Pos',
'Neg'])
self.trig_mode_choice.SetSelection(1)
self.trig_mode_choice.SetToolTipString ("Select trigger slope or Auto
(untriggered roll)")
wx.EVT_CHOICE (self, 1005, self.trig_mode_choice_event)
@@ -439,8 +439,8 @@
sink.set_trigger_mode (gr.gr_TRIG_NEG_SLOPE)
elif s == 'Auto':
sink.set_trigger_mode (gr.gr_TRIG_AUTO)
- elif s == 'None':
- sink.set_trigger_mode (gr.gr_TRIG_NONE)
+ elif s == 'Free':
+ sink.set_trigger_mode (gr.gr_TRIG_FREE)
else:
assert 0, "Bad trig_mode_choice string"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r10468 - in gnuradio/branches/developers/jblum/gui_guts: gnuradio-core/src/lib/io gr-wxgui/src/python,
jblum <=