[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r9171 - gnuradio/branches/features/experimental-gui
From: |
jblum |
Subject: |
[Commit-gnuradio] r9171 - gnuradio/branches/features/experimental-gui |
Date: |
Mon, 4 Aug 2008 16:17:30 -0600 (MDT) |
Author: jblum
Date: 2008-08-04 16:17:29 -0600 (Mon, 04 Aug 2008)
New Revision: 9171
Added:
gnuradio/branches/features/experimental-gui/number_window.py
gnuradio/branches/features/experimental-gui/numbersink.py
Modified:
gnuradio/branches/features/experimental-gui/const_window.py
gnuradio/branches/features/experimental-gui/fft_window.py
gnuradio/branches/features/experimental-gui/scope_window.py
gnuradio/branches/features/experimental-gui/waterfall_window.py
Log:
a window is a pubsub
Modified: gnuradio/branches/features/experimental-gui/const_window.py
===================================================================
--- gnuradio/branches/features/experimental-gui/const_window.py 2008-08-04
21:11:06 UTC (rev 9170)
+++ gnuradio/branches/features/experimental-gui/const_window.py 2008-08-04
22:17:29 UTC (rev 9171)
@@ -72,7 +72,7 @@
control_box.Add(common.LabelText(self, 'Options'), 0,
wx.ALIGN_CENTER)
#marker
control_box.AddStretchSpacer()
- self.marker_chooser = common.DropDownController(self, 'Marker',
MARKER_TYPES, parent.controller, MARKER_KEY)
+ self.marker_chooser = common.DropDownController(self, 'Marker',
MARKER_TYPES, parent, MARKER_KEY)
control_box.Add(self.marker_chooser, 0, wx.EXPAND)
#alpha
control_box.AddStretchSpacer()
@@ -92,7 +92,7 @@
control_box.Add(self.gain_mu_slider, 0, wx.EXPAND)
#run/stop
control_box.AddStretchSpacer()
- self.run_button = common.RunStopButtonController(self,
parent.controller, RUNNING_KEY)
+ self.run_button = common.RunStopButtonController(self, parent,
RUNNING_KEY)
control_box.Add(self.run_button, 0, wx.EXPAND)
#set sizer
self.SetSizerAndFit(control_box)
@@ -100,7 +100,7 @@
##################################################
# Constellation window with plotter and control panel
##################################################
-class const_window(wx.Panel, common.prop_setter):
+class const_window(wx.Panel, pubsub.pubsub, common.prop_setter):
def __init__(
self,
parent,
@@ -113,7 +113,7 @@
gain_mu_key,
gain_omega_key,
):
- self.controller = pubsub.pubsub()
+ pubsub.pubsub.__init__(self)
#setup
self.ext_controller = controller
self.alpha_key = alpha_key
@@ -141,15 +141,15 @@
#initial setup
self.ext_controller[self.alpha_key] =
self.ext_controller[self.alpha_key]
self.ext_controller[self.gain_mu_key] =
self.ext_controller[self.gain_mu_key]
- self._register_set_prop(self.controller, RUNNING_KEY, True)
- self._register_set_prop(self.controller, X_DIVS_KEY, 8)
- self._register_set_prop(self.controller, Y_DIVS_KEY, 8)
- self._register_set_prop(self.controller, MARKER_KEY,
DEFAULT_MARKER_TYPE)
+ self._register_set_prop(self, RUNNING_KEY, True)
+ self._register_set_prop(self, X_DIVS_KEY, 8)
+ self._register_set_prop(self, Y_DIVS_KEY, 8)
+ self._register_set_prop(self, MARKER_KEY, DEFAULT_MARKER_TYPE)
#register events
self.ext_controller.subscribe(msg_key, self.handle_msg)
for key in (
X_DIVS_KEY, Y_DIVS_KEY,
- ): self.controller.subscribe(key, self.update_grid)
+ ): self.subscribe(key, self.update_grid)
#initial update
self.update_grid()
@@ -158,7 +158,7 @@
Plot the samples onto the complex grid.
@param msg the array of complex samples
"""
- if not self.controller[RUNNING_KEY]: return
+ if not self[RUNNING_KEY]: return
#convert to complex floating point numbers
samples = numpy.fromstring(msg, numpy.complex64)
real = numpy.real(samples)
@@ -168,15 +168,15 @@
channel=0,
samples=(real, imag),
color_spec=CONST_PLOT_COLOR_SPEC,
- marker=self.controller[MARKER_KEY],
+ marker=self[MARKER_KEY],
)
#update the plotter
self.plotter.update()
def update_grid(self):
#grid parameters
- x_divs = self.controller[X_DIVS_KEY]
- y_divs = self.controller[Y_DIVS_KEY]
+ x_divs = self[X_DIVS_KEY]
+ y_divs = self[Y_DIVS_KEY]
#update the x axis
x_max = 1.2
self.plotter.set_x_grid(-x_max, x_max,
common.get_clean_num(2.0*x_max/x_divs))
Modified: gnuradio/branches/features/experimental-gui/fft_window.py
===================================================================
--- gnuradio/branches/features/experimental-gui/fft_window.py 2008-08-04
21:11:06 UTC (rev 9170)
+++ gnuradio/branches/features/experimental-gui/fft_window.py 2008-08-04
22:17:29 UTC (rev 9171)
@@ -69,7 +69,7 @@
control_box.Add(common.LabelText(self, 'Options'), 0,
wx.ALIGN_CENTER)
self.average_check_box = common.CheckBoxController(self,
'Average', parent.ext_controller, parent.average_key)
control_box.Add(self.average_check_box, 0, wx.EXPAND)
- self.peak_hold_check_box = common.CheckBoxController(self,
'Peak Hold', parent.controller, PEAK_HOLD_KEY)
+ self.peak_hold_check_box = common.CheckBoxController(self,
'Peak Hold', parent, PEAK_HOLD_KEY)
control_box.Add(self.peak_hold_check_box, 0, wx.EXPAND)
control_box.AddSpacer(2)
self.avg_alpha_slider = common.LogSliderController(
@@ -89,7 +89,7 @@
radio_button.Bind(wx.EVT_RADIOBUTTON,
self._on_y_per_div)
self.radio_buttons.append(radio_button)
radio_box.Add(radio_button, 0, wx.ALIGN_LEFT)
- parent.controller.subscribe(Y_PER_DIV_KEY,
self._on_set_y_per_div)
+ parent.subscribe(Y_PER_DIV_KEY, self._on_set_y_per_div)
control_box.Add(radio_box, 0, wx.EXPAND)
#ref lvl buttons
control_box.AddStretchSpacer()
@@ -99,7 +99,7 @@
control_box.Add(self._ref_lvl_buttons, 0, wx.ALIGN_CENTER)
#run/stop
control_box.AddStretchSpacer()
- self.run_button = common.RunStopButtonController(self,
parent.controller, RUNNING_KEY)
+ self.run_button = common.RunStopButtonController(self, parent,
RUNNING_KEY)
control_box.Add(self.run_button, 0, wx.EXPAND)
#set sizer
self.SetSizerAndFit(control_box)
@@ -115,18 +115,18 @@
def _on_y_per_div(self, event):
selected_radio_button = filter(lambda rb: rb.GetValue(),
self.radio_buttons)[0]
index = self.radio_buttons.index(selected_radio_button)
- self.parent.controller[Y_PER_DIV_KEY] = DIV_LEVELS[index]
+ self.parent[Y_PER_DIV_KEY] = DIV_LEVELS[index]
def _on_incr_ref_level(self, event):
self.parent.set_ref_level(
- self.parent.controller[REF_LEVEL_KEY] +
self.parent.controller[Y_PER_DIV_KEY])
+ self.parent[REF_LEVEL_KEY] + self.parent[Y_PER_DIV_KEY])
def _on_decr_ref_level(self, event):
self.parent.set_ref_level(
- self.parent.controller[REF_LEVEL_KEY] -
self.parent.controller[Y_PER_DIV_KEY])
+ self.parent[REF_LEVEL_KEY] - self.parent[Y_PER_DIV_KEY])
##################################################
# FFT window with plotter and control panel
##################################################
-class fft_window(wx.Panel, common.prop_setter):
+class fft_window(wx.Panel, pubsub.pubsub, common.prop_setter):
def __init__(
self,
parent,
@@ -145,7 +145,7 @@
peak_hold,
msg_key,
):
- self.controller = pubsub.pubsub()
+ pubsub.pubsub.__init__(self)
#ensure y_per_div
if y_per_div not in DIV_LEVELS: y_per_div = DIV_LEVELS[0]
#setup
@@ -170,13 +170,13 @@
#initial setup
self.ext_controller[self.average_key] =
self.ext_controller[self.average_key]
self.ext_controller[self.avg_alpha_key] =
self.ext_controller[self.avg_alpha_key]
- self._register_set_prop(self.controller, PEAK_HOLD_KEY,
peak_hold)
- self._register_set_prop(self.controller, Y_PER_DIV_KEY,
y_per_div)
- self._register_set_prop(self.controller, Y_DIVS_KEY, y_divs)
- self._register_set_prop(self.controller, X_DIVS_KEY, 8)
#approximate
- self._register_set_prop(self.controller, REF_LEVEL_KEY,
ref_level)
- self._register_set_prop(self.controller, BASEBAND_FREQ_KEY,
baseband_freq)
- self._register_set_prop(self.controller, RUNNING_KEY, True)
+ self._register_set_prop(self, PEAK_HOLD_KEY, peak_hold)
+ self._register_set_prop(self, Y_PER_DIV_KEY, y_per_div)
+ self._register_set_prop(self, Y_DIVS_KEY, y_divs)
+ self._register_set_prop(self, X_DIVS_KEY, 8) #approximate
+ self._register_set_prop(self, REF_LEVEL_KEY, ref_level)
+ self._register_set_prop(self, BASEBAND_FREQ_KEY, baseband_freq)
+ self._register_set_prop(self, RUNNING_KEY, True)
#register events
self.ext_controller.subscribe(msg_key, self.handle_msg)
self.ext_controller.subscribe(self.sample_rate_key,
self.update_grid)
@@ -184,7 +184,7 @@
BASEBAND_FREQ_KEY,
Y_PER_DIV_KEY, X_DIVS_KEY,
Y_DIVS_KEY, REF_LEVEL_KEY,
- ): self.controller.subscribe(key, self.update_grid)
+ ): self.subscribe(key, self.update_grid)
#initial update
self.update_grid()
@@ -197,7 +197,7 @@
If peak hold is enabled, plot peak vals as channel 2.
@param msg the fft array as a character array
"""
- if not self.controller[RUNNING_KEY]: return
+ if not self[RUNNING_KEY]: return
#convert to floating point numbers
samples = numpy.fromstring(msg, numpy.float32)[:self.fft_size]
#only take first frame
num_samps = len(samples)
@@ -205,7 +205,7 @@
if self.real: samples = samples[:num_samps/2]
else: samples = numpy.concatenate((samples[num_samps/2+1:],
samples[:num_samps/2]))
#peak hold calculation
- if self.controller[PEAK_HOLD_KEY]:
+ if self[PEAK_HOLD_KEY]:
if len(self.peak_vals) != len(samples): self.peak_vals
= samples
self.peak_vals = numpy.maximum(samples, self.peak_vals)
else: self.peak_vals = NO_PEAK_VALS
@@ -234,11 +234,11 @@
"""
#grid parameters
sample_rate = self.ext_controller[self.sample_rate_key]
- baseband_freq = self.controller[BASEBAND_FREQ_KEY]
- y_per_div = self.controller[Y_PER_DIV_KEY]
- y_divs = self.controller[Y_DIVS_KEY]
- x_divs = self.controller[X_DIVS_KEY]
- ref_level = self.controller[REF_LEVEL_KEY]
+ baseband_freq = self[BASEBAND_FREQ_KEY]
+ y_per_div = self[Y_PER_DIV_KEY]
+ y_divs = self[Y_DIVS_KEY]
+ x_divs = self[X_DIVS_KEY]
+ ref_level = self[REF_LEVEL_KEY]
#determine best fitting x_per_div
if self.real: x_width = sample_rate/2.0
else: x_width = sample_rate/1.0
Added: gnuradio/branches/features/experimental-gui/number_window.py
===================================================================
Added: gnuradio/branches/features/experimental-gui/numbersink.py
===================================================================
Modified: gnuradio/branches/features/experimental-gui/scope_window.py
===================================================================
--- gnuradio/branches/features/experimental-gui/scope_window.py 2008-08-04
21:11:06 UTC (rev 9170)
+++ gnuradio/branches/features/experimental-gui/scope_window.py 2008-08-04
22:17:29 UTC (rev 9171)
@@ -91,16 +91,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.controller, TRIGGER_MODE_KEY)
+ self.trigger_mode_chooser = common.DropDownController(self,
'Mode', TRIGGER_MODES, 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.controller, TRIGGER_LEVEL_KEY)
- parent.controller.subscribe(TRIGGER_MODE_KEY, lambda x:
self.trigger_level_chooser.Disable(x==0))
+ 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))
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.controller, TRIGGER_CHANNEL_KEY)
- parent.controller.subscribe(TRIGGER_MODE_KEY, lambda x:
self.trigger_channel_chooser.Disable(x==0))
+ 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))
control_box.Add(self.trigger_channel_chooser, 0, wx.EXPAND)
#axes options
SPACING = 15
@@ -118,7 +118,7 @@
control_box.Add(hbox, 0, wx.EXPAND)
hbox.Add(wx.StaticText(self, -1, ' Units/Div '), 1,
wx.ALIGN_CENTER_VERTICAL)
self.y_buttons = common.IncrDecrButtons(self,
self._on_incr_y_divs, self._on_decr_y_divs)
- parent.controller.subscribe(AUTORANGE_KEY,
self.y_buttons.Disable)
+ parent.subscribe(AUTORANGE_KEY, self.y_buttons.Disable)
hbox.Add(self.y_buttons, 0, wx.ALIGN_CENTER_VERTICAL)
hbox.AddSpacer(SPACING)
#y axis ref lvl
@@ -126,21 +126,21 @@
control_box.Add(hbox, 0, wx.EXPAND)
hbox.Add(wx.StaticText(self, -1, ' Y Offset '), 1,
wx.ALIGN_CENTER_VERTICAL)
self.y_off_buttons = common.IncrDecrButtons(self,
self._on_incr_y_off, self._on_decr_y_off)
- parent.controller.subscribe(AUTORANGE_KEY,
self.y_off_buttons.Disable)
+ parent.subscribe(AUTORANGE_KEY, self.y_off_buttons.Disable)
hbox.Add(self.y_off_buttons, 0, wx.ALIGN_CENTER_VERTICAL)
hbox.AddSpacer(SPACING)
#misc options
control_box.AddStretchSpacer()
control_box.Add(common.LabelText(self, 'Range Options'), 0,
wx.ALIGN_CENTER)
#ac couple check box
- self.ac_couple_check_box = common.CheckBoxController(self, 'AC
Couple', parent.controller, AC_COUPLE_KEY)
+ self.ac_couple_check_box = common.CheckBoxController(self, 'AC
Couple', parent, AC_COUPLE_KEY)
control_box.Add(self.ac_couple_check_box, 0, wx.ALIGN_LEFT)
#autorange check box
- self.autorange_check_box = common.CheckBoxController(self,
'Autorange', parent.controller, AUTORANGE_KEY)
+ self.autorange_check_box = common.CheckBoxController(self,
'Autorange', parent, AUTORANGE_KEY)
control_box.Add(self.autorange_check_box, 0, wx.ALIGN_LEFT)
#run/stop
control_box.AddStretchSpacer()
- self.run_button = common.RunStopButtonController(self,
parent.controller, RUNNING_KEY)
+ self.run_button = common.RunStopButtonController(self, parent,
RUNNING_KEY)
control_box.Add(self.run_button, 0, wx.EXPAND)
#set sizer
self.SetSizerAndFit(control_box)
@@ -150,27 +150,27 @@
##################################################
def _on_incr_x_divs(self, event):
self.parent.set_x_per_div(
-
common.get_clean_incr(self.parent.controller[X_PER_DIV_KEY]))
+ common.get_clean_incr(self.parent[X_PER_DIV_KEY]))
def _on_decr_x_divs(self, event):
self.parent.set_x_per_div(
-
common.get_clean_decr(self.parent.controller[X_PER_DIV_KEY]))
+ common.get_clean_decr(self.parent[X_PER_DIV_KEY]))
def _on_incr_y_divs(self, event):
self.parent.set_y_per_div(
-
common.get_clean_incr(self.parent.controller[Y_PER_DIV_KEY]))
+ common.get_clean_incr(self.parent[Y_PER_DIV_KEY]))
def _on_decr_y_divs(self, event):
self.parent.set_y_per_div(
-
common.get_clean_decr(self.parent.controller[Y_PER_DIV_KEY]))
+ common.get_clean_decr(self.parent[Y_PER_DIV_KEY]))
def _on_incr_y_off(self, event):
self.parent.set_y_off(
- self.parent.controller[Y_OFF_KEY] +
self.parent.controller[Y_PER_DIV_KEY])
+ self.parent[Y_OFF_KEY] + self.parent[Y_PER_DIV_KEY])
def _on_decr_y_off(self, event):
self.parent.set_y_off(
- self.parent.controller[Y_OFF_KEY] -
self.parent.controller[Y_PER_DIV_KEY])
+ self.parent[Y_OFF_KEY] - self.parent[Y_PER_DIV_KEY])
##################################################
# Scope window with plotter and control panel
##################################################
-class scope_window(wx.Panel, common.prop_setter):
+class scope_window(wx.Panel, pubsub.pubsub, common.prop_setter):
def __init__(
self,
parent,
@@ -189,7 +189,7 @@
scope_num_samples_key,
msg_key,
):
- self.controller = pubsub.pubsub()
+ pubsub.pubsub.__init__(self)
#check num inputs
assert num_inputs <= len(CHANNEL_COLOR_SPECS)
#setup
@@ -219,28 +219,28 @@
main_box.Add(self.control_panel, 0, wx.EXPAND)
self.SetSizerAndFit(main_box)
#initial setup
- self._register_set_prop(self.controller, RUNNING_KEY, True)
- self._register_set_prop(self.controller, AC_COUPLE_KEY,
ac_couple)
- self._register_set_prop(self.controller, AUTORANGE_KEY,
autorange)
- self._register_set_prop(self.controller, X_PER_DIV_KEY,
x_per_div)
- self._register_set_prop(self.controller, Y_PER_DIV_KEY,
y_per_div)
- self._register_set_prop(self.controller, X_OFF_KEY, 0)
- self._register_set_prop(self.controller, Y_OFF_KEY, 0)
- self._register_set_prop(self.controller, X_DIVS_KEY, 8)
- self._register_set_prop(self.controller, Y_DIVS_KEY, 8)
- self._register_set_prop(self.controller, FRAME_RATE_KEY,
frame_rate)
- self._register_set_prop(self.controller, TRIGGER_CHANNEL_KEY, 1)
- self._register_set_prop(self.controller, TRIGGER_MODE_KEY, 1)
- self._register_set_prop(self.controller, TRIGGER_LEVEL_KEY,
None)
+ self._register_set_prop(self, RUNNING_KEY, True)
+ self._register_set_prop(self, AC_COUPLE_KEY, ac_couple)
+ self._register_set_prop(self, AUTORANGE_KEY, autorange)
+ self._register_set_prop(self, X_PER_DIV_KEY, x_per_div)
+ self._register_set_prop(self, Y_PER_DIV_KEY, y_per_div)
+ self._register_set_prop(self, X_OFF_KEY, 0)
+ self._register_set_prop(self, Y_OFF_KEY, 0)
+ self._register_set_prop(self, X_DIVS_KEY, 8)
+ self._register_set_prop(self, Y_DIVS_KEY, 8)
+ self._register_set_prop(self, FRAME_RATE_KEY, frame_rate)
+ self._register_set_prop(self, TRIGGER_CHANNEL_KEY, 1)
+ self._register_set_prop(self, TRIGGER_MODE_KEY, 1)
+ self._register_set_prop(self, TRIGGER_LEVEL_KEY, None)
#register events
self.ext_controller.subscribe(msg_key, self.handle_msg)
self.ext_controller.subscribe(sample_rate_key,
self.update_decim)
- self.controller.subscribe(FRAME_RATE_KEY, self.update_decim)
+ self.subscribe(FRAME_RATE_KEY, self.update_decim)
for key in (
X_PER_DIV_KEY, Y_PER_DIV_KEY,
X_OFF_KEY, Y_OFF_KEY,
X_DIVS_KEY, Y_DIVS_KEY,
- ): self.controller.subscribe(key, self.update_grid)
+ ): self.subscribe(key, self.update_grid)
#initial update, dont do this here, wait for handle_msg #HACK
#self.update_grid()
#self.update_decim()
@@ -252,7 +252,7 @@
Each samples array gets its own channel.
@param msg the time domain data as a character array
"""
- if not self.controller[RUNNING_KEY]: return
+ if not self[RUNNING_KEY]: return
#convert to floating point numbers
samples = numpy.fromstring(msg, numpy.float32)
samps_per_ch = len(samples)/self.num_inputs
@@ -263,33 +263,33 @@
self.update_decim()
if self.frame_counter == 0: #decimate
#trigger level (must do before ac coupling)
- self.ext_controller[self.scope_trigger_channel_key] =
self.controller[TRIGGER_CHANNEL_KEY]
- self.ext_controller[self.scope_trigger_mode_key] =
self.controller[TRIGGER_MODE_KEY]
- trigger_level = self.controller[TRIGGER_LEVEL_KEY]
+ self.ext_controller[self.scope_trigger_channel_key] =
self[TRIGGER_CHANNEL_KEY]
+ self.ext_controller[self.scope_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] = ''
else:
- samples =
sampleses[self.controller[TRIGGER_CHANNEL_KEY]]
+ samples = sampleses[self[TRIGGER_CHANNEL_KEY]]
self.ext_controller[self.scope_trigger_level_key] = \
trigger_level*(numpy.max(samples)-numpy.min(samples))/2 + numpy.average(samples)
#ac coupling
- if self.controller[AC_COUPLE_KEY]:
+ if self[AC_COUPLE_KEY]:
sampleses = [samples - numpy.average(samples)
for samples in sampleses]
#autorange
- if self.controller[AUTORANGE_KEY] and time.time() -
self.autorange_ts > AUTORANGE_UPDATE_RATE:
+ if self[AUTORANGE_KEY] and time.time() -
self.autorange_ts > AUTORANGE_UPDATE_RATE:
bounds = [common.get_min_max(samples) for
samples in sampleses]
y_min = min(*[bound[0] for bound in bounds])
y_max = max(*[bound[1] for bound in bounds])
#adjust the y per div
- y_per_div =
common.get_clean_num((y_max-y_min)/self.controller[Y_DIVS_KEY])
- if y_per_div != self.controller[Y_PER_DIV_KEY]:
self.set_y_per_div(y_per_div)
+ y_per_div =
common.get_clean_num((y_max-y_min)/self[Y_DIVS_KEY])
+ if y_per_div != self[Y_PER_DIV_KEY]:
self.set_y_per_div(y_per_div)
#adjust the y offset
y_off =
y_per_div*round((y_max+y_min)/2/y_per_div)
- if y_off != self.controller[Y_OFF_KEY]:
self.set_y_off(y_off)
+ 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.controller[X_PER_DIV_KEY]*self.controller[X_DIVS_KEY]*self.ext_controller[self.sample_rate_key])
+ num_samps =
int(self[X_PER_DIV_KEY]*self[X_DIVS_KEY]*self.ext_controller[self.sample_rate_key])
#handle num samps out of bounds
while num_samps > len(samples): samples =
numpy.concatenate((samples, samples))
if num_samps < 2: num_samps = 0
@@ -307,17 +307,17 @@
"""!
Update the frame decimation when the frame rate or sample rate
changes.
"""
- decim =
self.ext_controller[self.sample_rate_key]/self.ext_controller[self.scope_num_samples_key]/self.controller[FRAME_RATE_KEY]
+ decim =
self.ext_controller[self.sample_rate_key]/self.ext_controller[self.scope_num_samples_key]/self[FRAME_RATE_KEY]
self.decim = max(1, int(decim))
def update_grid(self, *args):
#grid parameters
- x_per_div = self.controller[X_PER_DIV_KEY]
- y_per_div = self.controller[Y_PER_DIV_KEY]
- x_off = self.controller[X_OFF_KEY]
- y_off = self.controller[Y_OFF_KEY]
- x_divs = self.controller[X_DIVS_KEY]
- y_divs = self.controller[Y_DIVS_KEY]
+ x_per_div = self[X_PER_DIV_KEY]
+ y_per_div = self[Y_PER_DIV_KEY]
+ x_off = self[X_OFF_KEY]
+ y_off = self[Y_OFF_KEY]
+ x_divs = self[X_DIVS_KEY]
+ y_divs = self[Y_DIVS_KEY]
#update the x axis
exp = common.get_exp(x_per_div)
if exp > -2: x_units, scalar = 's', 1e0
Modified: gnuradio/branches/features/experimental-gui/waterfall_window.py
===================================================================
--- gnuradio/branches/features/experimental-gui/waterfall_window.py
2008-08-04 21:11:06 UTC (rev 9170)
+++ gnuradio/branches/features/experimental-gui/waterfall_window.py
2008-08-04 22:17:29 UTC (rev 9171)
@@ -85,7 +85,7 @@
control_box.Add(self.avg_alpha_slider, 0, wx.EXPAND)
#color mode
control_box.AddStretchSpacer()
- self.color_mode_chooser = common.DropDownController(self,
'Color', COLOR_MODES, parent.controller, COLOR_MODE_KEY)
+ self.color_mode_chooser = common.DropDownController(self,
'Color', COLOR_MODES, parent, COLOR_MODE_KEY)
control_box.Add(self.color_mode_chooser, 0, wx.EXPAND)
#dyanmic range buttons
control_box.AddStretchSpacer()
@@ -107,7 +107,7 @@
control_box.Add(self._num_lines_buttons, 0, wx.ALIGN_CENTER)
#run/stop
control_box.AddStretchSpacer()
- self.run_button = common.RunStopButtonController(self,
parent.controller, RUNNING_KEY)
+ self.run_button = common.RunStopButtonController(self, parent,
RUNNING_KEY)
control_box.Add(self.run_button, 0, wx.EXPAND)
#set sizer
self.SetSizerAndFit(control_box)
@@ -117,27 +117,27 @@
##################################################
def _on_incr_dynamic_range(self, event):
self.parent.set_dynamic_range(common.get_clean_incr(
- min(self.parent.controller[DYNAMIC_RANGE_KEY],
MAX_DYNAMIC_RANGE)))
+ min(self.parent[DYNAMIC_RANGE_KEY], MAX_DYNAMIC_RANGE)))
def _on_decr_dynamic_range(self, event):
self.parent.set_dynamic_range(common.get_clean_decr(
- max(self.parent.controller[DYNAMIC_RANGE_KEY],
MIN_DYNAMIC_RANGE)))
+ max(self.parent[DYNAMIC_RANGE_KEY], MIN_DYNAMIC_RANGE)))
def _on_incr_ref_level(self, event):
self.parent.set_ref_level(
- self.parent.controller[REF_LEVEL_KEY] +
self.parent.controller[DYNAMIC_RANGE_KEY]/10)
+ self.parent[REF_LEVEL_KEY] +
self.parent[DYNAMIC_RANGE_KEY]/10)
def _on_decr_ref_level(self, event):
self.parent.set_ref_level(
- self.parent.controller[REF_LEVEL_KEY] -
self.parent.controller[DYNAMIC_RANGE_KEY]/10)
+ self.parent[REF_LEVEL_KEY] -
self.parent[DYNAMIC_RANGE_KEY]/10)
def _on_incr_num_lines(self, event):
self.parent.set_num_lines(
-
min(self.parent.controller[NUM_LINES_KEY]+self.parent.controller[NUM_LINES_KEY]/10,
MAX_NUM_LINES))
+
min(self.parent[NUM_LINES_KEY]+self.parent[NUM_LINES_KEY]/10, MAX_NUM_LINES))
def _on_decr_num_lines(self, event):
self.parent.set_num_lines(
-
max(self.parent.controller[NUM_LINES_KEY]-self.parent.controller[NUM_LINES_KEY]/10,
MIN_NUM_LINES))
+
max(self.parent[NUM_LINES_KEY]-self.parent[NUM_LINES_KEY]/10, MIN_NUM_LINES))
##################################################
# Waterfall window with plotter and control panel
##################################################
-class waterfall_window(wx.Panel, common.prop_setter):
+class waterfall_window(wx.Panel, pubsub.pubsub, common.prop_setter):
def __init__(
self,
parent,
@@ -155,7 +155,7 @@
avg_alpha_key,
msg_key,
):
- self.controller = pubsub.pubsub()
+ pubsub.pubsub.__init__(self)
#setup
self.ext_controller = controller
self.real = real
@@ -176,27 +176,27 @@
main_box.Add(self.control_panel, 0, wx.EXPAND)
self.SetSizerAndFit(main_box)
#plotter listeners
- self.controller.subscribe(COLOR_MODE_KEY,
self.plotter.set_color_mode)
- self.controller.subscribe(NUM_LINES_KEY,
self.plotter.set_num_lines)
+ self.subscribe(COLOR_MODE_KEY, self.plotter.set_color_mode)
+ self.subscribe(NUM_LINES_KEY, self.plotter.set_num_lines)
#initial setup
self.ext_controller[self.average_key] =
self.ext_controller[self.average_key]
self.ext_controller[self.avg_alpha_key] =
self.ext_controller[self.avg_alpha_key]
- self._register_set_prop(self.controller, DYNAMIC_RANGE_KEY,
dynamic_range)
- self._register_set_prop(self.controller, NUM_LINES_KEY, 256)
- self._register_set_prop(self.controller, Y_DIVS_KEY, 8)
- self._register_set_prop(self.controller, X_DIVS_KEY, 8)
#approximate
- self._register_set_prop(self.controller, REF_LEVEL_KEY,
ref_level)
- self._register_set_prop(self.controller, BASEBAND_FREQ_KEY,
baseband_freq)
- self._register_set_prop(self.controller, COLOR_MODE_KEY,
COLOR_MODES[0][1])
- self._register_set_prop(self.controller, RUNNING_KEY, True)
+ self._register_set_prop(self, DYNAMIC_RANGE_KEY, dynamic_range)
+ self._register_set_prop(self, NUM_LINES_KEY, 256)
+ self._register_set_prop(self, Y_DIVS_KEY, 8)
+ self._register_set_prop(self, X_DIVS_KEY, 8) #approximate
+ self._register_set_prop(self, REF_LEVEL_KEY, ref_level)
+ self._register_set_prop(self, BASEBAND_FREQ_KEY, baseband_freq)
+ self._register_set_prop(self, COLOR_MODE_KEY, COLOR_MODES[0][1])
+ self._register_set_prop(self, RUNNING_KEY, True)
#register events
self.ext_controller.subscribe(msg_key, self.handle_msg)
self.ext_controller.subscribe(self.sample_rate_key,
self.update_grid)
self.ext_controller.subscribe(self.frame_rate_key,
self.update_grid)
- self.controller.subscribe(BASEBAND_FREQ_KEY, self.update_grid)
- self.controller.subscribe(NUM_LINES_KEY, self.update_grid)
- self.controller.subscribe(Y_DIVS_KEY, self.update_grid)
- self.controller.subscribe(X_DIVS_KEY, self.update_grid)
+ self.subscribe(BASEBAND_FREQ_KEY, self.update_grid)
+ self.subscribe(NUM_LINES_KEY, self.update_grid)
+ self.subscribe(Y_DIVS_KEY, self.update_grid)
+ self.subscribe(X_DIVS_KEY, self.update_grid)
#initial update
self.update_grid()
@@ -208,7 +208,7 @@
Send the data to the plotter.
@param msg the fft array as a character array
"""
- if not self.controller[RUNNING_KEY]: return
+ if not self[RUNNING_KEY]: return
#convert to floating point numbers
samples = numpy.fromstring(msg, numpy.float32)[:self.fft_size]
#only take first frame
num_samps = len(samples)
@@ -218,8 +218,8 @@
#plot the fft
self.plotter.set_samples(
samples=samples,
- minimum=self.controller[REF_LEVEL_KEY],
- maximum=self.controller[DYNAMIC_RANGE_KEY] +
self.controller[REF_LEVEL_KEY],
+ minimum=self[REF_LEVEL_KEY],
+ maximum=self[DYNAMIC_RANGE_KEY] + self[REF_LEVEL_KEY],
)
def update_grid(self, *args):
@@ -233,10 +233,10 @@
#grid parameters
sample_rate = self.ext_controller[self.sample_rate_key]
frame_rate = self.ext_controller[self.frame_rate_key]
- baseband_freq = self.controller[BASEBAND_FREQ_KEY]
- num_lines = self.controller[NUM_LINES_KEY]
- y_divs = self.controller[Y_DIVS_KEY]
- x_divs = self.controller[X_DIVS_KEY]
+ baseband_freq = self[BASEBAND_FREQ_KEY]
+ num_lines = self[NUM_LINES_KEY]
+ y_divs = self[Y_DIVS_KEY]
+ x_divs = self[X_DIVS_KEY]
#determine best fitting x_per_div
if self.real: x_width = sample_rate/2.0
else: x_width = sample_rate/1.0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r9171 - gnuradio/branches/features/experimental-gui,
jblum <=