GNU Radio's OWC Package
decimal_to_binary_mapper_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_DECIMAL_TO_BINARY_MAPPER_IMPL_H
24 #define INCLUDED_OWC_DECIMAL_TO_BINARY_MAPPER_IMPL_H
25 
27 
28 namespace gr {
29  namespace owc {
30 
32  {
33  private:
34  int d_modulation_order;
35 
36  public:
39 
40  void set_modulation_order(int modulation_order) { d_modulation_order = modulation_order; }
41  int modulation_order() { return d_modulation_order; }
42 
43  std::vector<int> decimal_to_binary(int decimal_value, int num_output_bits)
44  {
45  std::vector<int> binary_array;
46  int decimal_divide = decimal_value;
47  int rem = 0;
48 
49  for (int x = 0; x < num_output_bits; x++)
50  {
51  rem = decimal_divide % 2;
52  binary_array.push_back(rem);
53  decimal_divide = decimal_divide/2;
54  }
55 
56  reverse(binary_array.begin(),binary_array.end());
57  return binary_array;
58  }
59 
60  // Where all the action really happens
61  int work(
62  int noutput_items,
63  gr_vector_const_void_star &input_items,
64  gr_vector_void_star &output_items
65  );
66  };
67 
68  } // namespace owc
69 } // namespace gr
70 
71 #endif /* INCLUDED_OWC_DECIMAL_TO_BINARY_MAPPER_IMPL_H */
72 
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
void set_modulation_order(int modulation_order)
Definition: decimal_to_binary_mapper_impl.h:40
int modulation_order()
Definition: decimal_to_binary_mapper_impl.h:41
std::vector< int > decimal_to_binary(int decimal_value, int num_output_bits)
Definition: decimal_to_binary_mapper_impl.h:43
Definition: decimal_to_binary_mapper_impl.h:31
decimal_to_binary_mapper_impl(int modulation_order)
Definition: binary_to_decimal_mapper.h:29
<+description of block+>
Definition: decimal_to_binary_mapper.h:37