[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r9202 - gnuradio/branches/features/experimental-gui
From: |
jblum |
Subject: |
[Commit-gnuradio] r9202 - gnuradio/branches/features/experimental-gui |
Date: |
Thu, 7 Aug 2008 11:46:39 -0600 (MDT) |
Author: jblum
Date: 2008-08-07 11:46:33 -0600 (Thu, 07 Aug 2008)
New Revision: 9202
Added:
gnuradio/branches/features/experimental-gui/constants.py
Modified:
gnuradio/branches/features/experimental-gui/const_window.py
gnuradio/branches/features/experimental-gui/constsink.py
gnuradio/branches/features/experimental-gui/fft_window.py
gnuradio/branches/features/experimental-gui/fftsink.py
gnuradio/branches/features/experimental-gui/number_window.py
gnuradio/branches/features/experimental-gui/numbersink.py
gnuradio/branches/features/experimental-gui/scope_window.py
gnuradio/branches/features/experimental-gui/scopesink.py
gnuradio/branches/features/experimental-gui/waterfall_window.py
gnuradio/branches/features/experimental-gui/waterfallsink.py
Log:
moved controller keys to constants
Modified: gnuradio/branches/features/experimental-gui/const_window.py
===================================================================
--- gnuradio/branches/features/experimental-gui/const_window.py 2008-08-07
02:19:05 UTC (rev 9201)
+++ gnuradio/branches/features/experimental-gui/const_window.py 2008-08-07
17:46:33 UTC (rev 9202)
@@ -28,6 +28,7 @@
import numpy
import math
import pubsub
+from constants import *
##################################################
# Constants
@@ -46,10 +47,6 @@
('Line Link', None),
)
DEFAULT_MARKER_TYPE = MARKER_TYPES[1][1]
-RUNNING_KEY = 'running'
-X_DIVS_KEY = 'x_divs'
-Y_DIVS_KEY = 'y_divs'
-MARKER_KEY = 'marker'
##################################################
# Constellation window control panel
Added: gnuradio/branches/features/experimental-gui/constants.py
===================================================================
--- gnuradio/branches/features/experimental-gui/constants.py
(rev 0)
+++ gnuradio/branches/features/experimental-gui/constants.py 2008-08-07
17:46:33 UTC (rev 9202)
@@ -0,0 +1,59 @@
+#
+# Copyright 2008 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+##################################################
+# Controller Keys
+##################################################
+AC_COUPLE_KEY = 'ac_couple'
+ALPHA_KEY = 'alpha'
+AUTORANGE_KEY = 'autorange'
+AVERAGE_KEY = 'average'
+AVG_ALPHA_KEY = 'avg_alpha'
+BASEBAND_FREQ_KEY = 'baseband_freq'
+BETA_KEY = 'beta'
+COLOR_MODE_KEY = 'color_mode'
+DECIMATION_KEY = 'decimation'
+DYNAMIC_RANGE_KEY = 'dynamic_range'
+FRAME_RATE_KEY = 'frame_rate'
+GAIN_MU_KEY = 'gain_mu'
+GAIN_OMEGA_KEY = 'gain_omega'
+MARKER_KEY = 'marker'
+MSG_KEY = 'msg'
+NUM_LINES_KEY = 'num_lines'
+OMEGA_KEY = 'omega'
+PEAK_HOLD_KEY = 'peak_hold'
+REF_LEVEL_KEY = 'ref_level'
+RUNNING_KEY = 'running'
+SAMPLE_RATE_KEY = 'sample_rate'
+SCOPE_NUM_SAMPLES_KEY = 'scope_num_samples'
+SCOPE_TRIGGER_CHANNEL_KEY = 'scope_trigger_channel'
+SCOPE_TRIGGER_LEVEL_KEY = 'scope_trigger_level'
+SCOPE_TRIGGER_MODE_KEY = 'scope_trigger_mode'
+TRIGGER_CHANNEL_KEY = 'trigger_channel'
+TRIGGER_LEVEL_KEY = 'trigger_level'
+TRIGGER_MODE_KEY = 'trigger_mode'
+X_DIVS_KEY = 'x_divs'
+X_OFF_KEY = 'x_off'
+X_PER_DIV_KEY = 'x_per_div'
+Y_DIVS_KEY = 'y_divs'
+Y_OFF_KEY = 'y_off'
+Y_PER_DIV_KEY = 'y_per_div'
+
Modified: gnuradio/branches/features/experimental-gui/constsink.py
===================================================================
--- gnuradio/branches/features/experimental-gui/constsink.py 2008-08-07
02:19:05 UTC (rev 9201)
+++ gnuradio/branches/features/experimental-gui/constsink.py 2008-08-07
17:46:33 UTC (rev 9202)
@@ -26,19 +26,9 @@
import common
from gnuradio import gr, blks2
from pubsub import pubsub
+from constants import *
##################################################
-# Constants
-##################################################
-SAMPLE_RATE_KEY = 'sample_rate'
-ALPHA_KEY = 'alpha'
-BETA_KEY = 'beta'
-GAIN_MU_KEY = 'gain_mu'
-OMEGA_KEY = 'omega'
-GAIN_OMEGA_KEY = 'gain_omega'
-MSG_KEY = 'msg'
-
-##################################################
# Constellation sink block (wrapper for old wxgui)
##################################################
class const_sink_c(gr.hier_block2, common.prop_setter):
Modified: gnuradio/branches/features/experimental-gui/fft_window.py
===================================================================
--- gnuradio/branches/features/experimental-gui/fft_window.py 2008-08-07
02:19:05 UTC (rev 9201)
+++ gnuradio/branches/features/experimental-gui/fft_window.py 2008-08-07
17:46:33 UTC (rev 9202)
@@ -28,6 +28,7 @@
import numpy
import math
import pubsub
+from constants import *
##################################################
# Constants
@@ -40,13 +41,6 @@
FFT_PLOT_COLOR_SPEC = (0, 0, 1)
PEAK_VALS_COLOR_SPEC = (0, 1, 0)
NO_PEAK_VALS = list()
-PEAK_HOLD_KEY = 'peak_hold'
-Y_PER_DIV_KEY = 'y_per_div'
-Y_DIVS_KEY = 'y_divs'
-X_DIVS_KEY = 'x_divs'
-REF_LEVEL_KEY = 'ref_level'
-BASEBAND_FREQ_KEY = 'baseband_freq'
-RUNNING_KEY = 'running'
##################################################
# FFT window control panel
Modified: gnuradio/branches/features/experimental-gui/fftsink.py
===================================================================
--- gnuradio/branches/features/experimental-gui/fftsink.py 2008-08-07
02:19:05 UTC (rev 9201)
+++ gnuradio/branches/features/experimental-gui/fftsink.py 2008-08-07
17:46:33 UTC (rev 9202)
@@ -26,16 +26,9 @@
import common
from gnuradio import gr, blks2
from pubsub import pubsub
+from constants import *
##################################################
-# Constants
-##################################################
-SAMPLE_RATE_KEY = 'sample_rate'
-AVERAGE_KEY = 'average'
-AVG_ALPHA_KEY = 'avg_alpha'
-MSG_KEY = 'msg'
-
-##################################################
# FFT sink block (wrapper for old wxgui)
##################################################
class _fft_sink_base(gr.hier_block2, common.prop_setter):
Modified: gnuradio/branches/features/experimental-gui/number_window.py
===================================================================
--- gnuradio/branches/features/experimental-gui/number_window.py
2008-08-07 02:19:05 UTC (rev 9201)
+++ gnuradio/branches/features/experimental-gui/number_window.py
2008-08-07 17:46:33 UTC (rev 9202)
@@ -26,17 +26,17 @@
import numpy
import wx
import pubsub
+from constants import *
##################################################
# Constants
##################################################
+NEG_INF = float('-inf')
SLIDER_STEPS = 100
AVG_ALPHA_MIN_EXP, AVG_ALPHA_MAX_EXP = -3, 0
DEFAULT_NUMBER_RATE = 2
DEFAULT_WIN_SIZE = (300, 300)
DEFAULT_GAUGE_RANGE = 1000
-PEAK_HOLD_KEY = 'peak_hold'
-RUNNING_KEY = 'running'
##################################################
# Number window control panel
@@ -100,8 +100,8 @@
pubsub.pubsub.__init__(self)
wx.Panel.__init__(self, parent, -1, style=wx.SUNKEN_BORDER)
#setup
- self.peak_val_real = float('-inf')
- self.peak_val_imag = float('-inf')
+ self.peak_val_real = NEG_INF
+ self.peak_val_imag = NEG_INF
self.ext_controller = controller
self.real = real
self.units = units
@@ -135,38 +135,49 @@
self.ext_controller.subscribe(msg_key, self.handle_msg)
def show_gauges(self, show_gauge):
+ """!
+ Show or hide the gauges.
+ If this is real, never show the imaginary gauge.
+ @param show_gauge true to show
+ """
if show_gauge: self.gauge_real.Show()
else: self.gauge_real.Hide()
if show_gauge and not self.real: self.gauge_imag.Show()
else: self.gauge_imag.Hide()
def handle_msg(self, msg):
+ """!
+ Handle a message from the message queue.
+ Convert the string based message into a float or complex.
+ If more than one number was read, only take the last number.
+ Perform peak hold operations, set the gauges and display.
+ @param msg the number sample as a character array
+ """
if not self[RUNNING_KEY]: return
- #set text
+ #set gauge
+ def set_gauge_value(gauge, value):
+ gauge_val =
DEFAULT_GAUGE_RANGE*(value-self.minval)/(self.maxval-self.minval)
+ gauge_val = max(0, gauge_val) #clip
+ gauge_val = min(DEFAULT_GAUGE_RANGE, gauge_val) #clip
+ gauge.SetValue(gauge_val)
format_string = "%%.%df"%self.decimal_places
if self.real:
- sample = numpy.fromstring(msg, numpy.float32)[0]
+ sample = numpy.fromstring(msg, numpy.float32)[-1]
if self[PEAK_HOLD_KEY]: sample = self.peak_val_real =
max(self.peak_val_real, sample)
- else: self.peak_val_real = float('-inf')
label_text = "%s %s"%(format_string%sample, self.units)
+ set_gauge_value(self.gauge_real, sample)
else:
- sample = numpy.fromstring(msg, numpy.complex64)[0]
+ sample = numpy.fromstring(msg, numpy.complex64)[-1]
if self[PEAK_HOLD_KEY]:
self.peak_val_real = max(self.peak_val_real,
sample.real)
self.peak_val_imag = max(self.peak_val_imag,
sample.imag)
sample = self.peak_val_real +
self.peak_val_imag*1j
- else:
- self.peak_val_real = float('-inf')
- self.peak_val_imag = float('-inf')
label_text = "%s + %sj %s"%(format_string%sample.real,
format_string%sample.imag, self.units)
- self.text.SetLabel(label_text)
- #set gauge
- def set_gauge_value(gauge, value):
- gauge_val =
DEFAULT_GAUGE_RANGE*(value-self.minval)/(self.maxval-self.minval)
- gauge_val = max(0, gauge_val) #clip
- gauge_val = min(DEFAULT_GAUGE_RANGE, gauge_val) #clip
- gauge.SetValue(gauge_val)
- if self.real: set_gauge_value(self.gauge_real, sample)
- else:
set_gauge_value(self.gauge_real, sample.real)
set_gauge_value(self.gauge_imag, sample.imag)
+ #set label text
+ self.text.SetLabel(label_text)
+ #clear peak hold
+ if not self[PEAK_HOLD_KEY]:
+ self.peak_val_real = NEG_INF
+ self.peak_val_imag = NEG_INF
Modified: gnuradio/branches/features/experimental-gui/numbersink.py
===================================================================
--- gnuradio/branches/features/experimental-gui/numbersink.py 2008-08-07
02:19:05 UTC (rev 9201)
+++ gnuradio/branches/features/experimental-gui/numbersink.py 2008-08-07
17:46:33 UTC (rev 9202)
@@ -26,16 +26,9 @@
import common
from gnuradio import gr, blks2
from pubsub import pubsub
+from constants import *
##################################################
-# Constants
-##################################################
-SAMPLE_RATE_KEY = 'sample_rate'
-AVERAGE_KEY = 'average'
-AVG_ALPHA_KEY = 'avg_alpha'
-MSG_KEY = 'msg'
-
-##################################################
# Number sink block (wrapper for old wxgui)
##################################################
class _number_sink_base(gr.hier_block2, common.prop_setter):
@@ -64,9 +57,6 @@
):
#ensure avg alpha
if avg_alpha is None: avg_alpha = 2.0/number_rate
- self._avg_alpha = avg_alpha
- self.set_average(average)
- self.set_avg_alpha(avg_alpha)
#init
gr.hier_block2.__init__(
self,
@@ -93,6 +83,10 @@
sink = gr.message_sink(self._item_size, msgq, True)
#connect
self.connect(self, sd, mult, add, self._avg, sink)
+ #setup averaging
+ self._avg_alpha = avg_alpha
+ self.set_average(average)
+ self.set_avg_alpha(avg_alpha)
#controller
self.controller = pubsub()
self.controller.subscribe(SAMPLE_RATE_KEY, sd.set_sample_rate)
@@ -128,9 +122,8 @@
def get_average(self): return self._average
def set_average(self, average):
self._average = average
- #FIXME
- #if self.get_average(): self._avg.set_taps(self.get_avg_alpha())
- #else: self._avg.set_taps(1.0)
+ if self.get_average(): self._avg.set_taps(self.get_avg_alpha())
+ else: self._avg.set_taps(1.0)
def get_avg_alpha(self): return self._avg_alpha
def set_avg_alpha(self, avg_alpha):
Modified: gnuradio/branches/features/experimental-gui/scope_window.py
===================================================================
--- gnuradio/branches/features/experimental-gui/scope_window.py 2008-08-07
02:19:05 UTC (rev 9201)
+++ gnuradio/branches/features/experimental-gui/scope_window.py 2008-08-07
17:46:33 UTC (rev 9202)
@@ -28,6 +28,7 @@
import numpy
import time
import pubsub
+from constants import *
##################################################
# Constants
@@ -57,19 +58,6 @@
(1, 0, 1),
)
AUTORANGE_UPDATE_RATE = 0.5 #sec
-RUNNING_KEY = 'running'
-AUTORANGE_KEY = 'autorange'
-AC_COUPLE_KEY = 'ac_couple'
-X_PER_DIV_KEY = 'x_per_div'
-Y_PER_DIV_KEY = 'y_per_div'
-X_OFF_KEY = 'x_off'
-Y_OFF_KEY = 'y_off'
-Y_DIVS_KEY = 'y_divs'
-X_DIVS_KEY = 'x_divs'
-FRAME_RATE_KEY = 'frame_rate'
-TRIGGER_MODE_KEY = 'trigger_mode'
-TRIGGER_LEVEL_KEY = 'trigger_level'
-TRIGGER_CHANNEL_KEY = 'trigger_channel'
##################################################
# Scope window control panel
Modified: gnuradio/branches/features/experimental-gui/scopesink.py
===================================================================
--- gnuradio/branches/features/experimental-gui/scopesink.py 2008-08-07
02:19:05 UTC (rev 9201)
+++ gnuradio/branches/features/experimental-gui/scopesink.py 2008-08-07
17:46:33 UTC (rev 9202)
@@ -26,18 +26,9 @@
import common
from gnuradio import gr
from pubsub import pubsub
+from constants import *
##################################################
-# Constants
-##################################################
-MSG_KEY = 'msg'
-SAMPLE_RATE_KEY = 'sample_rate'
-SCOPE_TRIGGER_LEVEL_KEY = 'scope_trigger_level'
-SCOPE_TRIGGER_MODE_KEY = 'scope_trigger_mode'
-SCOPE_TRIGGER_CHANNEL_KEY = 'scope_trigger_channel'
-SCOPE_NUM_SAMPLES_KEY = 'scope_num_samples'
-
-##################################################
# Scope sink block (wrapper for old wxgui)
##################################################
class _scope_sink_base(gr.hier_block2, common.prop_setter):
Modified: gnuradio/branches/features/experimental-gui/waterfall_window.py
===================================================================
--- gnuradio/branches/features/experimental-gui/waterfall_window.py
2008-08-07 02:19:05 UTC (rev 9201)
+++ gnuradio/branches/features/experimental-gui/waterfall_window.py
2008-08-07 17:46:33 UTC (rev 9202)
@@ -28,6 +28,7 @@
import numpy
import math
import pubsub
+from constants import *
##################################################
# Constants
@@ -44,14 +45,6 @@
('RGB3', 'rgb3'),
('Gray', 'gray'),
)
-DYNAMIC_RANGE_KEY = 'dynamic_range'
-NUM_LINES_KEY = 'num_lines'
-Y_DIVS_KEY = 'y_divs'
-X_DIVS_KEY = 'x_divs'
-REF_LEVEL_KEY = 'ref_level'
-BASEBAND_FREQ_KEY = 'baseband_freq'
-COLOR_MODE_KEY = 'color_mode'
-RUNNING_KEY = 'running'
##################################################
# Waterfall window control panel
Modified: gnuradio/branches/features/experimental-gui/waterfallsink.py
===================================================================
--- gnuradio/branches/features/experimental-gui/waterfallsink.py
2008-08-07 02:19:05 UTC (rev 9201)
+++ gnuradio/branches/features/experimental-gui/waterfallsink.py
2008-08-07 17:46:33 UTC (rev 9202)
@@ -26,18 +26,9 @@
import common
from gnuradio import gr, blks2
from pubsub import pubsub
+from constants import *
##################################################
-# Constants
-##################################################
-SAMPLE_RATE_KEY = 'sample_rate'
-FRAME_RATE_KEY = 'frame_rate'
-DECIMATION_KEY = 'decimation'
-AVERAGE_KEY = 'average'
-AVG_ALPHA_KEY = 'avg_alpha'
-MSG_KEY = 'msg'
-
-##################################################
# Waterfall sink block (wrapper for old wxgui)
##################################################
class _waterfall_sink_base(gr.hier_block2, common.prop_setter):
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r9202 - gnuradio/branches/features/experimental-gui,
jblum <=