/* -*- c++ -*- */ /* * Copyright 2016 <+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 "strend_ff_impl.h" namespace gr { namespace create_tags { strend_ff::sptr strend_ff::make(float dblevels) { return gnuradio::get_initial_sptr (new strend_ff_impl(dblevels)); } /* * The private constructor */ strend_ff_impl::strend_ff_impl(float dblevels) : gr::sync_block("strend_ff", gr::io_signature::make(1, 1, sizeof(float)), gr::io_signature::make(1, 1, sizeof(float))),d_dblevels(dblevels) { d_time_var=0; } /* * Our virtual destructor. */ strend_ff_impl::~strend_ff_impl() { } int strend_ff_impl::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { const float *in = (const float *) input_items[0]; float *out = (float *) output_items[0]; //static int s_samples; //static int s_start; for (int i =0 ; i < noutput_items ; i++){ out[i]=10*log10(in[i]); if ( out[i] > d_dblevels ) { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); long d_time_var=ts.tv_nsec; strend_ff_impl::s_start=0; strend_ff_impl::s_samples=nitems_written(0)+i; if(strend_ff_impl::s_start=0){ pmt::pmt_t val=pmt::from_long(d_time_var); pmt::pmt_t key=pmt::string_to_symbol("Start time"); pmt::pmt_t scrid=pmt::string_to_symbol(this->name()); add_item_tag(0, strend_ff_impl::s_samples, key, val, scrid); strend_ff_impl::s_start=1; } } if(strend_ff_impl::s_start == 1){ if(((nitems_written(0)+i)-strend_ff_impl::s_samples) >= 100){ pmt::pmt_t val=pmt::from_long(d_time_var); pmt::pmt_t key=pmt::string_to_symbol("End time"); pmt::pmt_t scrid=pmt::string_to_symbol(this->name()); add_item_tag(0, strend_ff_impl::s_samples, key, val, scrid); strend_ff_impl::s_start=0; } } } // Do <+signal processing+> // Tell runtime system how many output items we produced. return noutput_items; } } /* namespace create_tags */ } /* namespace gr */