summaryrefslogtreecommitdiff
path: root/gr-qtgui
diff options
context:
space:
mode:
authorTom Rondeau <trondeau@vt.edu>2012-10-12 15:41:50 -0400
committerTom Rondeau <trondeau@vt.edu>2012-10-12 15:41:50 -0400
commit2d02b29a0f712faebd82fc17293f8ccd38045f78 (patch)
tree7d6c13efaad664504e8e2189bbf0366752b5b8f5 /gr-qtgui
parent03bc909716749d961b89adc4809b4ad1d11ca157 (diff)
qtgui: fixing qtgui time plot to use sample rate names instead of bandwidth/frequency.
Diffstat (limited to 'gr-qtgui')
-rw-r--r--gr-qtgui/grc/qtgui_time_sink_x.xml7
-rw-r--r--gr-qtgui/include/qtgui/time_sink_c.h5
-rw-r--r--gr-qtgui/include/qtgui/time_sink_f.h5
-rw-r--r--gr-qtgui/lib/time_sink_c_impl.cc17
-rw-r--r--gr-qtgui/lib/time_sink_c_impl.h5
-rw-r--r--gr-qtgui/lib/time_sink_f_impl.cc17
-rw-r--r--gr-qtgui/lib/time_sink_f_impl.h5
-rw-r--r--gr-qtgui/lib/timedisplayform.cc19
-rw-r--r--gr-qtgui/lib/timedisplayform.h4
9 files changed, 50 insertions, 34 deletions
diff --git a/gr-qtgui/grc/qtgui_time_sink_x.xml b/gr-qtgui/grc/qtgui_time_sink_x.xml
index 6fe910ca35..7b15aa840a 100644
--- a/gr-qtgui/grc/qtgui_time_sink_x.xml
+++ b/gr-qtgui/grc/qtgui_time_sink_x.xml
@@ -14,7 +14,7 @@
<make>#set $win = 'self._%s_win'%$id
qtgui.$(type.fcn)(
$size, \#size
- $bw, \#bw
+ $srate, \#samp_rate
$name, \#name
$nconnections \#number of inputs
)
@@ -26,6 +26,7 @@ $(gui_hint()($win))</make>
<callback>set_title($which, $title)</callback>
<callback>set_color($which, $color)</callback>
<callback>set_y_axis($ymin, $ymax)</callback>
+ <callback>set_samp_rate($srate)</callback>
<param>
<name>Type</name>
<key>type</key>
@@ -47,8 +48,8 @@ $(gui_hint()($win))</make>
<type>int</type>
</param>
<param>
- <name>Bandwidth (Hz)</name>
- <key>bw</key>
+ <name>Sample Rate</name>
+ <key>srate</key>
<value>samp_rate</value>
<type>real</type>
</param>
diff --git a/gr-qtgui/include/qtgui/time_sink_c.h b/gr-qtgui/include/qtgui/time_sink_c.h
index ea618ab758..ba31ae2fc8 100644
--- a/gr-qtgui/include/qtgui/time_sink_c.h
+++ b/gr-qtgui/include/qtgui/time_sink_c.h
@@ -54,12 +54,12 @@ namespace gr {
* \brief Build complex time sink
*
* \param size number of points to plot at once
- * \param bw bandwidth of signal (used to set x-axis labels)
+ * \param samp_rate sample rate (used to set x-axis labels)
* \param name title for the plot
* \param nconnections number of signals connected to sink
* \param parent a QWidget parent object, if any
*/
- static sptr make(int size, double bw,
+ static sptr make(int size, double samp_rate,
const std::string &name,
int nconnections,
QWidget *parent=NULL);
@@ -76,6 +76,7 @@ namespace gr {
virtual void set_line_style(int which, Qt::PenStyle style) = 0;
virtual void set_line_marker(int which, QwtSymbol::Style marker) = 0;
virtual void set_nsamps(const int newsize) = 0;
+ virtual void set_samp_rate(const double samp_rate) = 0;
virtual void set_size(int width, int height) = 0;
diff --git a/gr-qtgui/include/qtgui/time_sink_f.h b/gr-qtgui/include/qtgui/time_sink_f.h
index 34210e08a7..6ab10f117e 100644
--- a/gr-qtgui/include/qtgui/time_sink_f.h
+++ b/gr-qtgui/include/qtgui/time_sink_f.h
@@ -52,12 +52,12 @@ namespace gr {
* \brief Build floating point time sink
*
* \param size number of points to plot at once
- * \param bw bandwidth of signal (used to set x-axis labels)
+ * \param samp_rate sample rate (used to set x-axis labels)
* \param name title for the plot
* \param nconnections number of signals connected to sink
* \param parent a QWidget parent object, if any
*/
- static sptr make(int size, double bw,
+ static sptr make(int size, double samp_rate,
const std::string &name,
int nconnections,
QWidget *parent=NULL);
@@ -74,6 +74,7 @@ namespace gr {
virtual void set_line_style(int which, Qt::PenStyle style) = 0;
virtual void set_line_marker(int which, QwtSymbol::Style marker) = 0;
virtual void set_nsamps(const int newsize) = 0;
+ virtual void set_samp_rate(const double samp_rate) = 0;
virtual void set_size(int width, int height) = 0;
diff --git a/gr-qtgui/lib/time_sink_c_impl.cc b/gr-qtgui/lib/time_sink_c_impl.cc
index d3819b5d5c..c8efb63721 100644
--- a/gr-qtgui/lib/time_sink_c_impl.cc
+++ b/gr-qtgui/lib/time_sink_c_impl.cc
@@ -34,23 +34,23 @@ namespace gr {
namespace qtgui {
time_sink_c::sptr
- time_sink_c::make(int size, double bw,
+ time_sink_c::make(int size, double samp_rate,
const std::string &name,
int nconnections,
QWidget *parent)
{
return gnuradio::get_initial_sptr
- (new time_sink_c_impl(size, bw, name, nconnections, parent));
+ (new time_sink_c_impl(size, samp_rate, name, nconnections, parent));
}
- time_sink_c_impl::time_sink_c_impl(int size, double bw,
+ time_sink_c_impl::time_sink_c_impl(int size, double samp_rate,
const std::string &name,
int nconnections,
QWidget *parent)
: gr_sync_block("time_sink_c",
gr_make_io_signature(nconnections, nconnections, sizeof(gr_complex)),
gr_make_io_signature(0, 0, 0)),
- d_size(size), d_bandwidth(bw), d_name(name),
+ d_size(size), d_samp_rate(samp_rate), d_name(name),
d_nconnections(2*nconnections), d_parent(parent)
{
d_main_gui = NULL;
@@ -92,6 +92,7 @@ namespace gr {
d_main_gui = new TimeDisplayForm(d_nconnections, d_parent);
d_main_gui->setNPoints(d_size);
+ d_main_gui->setSampleRate(d_samp_rate);
// initialize update time to 10 times a second
set_update_time(0.1);
@@ -199,6 +200,14 @@ namespace gr {
}
void
+ time_sink_c_impl::set_samp_rate(const double samp_rate)
+ {
+ gruel::scoped_lock lock(d_mutex);
+ d_samp_rate = samp_rate;
+ d_main_gui->setSampleRate(d_samp_rate);
+ }
+
+ void
time_sink_c_impl::npoints_resize()
{
int newsize = d_main_gui->getNPoints();
diff --git a/gr-qtgui/lib/time_sink_c_impl.h b/gr-qtgui/lib/time_sink_c_impl.h
index 7e96e3ef5c..66980dd79e 100644
--- a/gr-qtgui/lib/time_sink_c_impl.h
+++ b/gr-qtgui/lib/time_sink_c_impl.h
@@ -39,7 +39,7 @@ namespace gr {
gruel::mutex d_mutex;
int d_size;
- double d_bandwidth;
+ double d_samp_rate;
std::string d_name;
int d_nconnections;
@@ -55,7 +55,7 @@ namespace gr {
void npoints_resize();
public:
- time_sink_c_impl(int size, double bw,
+ time_sink_c_impl(int size, double samp_rate,
const std::string &name,
int nconnections,
QWidget *parent=NULL);
@@ -74,6 +74,7 @@ namespace gr {
void set_line_style(int which, Qt::PenStyle style);
void set_line_marker(int which, QwtSymbol::Style marker);
void set_nsamps(const int size);
+ void set_samp_rate(const double samp_rate);
void set_size(int width, int height);
diff --git a/gr-qtgui/lib/time_sink_f_impl.cc b/gr-qtgui/lib/time_sink_f_impl.cc
index 3f1b161519..562da3ef86 100644
--- a/gr-qtgui/lib/time_sink_f_impl.cc
+++ b/gr-qtgui/lib/time_sink_f_impl.cc
@@ -34,23 +34,23 @@ namespace gr {
namespace qtgui {
time_sink_f::sptr
- time_sink_f::make(int size, double bw,
+ time_sink_f::make(int size, double samp_rate,
const std::string &name,
int nconnections,
QWidget *parent)
{
return gnuradio::get_initial_sptr
- (new time_sink_f_impl(size, bw, name, nconnections, parent));
+ (new time_sink_f_impl(size, samp_rate, name, nconnections, parent));
}
- time_sink_f_impl::time_sink_f_impl(int size, double bw,
+ time_sink_f_impl::time_sink_f_impl(int size, double samp_rate,
const std::string &name,
int nconnections,
QWidget *parent)
: gr_sync_block("time_sink_f",
gr_make_io_signature(nconnections, nconnections, sizeof(float)),
gr_make_io_signature(0, 0, 0)),
- d_size(size), d_bandwidth(bw), d_name(name),
+ d_size(size), d_samp_rate(samp_rate), d_name(name),
d_nconnections(nconnections), d_parent(parent)
{
d_main_gui = NULL;
@@ -92,6 +92,7 @@ namespace gr {
d_main_gui = new TimeDisplayForm(d_nconnections, d_parent);
d_main_gui->setNPoints(d_size);
+ d_main_gui->setSampleRate(d_samp_rate);
// initialize update time to 10 times a second
set_update_time(0.1);
@@ -198,6 +199,14 @@ namespace gr {
}
}
+ void
+ time_sink_f_impl::set_samp_rate(const double samp_rate)
+ {
+ gruel::scoped_lock lock(d_mutex);
+ d_samp_rate = samp_rate;
+ d_main_gui->setSampleRate(d_samp_rate);
+ }
+
int
time_sink_f_impl::nsamps() const
{
diff --git a/gr-qtgui/lib/time_sink_f_impl.h b/gr-qtgui/lib/time_sink_f_impl.h
index 6f665d9354..dd1dd6f699 100644
--- a/gr-qtgui/lib/time_sink_f_impl.h
+++ b/gr-qtgui/lib/time_sink_f_impl.h
@@ -39,7 +39,7 @@ namespace gr {
gruel::mutex d_mutex;
int d_size;
- double d_bandwidth;
+ double d_samp_rate;
std::string d_name;
int d_nconnections;
@@ -55,7 +55,7 @@ namespace gr {
void npoints_resize();
public:
- time_sink_f_impl(int size, double bw,
+ time_sink_f_impl(int size, double samp_rate,
const std::string &name,
int nconnections,
QWidget *parent=NULL);
@@ -74,6 +74,7 @@ namespace gr {
void set_line_style(int which, Qt::PenStyle style);
void set_line_marker(int which, QwtSymbol::Style marker);
void set_nsamps(const int newsize);
+ void set_samp_rate(const double samp_rate);
void set_size(int width, int height);
diff --git a/gr-qtgui/lib/timedisplayform.cc b/gr-qtgui/lib/timedisplayform.cc
index f42c979da5..e3c7f8a60b 100644
--- a/gr-qtgui/lib/timedisplayform.cc
+++ b/gr-qtgui/lib/timedisplayform.cc
@@ -82,24 +82,19 @@ TimeDisplayForm::customEvent(QEvent * e)
}
void
-TimeDisplayForm::setFrequencyRange(const double newCenterFrequency,
- const double newStartFrequency,
- const double newStopFrequency)
+TimeDisplayForm::setSampleRate(const double samprate)
{
- double fdiff = std::max(fabs(newStartFrequency), fabs(newStopFrequency));
-
- if(fdiff > 0) {
+ if(samprate > 0) {
std::string strtime[4] = {"sec", "ms", "us", "ns"};
- double units10 = floor(log10(fdiff));
+ double units10 = floor(log10(samprate));
double units3 = std::max(floor(units10 / 3.0), 0.0);
double units = pow(10, (units10-fmod(units10, 3.0)));
int iunit = static_cast<int>(units3);
- _startFrequency = newStartFrequency;
- _stopFrequency = newStopFrequency;
-
- getPlot()->SetSampleRate(_stopFrequency - _startFrequency,
- units, strtime[iunit]);
+ getPlot()->SetSampleRate(samprate, units, strtime[iunit]);
+ }
+ else {
+ throw std::runtime_error("TimeDisplayForm: samprate must be > 0.\n");
}
}
diff --git a/gr-qtgui/lib/timedisplayform.h b/gr-qtgui/lib/timedisplayform.h
index 52772a02ca..df8803c145 100644
--- a/gr-qtgui/lib/timedisplayform.h
+++ b/gr-qtgui/lib/timedisplayform.h
@@ -45,9 +45,7 @@ class TimeDisplayForm : public DisplayForm
public slots:
void customEvent(QEvent * e);
- void setFrequencyRange(const double newCenterFrequency,
- const double newStartFrequency,
- const double newStopFrequency);
+ void setSampleRate(const double samprate);
void setYaxis(double min, double max);
void setNPoints(const int);