GNU Radio 3.3.0 C++ API
gr_ofdm_insert_preamble.h
Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2007 Free Software Foundation, Inc.
00004  * 
00005  * This file is part of GNU Radio
00006  * 
00007  * GNU Radio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 3, or (at your option)
00010  * any later version.
00011  * 
00012  * GNU Radio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License along
00018  * with this program; if not, write to the Free Software Foundation, Inc.,
00019  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00020  */
00021 
00022 #ifndef INCLUDED_GR_OFDM_INSERT_PREAMBLE_H
00023 #define INCLUDED_GR_OFDM_INSERT_PREAMBLE_H
00024 
00025 #include <gr_block.h>
00026 #include <vector>
00027 
00028 class gr_ofdm_insert_preamble;
00029 typedef boost::shared_ptr<gr_ofdm_insert_preamble> gr_ofdm_insert_preamble_sptr;
00030 
00031 gr_ofdm_insert_preamble_sptr
00032 gr_make_ofdm_insert_preamble(int fft_length,
00033                              const std::vector<std::vector<gr_complex> > &preamble);
00034 
00035 /*!
00036  * \brief insert "pre-modulated" preamble symbols before each payload.
00037  * \ingroup sync_blk
00038  * \ingroup ofdm_blk
00039  *
00040  * <pre>
00041  * input 1: stream of vectors of gr_complex [fft_length]
00042  *          These are the modulated symbols of the payload.
00043  *
00044  * input 2: stream of char.  The LSB indicates whether the corresponding
00045  *          symbol on input 1 is the first symbol of the payload or not.
00046  *          It's a 1 if the corresponding symbol is the first symbol,
00047  *          otherwise 0.
00048  *
00049  * N.B., this implies that there must be at least 1 symbol in the payload.
00050  *
00051  *
00052  * output 1: stream of vectors of gr_complex [fft_length]
00053  *           These include the preamble symbols and the payload symbols.
00054  *
00055  * output 2: stream of char.  The LSB indicates whether the corresponding
00056  *           symbol on input 1 is the first symbol of a packet (i.e., the
00057  *           first symbol of the preamble.)   It's a 1 if the corresponding
00058  *           symbol is the first symbol, otherwise 0.
00059  * </pre>
00060  *
00061  * \param fft_length length of each symbol in samples.
00062  * \param preamble   vector of symbols that represent the pre-modulated preamble.
00063  */
00064 
00065 class gr_ofdm_insert_preamble : public gr_block
00066 {
00067   friend gr_ofdm_insert_preamble_sptr
00068   gr_make_ofdm_insert_preamble(int fft_length,
00069                                const std::vector<std::vector<gr_complex> > &preamble);
00070 
00071 protected:
00072   gr_ofdm_insert_preamble(int fft_length,
00073                           const std::vector<std::vector<gr_complex> > &preamble);
00074 
00075 private:
00076   enum state_t {
00077     ST_IDLE,
00078     ST_PREAMBLE,
00079     ST_FIRST_PAYLOAD,
00080     ST_PAYLOAD
00081   };
00082 
00083   int                                           d_fft_length;
00084   const std::vector<std::vector<gr_complex> >   d_preamble;
00085   state_t                                       d_state;
00086   int                                           d_nsymbols_output;
00087   int                                           d_pending_flag;
00088 
00089   void enter_idle();
00090   void enter_preamble();
00091   void enter_first_payload();
00092   void enter_payload();
00093   
00094 
00095 public:
00096   ~gr_ofdm_insert_preamble();
00097 
00098   int general_work (int noutput_items,
00099                     gr_vector_int &ninput_items,
00100                     gr_vector_const_void_star &input_items,
00101                     gr_vector_void_star &output_items);
00102 };
00103 
00104 #endif /* INCLUDED_GR_OFDM_INSERT_PREAMBLE_H */