|
gr-baz Package
|
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2004,2013 Free Software Foundation, Inc. 00004 * 00005 * This file is part of GNU Radio 00006 * 00007 * GNU Radio is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 3, or (at your option) 00010 * any later version. 00011 * 00012 * GNU Radio is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with GNU Radio; see the file COPYING. If not, write to 00019 * the Free Software Foundation, Inc., 51 Franklin Street, 00020 * Boston, MA 02110-1301, USA. 00021 */ 00022 00023 /* 00024 * gr-baz by Balint Seeber (http://spench.net/contact) 00025 * Information, documentation & samples: http://wiki.spench.net/wiki/gr-baz 00026 */ 00027 00028 #ifndef INCLUDED_BAZ_GATE_H 00029 #define INCLUDED_BAZ_GATE_H 00030 00031 #include <gr_sync_block.h> 00032 //#include <gr_msg_queue.h> 00033 #include <uhd/types/time_spec.hpp> 00034 #include <gruel/thread.h> 00035 00036 class BAZ_API baz_gate; 00037 00038 /* 00039 * We use boost::shared_ptr's instead of raw pointers for all access 00040 * to gr_blocks (and many other data structures). The shared_ptr gets 00041 * us transparent reference counting, which greatly simplifies storage 00042 * management issues. This is especially helpful in our hybrid 00043 * C++ / Python system. 00044 * 00045 * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm 00046 * 00047 * As a convention, the _sptr suffix indicates a boost::shared_ptr 00048 */ 00049 typedef boost::shared_ptr<baz_gate> baz_gate_sptr; 00050 00051 /*! 00052 * \brief Return a shared_ptr to a new instance of baz_gate. 00053 * 00054 * To avoid accidental use of raw pointers, baz_gate's 00055 * constructor is private. howto_make_square2_ff is the public 00056 * interface for creating new instances. 00057 */ 00058 BAZ_API baz_gate_sptr baz_make_gate (int item_size, bool block = true, float threshold = 1.0, int trigger_length = 0, bool tag = false, double delay = 0.0, int sample_rate = 0, bool no_delay = false); 00059 00060 /*! 00061 * \brief square2 a stream of floats. 00062 * \ingroup block 00063 * 00064 * This uses the preferred technique: subclassing gr_sync_block. 00065 */ 00066 class BAZ_API baz_gate : public gr_block 00067 { 00068 private: 00069 // The friend declaration allows howto_make_square2_ff to 00070 // access the private constructor. 00071 00072 friend BAZ_API baz_gate_sptr baz_make_gate (int item_size, bool block, float threshold, int trigger_length, bool tag, double delay, int sample_rate, bool no_delay); 00073 00074 baz_gate (int item_size, bool block, float threshold, int trigger_length, bool tag, double delay, int sample_rate, bool no_delay); // private constructor 00075 00076 int d_item_size; 00077 bool d_block; 00078 float d_threshold; 00079 int d_trigger_length; 00080 int d_trigger_count; 00081 bool d_tag; 00082 double d_delay; 00083 uhd::time_spec_t d_last_time; 00084 uint64_t d_time_offset; 00085 int d_sample_rate; 00086 bool d_in_burst; 00087 int d_output_index; 00088 bool d_no_delay; 00089 gruel::mutex d_mutex; 00090 00091 public: 00092 ~baz_gate (); // public destructor 00093 00094 void set_blocking(bool enable); 00095 void set_threshold(float threshold); 00096 void set_trigger_length(int trigger_length); 00097 void set_tagging(bool enable); 00098 void set_delay(double delay); 00099 void set_sample_rate(int sample_rate); 00100 void set_no_delay(bool no_delay); 00101 00102 void forecast(int noutput_items, gr_vector_int &ninput_items_required); 00103 00104 int general_work (int noutput_items, gr_vector_int &ninput_items, 00105 gr_vector_const_void_star &input_items, 00106 gr_vector_void_star &output_items); 00107 }; 00108 00109 #endif /* INCLUDED_BAZ_NATIVE_MUX_H */