GNU Radio's OWC Package
OOK_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_OOK_DEMODULATOR_IMPL_H
24 #define INCLUDED_OWC_OOK_DEMODULATOR_IMPL_H
25 
26 #include <owc/OOK_Demodulator.h>
27 
28 namespace gr {
29  namespace owc {
30 
32  {
33  private:
34  float d_threshold;
35  int d_samples_per_symbol;
36 
37  public:
40 
41  void set_threshold(float threshold) { d_threshold = threshold; }
42  float threshold() { return d_threshold; }
43 
44  void set_samples_per_symbol(int samples_per_symbol) { d_samples_per_symbol = samples_per_symbol; }
45  int samples_per_symbol() { return d_samples_per_symbol;}
46 
47  float samples_average_value(std::vector<float> samples_array, int num_incoming_samples)
48  {
49  float sum = 0;
50 
51  for (int i = 0; i < num_incoming_samples; i++)
52  {
53  sum += samples_array[i];
54  }
55 
56  return (sum/num_incoming_samples);
57  }
58 
59  // Where all the action really happens
60  int work(
61  int noutput_items,
62  gr_vector_const_void_star &input_items,
63  gr_vector_void_star &output_items
64  );
65  };
66 
67  } // namespace owc
68 } // namespace gr
69 
70 #endif /* INCLUDED_OWC_OOK_DEMODULATOR_IMPL_H */
71 
float threshold()
Definition: OOK_Demodulator_impl.h:42
int samples_per_symbol()
Definition: OOK_Demodulator_impl.h:45
OOK_Demodulator_impl(float threshold, int samples_per_symbol)
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
<+description of block+>
Definition: OOK_Demodulator.h:37
float samples_average_value(std::vector< float > samples_array, int num_incoming_samples)
Definition: OOK_Demodulator_impl.h:47
void set_samples_per_symbol(int samples_per_symbol)
Definition: OOK_Demodulator_impl.h:44
Definition: binary_to_decimal_mapper.h:29
Definition: OOK_Demodulator_impl.h:31
void set_threshold(float threshold)
Definition: OOK_Demodulator_impl.h:41