GNU Radio's OWC Package
VPPM_Demodulator_impl.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /* gr-owc OOT module for optical wireless communications.
3  *
4  * Copyright 2021 Arsalan Ahmed from The Ubiquitous Communications and Networking (UCAN) Lab, University of Massachusetts, Boston.
5  *
6  * This is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3, or (at your option)
9  * any later version.
10  *
11  * This software is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this software; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street,
19  * Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef INCLUDED_OWC_VPPM_DEMODULATOR_IMPL_H
24 #define INCLUDED_OWC_VPPM_DEMODULATOR_IMPL_H
25 
26 #include <owc/VPPM_Demodulator.h>
27 
28 namespace gr {
29  namespace owc {
30 
32  {
33  private:
34  int d_samples_per_symbol;
35  int d_samples_per_pulse;
36  float d_gain;
37 
38  public:
41 
42  void set_samples_per_symbol(int samples_per_symbol) { d_samples_per_symbol = samples_per_symbol; }
43  int samples_per_symbol() { return d_samples_per_symbol; }
44 
45  void set_samples_per_pulse(int samples_per_pulse) { d_samples_per_pulse = samples_per_pulse; }
46  int samples_per_pulse() { return d_samples_per_pulse; }
47 
48  void set_gain(float gain) { d_gain = gain; }
49  float gain() { return d_gain; }
50 
51  float matched_filter(std::vector<float> samples_array, int num_incoming_samples, int samples_per_pulse, float gain)
52  {
53  std::vector<float> matching_signal_for_low;
54  std::vector<float> matching_signal_for_high;
55 
56  for (int i = 0; i < num_incoming_samples; i++)
57  {
58  if (i < samples_per_pulse)
59  {
60  matching_signal_for_low.push_back(gain);
61  }
62  else
63  {
64  matching_signal_for_low.push_back(0);
65  }
66  }
67 
68  for (int j = 0; j < num_incoming_samples; j++)
69  {
70  if (j >= (num_incoming_samples - samples_per_pulse))
71  {
72  matching_signal_for_high.push_back((-1) * gain);
73  }
74  else
75  {
76  matching_signal_for_high.push_back(0);
77  }
78  }
79 
80  float positive_sum = 0;
81  float negative_sum = 0;
82 
83  for (int x = 0; x < num_incoming_samples; x++)
84  {
85  positive_sum += samples_array[x] * matching_signal_for_low[x];
86  negative_sum += samples_array[x] * matching_signal_for_high[x];
87  }
88 
89  return positive_sum + negative_sum;
90  }
91 
92  // Where all the action really happens
93  int work(
94  int noutput_items,
95  gr_vector_const_void_star &input_items,
96  gr_vector_void_star &output_items
97  );
98  };
99 
100  } // namespace owc
101 } // namespace gr
102 
103 #endif /* INCLUDED_OWC_VPPM_DEMODULATOR_IMPL_H */
104 
<+description of block+>
Definition: VPPM_Demodulator.h:37
float matched_filter(std::vector< float > samples_array, int num_incoming_samples, int samples_per_pulse, float gain)
Definition: VPPM_Demodulator_impl.h:51
void set_samples_per_pulse(int samples_per_pulse)
Definition: VPPM_Demodulator_impl.h:45
void set_samples_per_symbol(int samples_per_symbol)
Definition: VPPM_Demodulator_impl.h:42
VPPM_Demodulator_impl(int samples_per_symbol, int samples_per_pulse, float gain)
Definition: binary_to_decimal_mapper.h:29
int samples_per_symbol()
Definition: VPPM_Demodulator_impl.h:43
Definition: VPPM_Demodulator_impl.h:31
void set_gain(float gain)
Definition: VPPM_Demodulator_impl.h:48
int samples_per_pulse()
Definition: VPPM_Demodulator_impl.h:46
float gain()
Definition: VPPM_Demodulator_impl.h:49
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)