summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-core/src/lib')
-rw-r--r--gnuradio-core/src/lib/general/gr_constellation.cc21
-rw-r--r--gnuradio-core/src/lib/general/gr_constellation.h43
-rw-r--r--gnuradio-core/src/lib/general/gr_constellation.i23
3 files changed, 72 insertions, 15 deletions
diff --git a/gnuradio-core/src/lib/general/gr_constellation.cc b/gnuradio-core/src/lib/general/gr_constellation.cc
index 8b98a5731..477532e5c 100644
--- a/gnuradio-core/src/lib/general/gr_constellation.cc
+++ b/gnuradio-core/src/lib/general/gr_constellation.cc
@@ -43,6 +43,10 @@ gr_constellation::gr_constellation (std::vector<gr_complex> constellation) :
{
}
+gr_constellation::gr_constellation ()
+{
+}
+
unsigned int get_closest_point(std::vector<gr_complex> constellation, gr_complex sample) {
unsigned int table_size = constellation.size();
@@ -169,3 +173,20 @@ unsigned int gr_constellation_psk::calc_sector_value (unsigned int sector) {
}
+gr_constellation_bpsk_sptr
+gr_make_constellation_bpsk()
+{
+ return gr_constellation_bpsk_sptr(new gr_constellation_bpsk ());
+}
+
+gr_constellation_bpsk::gr_constellation_bpsk ()
+{
+ d_constellation.resize(2);
+ d_constellation[0] = gr_complex(-1, 0);
+ d_constellation[1] = gr_complex(1, 0);
+}
+
+unsigned int gr_constellation_bpsk::decision_maker(gr_complex sample)
+{
+ return (real(sample) > 0);
+}
diff --git a/gnuradio-core/src/lib/general/gr_constellation.h b/gnuradio-core/src/lib/general/gr_constellation.h
index d7f7b09b4..fcc947ca6 100644
--- a/gnuradio-core/src/lib/general/gr_constellation.h
+++ b/gnuradio-core/src/lib/general/gr_constellation.h
@@ -42,12 +42,12 @@ gr_constellation_sptr
gr_make_constellation (std::vector<gr_complex> constellation);
class gr_constellation : public boost::enable_shared_from_this<gr_constellation>
-//class gr_constellation
{
public:
gr_constellation (std::vector<gr_complex> constellation);
-
+ gr_constellation ();
+
//! Returns the set of points in this constellation.
std::vector<gr_complex> points() { return d_constellation;}
@@ -60,7 +60,6 @@ class gr_constellation : public boost::enable_shared_from_this<gr_constellation>
}
gr_constellation_sptr base() {
- //return gr_constellation_sptr(this);
return shared_from_this();
}
@@ -91,7 +90,7 @@ class gr_constellation_sector : public gr_constellation
unsigned int decision_maker (gr_complex sample);
- // protected:
+ protected:
virtual unsigned int get_sector (gr_complex sample) = 0;
@@ -101,7 +100,7 @@ class gr_constellation_sector : public gr_constellation
unsigned int n_sectors;
- // private:
+ private:
std::vector<unsigned int> sector_values;
@@ -133,13 +132,13 @@ class gr_constellation_rect : public gr_constellation_sector
gr_constellation_rect (std::vector<gr_complex> constellation, unsigned int real_sectors, unsigned int imag_sectors,
float width_real_sectors, float width_imag_sectors);
- // protected:
+ protected:
unsigned int get_sector (gr_complex sample);
unsigned int calc_sector_value (unsigned int sector);
- // private:
+ private:
unsigned int n_real_sectors;
unsigned int n_imag_sectors;
@@ -175,17 +174,43 @@ class gr_constellation_psk : public gr_constellation_sector
gr_constellation_psk (std::vector<gr_complex> constellation, unsigned int n_sectors);
- // protected:
+ protected:
unsigned int get_sector (gr_complex sample);
unsigned int calc_sector_value (unsigned int sector);
- // private:
+ private:
friend gr_constellation_psk_sptr
gr_make_constellation_psk (std::vector<gr_complex> constellation, unsigned int n_sectors);
};
+/************************************************************/
+/* gr_constellation_bpsk */
+/* */
+/* Only works for BPSK. */
+/* */
+/************************************************************/
+
+class gr_constellation_bpsk;
+typedef boost::shared_ptr<gr_constellation_bpsk> gr_constellation_bpsk_sptr;
+
+// public constructor
+gr_constellation_bpsk_sptr
+gr_make_constellation_bpsk ();
+
+class gr_constellation_bpsk : public gr_constellation
+{
+ public:
+
+ gr_constellation_bpsk ();
+ unsigned int decision_maker (gr_complex sample);
+
+ friend gr_constellation_bpsk_sptr
+ gr_make_constellation_bpsk ();
+
+};
+
#endif
diff --git a/gnuradio-core/src/lib/general/gr_constellation.i b/gnuradio-core/src/lib/general/gr_constellation.i
index 2d15b8b1e..a34aade9f 100644
--- a/gnuradio-core/src/lib/general/gr_constellation.i
+++ b/gnuradio-core/src/lib/general/gr_constellation.i
@@ -77,12 +77,23 @@ public:
std::vector<gr_complex> points ();
unsigned int decision_maker (gr_complex sample);
unsigned int bits_per_symbol ();
-
gr_constellation_sptr base ();
+};
+
+class gr_constellation_bpsk;
+typedef boost::shared_ptr<gr_constellation_bpsk> gr_constellation_bpsk_sptr;
+%template(gr_constellation_bpsk_sptr) boost::shared_ptr<gr_constellation_bpsk>;
+%rename(constellation_bpsk) gr_make_constellation_bpsk;
+gr_constellation_bpsk_sptr gr_make_constellation_bpsk();
+%ignore gr_constellation_bpsk;
- unsigned int get_sector (gr_complex sample);
- unsigned int calc_sector_value (unsigned int sector);
- void find_sector_values ();
- unsigned int n_sectors;
- std::vector<unsigned int> sector_values;
+class gr_constellation_bpsk : public gr_constellation
+{
+public:
+ gr_constellation_bpsk ();
+ std::vector<gr_complex> points();
+ unsigned int decision_maker (gr_complex sample);
+ unsigned int bits_per_symbol ();
+ gr_constellation_sptr base ();
};
+