[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r10467 - in gnuradio/branches/developers/jblum/gui_gut
From: |
jblum |
Subject: |
[Commit-gnuradio] r10467 - in gnuradio/branches/developers/jblum/gui_guts: gnuradio-core/src/lib/io gr-wxgui/src/python gr-wxgui/src/python/plotter |
Date: |
Thu, 19 Feb 2009 00:32:43 -0700 (MST) |
Author: jblum
Date: 2009-02-19 00:32:42 -0700 (Thu, 19 Feb 2009)
New Revision: 10467
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_sink.i
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/plotter/channel_plotter.py
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:
Pass the trigger offset to the scope gui.
Backwards compadible with non gl scope.
Added trigger type none, which is the old auto.
Auto now does pos trigger, perhaps auto can have a future automatic logic.
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 03:12:42 UTC (rev 10466)
+++
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_guts.cc
2009-02-19 07:32:42 UTC (rev 10467)
@@ -119,12 +119,10 @@
break;
case LOOK_FOR_TRIGGER:
- if (found_trigger ()){
- enter_post_trigger ();
- }else if (d_pre_trigger_count > OUTPUT_RECORD_SIZE/2){
- enter_post_trigger (); //too long without a trigger, force post 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)
+ enter_post_trigger ();
break;
case POST_TRIGGER:
@@ -165,6 +163,9 @@
{
d_state = POST_TRIGGER;
d_post_trigger_count = d_post_trigger_count_init;
+ //ensure that the trigger offset is no more than than half a sample
+ if (d_trigger_off > .5) d_trigger_off -= 1;
+ else d_post_trigger_count--;
}
// ----------------------------------------------------------------
@@ -173,18 +174,17 @@
bool
gr_oscope_guts::found_trigger ()
{
- if (d_obi == 0) return false;
-
- float prev_sample = d_buffer[d_trigger_channel][d_obi-1];
+ float prev_sample = d_buffer[d_trigger_channel][decr_bi(d_obi)];
float new_sample = d_buffer[d_trigger_channel][d_obi];
bool trig;
switch (d_trigger_mode){
- case gr_TRIG_AUTO: // always trigger
+ case gr_TRIG_NONE:
d_trigger_off = 0;
return true;
-
+
+ case gr_TRIG_AUTO: //not really automatic, just do pos slope
case gr_TRIG_POS_SLOPE:
trig = prev_sample < d_trigger_level && new_sample >= d_trigger_level;
break;
@@ -212,31 +212,29 @@
void
gr_oscope_guts::write_output_records ()
{
- // if the output queue if full, drop the data on the ground.
+ // if the output queue if full, drop the data like its hot.
if (d_msgq->full_p())
return;
-
- // Build a message to hold the output records
+ // Build a message to hold the output records
gr_message_sptr msg =
gr_make_message(0, // msg type
d_nchannels, // arg1 for
other side
- (OUTPUT_RECORD_SIZE-1), // arg2 for
other side
- d_nchannels * (OUTPUT_RECORD_SIZE-1) * sizeof(float)); // sizeof
payload
+ OUTPUT_RECORD_SIZE, // arg2 for
other side
+ ((d_nchannels * OUTPUT_RECORD_SIZE) + 1) * sizeof(float)); //
sizeof payload
float *out = (float *)msg->msg(); // get pointer to raw message buffer
- float prev_sample, curr_sample;
for (int ch = 0; ch < d_nchannels; ch++){
// note that d_obi + 1 points at the oldest sample in the buffer
- prev_sample = d_buffer[ch][wrap_bi(d_obi + 1)];
for (int i = 0; i < OUTPUT_RECORD_SIZE; i++){
- curr_sample = d_buffer[ch][wrap_bi(d_obi + 2 + i)];
- out[i] = (curr_sample - prev_sample)*d_trigger_off + prev_sample;
//perform interpolation
- prev_sample = curr_sample;
+ out[i] = d_buffer[ch][wrap_bi(d_obi + 1 + i)];
}
- out += (OUTPUT_RECORD_SIZE-1);
+ out += OUTPUT_RECORD_SIZE;
}
-
+ //Set the last sample as the trigger offset:
+ // The non gl scope sink will not look at this last sample.
+ // The gl scope sink will use this last sample as an offset.
+ out[0] = d_trigger_off;
d_msgq->handle(msg); // send the msg
}
@@ -292,6 +290,7 @@
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 ();
Modified:
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink.i
===================================================================
---
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink.i
2009-02-19 03:12:42 UTC (rev 10466)
+++
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink.i
2009-02-19 07:32:42 UTC (rev 10467)
@@ -20,11 +20,7 @@
* Boston, MA 02110-1301, USA.
*/
-enum gr_trigger_mode {
- gr_TRIG_AUTO, // auto trigger (on anything)
- gr_TRIG_POS_SLOPE, // trigger on positive slope across trigger
level
- gr_TRIG_NEG_SLOPE // trigger on negative slope across trigger
level
-};
+%include gr_trigger_mode.h
// GR_SWIG_BLOCK_MAGIC(gr,oscope_sink_x)
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 03:12:42 UTC (rev 10466)
+++
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_trigger_mode.h
2009-02-19 07:32:42 UTC (rev 10467)
@@ -24,7 +24,8 @@
#define INCLUDED_GR_TRIGGER_MODE_H
enum gr_trigger_mode {
- gr_TRIG_AUTO, // auto trigger (on anything)
+ gr_TRIG_NONE, // no triggering
+ gr_TRIG_AUTO, // auto trigger
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/plotter/channel_plotter.py
===================================================================
---
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/plotter/channel_plotter.py
2009-02-19 03:12:42 UTC (rev 10466)
+++
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/plotter/channel_plotter.py
2009-02-19 07:32:42 UTC (rev 10467)
@@ -34,6 +34,7 @@
SAMPLES_KEY = 'samples'
COLOR_SPEC_KEY = 'color_spec'
MARKERY_KEY = 'marker'
+TRIG_OFF_KEY = 'trig_off'
##################################################
# Channel Plotter for X Y Waveforms
@@ -121,7 +122,7 @@
x_scale, x_trans = 1.0/(self.x_max-self.x_min),
-self.x_min
points = zip(*samples)
else:
- x_scale, x_trans = 1.0/(num_samps-1), 0
+ x_scale, x_trans = 1.0/(num_samps-1),
-self._channels[channel][TRIG_OFF_KEY]
points = zip(numpy.arange(0, num_samps),
samples)
glScalef(x_scale, -1.0/(self.y_max-self.y_min), 1)
glTranslatef(x_trans, -self.y_min, 0)
@@ -188,13 +189,14 @@
txt.draw_text(wx.Point(x_off - w, self.padding_top/2 -
h/2))
x_off -= w + 4*LEGEND_BOX_PADDING
- def set_waveform(self, channel, samples, color_spec, marker=None):
+ def set_waveform(self, channel, samples, color_spec, marker=None,
trig_off=0):
"""
Set the waveform for a given channel.
@param channel the channel key
@param samples the waveform samples
@param color_spec the 3-tuple for line color
@param marker None for line
+ @param trig_off fraction of sample for trigger offset
"""
self.lock()
if channel not in self._channels.keys(): self.changed(True)
@@ -202,6 +204,7 @@
SAMPLES_KEY: samples,
COLOR_SPEC_KEY: color_spec,
MARKERY_KEY: marker,
+ TRIG_OFF_KEY: trig_off,
}
self.unlock()
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 03:12:42 UTC (rev 10466)
+++
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scope_window.py
2009-02-19 07:32:42 UTC (rev 10467)
@@ -38,7 +38,8 @@
DEFAULT_WIN_SIZE = (600, 300)
DEFAULT_V_SCALE = 1000
TRIGGER_MODES = (
- ('Off', gr.gr_TRIG_AUTO),
+ ('Off', gr.gr_TRIG_NONE),
+ ('Auto', gr.gr_TRIG_AUTO),
('Neg', gr.gr_TRIG_NEG_SLOPE),
('Pos', gr.gr_TRIG_POS_SLOPE),
)
@@ -91,12 +92,12 @@
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==0))
+ parent.subscribe(TRIGGER_MODE_KEY, lambda x:
self.trigger_level_chooser.Disable(x==gr.gr_TRIG_NONE))
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==0))
+ parent.subscribe(TRIGGER_MODE_KEY, lambda x:
self.trigger_channel_chooser.Disable(x==gr.gr_TRIG_NONE))
control_box.Add(self.trigger_channel_chooser, 0, wx.EXPAND)
#axes options
SPACING = 15
@@ -313,7 +314,7 @@
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, 1)
+ 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)
#register events
@@ -344,6 +345,9 @@
if time.time() - self.frame_rate_ts < 1.0/self[FRAME_RATE_KEY]:
return
#convert to floating point numbers
samples = numpy.fromstring(msg, numpy.float32)
+ #extract the trigger offset
+ self.trigger_offset = samples[-1]
+ samples = samples[:-1]
samps_per_ch = len(samples)/self.num_inputs
self.sampleses = [samples[samps_per_ch*i:samps_per_ch*(i+1)]
for i in range(self.num_inputs)]
#handle samples
@@ -435,6 +439,7 @@
samples=samples[:num_samps],
color_spec=CHANNEL_COLOR_SPECS[i],
marker=self[MARKER_KEY],
+ trig_off=self.trigger_offset,
)
#turn XY channel off
self.plotter.set_waveform(
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 03:12:42 UTC (rev 10466)
+++
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scopesink_gl.py
2009-02-19 07:32:42 UTC (rev 10467)
@@ -75,6 +75,7 @@
#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)
def set_trigger_level(level):
if level == '': scope.set_trigger_level_auto()
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 03:12:42 UTC (rev 10466)
+++
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scopesink_nongl.py
2009-02-19 07:32:42 UTC (rev 10467)
@@ -320,7 +320,8 @@
ctrlbox.Add (self.trig_chan_choice, 0, wx.ALIGN_CENTER)
self.trig_mode_choice = wx.Choice (self, 1005,
- choices = ['Auto', 'Pos', 'Neg'])
+ choices = ['None', '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)
ctrlbox.Add (self.trig_mode_choice, 0, wx.ALIGN_CENTER)
@@ -438,6 +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)
else:
assert 0, "Bad trig_mode_choice string"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r10467 - in gnuradio/branches/developers/jblum/gui_guts: gnuradio-core/src/lib/io gr-wxgui/src/python gr-wxgui/src/python/plotter,
jblum <=