diff options
author | Tom Rondeau <trondeau@vt.edu> | 2013-02-28 14:38:40 -0500 |
---|---|---|
committer | Tom Rondeau <trondeau@vt.edu> | 2013-02-28 14:38:40 -0500 |
commit | 9f29e51f2945f355b43f3012da43e37dcd95f6b4 (patch) | |
tree | bcc71c8975379c107bb6e94da944292a5ee9a03a /gnuradio-core | |
parent | 7afefc484137bf0bed7ab9a7ed86017c117d6a35 (diff) | |
parent | 2f55d7dfc33e8d990e44c5bbb7c6d2fbdaddd563 (diff) |
Merge branch 'next' into perf_monitor
Diffstat (limited to 'gnuradio-core')
48 files changed, 427 insertions, 2517 deletions
diff --git a/gnuradio-core/ctrlport.conf.example b/gnuradio-core/ctrlport.conf.example index 7c231eb7c9..51d9e934f2 100644 --- a/gnuradio-core/ctrlport.conf.example +++ b/gnuradio-core/ctrlport.conf.example @@ -1,5 +1,30 @@ ## Use this to create an endpoint used to export ControlPort. +## +## A typical configuation would be to specify using a particular +## interface (determined from the IP address) and port number: +## +## ControlPort.Endpoints=tcp -h 192.168.1.1 -p 9000 +## +## A similar endpoint without the port number stated will pick a +## random, free port: +## +## ControlPort.Endpoints=tcp -h 192.168.1.1 +## +## ICE has some wildcard capabilities, as well. The following tells +## ICE to use all available interfaces: +## +## ControlPort.Endpoints=tcp -h * +## +## Using 'default' for the host will use what 'hostname' resolves to. +## ## For more details: ## http://doc.zeroc.com/display/Ice/Proxy+and+Endpoint+Syntax +## http://www.zeroc.com/doc/Ice-3.2.1/manual/ProxyEndpointRef.51.2.html # ControlPort.Endpoints = tcp -t 300 -h 127.0.0.1 -p 23456 + + +## Set a default hostname (or IP) if no '-h' is used in the Endpoint +## configuration + +#Ice.Default.Host = myhost diff --git a/gnuradio-core/gnuradio-core.conf b/gnuradio-core/gnuradio-core.conf index 3ed9892c73..cf3df4aea7 100644 --- a/gnuradio-core/gnuradio-core.conf +++ b/gnuradio-core/gnuradio-core.conf @@ -12,4 +12,5 @@ export = True [ControlPort] on = False +edges_list = False config = # ${prefix}/etc/gnuradio/ctrlport.conf diff --git a/gnuradio-core/src/examples/ctrlport/pfb_sync_test-qt.grc b/gnuradio-core/src/examples/ctrlport/pfb_sync_test-qt.grc index 15452e5399..5287257d77 100644 --- a/gnuradio-core/src/examples/ctrlport/pfb_sync_test-qt.grc +++ b/gnuradio-core/src/examples/ctrlport/pfb_sync_test-qt.grc @@ -1,6 +1,6 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Thu Feb 21 19:08:22 2013</timestamp> + <timestamp>Tue Feb 26 14:26:03 2013</timestamp> <block> <key>options</key> <param> @@ -613,37 +613,6 @@ </param> </block> <block> - <key>gr_throttle</key> - <param> - <key>id</key> - <value>gr_throttle_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>byte</value> - </param> - <param> - <key>samples_per_second</key> - <value>samp_rate</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - <param> - <key>_coordinate</key> - <value>(623, 64)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> <key>gr_vector_source_x</key> <param> <key>id</key> @@ -748,8 +717,39 @@ <value>0</value> </param> </block> + <block> + <key>blocks_throttle</key> + <param> + <key>id</key> + <value>blocks_throttle_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>byte</value> + </param> + <param> + <key>samples_per_second</key> + <value>samp_rate</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(623, 64)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> <connection> - <source_block_id>gr_throttle_0</source_block_id> + <source_block_id>blocks_throttle_0</source_block_id> <sink_block_id>digital_psk_mod_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> @@ -798,7 +798,7 @@ </connection> <connection> <source_block_id>blocks_packed_to_unpacked_xx_0</source_block_id> - <sink_block_id>gr_throttle_0</sink_block_id> + <sink_block_id>blocks_throttle_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gnuradio-core/src/examples/ctrlport/pfb_sync_test.grc b/gnuradio-core/src/examples/ctrlport/pfb_sync_test.grc index 36238e5c18..20e8e7f7db 100644 --- a/gnuradio-core/src/examples/ctrlport/pfb_sync_test.grc +++ b/gnuradio-core/src/examples/ctrlport/pfb_sync_test.grc @@ -558,10 +558,10 @@ </param> </block> <block> - <key>gr_throttle</key> + <key>blocks_throttle</key> <param> <key>id</key> - <value>gr_throttle_0</value> + <value>blocks_throttle_0</value> </param> <param> <key>_enabled</key> @@ -624,7 +624,7 @@ </param> </block> <connection> - <source_block_id>gr_throttle_0</source_block_id> + <source_block_id>blocks_throttle_0</source_block_id> <sink_block_id>digital_psk_mod_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> @@ -661,7 +661,7 @@ </connection> <connection> <source_block_id>blocks_packed_to_unpacked_xx_0</source_block_id> - <sink_block_id>gr_throttle_0</sink_block_id> + <sink_block_id>blocks_throttle_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gnuradio-core/src/examples/mp-sched/affinity_set.py b/gnuradio-core/src/examples/mp-sched/affinity_set.py index 6db632e0fa..c1c1a33932 100755 --- a/gnuradio-core/src/examples/mp-sched/affinity_set.py +++ b/gnuradio-core/src/examples/mp-sched/affinity_set.py @@ -6,6 +6,7 @@ from gnuradio import eng_notation from gnuradio import gr +from gnuradio import blocks from gnuradio.eng_option import eng_option from gnuradio.gr import firdes from optparse import OptionParser @@ -25,7 +26,7 @@ class affinity_set(gr.top_block): # Blocks ################################################## vec_len = 1 - self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex*vec_len, samp_rate) + self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*vec_len, samp_rate) self.gr_null_source_0 = gr.null_source(gr.sizeof_gr_complex*vec_len) self.gr_null_sink_0 = gr.null_sink(gr.sizeof_gr_complex*vec_len) self.gr_filt_0 = gr.fir_filter_ccc(1, 40000*[0.2+0.3j,]) @@ -37,8 +38,8 @@ class affinity_set(gr.top_block): ################################################## # Connections ################################################## - self.connect((self.gr_null_source_0, 0), (self.gr_throttle_0, 0)) - self.connect((self.gr_throttle_0, 0), (self.gr_filt_0, 0)) + self.connect((self.gr_null_source_0, 0), (self.blocks_throttle_0, 0)) + self.connect((self.blocks_throttle_0, 0), (self.gr_filt_0, 0)) self.connect((self.gr_filt_0, 0), (self.gr_filt_1, 0)) self.connect((self.gr_filt_1, 0), (self.gr_null_sink_0, 0)) diff --git a/gnuradio-core/src/examples/network/dial_tone_source.py b/gnuradio-core/src/examples/network/dial_tone_source.py index a8d85c4c57..d0d3cc7a8d 100755 --- a/gnuradio-core/src/examples/network/dial_tone_source.py +++ b/gnuradio-core/src/examples/network/dial_tone_source.py @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks from gnuradio.eng_option import eng_option from optparse import OptionParser import sys @@ -45,7 +46,7 @@ class dial_tone_source(gr.top_block): add = blocks.add_ff() # Throttle needed here to account for the other side's audio card sampling rate - thr = gr.throttle(gr.sizeof_float, sample_rate) + thr = blocks.throttle(gr.sizeof_float, sample_rate) sink = gr.udp_sink(gr.sizeof_float, host, port, pkt_size, eof=eof) self.connect(src0, (add, 0)) self.connect(src1, (add, 1)) diff --git a/gnuradio-core/src/examples/tags/test_file_tags.py b/gnuradio-core/src/examples/tags/test_file_tags.py index 135626d2c6..1dfc9e46cd 100755 --- a/gnuradio-core/src/examples/tags/test_file_tags.py +++ b/gnuradio-core/src/examples/tags/test_file_tags.py @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks import sys try: @@ -36,7 +37,7 @@ def main(): src = gr.vector_source_s(data, True) trigger = gr.vector_source_s(trig, True) - thr = gr.throttle(gr.sizeof_short, 10e3) + thr = blocks.throttle(gr.sizeof_short, 10e3) ann = gr.annotator_alltoall(1000000, gr.sizeof_short) tagger = gr.burst_tagger(gr.sizeof_short) diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt index de75dee7b8..b844cf302c 100644 --- a/gnuradio-core/src/lib/general/CMakeLists.txt +++ b/gnuradio-core/src/lib/general/CMakeLists.txt @@ -163,21 +163,13 @@ set(gr_core_general_triple_threats gr_null_sink gr_null_source gr_pa_2x2_phase_combiner - gr_peak_detector2_fb gr_prefs gr_random_pdu - gr_regenerate_bb gr_remez gr_skiphead - gr_stretch_ff gr_test - gr_threshold_ff - gr_throttle - gr_transcendental gr_vco_f gr_vector_map - gr_unpack_k_bits_bb - gr_pack_k_bits_bb gr_annotator_alltoall gr_annotator_1to1 gr_annotator_raw diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i index 092582475d..ff4c95631b 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -40,23 +40,15 @@ #include <gr_firdes.h> #include <gr_random_pdu.h> #include <gr_fake_channel_coder_pp.h> -#include <gr_throttle.h> -#include <gr_transcendental.h> #include <gr_vco_f.h> -#include <gr_threshold_ff.h> -#include <gr_regenerate_bb.h> #include <gr_pa_2x2_phase_combiner.h> #include <gr_kludge_copy.h> #include <gr_prefs.h> #include <gr_constants.h> #include <gr_test_types.h> #include <gr_test.h> -#include <gr_unpack_k_bits_bb.h> -#include <gr_pack_k_bits_bb.h> #include <gr_feval.h> #include <gr_bin_statistics_f.h> -#include <gr_peak_detector2_fb.h> -#include <gr_stretch_ff.h> #include <gr_copy.h> #include <complex_vec_test.h> #include <gr_annotator_alltoall.h> @@ -86,23 +78,15 @@ %include "gr_firdes.i" %include "gr_random_pdu.i" %include "gr_fake_channel_coder_pp.i" -%include "gr_throttle.i" -%include "gr_transcendental.i" %include "gr_vco_f.i" -%include "gr_threshold_ff.i" -%include "gr_regenerate_bb.i" %include "gr_pa_2x2_phase_combiner.i" %include "gr_kludge_copy.i" %include "gr_prefs.i" %include "gr_constants.i" %include "gr_test_types.h" %include "gr_test.i" -%include "gr_unpack_k_bits_bb.i" -%include "gr_pack_k_bits_bb.i" %include "gr_feval.i" %include "gr_bin_statistics_f.i" -%include "gr_peak_detector2_fb.i" -%include "gr_stretch_ff.i" %include "gr_copy.i" %include "complex_vec_test.i" %include "gr_annotator_alltoall.i" diff --git a/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.cc b/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.cc deleted file mode 100644 index 0ea0c9e388..0000000000 --- a/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.cc +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio 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. - * - * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_pack_k_bits_bb.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <iostream> - -gr_pack_k_bits_bb_sptr gr_make_pack_k_bits_bb(unsigned k) -{ - return gnuradio::get_initial_sptr(new gr_pack_k_bits_bb(k)); -} - - -gr_pack_k_bits_bb::gr_pack_k_bits_bb (unsigned k) - : gr_sync_decimator("pack_k_bits_bb", - gr_make_io_signature (1, 1, sizeof(unsigned char)), - gr_make_io_signature (1, 1, sizeof(unsigned char)), - k), - d_k (k) -{ - if (d_k == 0) - throw std::out_of_range("interpolation must be > 0"); -} - -gr_pack_k_bits_bb::~gr_pack_k_bits_bb() -{ -} - -int -gr_pack_k_bits_bb::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *)input_items[0]; - unsigned char *out = (unsigned char *)output_items[0]; - - for(int i = 0; i < noutput_items; i++) { - out[i] = 0x00; - for(unsigned int j = 0; j < d_k; j++) { - out[i] |= (0x01 & in[i*d_k+j])<<(d_k-j-1); - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.h b/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.h deleted file mode 100644 index 8e1508c78b..0000000000 --- a/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio 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. - * - * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_PACK_K_BITS_BB_H -#define INCLUDED_GR_PACK_K_BITS_BB_H - -#include <gr_core_api.h> -#include <gr_sync_decimator.h> - -class gr_pack_k_bits_bb; -typedef boost::shared_ptr<gr_pack_k_bits_bb> gr_pack_k_bits_bb_sptr; -GR_CORE_API gr_pack_k_bits_bb_sptr gr_make_pack_k_bits_bb (unsigned k); - -class gr_pack_k_bits_bb; - -/*! - * \brief Converts a stream of bytes with 1 bit in the LSB to a byte with k relevent bits. - * \ingroup converter_blk - */ -class GR_CORE_API gr_pack_k_bits_bb : public gr_sync_decimator -{ - private: - friend GR_CORE_API gr_pack_k_bits_bb_sptr gr_make_pack_k_bits_bb (unsigned k); - - gr_pack_k_bits_bb (unsigned k); - - unsigned d_k; // number of relevent bits to pack from k input bytes - - public: - ~gr_pack_k_bits_bb (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.i b/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.i deleted file mode 100644 index 6ae2095ec7..0000000000 --- a/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio 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. - * - * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,pack_k_bits_bb) - -gr_pack_k_bits_bb_sptr gr_make_pack_k_bits_bb (int k) throw(std::exception); - -class gr_pack_k_bits_bb : public gr_sync_decimator -{ - private: - gr_pack_k_bits_bb (int k); - - public: - ~gr_pack_k_bits_bb (); -}; diff --git a/gnuradio-core/src/lib/general/gr_peak_detector2_fb.cc b/gnuradio-core/src/lib/general/gr_peak_detector2_fb.cc deleted file mode 100644 index a4179a8c2a..0000000000 --- a/gnuradio-core/src/lib/general/gr_peak_detector2_fb.cc +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio 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. - * - * GNU Radio 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 GNU Radio; 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 <gr_peak_detector2_fb.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_peak_detector2_fb_sptr -gr_make_peak_detector2_fb (float threshold_factor_rise, - int look_ahead, float alpha) -{ - return gnuradio::get_initial_sptr(new gr_peak_detector2_fb (threshold_factor_rise, - look_ahead, alpha)); -} - -gr_peak_detector2_fb::gr_peak_detector2_fb (float threshold_factor_rise, - int look_ahead, float alpha) - : gr_sync_block ("peak_detector2_fb", - gr_make_io_signature (1, 1, sizeof(float)), - gr_make_io_signature2 (1, 2, sizeof(char), sizeof(float))), - d_threshold_factor_rise(threshold_factor_rise), - d_look_ahead(look_ahead), d_alpha(alpha), d_avg(0.0f), d_found(false) -{ -} - -int -gr_peak_detector2_fb::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) { - float *iptr = (float *) input_items[0]; - char *optr = (char *) output_items[0]; - - assert(noutput_items >= 2); - - memset(optr, 0, noutput_items*sizeof(char)); - - for (int i = 0; i < noutput_items; i++) { - - if (!d_found) { - // Have not yet detected presence of peak - if (iptr[i] > d_avg * (1.0f + d_threshold_factor_rise)) { - d_found = true; - d_look_ahead_remaining = d_look_ahead; - d_peak_val = -(float)INFINITY; - } - else { - d_avg = d_alpha*iptr[i] + (1.0f - d_alpha)*d_avg; - } - } - else { - // Detected presence of peak - if (iptr[i] > d_peak_val) { - d_peak_val = iptr[i]; - d_peak_ind = i; - } - else if (d_look_ahead_remaining <= 0) { - optr[d_peak_ind] = 1; - d_found = false; - d_avg = iptr[i]; - } - - // Have not yet located peak, loop and keep searching. - d_look_ahead_remaining--; - } - - // Every iteration of the loop, write debugging signal out if - // connected: - if (output_items.size() == 2) { - float *sigout = (float *) output_items[1]; - sigout[i] = d_avg; - } - } // loop - - if (!d_found) - return noutput_items; - - // else if detected presence, keep searching during the next call to work. - int tmp = d_peak_ind; - d_peak_ind = 1; - - return tmp - 1; -} - - diff --git a/gnuradio-core/src/lib/general/gr_peak_detector2_fb.h b/gnuradio-core/src/lib/general/gr_peak_detector2_fb.h deleted file mode 100644 index 665a6b882c..0000000000 --- a/gnuradio-core/src/lib/general/gr_peak_detector2_fb.h +++ /dev/null @@ -1,109 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio 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. - * - * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_gr_peak_detector2_FB_H -#define INCLUDED_gr_peak_detector2_FB_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_peak_detector2_fb; -typedef boost::shared_ptr<gr_peak_detector2_fb> gr_peak_detector2_fb_sptr; - -GR_CORE_API gr_peak_detector2_fb_sptr gr_make_peak_detector2_fb (float threshold_factor_rise = 7, - int look_ahead = 1000, - float alpha = 0.001); - -/*! - * \brief Detect the peak of a signal - * \ingroup level_blk - * - * If a peak is detected, this block outputs a 1, - * or it outputs 0's. A separate debug output may be connected, to - * view the internal EWMA described below. - * - * \param threshold_factor_rise The threshold factor determins when a peak - * is present. An EWMA average of the signal is calculated and when the - * value of the signal goes over threshold_factor_rise*average, we - * call the peak. - * \param look_ahead The look-ahead value is used when the threshold is - * found to locate the peak within this range. - * \param alpha The gain value of a single-pole moving average filter - */ - -class GR_CORE_API gr_peak_detector2_fb : public gr_sync_block -{ - friend GR_CORE_API gr_peak_detector2_fb_sptr - gr_make_peak_detector2_fb (float threshold_factor_rise, int look_ahead, float alpha); - - gr_peak_detector2_fb (float threshold_factor_rise, int look_ahead, float alpha); - -private: - float d_threshold_factor_rise; - int d_look_ahead; - int d_look_ahead_remaining; - int d_peak_ind; - float d_peak_val; - float d_alpha; - float d_avg; - bool d_found; - -public: - - /*! \brief Set the threshold factor value for the rise time - * \param thr new threshold factor - */ - void set_threshold_factor_rise(float thr) { d_threshold_factor_rise = thr; } - - /*! \brief Set the look-ahead factor - * \param look new look-ahead factor - */ - void set_look_ahead(int look) { d_look_ahead = look; } - - /*! \brief Set the running average alpha - * \param alpha new alpha for running average - */ - void set_alpha(int alpha) { d_alpha = alpha; } - - /*! \brief Get the threshold factor value for the rise time - * \return threshold factor - */ - float threshold_factor_rise() { return d_threshold_factor_rise; } - - /*! \brief Get the look-ahead factor value - * \return look-ahead factor - */ - int look_ahead() { return d_look_ahead; } - - /*! \brief Get the alpha value of the running average - * \return alpha - */ - float alpha() { return d_alpha; } - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif - - diff --git a/gnuradio-core/src/lib/general/gr_peak_detector2_fb.i b/gnuradio-core/src/lib/general/gr_peak_detector2_fb.i deleted file mode 100644 index ec7227e690..0000000000 --- a/gnuradio-core/src/lib/general/gr_peak_detector2_fb.i +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio 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. - * - * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - -GR_SWIG_BLOCK_MAGIC(gr,peak_detector2_fb) - - gr_peak_detector2_fb_sptr gr_make_peak_detector2_fb (float threshold_factor_rise = 7, - int look_ahead = 1000, - float alpha=0.001); - -class gr_peak_detector2_fb : public gr_sync_block -{ -private: - gr_peak_detector2_fb (float threshold_factor_rise, int look_ahead, float alpha); - -public: - void set_threshold_factor_rise(float thr) { d_threshold_factor_rise = thr; } - void set_look_ahead(int look) { d_look_ahead = look; } - void set_alpha(int alpha) { d_avg_alpha = alpha; } - - float threshold_factor_rise() { return d_threshold_factor_rise; } - int look_ahead() { return d_look_ahead; } - float alpha() { return d_avg_alpha; } -}; - - diff --git a/gnuradio-core/src/lib/general/gr_regenerate_bb.cc b/gnuradio-core/src/lib/general/gr_regenerate_bb.cc deleted file mode 100644 index c96cf247d0..0000000000 --- a/gnuradio-core/src/lib/general/gr_regenerate_bb.cc +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio 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. - * - * GNU Radio 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 GNU Radio; 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 <gr_regenerate_bb.h> -#include <gr_io_signature.h> - -gr_regenerate_bb_sptr -gr_make_regenerate_bb (int period, unsigned int max_regen) -{ - return gnuradio::get_initial_sptr(new gr_regenerate_bb (period, max_regen)); -} - -gr_regenerate_bb::gr_regenerate_bb (int period, unsigned int max_regen) - : gr_sync_block ("regenerate_bb", - gr_make_io_signature (1, 1, sizeof (char)), - gr_make_io_signature (1, 1, sizeof (char))), - d_period(period), - d_countdown(0), - d_max_regen(max_regen), - d_regen_count(max_regen) -{ -} - -void gr_regenerate_bb::set_max_regen(unsigned int regen) -{ - d_max_regen = regen; - d_countdown = 0; - d_regen_count = d_max_regen; -} - -void gr_regenerate_bb::set_period(int period) -{ - d_period = period; - d_countdown = 0; - d_regen_count = d_max_regen; -} - -int -gr_regenerate_bb::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const char *iptr = (const char *) input_items[0]; - char *optr = (char *) output_items[0]; - - for (int i = 0; i < noutput_items; i++){ - optr[i] = 0; - - if(d_regen_count < d_max_regen) { - d_countdown--; - - if(d_countdown == 0) { - optr[i] = 1; - d_countdown = d_period; - d_regen_count++; - } - } - - if(iptr[i] == 1) { - d_countdown = d_period; - optr[i] = 1; - d_regen_count = 0; - } - - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_regenerate_bb.h b/gnuradio-core/src/lib/general/gr_regenerate_bb.h deleted file mode 100644 index e820db69e8..0000000000 --- a/gnuradio-core/src/lib/general/gr_regenerate_bb.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio 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. - * - * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_REGENERATE_BB_H -#define INCLUDED_GR_REGENERATE_BB_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_regenerate_bb; -typedef boost::shared_ptr<gr_regenerate_bb> gr_regenerate_bb_sptr; - -GR_CORE_API gr_regenerate_bb_sptr gr_make_regenerate_bb (int period, unsigned int max_regen=500); - -/*! - * \brief Detect the peak of a signal and repeat every period samples - * \ingroup level_blk - * - * If a peak is detected, this block outputs a 1 repeated every period samples - * until reset by detection of another 1 on the input or stopped after max_regen - * regenerations have occurred. - * - * Note that if max_regen=(-1)/ULONG_MAX then the regeneration will run forever. - */ -class GR_CORE_API gr_regenerate_bb : public gr_sync_block -{ - /*! - * \brief Make a regenerate block - * \param period The number of samples between regenerations - * \param max_regen The maximum number of regenerations to perform; if set to - * ULONG_MAX, it will regenerate continuously. - */ - friend GR_CORE_API gr_regenerate_bb_sptr gr_make_regenerate_bb (int period, unsigned int max_regen); - - gr_regenerate_bb (int period, unsigned int max_regen); - - private: - int d_period; - int d_countdown; - unsigned int d_max_regen; - unsigned int d_regen_count; - - public: - /*! \brief Reset the maximum regeneration count; this will reset the current regen. - */ - void set_max_regen(unsigned int regen); - - /*! \brief Reset the period of regenerations; this will reset the current regen. - */ - void set_period(int period); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_regenerate_bb.i b/gnuradio-core/src/lib/general/gr_regenerate_bb.i deleted file mode 100644 index 064b0a2789..0000000000 --- a/gnuradio-core/src/lib/general/gr_regenerate_bb.i +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio 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. - * - * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,regenerate_bb) - -gr_regenerate_bb_sptr gr_make_regenerate_bb (int period, unsigned int max_regen=500); - -class gr_regenerate_bb : public gr_sync_block -{ - private: - gr_regenerate_bb (int period, unsigned int max_regen); - -public: - void set_max_regen(unsigned int regen); - - /*! \brief Reset the period of regenerations; this will reset the current regen. - */ - void set_period(int period); -}; diff --git a/gnuradio-core/src/lib/general/gr_stretch_ff.cc b/gnuradio-core/src/lib/general/gr_stretch_ff.cc deleted file mode 100644 index e89eadf8b1..0000000000 --- a/gnuradio-core/src/lib/general/gr_stretch_ff.cc +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio 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. - * - * GNU Radio 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 GNU Radio; 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 <gr_stretch_ff.h> -#include <gr_io_signature.h> - -gr_stretch_ff_sptr -gr_make_stretch_ff(float lo, size_t vlen) -{ - return gnuradio::get_initial_sptr(new gr_stretch_ff(lo, vlen)); -} - -gr_stretch_ff::gr_stretch_ff(float lo, size_t vlen) - : gr_sync_block("stretch_ff", - gr_make_io_signature(1, 1, vlen * sizeof(float)), - gr_make_io_signature(1, 1, vlen * sizeof(float))), - d_lo(lo), d_vlen(vlen) -{ -} - -int -gr_stretch_ff::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]; - - for (int count = 0; count < noutput_items; count++) { - float vmax = in[0] - d_lo; - - for (unsigned int i = 1; i < d_vlen; i++) { - float vtmp = in[i] - d_lo; - if (vtmp > vmax) - vmax = vtmp; - } - - if (vmax != 0.0) - for (unsigned int i = 0; i < d_vlen; i++) - out[i] = d_lo * (1.0 - (in[i] - d_lo) / vmax); - else - for (unsigned int i = 0; i < d_vlen; i++) - out[i] = in[i]; - - in += d_vlen; - out += d_vlen; - } - - return noutput_items; -} - diff --git a/gnuradio-core/src/lib/general/gr_stretch_ff.h b/gnuradio-core/src/lib/general/gr_stretch_ff.h deleted file mode 100644 index f592c94a78..0000000000 --- a/gnuradio-core/src/lib/general/gr_stretch_ff.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio 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. - * - * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_STRETCH_FF_H_ -# define INCLUDED_GR_STRETCH_FF_H_ - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -/*! - * \brief adjust y-range of an input vector by mapping to range - * (max-of-input, stipulated-min). Primarily for spectral signature - * matching by normalizing spectrum dynamic ranges. - * \ingroup misc_blk - */ - - -class gr_stretch_ff; -typedef boost::shared_ptr<gr_stretch_ff> gr_stretch_ff_sptr; - -GR_CORE_API gr_stretch_ff_sptr gr_make_stretch_ff(float lo, size_t vlen); - -class GR_CORE_API gr_stretch_ff : public gr_sync_block -{ - friend GR_CORE_API gr_stretch_ff_sptr gr_make_stretch_ff(float lo, size_t vlen); - - float d_lo; // the constant - size_t d_vlen; - gr_stretch_ff(float lo, size_t vlen); - - public: - float lo() const { return d_lo; } - void set_lo(float lo) { d_lo = lo; } - size_t vlen() const { return d_vlen; } - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_stretch_ff.i b/gnuradio-core/src/lib/general/gr_stretch_ff.i deleted file mode 100644 index 81366655eb..0000000000 --- a/gnuradio-core/src/lib/general/gr_stretch_ff.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio 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. - * - * GNU Radio 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 program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,stretch_ff); - -gr_stretch_ff_sptr gr_make_stretch_ff(float lo, size_t vlen); - -class gr_stretch_ff : public gr_sync_block -{ -private: - gr_stretch_ff(float lo, size_t vlen); -}; - diff --git a/gnuradio-core/src/lib/general/gr_threshold_ff.cc b/gnuradio-core/src/lib/general/gr_threshold_ff.cc deleted file mode 100644 index 952613151f..0000000000 --- a/gnuradio-core/src/lib/general/gr_threshold_ff.cc +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio 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. - * - * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// WARNING: this file is machine generated. Edits will be over written - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_threshold_ff.h> -#include <gr_io_signature.h> - -gr_threshold_ff_sptr -gr_make_threshold_ff (float lo, float hi, float initial_state) -{ - return gnuradio::get_initial_sptr(new gr_threshold_ff (lo, hi, initial_state)); -} - -gr_threshold_ff::gr_threshold_ff (float lo, float hi, float initial_state) - : gr_sync_block ("threshold_ff", - gr_make_io_signature (1, 1, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (float))), - d_lo (lo), d_hi (hi), d_last_state (initial_state) -{ -} - -int -gr_threshold_ff::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]; - - - for(int i=0; i<noutput_items; i++) { - if (in[i] > d_hi) { - out[i] = 1.0; - d_last_state = 1.0; - } else if (in[i] < d_lo) { - out[i] = 0.0; - d_last_state = 0.0; - } else - out[i] = d_last_state; - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_threshold_ff.h b/gnuradio-core/src/lib/general/gr_threshold_ff.h deleted file mode 100644 index 678f8b1d2d..0000000000 --- a/gnuradio-core/src/lib/general/gr_threshold_ff.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio 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. - * - * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_THRESHOLD_FF_H -#define INCLUDED_GR_THRESHOLD_FF_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_threshold_ff; -typedef boost::shared_ptr<gr_threshold_ff> gr_threshold_ff_sptr; - -GR_CORE_API gr_threshold_ff_sptr gr_make_threshold_ff (float lo, float hi, float initial_state=0); - -/*! - * \brief Please fix my documentation - * \ingroup misc_blk - */ -class GR_CORE_API gr_threshold_ff : public gr_sync_block -{ - friend GR_CORE_API gr_threshold_ff_sptr gr_make_threshold_ff (float lo, float hi, float initial_state); - - float d_lo,d_hi; // the constant - float d_last_state; - gr_threshold_ff (float lo, float hi, float initial_state); - - public: - float lo () const { return d_lo; } - void set_lo (float lo) { d_lo = lo; } - float hi () const { return d_hi; } - void set_hi (float hi) { d_hi = hi; } - float last_state () const { return d_last_state; } - void set_last_state (float last_state) { d_last_state = last_state; } - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_threshold_ff.i b/gnuradio-core/src/lib/general/gr_threshold_ff.i deleted file mode 100644 index 7584feea8a..0000000000 --- a/gnuradio-core/src/lib/general/gr_threshold_ff.i +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio 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. - * - * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,threshold_ff); - -gr_threshold_ff_sptr gr_make_threshold_ff (float lo, float hi, float initial_state=0); - -class gr_threshold_ff : public gr_sync_block -{ - private: - gr_threshold_ff (float lo, float hi, float initial_state); - - public: - float lo () const { return d_lo; } - void set_lo (float lo) { d_lo = lo; } - float hi () const { return d_hi; } - void set_hi (float hi) { d_hi = hi; } - float last_state () const { return d_last_state; } - void set_last_state (float last_state) { d_last_state = last_state; } -}; diff --git a/gnuradio-core/src/lib/general/gr_throttle.cc b/gnuradio-core/src/lib/general/gr_throttle.cc deleted file mode 100644 index 1c6c8cf893..0000000000 --- a/gnuradio-core/src/lib/general/gr_throttle.cc +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005-2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio 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. - * - * GNU Radio 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 GNU Radio; 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 <gr_throttle.h> -#include <gr_io_signature.h> -#include <cstring> -#include <boost/thread/thread.hpp> - -class gr_throttle_impl : public gr_throttle{ -public: - gr_throttle_impl(size_t itemsize): - gr_sync_block("throttle", - gr_make_io_signature(1, 1, itemsize), - gr_make_io_signature(1, 1, itemsize)), - d_itemsize(itemsize) - { - /* NOP */ - } - - double sample_rate(){ - return d_samps_per_us*1e6; - } - - void set_sample_rate(double rate){ - //changing the sample rate performs a reset of state params - d_start = boost::get_system_time(); - d_total_samples = 0; - d_samps_per_tick = rate/boost::posix_time::time_duration::ticks_per_second(); - d_samps_per_us = rate/1e6; - } - - int work ( - int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items - ){ - //calculate the expected number of samples to have passed through - boost::system_time now = boost::get_system_time(); - boost::int64_t ticks = (now - d_start).ticks(); - uint64_t expected_samps = uint64_t(d_samps_per_tick*ticks); - - //if the expected samples was less, we need to throttle back - if (d_total_samples > expected_samps){ - boost::this_thread::sleep(boost::posix_time::microseconds( - long((d_total_samples - expected_samps)/d_samps_per_us) - )); - } - - //copy all samples output[i] <= input[i] - const char *in = (const char *) input_items[0]; - char *out = (char *) output_items[0]; - std::memcpy(out, in, noutput_items * d_itemsize); - d_total_samples += noutput_items; - return noutput_items; - } - -private: - boost::system_time d_start; - size_t d_itemsize; - uint64_t d_total_samples; - double d_samps_per_tick, d_samps_per_us; - - void setup_rpc(){ -#ifdef GR_CTRLPORT - d_rpc_vars.push_back( - rpcbasic_sptr(new rpcbasic_register_get<gr_throttle_impl, double>( - alias(), "sample_rate", &gr_throttle_impl::sample_rate, - pmt::mp(0.0), pmt::mp(100.0e6), pmt::mp(0.0), - "Hz", "Sample Rate", RPC_PRIVLVL_MIN, - DISPTIME | DISPOPTSTRIP))); - d_rpc_vars.push_back( - rpcbasic_sptr(new rpcbasic_register_set<gr_throttle_impl, double>( - alias(), "sample_rate", &gr_throttle_impl::set_sample_rate, - pmt::mp(0.0), pmt::mp(100.0e6), pmt::mp(0.0), - "Hz", "Sample Rate", RPC_PRIVLVL_MIN, - DISPTIME | DISPOPTSTRIP))); -#endif - } -}; - -gr_throttle::sptr -gr_make_throttle(size_t itemsize, double samples_per_sec) -{ - gr_throttle::sptr throttle(new gr_throttle_impl(itemsize)); - throttle->set_sample_rate(samples_per_sec); - return throttle; -} diff --git a/gnuradio-core/src/lib/general/gr_throttle.h b/gnuradio-core/src/lib/general/gr_throttle.h deleted file mode 100644 index 2235ffacf1..0000000000 --- a/gnuradio-core/src/lib/general/gr_throttle.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005-2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio 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. - * - * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_THROTTLE_H -#define INCLUDED_GR_THROTTLE_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -/*! - * \brief throttle flow of samples such that the average rate does not exceed samples_per_sec. - * \ingroup misc_blk - * - * input: one stream of itemsize; output: one stream of itemsize - * - * N.B. this should only be used in GUI apps where there is no other - * rate limiting block. It is not intended nor effective at precisely - * controlling the rate of samples. That should be controlled by a - * source or sink tied to sample clock. E.g., a USRP or audio card. - */ -class GR_CORE_API gr_throttle : virtual public gr_sync_block -{ -public: - typedef boost::shared_ptr<gr_throttle> sptr; - - //! Sets the sample rate in samples per second - virtual double sample_rate() = 0; - virtual void set_sample_rate(double rate) = 0; -}; - -GR_CORE_API gr_throttle::sptr gr_make_throttle(size_t itemsize, double samples_per_sec); - -#endif /* INCLUDED_GR_THROTTLE_H */ diff --git a/gnuradio-core/src/lib/general/gr_throttle.i b/gnuradio-core/src/lib/general/gr_throttle.i deleted file mode 100644 index 5ba32de6ed..0000000000 --- a/gnuradio-core/src/lib/general/gr_throttle.i +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005-2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio 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. - * - * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -%{ -#include <gr_throttle.h> -%} - -GR_SWIG_BLOCK_MAGIC(gr,throttle); - -%include <gr_throttle.h> diff --git a/gnuradio-core/src/lib/general/gr_transcendental.cc b/gnuradio-core/src/lib/general/gr_transcendental.cc deleted file mode 100644 index c1482491ba..0000000000 --- a/gnuradio-core/src/lib/general/gr_transcendental.cc +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio 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. - * - * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <gr_transcendental.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <complex> //complex math -#include <cmath> //real math -#include <map> - -/*********************************************************************** - * work function creation and registration - **********************************************************************/ -typedef int(*work_fcn_type)(int, gr_vector_const_void_star &, gr_vector_void_star &); -struct map_val_type{ - work_fcn_type work_fcn; - size_t io_size; -}; -typedef std::map<std::string, map_val_type> map_type; - -//construct map on first use idiom -static map_type &get_map(void){ - static map_type map; - return map; -} - -//static initialization of this object registers a function -struct gr_transcendental_registrant{ - gr_transcendental_registrant( - const std::string &key, - const work_fcn_type &work_fcn, - const size_t io_size - ){ - map_val_type val; - val.work_fcn = work_fcn; - val.io_size = io_size; - get_map()[key] = val; - } -}; - -//macro to create a work function and register it -#define REGISTER_FUNCTION(__fcn__, __type__, __key__) \ - static int __key__ ## _work( \ - int noutput_items, \ - gr_vector_const_void_star &input_items, \ - gr_vector_void_star &output_items \ - ){ \ - const __type__ *in = (const __type__ *) input_items[0]; \ - __type__ *out = (__type__ *) output_items[0]; \ - for (size_t i = 0; i < size_t(noutput_items); i++){ \ - out[i] = std::__fcn__(in[i]); \ - } \ - return noutput_items; \ - } \ - gr_transcendental_registrant __key__ ## _registrant(#__key__, &__key__ ## _work, sizeof(__type__)); - -//register work functions for real types -#define REGISTER_REAL_FUNCTIONS(__fcn__) \ - REGISTER_FUNCTION(__fcn__, float, __fcn__ ## _float) \ - REGISTER_FUNCTION(__fcn__, double, __fcn__ ## _double) - -//register work functions for complex types -#define REGISTER_COMPLEX_FUNCTIONS(__fcn__) \ - REGISTER_FUNCTION(__fcn__, std::complex<float>, __fcn__ ## _complex_float) \ - REGISTER_FUNCTION(__fcn__, std::complex<double>, __fcn__ ## _complex_double) - -//register both complex and real -#define REGISTER_FUNCTIONS(__fcn__) \ - REGISTER_REAL_FUNCTIONS(__fcn__) \ - REGISTER_COMPLEX_FUNCTIONS(__fcn__) - -//create and register transcendental work functions -REGISTER_FUNCTIONS(cos) -REGISTER_FUNCTIONS(sin) -REGISTER_FUNCTIONS(tan) -REGISTER_REAL_FUNCTIONS(acos) -REGISTER_REAL_FUNCTIONS(asin) -REGISTER_REAL_FUNCTIONS(atan) -REGISTER_FUNCTIONS(cosh) -REGISTER_FUNCTIONS(sinh) -REGISTER_FUNCTIONS(tanh) -REGISTER_FUNCTIONS(exp) -REGISTER_FUNCTIONS(log) -REGISTER_FUNCTIONS(log10) -REGISTER_FUNCTIONS(sqrt) - -/*********************************************************************** - * implementation block simply calls into the function pointer - **********************************************************************/ -class gr_transcendental_impl : public gr_transcendental{ -public: - gr_transcendental_impl( - const work_fcn_type &work_fcn, const size_t io_size - ): - gr_sync_block( - "transcendental", - gr_make_io_signature(1, 1, io_size), - gr_make_io_signature(1, 1, io_size) - ), - _work_fcn(work_fcn) - { - // NOP - } - - int work( - int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items - ){ - return _work_fcn(noutput_items, input_items, output_items); - } - -private: - const work_fcn_type &_work_fcn; -}; - -/*********************************************************************** - * factory function to make transcendental block - **********************************************************************/ -gr_transcendental::sptr gr_make_transcendental( - const std::string &name, - const std::string &type -){ - //search for an entry in the map - const std::string key = name + "_" + type; - const bool has_key = get_map().count(key) != 0; - if (!has_key) throw std::runtime_error( - "could not find transcendental function for " + key - ); - - //make a new block with found work function - return gr_transcendental::sptr(new gr_transcendental_impl( - get_map()[key].work_fcn, get_map()[key].io_size - )); -} diff --git a/gnuradio-core/src/lib/general/gr_transcendental.h b/gnuradio-core/src/lib/general/gr_transcendental.h deleted file mode 100644 index 9841a53e95..0000000000 --- a/gnuradio-core/src/lib/general/gr_transcendental.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio 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. - * - * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_TRANSCENDENTAL_H -#define INCLUDED_GR_TRANSCENDENTAL_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <string> - -/*! - * \brief A block that performs various transcendental math operations. - * - * Possible function names can be found in the cmath library. - * IO may be either complex or real, double or single precision. - * - * Possible type strings: float, double, complex_float, complex_double - * - * output[i] = trans_fcn(input[i]) - */ -class GR_CORE_API gr_transcendental : virtual public gr_sync_block{ -public: - typedef boost::shared_ptr<gr_transcendental> sptr; -}; - -GR_CORE_API gr_transcendental::sptr gr_make_transcendental( - const std::string &name, - const std::string &type = "float" -); - -#endif /* INCLUDED_GR_TRANSCENDENTAL_H */ diff --git a/gnuradio-core/src/lib/general/gr_transcendental.i b/gnuradio-core/src/lib/general/gr_transcendental.i deleted file mode 100644 index 6acdb10b7e..0000000000 --- a/gnuradio-core/src/lib/general/gr_transcendental.i +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio 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. - * - * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -//////////////////////////////////////////////////////////////////////// -// block headers -//////////////////////////////////////////////////////////////////////// -%{ -#include <gr_transcendental.h> -%} - -//////////////////////////////////////////////////////////////////////// -// block magic -//////////////////////////////////////////////////////////////////////// -GR_SWIG_BLOCK_MAGIC(gr,transcendental) -%include <gr_transcendental.h> diff --git a/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.cc b/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.cc deleted file mode 100644 index 00b88e9724..0000000000 --- a/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.cc +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio 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. - * - * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_unpack_k_bits_bb.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <iostream> - -gr_unpack_k_bits_bb_sptr gr_make_unpack_k_bits_bb (unsigned k) -{ - return gnuradio::get_initial_sptr(new gr_unpack_k_bits_bb (k)); -} - - -gr_unpack_k_bits_bb::gr_unpack_k_bits_bb (unsigned k) - : gr_sync_interpolator ("unpack_k_bits_bb", - gr_make_io_signature (1, 1, sizeof (unsigned char)), - gr_make_io_signature (1, 1, sizeof (unsigned char)), - k), - d_k (k) -{ - if (d_k == 0) - throw std::out_of_range ("interpolation must be > 0"); -} - -gr_unpack_k_bits_bb::~gr_unpack_k_bits_bb () -{ -} - -int -gr_unpack_k_bits_bb::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - - int n = 0; - for (unsigned int i = 0; i < noutput_items/d_k; i++){ - unsigned int t = in[i]; - for (int j = d_k - 1; j >= 0; j--) - out[n++] = (t >> j) & 0x01; - } - - assert(n == noutput_items); - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.h b/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.h deleted file mode 100644 index c3ea28d3fa..0000000000 --- a/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio 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. - * - * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_UNPACK_K_BITS_BB_H -#define INCLUDED_GR_UNPACK_K_BITS_BB_H - -#include <gr_core_api.h> -#include <gr_sync_interpolator.h> - -class gr_unpack_k_bits_bb; -typedef boost::shared_ptr<gr_unpack_k_bits_bb> gr_unpack_k_bits_bb_sptr; -GR_CORE_API gr_unpack_k_bits_bb_sptr gr_make_unpack_k_bits_bb (unsigned k); - -class gr_unpack_k_bits_bb; - -/*! - * \brief Converts a byte with k relevent bits to k output bytes with 1 bit in the LSB. - * \ingroup converter_blk - */ -class GR_CORE_API gr_unpack_k_bits_bb : public gr_sync_interpolator -{ - private: - friend GR_CORE_API gr_unpack_k_bits_bb_sptr gr_make_unpack_k_bits_bb (unsigned k); - - gr_unpack_k_bits_bb (unsigned k); - - unsigned d_k; // number of relevent bits to unpack into k output bytes - - public: - ~gr_unpack_k_bits_bb (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.i b/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.i deleted file mode 100644 index de0f4b33e7..0000000000 --- a/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio 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. - * - * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,unpack_k_bits_bb) - -gr_unpack_k_bits_bb_sptr gr_make_unpack_k_bits_bb (int k) throw(std::exception); - -class gr_unpack_k_bits_bb : public gr_sync_interpolator -{ - private: - gr_unpack_k_bits_bb (int k); - - public: - ~gr_unpack_k_bits_bb (); -}; diff --git a/gnuradio-core/src/lib/io/CMakeLists.txt b/gnuradio-core/src/lib/io/CMakeLists.txt index 59ca06b5a2..23c019d63b 100644 --- a/gnuradio-core/src/lib/io/CMakeLists.txt +++ b/gnuradio-core/src/lib/io/CMakeLists.txt @@ -105,7 +105,6 @@ set(gr_core_io_triple_threats gr_wavfile_sink gr_tagged_file_sink gr_tagged_stream_to_pdu - gr_tuntap_pdu gr_socket_pdu ) diff --git a/gnuradio-core/src/lib/io/gr_pdu.h b/gnuradio-core/src/lib/io/gr_pdu.h index a5ae87db7f..53058ccb6c 100644 --- a/gnuradio-core/src/lib/io/gr_pdu.h +++ b/gnuradio-core/src/lib/io/gr_pdu.h @@ -23,17 +23,18 @@ #ifndef GR_PDU_H #define GR_PDU_H +#include <gr_core_api.h> #include <gr_complex.h> #include <gruel/pmt.h> -#define pdu_port_id pmt::mp("pdus") -#define pdu_length_tag pmt::mp("pdu_length") +#define PDU_PORT_ID pmt::mp("pdus") +#define PDU_LENGTH_TAG pmt::mp("pdu_length") enum gr_pdu_vector_type { pdu_byte, pdu_float, pdu_complex }; -size_t gr_pdu_itemsize(gr_pdu_vector_type type); -bool gr_pdu_type_matches(gr_pdu_vector_type type, pmt::pmt_t v); -pmt::pmt_t gr_pdu_make_vector(gr_pdu_vector_type type, const uint8_t* buf, size_t items); -gr_pdu_vector_type type_from_pmt(pmt::pmt_t vector); +GR_CORE_API size_t gr_pdu_itemsize(gr_pdu_vector_type type); +GR_CORE_API bool gr_pdu_type_matches(gr_pdu_vector_type type, pmt::pmt_t v); +GR_CORE_API pmt::pmt_t gr_pdu_make_vector(gr_pdu_vector_type type, const uint8_t* buf, size_t items); +GR_CORE_API gr_pdu_vector_type type_from_pmt(pmt::pmt_t vector); #endif diff --git a/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.cc b/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.cc index 9354a1366d..79011d8536 100644 --- a/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.cc +++ b/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.cc @@ -49,7 +49,7 @@ gr_pdu_to_tagged_stream::gr_pdu_to_tagged_stream (gr_pdu_vector_type t) gr_make_io_signature(1, 1, gr_pdu_itemsize(t))), d_vectortype(t), d_itemsize(gr_pdu_itemsize(t)) { - message_port_register_in(pdu_port_id); + message_port_register_in(PDU_PORT_ID); } gr_pdu_to_tagged_stream::~gr_pdu_to_tagged_stream() @@ -77,8 +77,8 @@ gr_pdu_to_tagged_stream::work(int noutput_items, if(noutput_items > 0){ // grab a message if one exists - //pmt::pmt_t msg( delete_head_nowait( pdu_port_id ) ); - pmt::pmt_t msg( delete_head_blocking( pdu_port_id ) ); + //pmt::pmt_t msg( delete_head_nowait( PDU_PORT_ID ) ); + pmt::pmt_t msg( delete_head_blocking( PDU_PORT_ID ) ); if(msg.get() == NULL ){ return nout; } @@ -99,7 +99,7 @@ gr_pdu_to_tagged_stream::work(int noutput_items, uint64_t offset = nitems_written(0) + nout; // add a tag for pdu length - add_item_tag(0, offset, pdu_length_tag, pmt::from_long( pmt::length(vect) ), pmt::mp(alias())); + add_item_tag(0, offset, PDU_LENGTH_TAG, pmt::from_long( pmt::length(vect) ), pmt::mp(alias())); // if we recieved metadata add it as tags if( !eq(meta, pmt::PMT_NIL) ){ diff --git a/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.cc b/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.cc index 3493f6a389..7daac6db26 100644 --- a/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.cc +++ b/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.cc @@ -49,7 +49,7 @@ gr_tagged_stream_to_pdu::gr_tagged_stream_to_pdu (gr_pdu_vector_type t) d_vectortype(t), d_itemsize(gr_pdu_itemsize(t)), d_inpdu(false), d_pdu_meta(pmt::PMT_NIL), d_pdu_vector(pmt::PMT_NIL) { - message_port_register_out(pdu_port_id); + message_port_register_out(PDU_PORT_ID); } gr_tagged_stream_to_pdu::~gr_tagged_stream_to_pdu() @@ -70,7 +70,7 @@ gr_tagged_stream_to_pdu::work(int noutput_items, get_tags_in_range(d_tags, 0, abs_N, abs_N+1); bool found_length_tag(false); for(d_tags_itr = d_tags.begin(); (d_tags_itr != d_tags.end()) && (!found_length_tag); d_tags_itr++){ - if( pmt::equal( (*d_tags_itr).key, pdu_length_tag ) ){ + if( pmt::equal( (*d_tags_itr).key, PDU_LENGTH_TAG ) ){ if( (*d_tags_itr).offset != abs_N ){ throw std::runtime_error("expected next pdu length tag on a different item..."); } @@ -91,7 +91,7 @@ gr_tagged_stream_to_pdu::work(int noutput_items, // copy any tags in this range into our meta object get_tags_in_range(d_tags, 0, abs_N, abs_N+ncopy); for(d_tags_itr = d_tags.begin(); d_tags_itr != d_tags.end(); d_tags_itr++){ - if( ! equal( (*d_tags_itr).key, pdu_length_tag ) ){ + if( ! equal( (*d_tags_itr).key, PDU_LENGTH_TAG ) ){ d_pdu_meta = dict_add(d_pdu_meta, (*d_tags_itr).key, (*d_tags_itr).value); } } @@ -127,7 +127,7 @@ void gr_tagged_stream_to_pdu::send_message(){ } pmt::pmt_t msg = pmt::cons( d_pdu_meta, d_pdu_vector ); - message_port_pub( pdu_port_id, msg ); + message_port_pub( PDU_PORT_ID, msg ); d_pdu_meta = pmt::PMT_NIL; d_pdu_vector = pmt::PMT_NIL; diff --git a/gnuradio-core/src/lib/io/gr_tuntap_pdu.cc b/gnuradio-core/src/lib/io/gr_tuntap_pdu.cc deleted file mode 100644 index 8dd4b18a10..0000000000 --- a/gnuradio-core/src/lib/io/gr_tuntap_pdu.cc +++ /dev/null @@ -1,145 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio 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. - * - * GNU Radio 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 GNU Radio; 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 <gr_tuntap_pdu.h> -#include <gr_io_signature.h> -#include <cstdio> -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <stdexcept> -#include <string.h> -#include <iostream> -#include <gr_pdu.h> -#include <boost/format.hpp> - -#if (defined(linux) || defined(__linux) || defined(__linux__)) - -#include <sys/ioctl.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> - -#include <arpa/inet.h> -#include <linux/if.h> - - -// public constructor that returns a shared_ptr - -gr_tuntap_pdu_sptr -gr_make_tuntap_pdu (std::string dev, int MTU) -{ - return gnuradio::get_initial_sptr(new gr_tuntap_pdu(dev, MTU)); -} - -gr_tuntap_pdu::gr_tuntap_pdu (std::string dev, int MTU) - : gr_stream_pdu_base(MTU) -{ - - // make the tuntap - char dev_cstr[1024]; - memset(dev_cstr, 0x00, 1024); - strncpy(dev_cstr, dev.c_str(), std::min(sizeof(dev_cstr), dev.size())); - d_fd = tun_alloc(dev_cstr); - if(d_fd <= 0){ - throw std::runtime_error("TunTap make: tun_alloc failed (are you running as root?)"); - } - - std::cout << boost::format( - "Allocated virtual ethernet interface: %s\n" - "You must now use ifconfig to set its IP address. E.g.,\n" - " $ sudo ifconfig %s 192.168.200.1\n" - "Be sure to use a different address in the same subnet for each machine.\n" - ) % dev % dev << std::endl; - - // set up output message port - message_port_register_out(pmt::mp("pdus")); - start_rxthread(pmt::mp("pdus")); - - // set up input message port - message_port_register_in(pmt::mp("pdus")); - set_msg_handler(pmt::mp("pdus"), boost::bind(&gr_tuntap_pdu::send, this, _1)); -} - - -int gr_tuntap_pdu::tun_alloc(char *dev, int flags) { - struct ifreq ifr; - int fd, err; - const char *clonedev = "/dev/net/tun"; - - /* Arguments taken by the function: - * - * char *dev: the name of an interface (or '\0'). MUST have enough - * space to hold the interface name if '\0' is passed - * int flags: interface flags (eg, IFF_TUN etc.) - */ - - /* open the clone device */ - if( (fd = open(clonedev, O_RDWR)) < 0 ) { - return fd; - } - - /* preparation of the struct ifr, of type "struct ifreq" */ - memset(&ifr, 0, sizeof(ifr)); - - ifr.ifr_flags = flags; /* IFF_TUN or IFF_TAP, plus maybe IFF_NO_PI */ - - if (*dev) { - /* if a device name was specified, put it in the structure; otherwise, - * the kernel will try to allocate the "next" device of the - * specified type */ - strncpy(ifr.ifr_name, dev, IFNAMSIZ); - } - - /* try to create the device */ - if( (err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 ) { - close(fd); - return err; - } - - /* if the operation was successful, write back the name of the - * interface to the variable "dev", so the caller can know - * it. Note that the caller MUST reserve space in *dev (see calling - * code below) */ - strcpy(dev, ifr.ifr_name); - - /* this is the special file descriptor that the caller will use to talk - * with the virtual interface */ - return fd; -} - -#else //if not linux - -gr_block_sptr -gr_make_tuntap_pdu(std::string dev, int MTU) -{ - gr_block_sptr rv; - throw std::runtime_error("tuntap only implemented on linux"); - return rv; -} - -#endif diff --git a/gnuradio-core/src/lib/io/gr_tuntap_pdu.h b/gnuradio-core/src/lib/io/gr_tuntap_pdu.h deleted file mode 100644 index 18c83f42b2..0000000000 --- a/gnuradio-core/src/lib/io/gr_tuntap_pdu.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio 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. - * - * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_TUNTAP_PDU_H -#define INCLUDED_GR_TUNTAP_PDU_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_message.h> -#include <gr_msg_queue.h> -#include <gr_stream_pdu_base.h> - -#if (defined(linux) || defined(__linux) || defined(__linux__)) - -#include <linux/if_tun.h> - -class gr_tuntap_pdu; -typedef boost::shared_ptr<gr_tuntap_pdu> gr_tuntap_pdu_sptr; - -GR_CORE_API gr_tuntap_pdu_sptr gr_make_tuntap_pdu (std::string dev, int MTU=10000); - -/*! - * \brief Gather received items into messages and insert into msgq - * \ingroup sink_blk - */ -class GR_CORE_API gr_tuntap_pdu : public gr_stream_pdu_base -{ - private: - friend GR_CORE_API gr_tuntap_pdu_sptr - gr_make_tuntap_pdu(std::string dev, int MTU); - int tun_alloc(char* dev, int flags = IFF_TAP | IFF_NO_PI); - std::string d_dev; - protected: - gr_tuntap_pdu (std::string dev, int MTU=10000); - - public: - ~gr_tuntap_pdu () {} - -}; - -#else // if not linux - -class gr_tuntap_pdu -{ -private: - gr_tuntap_pdu() {}; -public: - ~gr_tuntap_pdu() {}; -}; - -GR_CORE_API gr_block_sptr gr_make_tuntap_pdu (std::string dev, int MTU=0); - -#endif - -#endif /* INCLUDED_GR_TUNTAP_PDU_H */ diff --git a/gnuradio-core/src/lib/io/gr_tuntap_pdu.i b/gnuradio-core/src/lib/io/gr_tuntap_pdu.i deleted file mode 100644 index 589bbc3853..0000000000 --- a/gnuradio-core/src/lib/io/gr_tuntap_pdu.i +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio 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. - * - * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,tuntap_pdu); - -%{ -#include <gr_tuntap_pdu.h> -%} - -%include "gr_tuntap_pdu.h" - diff --git a/gnuradio-core/src/lib/io/io.i b/gnuradio-core/src/lib/io/io.i index e2de4eb976..33cc906e92 100644 --- a/gnuradio-core/src/lib/io/io.i +++ b/gnuradio-core/src/lib/io/io.i @@ -49,7 +49,6 @@ #include <gr_tagged_stream_to_pdu.h> #include <gr_message_debug.h> #include <gr_pdu.h> -#include <gr_tuntap_pdu.h> #include <gr_socket_pdu.h> %} @@ -77,7 +76,6 @@ %include "gr_tagged_stream_to_pdu.i" %include "gr_message_debug.i" %include "gr_pdu.i" -%include "gr_tuntap_pdu.i" %include "gr_socket_pdu.i" diff --git a/gnuradio-core/src/lib/runtime/gr_block.h b/gnuradio-core/src/lib/runtime/gr_block.h index 034f6136d9..acd938080a 100644 --- a/gnuradio-core/src/lib/runtime/gr_block.h +++ b/gnuradio-core/src/lib/runtime/gr_block.h @@ -628,6 +628,12 @@ class GR_CORE_API gr_block : public gr_basic_block { std::vector<long> d_max_output_buffer; std::vector<long> d_min_output_buffer; + /*! Used by block's setters and work functions to make + * setting/resetting of parameters thread-safe. + * + * Used by calling gruel::scoped_lock l(d_setlock); + */ + gruel::mutex d_setlock; // These are really only for internal use, but leaving them public avoids // having to work up an ever-varying list of friend GR_CORE_APIs diff --git a/gnuradio-core/src/lib/runtime/gr_top_block.cc b/gnuradio-core/src/lib/runtime/gr_top_block.cc index e5859768de..c6118bcfdd 100644 --- a/gnuradio-core/src/lib/runtime/gr_top_block.cc +++ b/gnuradio-core/src/lib/runtime/gr_top_block.cc @@ -138,13 +138,15 @@ gr_top_block::setup_rpc() "items", "Max number of output items", RPC_PRIVLVL_MIN, DISPNULL))); - add_rpc_variable( - rpcbasic_sptr(new rpcbasic_register_get<gr_top_block, std::string>( - alias(), "edge list", - &gr_top_block::edge_list, - pmt::mp(""), pmt::mp(""), pmt::mp(""), - "edges", "List of edges in the graph", - RPC_PRIVLVL_MIN, DISPNULL))); + if(gr_prefs::singleton()->get_bool("ControlPort", "edges_list", false)) { + add_rpc_variable( + rpcbasic_sptr(new rpcbasic_register_get<gr_top_block, std::string>( + alias(), "edge list", + &gr_top_block::edge_list, + pmt::mp(""), pmt::mp(""), pmt::mp(""), + "edges", "List of edges in the graph", + RPC_PRIVLVL_MIN, DISPNULL))); + } // Setters add_rpc_variable( diff --git a/gnuradio-core/src/python/gnuradio/ctrlport/GrDataPlotter.py b/gnuradio-core/src/python/gnuradio/ctrlport/GrDataPlotter.py index 27858b575b..f797271970 100644 --- a/gnuradio-core/src/python/gnuradio/ctrlport/GrDataPlotter.py +++ b/gnuradio-core/src/python/gnuradio/ctrlport/GrDataPlotter.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks import sys, time try: @@ -31,34 +32,68 @@ except ImportError: print "Error: Program requires PyQt4 and gr-qtgui." sys.exit(1) -class GrDataPlotterC(gr.top_block): - def __init__(self, name, rate, pmin=None, pmax=None, stripchart=False): +class GrDataPlotParent(gr.top_block, QtGui.QWidget): + # Setup signals + plotupdated = QtCore.pyqtSignal(QtGui.QWidget) + + def __init__(self, name, rate, pmin=None, pmax=None): gr.top_block.__init__(self) + QtGui.QWidget.__init__(self, None) - self._stripchart = stripchart self._name = name self._npts = 500 - samp_rate = 1.0 + self._rate = rate + self.knobnames = [name,] + + self.layout = QtGui.QVBoxLayout() + self.setLayout(self.layout) + + self.setAcceptDrops(True) - self._last_data = self._npts*[0,] - self._data_len = 0 + def _setup(self, nconnections): + self.stop() + self.wait() - self.src = gr.vector_source_c([]) - self.thr = gr.throttle(gr.sizeof_gr_complex, rate) - self.snk = qtgui.time_sink_c(self._npts, samp_rate, - self._name, 1) - self.snk.enable_autoscale(True) + if(self.layout.count() > 0): + # Remove and disconnect. Making sure no references to snk + # remain so that the plot gets deleted. + self.layout.removeWidget(self.py_window) + self.disconnect(self.thr, (self.snk, 0)) + self.disconnect(self.src[0], self.thr) + for n in xrange(1, self._ncons): + self.disconnect(self.src[n], (self.snk,n)) - self.connect(self.src, self.thr, (self.snk, 0)) + self._ncons = nconnections + self._data_len = self._ncons*[0,] - self.snk.set_line_label(0, "Real") - self.snk.set_line_label(1, "Imag") + self.thr = blocks.throttle(self._datasize, self._rate) + self.snk = self.get_qtsink() + + self.connect(self.thr, (self.snk, 0)) + + self._last_data = [] + self.src = [] + for n in xrange(self._ncons): + self.set_line_label(n, self.knobnames[n]) + + self._last_data.append(int(self._npts)*[0,]) + self.src.append(self.get_vecsource()) + + if(n == 0): + self.connect(self.src[n], self.thr) + else: + self.connect(self.src[n], (self.snk,n)) self.py_window = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget) + self.layout.addWidget(self.py_window) + def __del__(self): pass + def close(self): + self.snk.close() + def qwidget(self): return self.py_window @@ -68,162 +103,172 @@ class GrDataPlotterC(gr.top_block): def semilogy(self, en=True): self.snk.enable_semilogy(en) - def stem(self, en=True): - self.snk.enable_stem_plot(en) + def dragEnterEvent(self, e): + e.acceptProposedAction() + + def dropEvent(self, e): + if(e.mimeData().hasFormat("text/plain")): + data = str(e.mimeData().text()) + + #"PlotData:{0}:{1}".format(tag, iscomplex) + datalst = data.split(":::") + tag = datalst[0] + name = datalst[1] + cpx = datalst[2] != "0" + + if(tag == "PlotData" and cpx == self._iscomplex): + self.knobnames.append(name) + + # create a new qwidget plot with the new data stream. + self._setup(len(self.knobnames)) + + # emit that this plot has been updated with a new qwidget. + self.plotupdated.emit(self) + + e.acceptProposedAction() + + def data_to_complex(self, data): + if(self._iscomplex): + data_r = data[0::2] + data_i = data[1::2] + data = [complex(r,i) for r,i in zip(data_r, data_i)] + return data def update(self, data): # Ask GUI if there has been a change in nsamps - npts = self.snk.nsamps() + npts = self.get_npts() if(self._npts != npts): # Adjust buffers to accomodate new settings - if(npts < self._npts): - if(self._data_len < npts): - self._last_data = self._last_data[0:npts] + for n in xrange(self._ncons): + if(npts < self._npts): + if(self._data_len[n] < npts): + self._last_data[n] = self._last_data[n][0:npts] + else: + self._last_data[n] = self._last_data[n][self._data_len[n]-npts:self._data_len[n]] + self._data_len[n] = npts else: - self._last_data = self._last_data[self._data_len-npts:self._data_len] - self._data_len = npts - else: - self._last_data += (npts - self._npts)*[0,] + self._last_data[n] += (npts - self._npts)*[0,] self._npts = npts self.snk.reset() - + if(self._stripchart): # Update the plot data depending on type - if(type(data) == list): - data_r = data[0::2] - data_i = data[1::2] - data = [complex(r,i) for r,i in zip(data_r, data_i)] - if(len(data) > self._npts): - self.src.set_data(data) - self._last_data = data[-self._npts:] - else: - newdata = self._last_data[-(self._npts-len(data)):] - newdata += data - self.src.set_data(newdata) - self._last_data = newdata - - else: # single value update - if(self._data_len < self._npts): - self._last_data[self._data_len] = data - self._data_len += 1 - else: - self._last_data = self._last_data[1:] - self._last_data.append(data) - self.src.set_data(self._last_data) + for n in xrange(self._ncons): + if(type(data[n]) == list): + data[n] = self.data_to_complex(data[n]) + if(len(data[n]) > self._npts): + self.src[n].set_data(data[n]) + self._last_data[n] = data[n][-self._npts:] + else: + newdata = self._last_data[n][-(self._npts-len(data)):] + newdata += data[n] + self.src[n].set_data(newdata) + self._last_data[n] = newdata + + else: # single value update + if(self._iscomplex): + data[n] = complex(data[n][0], data[n][1]) + if(self._data_len[n] < self._npts): + self._last_data[n][self._data_len[n]] = data[n] + self._data_len[n] += 1 + else: + self._last_data[n] = self._last_data[n][1:] + self._last_data[n].append(data[n]) + self.src[n].set_data(self._last_data[n]) else: - if(type(data) != list): - data = [data,] - self.src.set_data(data) + for n in xrange(self._ncons): + if(type(data[n]) != list): + data[n] = [data[n],] + data[n] = self.data_to_complex(data[n]) + self.src[n].set_data(data[n]) + + -class GrDataPlotterF(gr.top_block): +class GrDataPlotterC(GrDataPlotParent): def __init__(self, name, rate, pmin=None, pmax=None, stripchart=False): - gr.top_block.__init__(self) + GrDataPlotParent.__init__(self, name, rate, pmin, pmax) self._stripchart = stripchart - self._name = name - self._npts = 500 - samp_rate = 1.0 + self._datasize = gr.sizeof_gr_complex + self._iscomplex = True - self._last_data = self._npts*[0,] - self._data_len = 0 + self._setup(1) - self.src = gr.vector_source_f([]) - self.thr = gr.throttle(gr.sizeof_float, rate) - self.snk = qtgui.time_sink_f(self._npts, samp_rate, - self._name, 1) - self.snk.enable_autoscale(True) + def stem(self, en=True): + self.snk.enable_stem_plot(en) - self.connect(self.src, self.thr, (self.snk, 0)) + def get_qtsink(self): + snk = qtgui.time_sink_c(self._npts, 1.0, + self._name, self._ncons) + snk.enable_autoscale(True) + return snk - self.py_window = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget) + def get_vecsource(self): + return gr.vector_source_c([]) - def __del__(self): - pass + def get_npts(self): + self._npts = self.snk.nsamps() + return self._npts - def qwidget(self): - return self.py_window + def set_line_label(self, n, name): + self.snk.set_line_label(2*n+0, "Re{" + self.knobnames[n] + "}") + self.snk.set_line_label(2*n+1, "Im{" + self.knobnames[n] + "}") - def name(self): - return self._name - def semilogy(self, en=True): - self.snk.enable_semilogy(en) +class GrDataPlotterF(GrDataPlotParent): + def __init__(self, name, rate, pmin=None, pmax=None, stripchart=False): + GrDataPlotParent.__init__(self, name, rate, pmin, pmax) - def stem(self, en=True): - self.snk.enable_stem_plot(en) + self._stripchart = stripchart + self._datasize = gr.sizeof_float + self._iscomplex = False - def update(self, data): - # Ask GUI if there has been a change in nsamps - npts = self.snk.nsamps() - if(self._npts != npts): + self._setup(1) - # Adjust buffers to accomodate new settings - if(npts < self._npts): - if(self._data_len < npts): - self._last_data = self._last_data[0:npts] - else: - self._last_data = self._last_data[self._data_len-npts:self._data_len] - self._data_len = npts - else: - self._last_data += (npts - self._npts)*[0,] - self._npts = npts - self.snk.reset() + def stem(self, en=True): + self.snk.enable_stem_plot(en) - if(self._stripchart): - # Update the plot data depending on type - if(type(data) == list): - if(len(data) > self._npts): - self.src.set_data(data) - self._last_data = data[-self._npts:] - else: - newdata = self._last_data[-(self._npts-len(data)):] - newdata += data - self.src.set_data(newdata) - self._last_data = newdata - - else: # single value update - if(self._data_len < self._npts): - self._last_data[self._data_len] = data - self._data_len += 1 - else: - self._last_data = self._last_data[1:] - self._last_data.append(data) - self.src.set_data(self._last_data) - else: - if(type(data) != list): - data = [data,] - self.src.set_data(data) + def get_qtsink(self): + snk = qtgui.time_sink_f(self._npts, 1.0, + self._name, self._ncons) + snk.enable_autoscale(True) + return snk + + def get_vecsource(self): + return gr.vector_source_f([]) + + def get_npts(self): + self._npts = self.snk.nsamps() + return self._npts + + def set_line_label(self, n, name): + self.snk.set_line_label(n, self.knobnames[n]) -class GrDataPlotterConst(gr.top_block): - def __init__(self, name, rate, pmin=None, pmax=None): - gr.top_block.__init__(self) - - self._name = name - self._npts = 500 - samp_rate = 1.0 - self._last_data = self._npts*[0,] - self._data_len = 0 - - self.src = gr.vector_source_c([]) - self.thr = gr.throttle(gr.sizeof_gr_complex, rate) - self.snk = qtgui.const_sink_c(self._npts, - self._name, 1) - self.snk.enable_autoscale(True) +class GrDataPlotterConst(GrDataPlotParent): + def __init__(self, name, rate, pmin=None, pmax=None): + GrDataPlotParent.__init__(self, name, rate, pmin, pmax) - self.connect(self.src, self.thr, (self.snk, 0)) + self._datasize = gr.sizeof_gr_complex + self._stripchart = False + self._iscomplex = True - self.py_window = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget) + self._setup(1) - def __del__(self): - pass + def get_qtsink(self): + snk = qtgui.const_sink_c(self._npts, + self._name, + self._ncons) + snk.enable_autoscale(True) + return snk - def qwidget(self): - return self.py_window + def get_vecsource(self): + return gr.vector_source_c([]) - def name(self): - return self._name + def get_npts(self): + self._npts = self.snk.nsamps() + return self._npts def scatter(self, en=True): if(en): @@ -231,327 +276,133 @@ class GrDataPlotterConst(gr.top_block): else: self.snk.set_line_style(0, 1) - def update(self, data): - # Ask GUI if there has been a change in nsamps - npts = self.snk.nsamps() - if(self._npts != npts): - - # Adjust buffers to accomodate new settings - if(npts < self._npts): - if(self._data_len < npts): - self._last_data = self._last_data[0:npts] - else: - self._last_data = self._last_data[self._data_len-npts:self._data_len] - self._data_len = npts - else: - self._last_data += (npts - self._npts)*[0,] - self._npts = npts - self.snk.reset() - - # Update the plot data depending on type - if(type(data) == list): - data_r = data[0::2] - data_i = data[1::2] - data = [complex(r,i) for r,i in zip(data_r, data_i)] - if(len(data) > self._npts): - self.src.set_data(data) - self._last_data = data[-self._npts:] - else: - newdata = self._last_data[-(self._npts-len(data)):] - newdata += data - self.src.set_data(newdata) - self._last_data = newdata - - else: # single value update - if(self._data_len < self._npts): - self._last_data[self._data_len] = data - self._data_len += 1 - else: - self._last_data = self._last_data[1:] - self._last_data.append(data) - self.src.set_data(self._last_data) + def set_line_label(self, n, name): + self.snk.set_line_label(n, self.knobnames[n]) -class GrDataPlotterPsdC(gr.top_block): +class GrDataPlotterPsdC(GrDataPlotParent): def __init__(self, name, rate, pmin=None, pmax=None): - gr.top_block.__init__(self) + GrDataPlotParent.__init__(self, name, rate, pmin, pmax) - self._name = name - self._samp_rate = 1.0 - self._fftsize = 2048 + self._datasize = gr.sizeof_gr_complex + self._stripchart = True + self._iscomplex = True + + self._npts = 2048 self._wintype = gr.firdes.WIN_BLACKMAN_hARRIS self._fc = 0 - - self._last_data = self._fftsize*[0,] - self._data_len = 0 - self.src = gr.vector_source_c([]) - self.thr = gr.throttle(gr.sizeof_gr_complex, rate) - self.snk = qtgui.freq_sink_c(self._fftsize, self._wintype, - self._fc, self._samp_rate, - self._name, 1) - self.snk.enable_autoscale(True) + self._setup(1) - self.connect(self.src, self.thr, (self.snk, 0)) + def get_qtsink(self): + snk = qtgui.freq_sink_c(self._npts, self._wintype, + self._fc, 1.0, + self._name, + self._ncons) + snk.enable_autoscale(True) + return snk - self.py_window = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget) - - def __del__(self): - pass + def get_vecsource(self): + return gr.vector_source_c([]) - def qwidget(self): - return self.py_window + def get_npts(self): + self._npts = self.snk.fft_size() + return self._npts - def name(self): - return self._name + def set_line_label(self, n, name): + self.snk.set_line_label(n, self.knobnames[n]) - def update(self, data): - # Ask GUI if there has been a change in nsamps - fftsize = self.snk.fft_size() - if(self._fftsize != fftsize): - - # Adjust buffers to accomodate new settings - if(fftsize < self._fftsize): - if(self._data_len < fftsize): - self._last_data = self._last_data[0:fftsize] - else: - self._last_data = self._last_data[self._data_len-fftsize:self._data_len] - self._data_len = fftsize - else: - self._last_data += (fftsize - self._fftsize)*[0,] - self._fftsize = fftsize - self.snk.reset() - - # Update the plot data depending on type - if(type(data) == list): - data_r = data[0::2] - data_i = data[1::2] - data = [complex(r,i) for r,i in zip(data_r, data_i)] - if(len(data) > self._fftsize): - self.src.set_data(data) - self._last_data = data[-self._fftsize:] - else: - newdata = self._last_data[-(self._fftsize-len(data)):] - newdata += data - self.src.set_data(newdata) - self._last_data = newdata - - else: # single value update - if(self._data_len < self._fftsize): - self._last_data[self._data_len] = data - self._data_len += 1 - else: - self._last_data = self._last_data[1:] - self._last_data.append(data) - self.src.set_data(self._last_data) -class GrDataPlotterPsdF(gr.top_block): +class GrDataPlotterPsdF(GrDataPlotParent): def __init__(self, name, rate, pmin=None, pmax=None): - gr.top_block.__init__(self) + GrDataPlotParent.__init__(self, name, rate, pmin, pmax) - self._name = name - self._samp_rate = 1.0 - self._fftsize = 2048 + self._datasize = gr.sizeof_float + self._stripchart = True + self._iscomplex = False + + self._npts = 2048 self._wintype = gr.firdes.WIN_BLACKMAN_hARRIS self._fc = 0 - - self._last_data = self._fftsize*[0,] - self._data_len = 0 - self.src = gr.vector_source_f([]) - self.thr = gr.throttle(gr.sizeof_float, rate) - self.snk = qtgui.freq_sink_f(self._fftsize, self._wintype, - self._fc, self._samp_rate, - self._name, 1) - self.snk.enable_autoscale(True) + self._setup(1) - self.connect(self.src, self.thr, (self.snk, 0)) + def get_qtsink(self): + snk = qtgui.freq_sink_f(self._npts, self._wintype, + self._fc, 1.0, + self._name, + self._ncons) + snk.enable_autoscale(True) + return snk - self.py_window = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget) - - def __del__(self): - pass + def get_vecsource(self): + return gr.vector_source_f([]) - def qwidget(self): - return self.py_window + def get_npts(self): + self._npts = self.snk.fft_size() + return self._npts - def name(self): - return self._name + def set_line_label(self, n, name): + self.snk.set_line_label(n, self.knobnames[n]) - def update(self, data): - # Ask GUI if there has been a change in nsamps - fftsize = self.snk.fft_size() - if(self._fftsize != fftsize): - - # Adjust buffers to accomodate new settings - if(fftsize < self._fftsize): - if(self._data_len < fftsize): - self._last_data = self._last_data[0:fftsize] - else: - self._last_data = self._last_data[self._data_len-fftsize:self._data_len] - self._data_len = fftsize - else: - self._last_data += (fftsize - self._fftsize)*[0,] - self._fftsize = fftsize - self.snk.reset() - - # Update the plot data depending on type - if(type(data) == list): - data_r = data[0::2] - data_i = data[1::2] - data = [complex(r,i) for r,i in zip(data_r, data_i)] - if(len(data) > self._fftsize): - self.src.set_data(data) - self._last_data = data[-self._fftsize:] - else: - newdata = self._last_data[-(self._fftsize-len(data)):] - newdata += data - self.src.set_data(newdata) - self._last_data = newdata - - else: # single value update - if(self._data_len < self._fftsize): - self._last_data[self._data_len] = data - self._data_len += 1 - else: - self._last_data = self._last_data[1:] - self._last_data.append(data) - self.src.set_data(self._last_data) - -class GrTimeRasterF(gr.top_block): +class GrTimeRasterF(GrDataPlotParent): def __init__(self, name, rate, pmin=None, pmax=None): - gr.top_block.__init__(self) - - self._name = name - self._npts = 100 - self._rows = 100 - samp_rate = 1.0 - - self._last_data = self._npts*[0,] - self._data_len = 0 + GrDataPlotParent.__init__(self, name, rate, pmin, pmax) - self.src = gr.vector_source_f([]) - self.thr = gr.throttle(gr.sizeof_float, rate) - self.snk = qtgui.time_raster_sink_f(samp_rate, self._npts, self._rows, - [], [], self._name, 1) + self._npts = 10 + self._rows = 40 - self.connect(self.src, self.thr, (self.snk, 0)) + self._datasize = gr.sizeof_float + self._stripchart = False + self._iscomplex = False - self.py_window = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget) + self._setup(1) - def __del__(self): - pass + def get_qtsink(self): + snk = qtgui.time_raster_sink_f(1.0, self._npts, self._rows, + [], [], self._name, + self._ncons) + return snk - def qwidget(self): - return self.py_window + def get_vecsource(self): + return gr.vector_source_f([]) - def name(self): - return self._name + def get_npts(self): + self._npts = self.snk.num_cols() + return self._npts - def update(self, data): - # Ask GUI if there has been a change in nsamps - npts = int(self.snk.num_cols()) - if(self._npts != npts): - - # Adjust buffers to accomodate new settings - if(npts < self._npts): - if(self._data_len < npts): - self._last_data = self._last_data[0:npts] - else: - self._last_data = self._last_data[self._data_len-npts:self._data_len] - self._data_len = npts - else: - self._last_data += (npts - self._npts)*[0,] - self._npts = npts - self.snk.reset() - - # Update the plot data depending on type - if(type(data) == list): - if(len(data) > self._npts): - self.src.set_data(data) - self._last_data = data[-self._npts:] - else: - newdata = self._last_data[-(self._npts-len(data)):] - newdata += data - self.src.set_data(newdata) - self._last_data = newdata - - else: # single value update - if(self._data_len < self._npts): - self._last_data[self._data_len] = data - self._data_len += 1 - else: - self._last_data = self._last_data[1:] - self._last_data.append(data) - self.src.set_data(self._last_data) + def set_line_label(self, n, name): + self.snk.set_line_label(n, self.knobnames[n]) -class GrTimeRasterB(gr.top_block): +class GrTimeRasterB(GrDataPlotParent): def __init__(self, name, rate, pmin=None, pmax=None): - gr.top_block.__init__(self) - - self._name = name - self._npts = 100 - self._rows = 100 - samp_rate = 1.0 + GrDataPlotParent.__init__(self, name, rate, pmin, pmax) - self._last_data = self._npts*[0,] - self._data_len = 0 + self._npts = 10 + self._rows = 40 - self.src = gr.vector_source_b([]) - self.thr = gr.throttle(gr.sizeof_char, rate) - self.snk = qtgui.time_raster_sink_b(samp_rate, self._npts, self._rows, - [], [], self._name, 1) + self._datasize = gr.sizeof_char + self._stripchart = False + self._iscomplex = False - self.connect(self.src, self.thr, (self.snk, 0)) + self._setup(1) - self.py_window = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget) + def get_qtsink(self): + snk = qtgui.time_raster_sink_b(1.0, self._npts, self._rows, + [], [], self._name, + self._ncons) + return snk - def __del__(self): - pass - - def qwidget(self): - return self.py_window - - def name(self): - return self._name + def get_vecsource(self): + return gr.vector_source_b([]) - def update(self, data): - # Ask GUI if there has been a change in nsamps - npts = self.snk.num_cols() - if(self._npts != npts): + def get_npts(self): + self._npts = self.snk.num_cols() + return self._npts - # Adjust buffers to accomodate new settings - if(npts < self._npts): - if(self._data_len < npts): - self._last_data = self._last_data[0:npts] - else: - self._last_data = self._last_data[self._data_len-npts:self._data_len] - self._data_len = npts - else: - self._last_data += (npts - self._npts)*[0,] - self._npts = npts - self.snk.reset() - - # Update the plot data depending on type - if(type(data) == list): - if(len(data) > self._npts): - self.src.set_data(data) - self._last_data = data[-self._npts:] - else: - newdata = self._last_data[-(self._npts-len(data)):] - newdata += data - self.src.set_data(newdata) - self._last_data = newdata - - else: # single value update - if(self._data_len < self._npts): - self._last_data[self._data_len] = data - self._data_len += 1 - else: - self._last_data = self._last_data[1:] - self._last_data.append(data) - self.src.set_data(self._last_data) + def set_line_label(self, n, name): + self.snk.set_line_label(n, self.knobnames[n]) class GrDataPlotterValueTable: diff --git a/gnuradio-core/src/python/gnuradio/ctrlport/gr-ctrlport-monitor b/gnuradio-core/src/python/gnuradio/ctrlport/gr-ctrlport-monitor index 60a810b04e..e71cd92ab7 100755 --- a/gnuradio-core/src/python/gnuradio/ctrlport/gr-ctrlport-monitor +++ b/gnuradio-core/src/python/gnuradio/ctrlport/gr-ctrlport-monitor @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -24,7 +24,7 @@ from gnuradio import gr, ctrlport from PyQt4 import QtCore,Qt import PyQt4.QtGui as QtGui -import sys, time +import os, sys, time import Ice from gnuradio.ctrlport.IceRadioClient import * @@ -55,7 +55,7 @@ class MAINWindow(QtGui.QMainWindow): def __init__(self, radio, port, interface): super(MAINWindow, self).__init__() - self.updateRate = 2000; + self.updateRate = 1000; self.conns = [] self.plots = [] self.knobprops = [] @@ -83,6 +83,11 @@ class MAINWindow(QtGui.QMainWindow): icon = QtGui.QIcon(ctrlport.__path__[0] + "/icon.png" ) self.setWindowIcon(icon) + # Locally turn off ControlPort export from GR. This prevents + # our GR-based plotters from launching their own ControlPort + # instance (and possibly causing a port collision if one has + # been specified). + os.environ['GR_CONF_CONTROLPORT_ON'] = 'False' def setUpdateRate(self,nur): self.updateRate = int(nur); @@ -217,17 +222,55 @@ class MAINWindow(QtGui.QMainWindow): else: self.newPlotPsdC(tag, uid, title) + def startDrag(self, e): + drag = QtGui.QDrag(self) + mime_data = QtCore.QMimeData() + + tag = str(e.text(0)) + tree = e.treeWidget().parent() + knobprop = self.knobprops[tree.uid][tag] + disp = knobprop.display + iscomplex = (disp & gr.DISPOPTCPLX) or (disp & gr.DISPXY) + + if(disp != gr.DISPNULL): + data = "PlotData:::{0}:::{1}".format(tag, iscomplex) + else: + data = "OtherData:::{0}:::{1}".format(tag, iscomplex) + + mime_data.setText(data) + drag.setMimeData(mime_data) + + drop = drag.start() + def createPlot(self, plot, uid, title): plot.start() self.plots[uid].append(plot) - self.mdiArea.addSubWindow(plot.qwidget()) - plot.qwidget().setWindowTitle("{0}: {1}".format(title, plot.name())) + self.mdiArea.addSubWindow(plot) + plot.setWindowTitle("{0}: {1}".format(title, plot.name())) self.connect(plot.qwidget(), QtCore.SIGNAL('destroyed(QObject*)'), self.destroyPlot) - plot.qwidget().show() + # when the plot is updated via drag-and-drop, we need to be + # notified of the new qwidget that's created so we can + # properly destroy it. + plot.plotupdated.connect(self.plotUpdated) + + plot.show() + + def plotUpdated(self, q): + # the plot has been updated with a new qwidget; make sure this + # gets dies to the destroyPlot function. + for i, plots in enumerate(self.plots): + for p in plots: + if(p == q): + #plots.remove(p) + #plots.append(q) + self.connect(q.qwidget(), + QtCore.SIGNAL('destroyed(QObject*)'), + self.destroyPlot) + break def destroyPlot(self, obj): for plots in self.plots: @@ -275,7 +318,9 @@ class MAINWindow(QtGui.QMainWindow): def update(self, knobs, uid): #sys.stderr.write("KNOB KEYS: {0}\n".format(knobs.keys())) for plot in self.plots[uid]: - data = knobs[plot.name()].value + data = [] + for n in plot.knobnames: + data.append(knobs[n].value) plot.update(data) plot.stop() plot.wait() @@ -639,7 +684,7 @@ class MForm(QtGui.QWidget): self.table.treeWidget.setEditTriggers(QtGui.QAbstractItemView.EditKeyPressed) self.table.treeWidget.setSortingEnabled(True) self.table.treeWidget.setDragEnabled(True) - + # add things to layouts self.horizontalLayout.addWidget(self.table.treeWidget) @@ -657,6 +702,11 @@ class MForm(QtGui.QWidget): QtCore.SIGNAL('itemDoubleClicked(QTreeWidgetItem*, int)'), self.parent.newSub); + # Allow drag/drop event from table item to plotter + self.connect(self.table.treeWidget, + QtCore.SIGNAL('itemPressed(QTreeWidgetItem*, int)'), + self.parent.startDrag) + def openMenu(self, pos): index = self.table.treeWidget.selectedIndexes() item = self.table.treeWidget.itemFromIndex(index[0]) diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_pack_k_bits.py b/gnuradio-core/src/python/gnuradio/gr/qa_pack_k_bits.py deleted file mode 100755 index 25fc5e9fcc..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_pack_k_bits.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2006,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio 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. -# -# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest -import random - -class test_pack(gr_unittest.TestCase): - - def setUp(self): - self.tb = gr.top_block () - - def tearDown(self): - self.tb = None - - def test_001(self): - src_data = (1,0,1,1,0,1,1,0) - expected_results = (1,0,1,1,0,1,1,0) - src = gr.vector_source_b(src_data,False) - op = gr.pack_k_bits_bb(1) - dst = gr.vector_sink_b() - self.tb.connect(src, op, dst) - self.tb.run() - self.assertEqual(expected_results, dst.data()) - - def test_002(self): - src_data = (1,0,1,1,0,0,0,1) - expected_results = ( 2, 3, 0, 1) - src = gr.vector_source_b(src_data,False) - op = gr.pack_k_bits_bb(2) - dst = gr.vector_sink_b() - self.tb.connect(src, op, dst) - self.tb.run() - #self.assertEqual(expected_results, dst.data()) - self.assertEqual(expected_results, dst.data()) - - def test_003(self): - src_data = expected_results = map(lambda x: random.randint(0,3), range(10)); - src = gr.vector_source_b( src_data ); - pack = gr.pack_k_bits_bb(2); - unpack = gr.unpack_k_bits_bb(2); - snk = gr.vector_sink_b(); - self.tb.connect(src,unpack,pack,snk); - self.tb.run() - self.assertEqual(list(expected_results), list(snk.data())); - -if __name__ == '__main__': - gr_unittest.run(test_pack, "test_pack.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_regenerate.py b/gnuradio-core/src/python/gnuradio/gr/qa_regenerate.py deleted file mode 100755 index 5aca03b777..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_regenerate.py +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2007,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio 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. -# -# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest -import math - -class test_regenerate (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_regen1 (self): - tb = self.tb - - data = [0, 0, 0, - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - - expected_result = (0, 0, 0, - 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) - - - src = gr.vector_source_b(data, False) - regen = gr.regenerate_bb(5, 2) - dst = gr.vector_sink_b() - - tb.connect (src, regen) - tb.connect (regen, dst) - tb.run () - - dst_data = dst.data () - - self.assertEqual (expected_result, dst_data) - - def test_regen2 (self): - tb = self.tb - - data = 200*[0,] - data[9] = 1 - data[99] = 1 - - expected_result = 200*[0,] - expected_result[9] = 1 - expected_result[19] = 1 - expected_result[29] = 1 - expected_result[39] = 1 - - expected_result[99] = 1 - expected_result[109] = 1 - expected_result[119] = 1 - expected_result[129] = 1 - - src = gr.vector_source_b(data, False) - regen = gr.regenerate_bb(10, 3) - dst = gr.vector_sink_b() - - tb.connect (src, regen) - tb.connect (regen, dst) - tb.run () - - dst_data = dst.data () - - self.assertEqual (tuple(expected_result), dst_data) - - -if __name__ == '__main__': - gr_unittest.run(test_regenerate, "test_regenerate.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_unpack_k_bits.py b/gnuradio-core/src/python/gnuradio/gr/qa_unpack_k_bits.py deleted file mode 100755 index bb4e7733d4..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_unpack_k_bits.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2006,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio 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. -# -# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest -import random - -class test_unpack(gr_unittest.TestCase): - - def setUp(self): - self.tb = gr.top_block () - - def tearDown(self): - self.tb = None - - def test_001(self): - src_data = (1,0,1,1,0,1,1,0) - expected_results = (1,0,1,1,0,1,1,0) - src = gr.vector_source_b(src_data,False) - op = gr.unpack_k_bits_bb(1) - dst = gr.vector_sink_b() - self.tb.connect(src, op, dst) - self.tb.run() - self.assertEqual(expected_results, dst.data()) - - def test_002(self): - src_data = ( 2, 3, 0, 1) - expected_results = (1,0,1,1,0,0,0,1) - src = gr.vector_source_b(src_data,False) - op = gr.unpack_k_bits_bb(2) - dst = gr.vector_sink_b() - self.tb.connect(src, op, dst) - self.tb.run() - self.assertEqual(expected_results, dst.data()) - - -if __name__ == '__main__': - gr_unittest.run(test_unpack, "test_unpack.xml") - |