/* -*- c++ -*- */ /* * Copyright 2014 <+YOU OR YOUR COMPANY+>. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include "burst_to_power_impl.h" namespace gr { namespace gsm_measure { burst_to_power::sptr burst_to_power::make() { return gnuradio::get_initial_sptr (new burst_to_power_impl()); } /* * The private constructor */ burst_to_power_impl::burst_to_power_impl() : gr::block("burst_to_power", gr::io_signature::make(0,0,0), gr::io_signature::make(0,0,0)) { message_port_register_in(pmt::mp("bursts")); message_port_register_out(pmt::mp("power")); set_msg_handler(pmt::mp("bursts"), boost::bind(&burst_to_power_impl::to_power, this, _1)); } /* * Our virtual destructor. */ burst_to_power_impl::~burst_to_power_impl() { } void burst_to_power_impl::to_power(pmt::pmt_t pmt_vector){ std::vector burst; double power = 0; if (pmt::is_c32vector(pmt_vector)){ //std::cout << "It's a c32vector, computing power " << std::endl; burst = pmt::c32vector_elements(pmt_vector); for (int i = 0; i < burst.size(); i++){ power = power + std::norm(burst.at(i)); } power = power/burst.size(); message_port_pub(pmt::mp("power"), pmt::from_double(power)); } else std::cout << "Not a c32vector!!! Check your flowgraph" << std::endl; } } /* namespace gsm_measure */ } /* namespace gr */