gr-baz Package

baz_gate.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2004,2013 Free Software Foundation, Inc.
4 *
5 * This file is part of GNU Radio
6 *
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
10 * any later version.
11 *
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
21 */
22
23/*
24 * gr-baz by Balint Seeber (http://spench.net/contact)
25 * Information, documentation & samples: http://wiki.spench.net/wiki/gr-baz
26 */
27
28#ifndef INCLUDED_BAZ_GATE_H
29#define INCLUDED_BAZ_GATE_H
30
31#include <gnuradio/sync_block.h>
32//#include <gnuradio/msg_queue.h>
33#include <uhd/types/time_spec.hpp>
34#include <gnuradio/thread/thread.h>
35
36 class BAZ_API baz_gate;
37
38/*
39 * We use boost::shared_ptr's instead of raw pointers for all access
40 * to gr::blocks (and many other data structures). The shared_ptr gets
41 * us transparent reference counting, which greatly simplifies storage
42 * management issues. This is especially helpful in our hybrid
43 * C++ / Python system.
44 *
45 * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm
46 *
47 * As a convention, the _sptr suffix indicates a boost::shared_ptr
48 */
49 typedef boost::shared_ptr<baz_gate> baz_gate_sptr;
50
51/*!
52 * \brief Return a shared_ptr to a new instance of baz_gate.
53 *
54 * To avoid accidental use of raw pointers, baz_gate's
55 * constructor is private. howto_make_square2_ff is the public
56 * interface for creating new instances.
57 */
58 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, bool verbose = true, bool retriggerable = false, const std::string& length_tag_name = "", bool complete_output = false, bool byte_trigger = false, const std::string& trigger_tag_name = "");
59
60/*!
61 * \brief square2 a stream of floats.
62 * \ingroup block
63 *
64 * This uses the preferred technique: subclassing gr::sync_block.
65 */
66 class BAZ_API baz_gate : public gr::block
67{
68 private:
69 // The friend declaration allows howto_make_square2_ff to
70 // access the private constructor.
71
72 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, bool verbose, bool retriggerable, const std::string& length_tag_name, bool complete_output, bool byte_trigger, const std::string& trigger_tag_name);
73
74 baz_gate (int item_size, bool block, float threshold, int trigger_length, bool tag, double delay, int sample_rate, bool no_delay, bool verbose, bool retriggerable, const std::string& length_tag_name, bool complete_output, bool byte_trigger, const std::string& trigger_tag_name); // private constructor
75
76 int d_item_size;
77 bool d_block;
78 float d_threshold;
79 int d_trigger_length;
80 int d_trigger_count;
81 bool d_tag;
82 double d_delay;
83 uhd::time_spec_t d_last_time;
84 uint64_t d_time_offset;
85 int d_sample_rate;
86 bool d_in_burst;
87 int d_output_index;
88 bool d_no_delay;
89 gr::thread::mutex d_mutex;
90 bool d_verbose;
91 bool d_retriggerable;
92 int d_flush_length;
93 int d_flush_count;
94 int d_burst_sample_count;
95 pmt::pmt_t d_length_tag_name;
96 bool d_complete_output;
97 int d_remaining_to_complete;
98 bool d_byte_trigger;
99 pmt::pmt_t d_trigger_tag_name;
100
101 public:
102 ~baz_gate (); // public destructor
103
104 void set_blocking(bool enable);
105 void set_threshold(float threshold);
106 void set_trigger_length(int trigger_length);
107 void set_tagging(bool enable);
108 void set_delay(double delay);
109 void set_sample_rate(int sample_rate);
110 void set_no_delay(bool no_delay);
111
112 void forecast(int noutput_items, gr_vector_int &ninput_items_required);
113
114 int general_work (int noutput_items, gr_vector_int &ninput_items,
115 gr_vector_const_void_star &input_items,
116 gr_vector_void_star &output_items);
117};
118
119#endif /* INCLUDED_BAZ_NATIVE_MUX_H */
BAZ_API
#define BAZ_API
Definition api.h:19
baz_gate
class BAZ_API baz_gate
Definition baz_gate.h:36
baz_make_gate
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, bool verbose=true, bool retriggerable=false, const std::string &length_tag_name="", bool complete_output=false, bool byte_trigger=false, const std::string &trigger_tag_name="")
Return a shared_ptr to a new instance of baz_gate.
baz_gate
square2 a stream of floats.
Definition baz_gate.h:67
baz_gate::set_tagging
void set_tagging(bool enable)
baz_gate::set_blocking
void set_blocking(bool enable)
baz_gate::set_threshold
void set_threshold(float threshold)
baz_gate::~baz_gate
~baz_gate()
baz_gate::set_no_delay
void set_no_delay(bool no_delay)
baz_gate::set_trigger_length
void set_trigger_length(int trigger_length)
baz_gate::forecast
void forecast(int noutput_items, gr_vector_int &ninput_items_required)
baz_gate::set_delay
void set_delay(double delay)
baz_gate::general_work
int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
baz_gate::baz_make_gate
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, bool verbose, bool retriggerable, const std::string &length_tag_name, bool complete_output, bool byte_trigger, const std::string &trigger_tag_name)
Return a shared_ptr to a new instance of baz_gate.
baz_gate::set_sample_rate
void set_sample_rate(int sample_rate)