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