diff options
author | Tom Rondeau <trondeau@vt.edu> | 2013-03-18 15:55:38 -0400 |
---|---|---|
committer | Tom Rondeau <trondeau@vt.edu> | 2013-03-18 16:47:15 -0400 |
commit | c856fe0106bcbcad871452014af2eb459a32e916 (patch) | |
tree | 4b7c3fa9cc5064edc4a36ca0de6c0d15c6a385ac /gnuradio-core/src/lib/io | |
parent | 1b10a63a952612858a5e44321b6babf1d0232b52 (diff) |
wxgui: Moved oscope and histogram bases into wxgui.
This makes gr-wxgui more like a normal component that generates a libgnuradio-wxgui.so file.
Diffstat (limited to 'gnuradio-core/src/lib/io')
-rw-r--r-- | gnuradio-core/src/lib/io/CMakeLists.txt | 58 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_histo_sink.i | 39 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_histo_sink_f.cc | 165 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_histo_sink_f.h | 71 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_oscope_guts.cc | 437 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_oscope_guts.h | 123 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_oscope_sink.i | 77 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_oscope_sink_f.cc | 78 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_oscope_sink_f.h | 63 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_oscope_sink_x.cc | 156 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_oscope_sink_x.h | 77 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_trigger_mode.h | 38 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/io.i | 37 |
13 files changed, 0 insertions, 1419 deletions
diff --git a/gnuradio-core/src/lib/io/CMakeLists.txt b/gnuradio-core/src/lib/io/CMakeLists.txt deleted file mode 100644 index ee8e9befa5..0000000000 --- a/gnuradio-core/src/lib/io/CMakeLists.txt +++ /dev/null @@ -1,58 +0,0 @@ -# Copyright 2010-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. - -######################################################################## -# This file included, use CMake directory variables -######################################################################## - -######################################################################## -# Append gnuradio-core library sources -######################################################################## -list(APPEND gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/gr_histo_sink_f.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_oscope_guts.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_oscope_sink_f.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_oscope_sink_x.cc -) - -######################################################################## -# Install runtime headers -######################################################################## -install(FILES - ${CMAKE_CURRENT_SOURCE_DIR}/gr_histo_sink_f.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_oscope_guts.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_oscope_sink_f.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_oscope_sink_x.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_trigger_mode.h - DESTINATION ${GR_INCLUDE_DIR}/gnuradio - COMPONENT "core_devel" -) - -######################################################################## -# Install swig headers -######################################################################## -if(ENABLE_PYTHON) -install(FILES - ${CMAKE_CURRENT_SOURCE_DIR}/io.i - ${CMAKE_CURRENT_SOURCE_DIR}/gr_histo_sink.i - ${CMAKE_CURRENT_SOURCE_DIR}/gr_oscope_sink.i - DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig - COMPONENT "core_swig" -) -endif(ENABLE_PYTHON) diff --git a/gnuradio-core/src/lib/io/gr_histo_sink.i b/gnuradio-core/src/lib/io/gr_histo_sink.i deleted file mode 100644 index 14079e1907..0000000000 --- a/gnuradio-core/src/lib/io/gr_histo_sink.i +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 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,histo_sink_f) - -gr_histo_sink_f_sptr gr_make_histo_sink_f (gr_msg_queue_sptr msgq); - -class gr_histo_sink_f : public gr_sync_block -{ -public: - ~gr_histo_sink_f (void); - - unsigned int get_frame_size(void); - unsigned int get_num_bins(void); - - void set_frame_size(unsigned int frame_size); - void set_num_bins(unsigned int num_bins); - -}; diff --git a/gnuradio-core/src/lib/io/gr_histo_sink_f.cc b/gnuradio-core/src/lib/io/gr_histo_sink_f.cc deleted file mode 100644 index fc0c12ce64..0000000000 --- a/gnuradio-core/src/lib/io/gr_histo_sink_f.cc +++ /dev/null @@ -1,165 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2010,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_histo_sink_f.h> -#include <gr_io_signature.h> -#include <boost/math/special_functions/round.hpp> - -static float get_clean_num(float num){ - if (num == 0) return 0; - /* extract sign and exponent from num */ - int sign = (num < 0) ? -1 : 1; num = fabs(num); - float exponent = floor(log10(num)); - /* search for closest number with base 1, 2, 5, 10 */ - float closest_num = 10*pow(10, exponent); - if (fabs(num - 1*pow(10, exponent)) < fabs(num - closest_num)) - closest_num = 1*pow(10, exponent); - if (fabs(num - 2*pow(10, exponent)) < fabs(num - closest_num)) - closest_num = 2*pow(10, exponent); - if (fabs(num - 5*pow(10, exponent)) < fabs(num - closest_num)) - closest_num = 5*pow(10, exponent); - return sign*closest_num; -} - -gr_histo_sink_f_sptr -gr_make_histo_sink_f (gr_msg_queue_sptr msgq) -{ - return gnuradio::get_initial_sptr(new gr_histo_sink_f (msgq)); -} - -gr_histo_sink_f::gr_histo_sink_f (gr_msg_queue_sptr msgq) - : gr_sync_block ("histo_sink_f", gr_make_io_signature (1, 1, sizeof (float)), gr_make_io_signature (0, 0, 0)), - d_msgq (msgq), d_num_bins(11), d_frame_size(1000), d_sample_count(0), d_bins(NULL), d_samps(NULL) -{ - //allocate arrays and clear - set_num_bins(d_num_bins); - set_frame_size(d_frame_size); -} - -gr_histo_sink_f::~gr_histo_sink_f (void) -{ - delete [] d_samps; - delete [] d_bins; -} - -int -gr_histo_sink_f::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]; - gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function - for (unsigned int i = 0; i < (unsigned int)noutput_items; i++){ - d_samps[d_sample_count] = in[i]; - d_sample_count++; - /* processed a frame? */ - if (d_sample_count == d_frame_size){ - send_frame(); - clear(); - } - } - return noutput_items; -} - -void -gr_histo_sink_f::send_frame(void){ - /* output queue full, drop the data */ - if (d_msgq->full_p()) return; - /* find the minimum and maximum */ - float minimum = d_samps[0]; - float maximum = d_samps[0]; - for (unsigned int i = 0; i < d_frame_size; i++){ - if (d_samps[i] < minimum) minimum = d_samps[i]; - if (d_samps[i] > maximum) maximum = d_samps[i]; - } - minimum = get_clean_num(minimum); - maximum = get_clean_num(maximum); - if (minimum == maximum || minimum > maximum) return; //useless data or screw up? - /* load the bins */ - int index; - float bin_width = (maximum - minimum)/(d_num_bins-1); - for (unsigned int i = 0; i < d_sample_count; i++){ - index = boost::math::iround((d_samps[i] - minimum)/bin_width); - /* ensure the index range in case a small floating point error is involed */ - if (index < 0) index = 0; - if (index >= (int)d_num_bins) index = d_num_bins-1; - d_bins[index]++; - } - /* Build a message to hold the output records */ - gr_message_sptr msg = gr_make_message(0, minimum, maximum, d_num_bins*sizeof(float)); - float *out = (float *)msg->msg(); // get pointer to raw message buffer - /* normalize the bins and put into message */ - for (unsigned int i = 0; i < d_num_bins; i++){ - out[i] = ((float)d_bins[i])/d_frame_size; - } - /* send the message */ - d_msgq->handle(msg); -} - -void -gr_histo_sink_f::clear(void){ - d_sample_count = 0; - /* zero the bins */ - for (unsigned int i = 0; i < d_num_bins; i++){ - d_bins[i] = 0; - } -} - -/************************************************** - * Getters - **************************************************/ -unsigned int -gr_histo_sink_f::get_frame_size(void){ - return d_frame_size; -} - -unsigned int -gr_histo_sink_f::get_num_bins(void){ - return d_num_bins; -} - -/************************************************** - * Setters - **************************************************/ -void -gr_histo_sink_f::set_frame_size(unsigned int frame_size){ - gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function - d_frame_size = frame_size; - /* allocate a new sample array */ - delete [] d_samps; - d_samps = new float[d_frame_size]; - clear(); -} - -void -gr_histo_sink_f::set_num_bins(unsigned int num_bins){ - gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function - d_num_bins = num_bins; - /* allocate a new bin array */ - delete [] d_bins; - d_bins = new unsigned int[d_num_bins]; - clear(); -} diff --git a/gnuradio-core/src/lib/io/gr_histo_sink_f.h b/gnuradio-core/src/lib/io/gr_histo_sink_f.h deleted file mode 100644 index 934066ba20..0000000000 --- a/gnuradio-core/src/lib/io/gr_histo_sink_f.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 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_HISTO_SINK_F_H -#define INCLUDED_GR_HISTO_SINK_F_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_msg_queue.h> -#include <gruel/thread.h> - -class gr_histo_sink_f; -typedef boost::shared_ptr<gr_histo_sink_f> gr_histo_sink_f_sptr; - -GR_CORE_API gr_histo_sink_f_sptr gr_make_histo_sink_f (gr_msg_queue_sptr msgq); - -/*! - * \brief Histogram module. - * \ingroup sink_blk - */ -class GR_CORE_API gr_histo_sink_f : public gr_sync_block -{ -private: - gr_msg_queue_sptr d_msgq; - unsigned int d_num_bins; - unsigned int d_frame_size; - unsigned int d_sample_count; - unsigned int *d_bins; - float *d_samps; - gruel::mutex d_mutex; - - friend GR_CORE_API gr_histo_sink_f_sptr gr_make_histo_sink_f (gr_msg_queue_sptr msgq); - gr_histo_sink_f (gr_msg_queue_sptr msgq); - void send_frame(void); - void clear(void); - -public: - ~gr_histo_sink_f (void); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - unsigned int get_frame_size(void); - unsigned int get_num_bins(void); - - void set_frame_size(unsigned int frame_size); - void set_num_bins(unsigned int num_bins); - -}; - -#endif /* INCLUDED_GR_HISTO_SINK_F_H */ diff --git a/gnuradio-core/src/lib/io/gr_oscope_guts.cc b/gnuradio-core/src/lib/io/gr_oscope_guts.cc deleted file mode 100644 index a5ea3002a9..0000000000 --- a/gnuradio-core/src/lib/io/gr_oscope_guts.cc +++ /dev/null @@ -1,437 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_oscope_guts.h> -#include <stdexcept> -#include <stdio.h> -#include <algorithm> -#include <unistd.h> -#include <math.h> -#include <assert.h> - -/* - * Bad performance if it's large, and flaky triggering if it's too small - */ -static const int OUTPUT_RECORD_SIZE = 1024; // Must be power of 2 - -/* - * For (slow-updated) STRIPCHART triggering, we make the record size larger, since we - * potentially want to be able to "see" hours of data. This works as long as the - * update rates to a STRIPCHART are low, which they generally are--that's rather what - * a stripchart is all about! - */ -static const int SCHART_MULT = 8; - - -static inline int -wrap_bi (int buffer_index, int mx) // wrap buffer index -{ - return buffer_index & (mx - 1); -} - -static inline int -incr_bi (int buffer_index, int mx) // increment buffer index -{ - return wrap_bi (buffer_index + 1, mx); -} - -static inline int -decr_bi (int buffer_index, int mx) // decrement buffer index -{ - return wrap_bi (buffer_index - 1, mx); -} - -gr_oscope_guts::gr_oscope_guts (double sample_rate, gr_msg_queue_sptr msgq) - : d_nchannels (1), - d_msgq (msgq), - d_trigger_mode (gr_TRIG_MODE_AUTO), - d_trigger_slope (gr_TRIG_SLOPE_POS), - d_trigger_channel (0), - d_sample_rate (sample_rate), - d_update_rate (20), - d_trigger_level (0), - d_obi (0), - d_state (HOLD_OFF), - d_decimator_count (0), - d_decimator_count_init (1), - d_hold_off_count (0), - d_hold_off_count_init (OUTPUT_RECORD_SIZE/2-1), - d_pre_trigger_count (0), - d_post_trigger_count (0), - d_post_trigger_count_init (OUTPUT_RECORD_SIZE/2) -{ - for (int i = 0; i < MAX_CHANNELS; i++) - d_buffer[i] = 0; - - for (int i = 0; i < MAX_CHANNELS; i++){ - d_buffer[i] = new float [OUTPUT_RECORD_SIZE*SCHART_MULT]; - for (int j = 0; j < OUTPUT_RECORD_SIZE*SCHART_MULT; j++) - d_buffer[i][j] = 0.0; - } - - // be sure buffer is full before first write - enter_hold_off (); - update_rate_or_decimation_changed (); -} - -gr_oscope_guts::~gr_oscope_guts () -{ - for (int i = 0; i < MAX_CHANNELS; i++) - delete [] d_buffer[i]; -} - -// MANIPULATORS - -// \p channel_data points to nchannels float values. These are the values -// for each channel at this sample time. - -void -gr_oscope_guts::process_sample (const float *channel_data) -{ - d_decimator_count--; - if (d_decimator_count > 0) - return; - - d_decimator_count = d_decimator_count_init; - - if (d_trigger_mode != gr_TRIG_MODE_STRIPCHART) - { - for (int i = 0; i < d_nchannels; i++) - d_buffer[i][d_obi] = channel_data[i]; // copy data into buffer - - switch (d_state){ - case HOLD_OFF: - d_hold_off_count--; - if (d_hold_off_count <= 0) - enter_look_for_trigger (); - break; - - case LOOK_FOR_TRIGGER: - if (found_trigger ()) - enter_post_trigger (); - break; - - case POST_TRIGGER: - d_post_trigger_count--; - if (d_post_trigger_count <= 0){ - write_output_records (); - enter_hold_off (); - } - break; - - default: - assert (0); - } - - d_obi = incr_bi (d_obi, OUTPUT_RECORD_SIZE); - } - else - { - for (int i = 0; i < d_nchannels; i++) - { - for (int j = (OUTPUT_RECORD_SIZE*SCHART_MULT)-1; j > 0; j--) - { - d_buffer[i][j] = d_buffer[i][j-1]; - } - d_buffer[i][0] = channel_data[i]; - } - d_trigger_off = 0; - write_output_records(); - } -} - -/* - * Functions called on state entry - */ - -void -gr_oscope_guts::enter_hold_off () -{ - d_state = HOLD_OFF; - d_hold_off_count = d_hold_off_count_init; -} - -void -gr_oscope_guts::enter_look_for_trigger () -{ - d_pre_trigger_count = 0; - d_state = LOOK_FOR_TRIGGER; -} - -void -gr_oscope_guts::enter_post_trigger () -{ - d_state = POST_TRIGGER; - d_post_trigger_count = d_post_trigger_count_init; - //ensure that the trigger offset is no more than than half a sample - if (d_trigger_off > .5) d_trigger_off -= 1; - else d_post_trigger_count--; -} - -// ---------------------------------------------------------------- -// returns true if trigger found - -bool -gr_oscope_guts::found_trigger () -{ - int mx = d_trigger_mode == gr_TRIG_MODE_STRIPCHART ? OUTPUT_RECORD_SIZE*SCHART_MULT : - OUTPUT_RECORD_SIZE; - - float prev_sample = d_buffer[d_trigger_channel][decr_bi(d_obi, mx)]; - float new_sample = d_buffer[d_trigger_channel][d_obi]; - - switch (d_trigger_mode){ - - case gr_TRIG_MODE_AUTO: //too many samples without a trigger - d_pre_trigger_count++; - if (d_pre_trigger_count > OUTPUT_RECORD_SIZE/2) return true; - - case gr_TRIG_MODE_NORM: //look for trigger - switch (d_trigger_slope){ - - case gr_TRIG_SLOPE_POS: //trigger point in pos slope? - if (new_sample < d_trigger_level || prev_sample >= d_trigger_level) return false; - break; - - case gr_TRIG_SLOPE_NEG: //trigger point in neg slope? - if (new_sample > d_trigger_level || prev_sample <= d_trigger_level) return false; - break; - } - - //calculate the trigger offset in % sample - d_trigger_off = (d_trigger_level - prev_sample)/(new_sample - prev_sample); - return true; - - case gr_TRIG_MODE_FREE: //free run mode, always trigger - d_trigger_off = 0; - return true; - - default: - assert (0); - return false; - } -} - -// ---------------------------------------------------------------- -// write output records (duh!) - -void -gr_oscope_guts::write_output_records () -{ - int mx; - - mx = d_trigger_mode == gr_TRIG_MODE_STRIPCHART ? - OUTPUT_RECORD_SIZE*SCHART_MULT : OUTPUT_RECORD_SIZE; - - // if the output queue if full, drop the data like its hot. - if (d_msgq->full_p()) - return; - // Build a message to hold the output records - gr_message_sptr msg = - gr_make_message(0, // msg type - d_nchannels, // arg1 for other side - mx, // arg2 for other side - ((d_nchannels * mx) + 1) * sizeof(float)); // sizeof payload - - float *out = (float *)msg->msg(); // get pointer to raw message buffer - - for (int ch = 0; ch < d_nchannels; ch++){ - // note that d_obi + 1 points at the oldest sample in the buffer - for (int i = 0; i < mx; i++){ - out[i] = d_buffer[ch][wrap_bi(d_obi + 1 + i, mx)]; - } - out += mx; - } - //Set the last sample as the trigger offset: - // The non gl scope sink will not look at this last sample. - // The gl scope sink will use this last sample as an offset. - out[0] = d_trigger_off; - d_msgq->handle(msg); // send the msg -} - -// ---------------------------------------------------------------- - -bool -gr_oscope_guts::set_update_rate (double update_rate) -{ - d_update_rate = std::min (std::max (1./10., update_rate), d_sample_rate); - update_rate_or_decimation_changed (); - return true; -} - -bool -gr_oscope_guts::set_decimation_count (int decimator_count) -{ - decimator_count = std::max (1, decimator_count); - d_decimator_count_init = decimator_count; - update_rate_or_decimation_changed (); - return true; -} - -bool -gr_oscope_guts::set_sample_rate(double sample_rate) -{ - d_sample_rate = sample_rate; - return set_update_rate(update_rate()); -} - - -void -gr_oscope_guts::update_rate_or_decimation_changed () -{ - d_hold_off_count_init = - (int) rint (d_sample_rate / d_update_rate / d_decimator_count_init); -} - -bool -gr_oscope_guts::set_trigger_channel (int channel) -{ - if (channel >= 0 && channel < d_nchannels){ - d_trigger_channel = channel; - trigger_changed (); - return true; - } - - return false; -} - -bool -gr_oscope_guts::set_trigger_mode (gr_trigger_mode mode) -{ - d_trigger_mode = mode; - trigger_changed (); - return true; -} - -bool -gr_oscope_guts::set_trigger_slope (gr_trigger_slope slope) -{ - d_trigger_slope = slope; - trigger_changed (); - return true; -} - -bool -gr_oscope_guts::set_trigger_level (double trigger_level) -{ - d_trigger_level = trigger_level; - trigger_changed (); - return true; -} - -bool -gr_oscope_guts::set_trigger_level_auto () -{ - // find the level 1/2 way between the min and the max - - float min_v = d_buffer[d_trigger_channel][0]; - float max_v = d_buffer[d_trigger_channel][0]; - - for (int i = 1; i < OUTPUT_RECORD_SIZE; i++){ - min_v = std::min (min_v, d_buffer[d_trigger_channel][i]); - max_v = std::max (max_v, d_buffer[d_trigger_channel][i]); - } - return set_trigger_level((min_v + max_v) * 0.5); -} - -bool -gr_oscope_guts::set_num_channels(int nchannels) -{ - if (nchannels > 0 && nchannels <= MAX_CHANNELS){ - d_nchannels = nchannels; - return true; - } - return false; -} - - -void -gr_oscope_guts::trigger_changed () -{ - enter_look_for_trigger (); -} - -// ACCESSORS - -int -gr_oscope_guts::num_channels () const -{ - return d_nchannels; -} - -double -gr_oscope_guts::sample_rate () const -{ - return d_sample_rate; -} - -double -gr_oscope_guts::update_rate () const -{ - return d_update_rate; -} - -int -gr_oscope_guts::get_decimation_count () const -{ - return d_decimator_count_init; -} - -int -gr_oscope_guts::get_trigger_channel () const -{ - return d_trigger_channel; -} - -gr_trigger_mode -gr_oscope_guts::get_trigger_mode () const -{ - return d_trigger_mode; -} - -gr_trigger_slope -gr_oscope_guts::get_trigger_slope () const -{ - return d_trigger_slope; -} - -double -gr_oscope_guts::get_trigger_level () const -{ - return d_trigger_level; -} - -int -gr_oscope_guts::get_samples_per_output_record () const -{ - int mx; - - mx = OUTPUT_RECORD_SIZE; - if (d_trigger_mode == gr_TRIG_MODE_STRIPCHART) - { - mx = OUTPUT_RECORD_SIZE*SCHART_MULT; - } - return mx; -} diff --git a/gnuradio-core/src/lib/io/gr_oscope_guts.h b/gnuradio-core/src/lib/io/gr_oscope_guts.h deleted file mode 100644 index bc9513c7e7..0000000000 --- a/gnuradio-core/src/lib/io/gr_oscope_guts.h +++ /dev/null @@ -1,123 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,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. - */ - - -#ifndef INCLUDED_GR_OSCOPE_GUTS_H -#define INCLUDED_GR_OSCOPE_GUTS_H - -#include <gr_core_api.h> -#include <gr_trigger_mode.h> -#include <gr_msg_queue.h> - -/*! - * \brief guts of oscilloscope trigger and buffer module - * - * This module processes sets of samples provided the \p process_sample - * method. When appropriate given the updateRate, sampleRate and - * trigger conditions, process_sample will periodically write output - * records of captured data to output_fd. For each trigger event, - * nchannels records will be written. Each record consists of - * get_samples_per_output_record binary floats. The trigger instant - * occurs at the 1/2 way point in the buffer. Thus, output records - * consist of 50% pre-trigger data and 50% post-trigger data. - */ - -class GR_CORE_API gr_oscope_guts { -public: - static const int MAX_CHANNELS = 8; -private: - enum scope_state { HOLD_OFF, LOOK_FOR_TRIGGER, POST_TRIGGER }; - - int d_nchannels; // how many channels - gr_msg_queue_sptr d_msgq; // message queue we stuff output records into - gr_trigger_mode d_trigger_mode; - gr_trigger_slope d_trigger_slope; - int d_trigger_channel; // which channel to watch for trigger condition - double d_sample_rate; // input sample rate in Hz - double d_update_rate; // approx freq to produce an output record (Hz) - double d_trigger_level; - - int d_obi; // output buffer index - float *d_buffer[MAX_CHANNELS]; - - scope_state d_state; - int d_decimator_count; - int d_decimator_count_init; - int d_hold_off_count; - int d_hold_off_count_init; - int d_pre_trigger_count; - int d_post_trigger_count; - int d_post_trigger_count_init; - float d_trigger_off; //%sample trigger is off - - // NOT IMPLEMENTED - gr_oscope_guts (const gr_oscope_guts &rhs); // no copy constructor - gr_oscope_guts &operator= (const gr_oscope_guts &rhs); // no assignment operator - - void trigger_changed (); - void update_rate_or_decimation_changed (); - bool found_trigger (); // returns true if found - void write_output_records (); - - void enter_hold_off (); // called on state entry - void enter_look_for_trigger (); - void enter_post_trigger (); - -public: - // CREATORS - gr_oscope_guts (double sample_rate, gr_msg_queue_sptr msgq); - ~gr_oscope_guts (); - - // MANIPULATORS - - /*! - * \p channel_data points to nchannels float values. These are the values - * for each channel at this sample time. - */ - void process_sample (const float *channel_data); - - bool set_update_rate (double update_rate); - bool set_decimation_count (int decimation_count); - bool set_trigger_channel (int channel); - bool set_trigger_mode (gr_trigger_mode mode); - bool set_trigger_slope (gr_trigger_slope slope); - bool set_trigger_level (double trigger_level); - bool set_trigger_level_auto (); // set to 50% level - bool set_sample_rate(double sample_rate); - bool set_num_channels(int nchannels); - - - // ACCESSORS - int num_channels () const; - double sample_rate () const; - double update_rate () const; - int get_decimation_count () const; - int get_trigger_channel () const; - gr_trigger_mode get_trigger_mode () const; - gr_trigger_slope get_trigger_slope () const; - double get_trigger_level () const; - - // # of samples written to each output record. - int get_samples_per_output_record () const; -}; - -#endif /* INCLUDED_GR_OSCOPE_GUTS_H */ diff --git a/gnuradio-core/src/lib/io/gr_oscope_sink.i b/gnuradio-core/src/lib/io/gr_oscope_sink.i deleted file mode 100644 index 3d7072ed45..0000000000 --- a/gnuradio-core/src/lib/io/gr_oscope_sink.i +++ /dev/null @@ -1,77 +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. - */ - -%include gr_trigger_mode.h - -// GR_SWIG_BLOCK_MAGIC(gr,oscope_sink_x) - -%ignore gr_oscope_sink_x; -class gr_oscope_sink_x : public gr_sync_block -{ - protected: - gr_oscope_sink_x (const std::string name, - gr_io_signature_sptr input_sig, - double sample_rate); - - public: - ~gr_oscope_sink_x (); - - bool set_update_rate (double update_rate); - bool set_decimation_count (int decimation_count); - bool set_trigger_channel (int channel); - bool set_trigger_mode (gr_trigger_mode mode); - bool set_trigger_slope (gr_trigger_slope slope); - bool set_trigger_level (double trigger_level); - bool set_trigger_level_auto (); // set to 50% level - bool set_sample_rate(double sample_rate); - - // ACCESSORS - int num_channels () const; - double sample_rate () const; - double update_rate () const; - int get_decimation_count () const; - int get_trigger_channel () const; - gr_trigger_mode get_trigger_mode () const; - gr_trigger_slope get_trigger_slope () const; - double get_trigger_level () const; - - // # of samples written to each output record. - int get_samples_per_output_record () const; -}; - -// ---------------------------------------------------------------- - -GR_SWIG_BLOCK_MAGIC(gr,oscope_sink_f) - -gr_oscope_sink_f_sptr -gr_make_oscope_sink_f (double sample_rate, gr_msg_queue_sptr msgq); - -class gr_oscope_sink_f : public gr_oscope_sink_x -{ -private: - gr_oscope_sink_f (double sample_rate, gr_msg_queue_sptr msgq); - -public: - ~gr_oscope_sink_f (); -}; - -// ---------------------------------------------------------------- diff --git a/gnuradio-core/src/lib/io/gr_oscope_sink_f.cc b/gnuradio-core/src/lib/io/gr_oscope_sink_f.cc deleted file mode 100644 index 493a25e81e..0000000000 --- a/gnuradio-core/src/lib/io/gr_oscope_sink_f.cc +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,2004,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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_oscope_sink_f.h> -#include <gr_io_signature.h> -#include <gr_oscope_guts.h> - - -gr_oscope_sink_f_sptr -gr_make_oscope_sink_f (double sampling_rate, gr_msg_queue_sptr msgq) -{ - return gnuradio::get_initial_sptr(new gr_oscope_sink_f (sampling_rate, msgq)); -} - - -gr_oscope_sink_f::gr_oscope_sink_f (double sampling_rate, gr_msg_queue_sptr msgq) - : gr_oscope_sink_x ("oscope_sink_f", - gr_make_io_signature (1, gr_oscope_guts::MAX_CHANNELS, sizeof (float)), - sampling_rate), - d_msgq(msgq) -{ - d_guts = new gr_oscope_guts (d_sampling_rate, d_msgq); -} - - -bool -gr_oscope_sink_f::check_topology (int ninputs, int noutputs) -{ - return d_guts->set_num_channels(ninputs); -} - - -gr_oscope_sink_f::~gr_oscope_sink_f () -{ -} - -int -gr_oscope_sink_f::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - int ni = input_items.size (); - float tmp[gr_oscope_guts::MAX_CHANNELS]; - - for (int i = 0; i < noutput_items; i++){ - - // FIXME for now, copy the data. Fix later if reqd - for (int ch = 0; ch < ni; ch++) - tmp[ch] = ((const float *) input_items[ch])[i]; - - d_guts->process_sample (tmp); - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/io/gr_oscope_sink_f.h b/gnuradio-core/src/lib/io/gr_oscope_sink_f.h deleted file mode 100644 index 8d434d2bc4..0000000000 --- a/gnuradio-core/src/lib/io/gr_oscope_sink_f.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,2004,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. - */ - -#ifndef INCLUDED_GR_OSCOPE_SINK_F_H -#define INCLUDED_GR_OSCOPE_SINK_F_H - -#include <gr_core_api.h> -#include <gr_oscope_sink_x.h> -#include <gr_msg_queue.h> - -class gr_oscope_sink_f; -typedef boost::shared_ptr<gr_oscope_sink_x> gr_oscope_sink_f_sptr; - -GR_CORE_API gr_oscope_sink_f_sptr gr_make_oscope_sink_f (double sampling_rate, gr_msg_queue_sptr msgq); - - -/*! - * \brief Building block for python oscilloscope module. - * \ingroup sink_blk - * - * Accepts multiple float streams. - */ -class GR_CORE_API gr_oscope_sink_f : public gr_oscope_sink_x -{ -private: - friend GR_CORE_API gr_oscope_sink_f_sptr - gr_make_oscope_sink_f (double sampling_rate, gr_msg_queue_sptr msgq); - - gr_oscope_sink_f (double sampling_rate, gr_msg_queue_sptr msgq); - - gr_msg_queue_sptr d_msgq; - - public: - ~gr_oscope_sink_f (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - bool check_topology (int ninputs, int noutputs); -}; - -#endif /* INCLUDED_GR_OSCOPE_SINK_F_H */ - diff --git a/gnuradio-core/src/lib/io/gr_oscope_sink_x.cc b/gnuradio-core/src/lib/io/gr_oscope_sink_x.cc deleted file mode 100644 index 9580dbf6a3..0000000000 --- a/gnuradio-core/src/lib/io/gr_oscope_sink_x.cc +++ /dev/null @@ -1,156 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_oscope_sink_x.h> -#include <gr_io_signature.h> -#include <gr_oscope_guts.h> - - -gr_oscope_sink_x::gr_oscope_sink_x (const std::string name, - gr_io_signature_sptr input_sig, - double sampling_rate) - : gr_sync_block (name, input_sig, gr_make_io_signature (0, 0, 0)), - d_sampling_rate (sampling_rate), d_guts (0) -{ -} - -gr_oscope_sink_x::~gr_oscope_sink_x () -{ - delete d_guts; -} - -// ---------------------------------------------------------------- - -bool -gr_oscope_sink_x::set_update_rate (double update_rate) -{ - return d_guts->set_update_rate (update_rate); -} - -bool -gr_oscope_sink_x::set_decimation_count (int decimation_count) -{ - return d_guts->set_decimation_count (decimation_count); -} - -bool -gr_oscope_sink_x::set_trigger_channel (int channel) -{ - return d_guts->set_trigger_channel (channel); -} - -bool -gr_oscope_sink_x::set_trigger_mode (gr_trigger_mode mode) -{ - return d_guts->set_trigger_mode (mode); -} - -bool -gr_oscope_sink_x::set_trigger_slope (gr_trigger_slope slope) -{ - return d_guts->set_trigger_slope (slope); -} - -bool -gr_oscope_sink_x::set_trigger_level (double trigger_level) -{ - return d_guts->set_trigger_level (trigger_level); -} - - -bool -gr_oscope_sink_x::set_trigger_level_auto () -{ - return d_guts->set_trigger_level_auto (); -} - -bool -gr_oscope_sink_x::set_sample_rate (double sample_rate) -{ - return d_guts->set_sample_rate (sample_rate); -} - -bool -gr_oscope_sink_x::set_num_channels (int nchannels) -{ - return d_guts->set_num_channels (nchannels); -} - -// ACCESSORS - -int -gr_oscope_sink_x::num_channels () const -{ - return d_guts->num_channels (); -} - -double -gr_oscope_sink_x::sample_rate () const -{ - return d_guts->sample_rate (); -} - -double -gr_oscope_sink_x::update_rate () const -{ - return d_guts->update_rate (); -} - -int -gr_oscope_sink_x::get_decimation_count () const -{ - return d_guts->get_decimation_count (); -} - -int -gr_oscope_sink_x::get_trigger_channel () const -{ - return d_guts->get_trigger_channel (); -} - -gr_trigger_mode -gr_oscope_sink_x::get_trigger_mode () const -{ - return d_guts->get_trigger_mode (); -} - -gr_trigger_slope -gr_oscope_sink_x::get_trigger_slope () const -{ - return d_guts->get_trigger_slope (); -} - -double -gr_oscope_sink_x::get_trigger_level () const -{ - return d_guts->get_trigger_level (); -} - -int -gr_oscope_sink_x::get_samples_per_output_record () const -{ - return d_guts->get_samples_per_output_record (); -} diff --git a/gnuradio-core/src/lib/io/gr_oscope_sink_x.h b/gnuradio-core/src/lib/io/gr_oscope_sink_x.h deleted file mode 100644 index 153d0937ab..0000000000 --- a/gnuradio-core/src/lib/io/gr_oscope_sink_x.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,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_OSCOPE_SINK_X_H -#define INCLUDED_GR_OSCOPE_SINK_X_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_trigger_mode.h> - -class gr_oscope_guts; - -/*! - * \brief Abstract class for python oscilloscope module. - * \ingroup sink_blk - * - * Don't instantiate this. Use gr_oscope_sink_f or gr_oscope_sink_c instead. - */ -class GR_CORE_API gr_oscope_sink_x : public gr_sync_block -{ -protected: - double d_sampling_rate; - gr_oscope_guts *d_guts; - - gr_oscope_sink_x (const std::string name, - gr_io_signature_sptr input_sig, - double sampling_rate); - -public: - ~gr_oscope_sink_x (); - - bool set_update_rate (double update_rate); - bool set_decimation_count (int decimation_count); - bool set_trigger_channel (int channel); - bool set_trigger_mode (gr_trigger_mode mode); - bool set_trigger_slope (gr_trigger_slope slope); - bool set_trigger_level (double trigger_level); - bool set_trigger_level_auto (); // set to 50% level - bool set_sample_rate(double sample_rate); - bool set_num_channels (int nchannels); - - - // ACCESSORS - int num_channels () const; - double sample_rate () const; - double update_rate () const; - int get_decimation_count () const; - int get_trigger_channel () const; - gr_trigger_mode get_trigger_mode () const; - gr_trigger_slope get_trigger_slope () const; - double get_trigger_level () const; - - // # of samples written to each output record. - int get_samples_per_output_record () const; - -}; - -#endif /* INCLUDED_GR_OSCOPE_SINK_X_H */ diff --git a/gnuradio-core/src/lib/io/gr_trigger_mode.h b/gnuradio-core/src/lib/io/gr_trigger_mode.h deleted file mode 100644 index be131686b4..0000000000 --- a/gnuradio-core/src/lib/io/gr_trigger_mode.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,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_TRIGGER_MODE_H -#define INCLUDED_GR_TRIGGER_MODE_H - -enum gr_trigger_mode { - gr_TRIG_MODE_FREE, - gr_TRIG_MODE_AUTO, - gr_TRIG_MODE_NORM, - gr_TRIG_MODE_STRIPCHART, -}; - -enum gr_trigger_slope { - gr_TRIG_SLOPE_POS, - gr_TRIG_SLOPE_NEG, -}; - -#endif /* INCLUDED_GR_TRIGGER_MODE_H */ diff --git a/gnuradio-core/src/lib/io/io.i b/gnuradio-core/src/lib/io/io.i deleted file mode 100644 index 2c8def973c..0000000000 --- a/gnuradio-core/src/lib/io/io.i +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,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. - */ - -%{ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_histo_sink_f.h> -#include <gr_oscope_sink_x.h> -#include <gr_oscope_sink_f.h> -%} - -%include "gr_histo_sink.i" -%include "gr_oscope_sink.i" - - |