summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rondeau2011-04-23 12:00:54 -0400
committerTom Rondeau2011-04-23 12:08:13 -0400
commitbbb5e850224aca9dae15d24bd898cc56232327c9 (patch)
treebcb8668d2326e71fc18381eadf785bb54c153709
parent240ff2e7468d1651ad0b7557c061bb46aed8a4a3 (diff)
downloadgnuradio-bbb5e850224aca9dae15d24bd898cc56232327c9.tar.gz
gnuradio-bbb5e850224aca9dae15d24bd898cc56232327c9.tar.bz2
gnuradio-bbb5e850224aca9dae15d24bd898cc56232327c9.zip
gr-qtgui: setting up ability to have multiple connections to the time sink.
-rw-r--r--gr-qtgui/lib/qtgui_time_sink_c.cc34
-rw-r--r--gr-qtgui/lib/qtgui_time_sink_c.h6
-rw-r--r--gr-qtgui/lib/spectrumUpdateEvents.cc4
-rw-r--r--gr-qtgui/lib/spectrumUpdateEvents.h3
-rw-r--r--gr-qtgui/swig/qtgui_time_sink_c.i3
5 files changed, 35 insertions, 15 deletions
diff --git a/gr-qtgui/lib/qtgui_time_sink_c.cc b/gr-qtgui/lib/qtgui_time_sink_c.cc
index 064463162..cff265835 100644
--- a/gr-qtgui/lib/qtgui_time_sink_c.cc
+++ b/gr-qtgui/lib/qtgui_time_sink_c.cc
@@ -33,25 +33,30 @@
qtgui_time_sink_c_sptr
qtgui_make_time_sink_c (int size, double bw,
const std::string &name,
+ int nconnections,
QWidget *parent)
{
return gnuradio::get_initial_sptr(new qtgui_time_sink_c (size, bw, name,
- parent));
+ nconnections, parent));
}
qtgui_time_sink_c::qtgui_time_sink_c (int size, double bw,
const std::string &name,
+ int nconnections,
QWidget *parent)
: gr_block ("time_sink_c",
- gr_make_io_signature (1, -1, sizeof(gr_complex)),
+ 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_parent(parent)
+ d_nconnections(nconnections), d_parent(parent)
{
d_main_gui = NULL;
d_index = 0;
- d_residbuf = new gr_complex[d_size];
+
+ for(int i = 0; i < d_nconnections; i++) {
+ d_residbufs.push_back(new gr_complex[d_size]);
+ }
initialize();
}
@@ -59,7 +64,9 @@ qtgui_time_sink_c::qtgui_time_sink_c (int size, double bw,
qtgui_time_sink_c::~qtgui_time_sink_c()
{
// d_main_gui is a qwidget destroyed with its parent
- delete [] d_residbuf;
+ for(int i = 0; i < d_nconnections; i++) {
+ delete [] d_residbufs[i];
+ }
}
void
@@ -129,7 +136,7 @@ qtgui_time_sink_c::general_work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- int j=0;
+ int n=0, j=0;
const gr_complex *in = (const gr_complex*)input_items[0];
for(int i=0; i < noutput_items; i+=d_size) {
@@ -140,19 +147,24 @@ qtgui_time_sink_c::general_work (int noutput_items,
if(datasize >= resid) {
const timespec currentTime = get_highres_clock();
- // Fill up residbuf with d_fftsize number of items
- memcpy(d_residbuf+d_index, &in[j], sizeof(gr_complex)*resid);
+ // Fill up residbufs with d_fftsize number of items
+ for(n = 0; n < d_nconnections; n++) {
+ memcpy(d_residbufs[n]+d_index, &in[j], sizeof(gr_complex)*resid);
+ }
+
d_index = 0;
j += resid;
d_qApplication->postEvent(d_main_gui,
- new TimeUpdateEvent(d_residbuf, d_size,
+ new TimeUpdateEvent(d_residbufs, d_size,
currentTime, true));
}
- // Otherwise, copy what we received into the residbuf for next time
+ // Otherwise, copy what we received into the residbufs for next time
else {
- memcpy(d_residbuf+d_index, &in[j], sizeof(gr_complex)*datasize);
+ for(n = 0; n < d_nconnections; n++) {
+ memcpy(d_residbufs[n]+d_index, &in[j], sizeof(gr_complex)*datasize);
+ }
d_index += datasize;
j += datasize;
}
diff --git a/gr-qtgui/lib/qtgui_time_sink_c.h b/gr-qtgui/lib/qtgui_time_sink_c.h
index cdcf095ce..0c4e93803 100644
--- a/gr-qtgui/lib/qtgui_time_sink_c.h
+++ b/gr-qtgui/lib/qtgui_time_sink_c.h
@@ -35,6 +35,7 @@ typedef boost::shared_ptr<qtgui_time_sink_c> qtgui_time_sink_c_sptr;
qtgui_time_sink_c_sptr qtgui_make_time_sink_c(int size, double bw,
const std::string &name,
+ int nconnectons=1,
QWidget *parent=NULL);
class qtgui_time_sink_c : public gr_block
@@ -42,9 +43,11 @@ class qtgui_time_sink_c : public gr_block
private:
friend qtgui_time_sink_c_sptr qtgui_make_time_sink_c(int size, double bw,
const std::string &name,
+ int nconnections,
QWidget *parent);
qtgui_time_sink_c(int size, double bw,
const std::string &name,
+ int nconnections,
QWidget *parent=NULL);
void forecast(int noutput_items, gr_vector_int &ninput_items_required);
@@ -54,9 +57,10 @@ private:
int d_size;
double d_bandwidth;
std::string d_name;
+ int d_nconnections;
int d_index;
- gr_complex *d_residbuf;
+ std::vector<gr_complex*> d_residbufs;
double d_update_time;
diff --git a/gr-qtgui/lib/spectrumUpdateEvents.cc b/gr-qtgui/lib/spectrumUpdateEvents.cc
index ab5ef3be5..7d297a0d2 100644
--- a/gr-qtgui/lib/spectrumUpdateEvents.cc
+++ b/gr-qtgui/lib/spectrumUpdateEvents.cc
@@ -180,7 +180,7 @@ SpectrumFrequencyRangeEvent::GetStopFrequency() const
/***************************************************************************/
-TimeUpdateEvent::TimeUpdateEvent(const gr_complex *timeDomainPoints,
+TimeUpdateEvent::TimeUpdateEvent(const std::vector<gr_complex*> &timeDomainPoints,
const uint64_t numTimeDomainDataPoints,
const timespec dataTimestamp,
const bool repeatDataFlag)
@@ -196,7 +196,7 @@ TimeUpdateEvent::TimeUpdateEvent(const gr_complex *timeDomainPoints,
_dataTimeDomainPoints = new gr_complex[_numTimeDomainDataPoints];
memset(_dataTimeDomainPoints, 0x0, _numTimeDomainDataPoints*sizeof(gr_complex));
if(numTimeDomainDataPoints > 0) {
- memcpy(_dataTimeDomainPoints, timeDomainPoints,
+ memcpy(_dataTimeDomainPoints, timeDomainPoints[0],
numTimeDomainDataPoints*sizeof(gr_complex));
}
diff --git a/gr-qtgui/lib/spectrumUpdateEvents.h b/gr-qtgui/lib/spectrumUpdateEvents.h
index fcebd5d5a..1a92eefb5 100644
--- a/gr-qtgui/lib/spectrumUpdateEvents.h
+++ b/gr-qtgui/lib/spectrumUpdateEvents.h
@@ -5,6 +5,7 @@
#include <QEvent>
#include <QString>
#include <complex>
+#include <vector>
#include <highResTimeFunctions.h>
#include <gr_complex.h>
@@ -93,7 +94,7 @@ private:
class TimeUpdateEvent: public QEvent
{
public:
- TimeUpdateEvent(const gr_complex *timeDomainPoints,
+ TimeUpdateEvent(const std::vector<gr_complex*> &timeDomainPoints,
const uint64_t numTimeDomainDataPoints,
const timespec dataTimestamp,
const bool repeatDataFlag);
diff --git a/gr-qtgui/swig/qtgui_time_sink_c.i b/gr-qtgui/swig/qtgui_time_sink_c.i
index 2ac0023ed..6e6491399 100644
--- a/gr-qtgui/swig/qtgui_time_sink_c.i
+++ b/gr-qtgui/swig/qtgui_time_sink_c.i
@@ -30,6 +30,7 @@ GR_SWIG_BLOCK_MAGIC(qtgui,time_sink_c)
qtgui_time_sink_c_sptr qtgui_make_time_sink_c(int size, double bw,
const std::string &name,
+ int nconnections=1,
QWidget *parent=NULL);
class qtgui_time_sink_c : public gr_block
@@ -37,9 +38,11 @@ class qtgui_time_sink_c : public gr_block
private:
friend qtgui_time_sink_c_sptr qtgui_make_time_sink_c(int size, double bw,
const std::string &name,
+ int nconnections,
QWidget *parent);
qtgui_time_sink_c(int size, double bw,
const std::string &name,
+ int nconnections,
QWidget *parent=NULL);
public: