Vadim Yanitskiy | 0aafe28 | 2017-12-01 19:24:14 +0700 | [diff] [blame] | 1 | /* -*- c++ -*- */ |
| 2 | /* @file |
| 3 | * @author Piotr Krysik <ptrkrysik@gmail.com> |
| 4 | * @author Vadim Yanitskiy <axilirator@gmail.com> |
| 5 | * @section LICENSE |
| 6 | * |
| 7 | * Gr-gsm 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 | * Gr-gsm 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 gr-gsm; 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 | #ifdef HAVE_CONFIG_H |
| 25 | #include "config.h" |
| 26 | #endif |
| 27 | |
| 28 | #include <gnuradio/io_signature.h> |
| 29 | #include "burst_to_fn_time_impl.h" |
| 30 | |
| 31 | namespace gr { |
| 32 | namespace gsm { |
| 33 | |
| 34 | burst_to_fn_time::sptr |
| 35 | burst_to_fn_time::make(void) |
| 36 | { |
| 37 | return gnuradio::get_initial_sptr |
| 38 | (new burst_to_fn_time_impl()); |
| 39 | } |
| 40 | |
| 41 | /* |
| 42 | * The private constructor |
| 43 | */ |
| 44 | burst_to_fn_time_impl::burst_to_fn_time_impl(void) |
| 45 | : gr::block("burst_to_fn_time", |
| 46 | gr::io_signature::make(0, 0, 0), |
| 47 | gr::io_signature::make(0, 0, 0)) |
| 48 | { |
| 49 | // Register I/O ports |
| 50 | message_port_register_in(pmt::mp("bursts_in")); |
| 51 | message_port_register_out(pmt::mp("fn_time_out")); |
| 52 | |
| 53 | // Bind a port handler |
| 54 | set_msg_handler(pmt::mp("bursts_in"), |
| 55 | boost::bind(&burst_to_fn_time_impl::handle_burst, this, _1)); |
| 56 | } |
| 57 | |
| 58 | /* |
| 59 | * Our virtual destructor. |
| 60 | */ |
| 61 | burst_to_fn_time_impl::~burst_to_fn_time_impl() |
| 62 | { |
| 63 | } |
| 64 | |
| 65 | void |
| 66 | burst_to_fn_time_impl::handle_burst(pmt::pmt_t msg_in) |
| 67 | { |
| 68 | // Obtain fn_time tag from message |
| 69 | pmt::pmt_t blob = pmt::car(msg_in); |
| 70 | pmt::pmt_t fn_time = pmt::dict_ref(blob, |
| 71 | pmt::intern("fn_time"), pmt::PMT_NIL); |
| 72 | |
| 73 | // Drop messages without required tag |
| 74 | if (fn_time == pmt::PMT_NIL) |
| 75 | return; |
| 76 | |
| 77 | // Compose and send a new message |
| 78 | pmt::pmt_t msg_out = pmt::dict_add(pmt::make_dict(), |
| 79 | pmt::intern("fn_time"), fn_time); |
| 80 | message_port_pub(pmt::mp("fn_time_out"), msg_out); |
| 81 | } |
| 82 | |
| 83 | } /* namespace gsm */ |
| 84 | } /* namespace gr */ |