28#ifndef INCLUDED_BAZ_BURSTER_H
29#define INCLUDED_BAZ_BURSTER_H
32#include <boost/thread/thread.hpp>
38#include <gnuradio/sync_block.h>
39#include <gnuradio/msg_queue.h>
57typedef boost::shared_ptr<baz_burster> baz_burster_sptr;
83 typedef struct burst_time_t
86 double fractional_seconds;
87 uint64_t sample_offset;
91 inline static burst_time burst_time_absorb_whole_samples(
const burst_time& t)
94 uint64_t s = t.sample_offset / t.sample_rate;
96 _t.sample_offset -= (s * t.sample_rate);
100 inline static burst_time burst_time_absorb_samples(
const burst_time& t)
103 double d = (double)t.sample_offset / (
double)t.sample_rate;
104 _t.seconds += (int)d;
105 _t.fractional_seconds += (d - (int)d);
106 _t.sample_offset = 0;
110 inline static burst_time burst_time_difference(
const burst_time& t1,
const burst_time& t2,
bool relative_to_second =
true)
114 if ((t1.sample_rate == t2.sample_rate))
116 t.sample_rate = t1.sample_rate;
118 t.fractional_seconds = 0;
120 (t1.sample_rate * (t1.seconds - t2.seconds)) +
121 (uint64_t)((
double)t1.sample_rate * (t1.fractional_seconds - t2.fractional_seconds)) +
122 (t1.sample_offset - t2.sample_offset);
126 if ((t1.sample_rate != t2.sample_rate) && ((t1.sample_offset > 0) || (t2.sample_offset > 0)))
128 return burst_time_difference(burst_time_absorb_samples(t1), burst_time_absorb_samples(t2));
132 t.fractional_seconds = 0;
134 if (relative_to_second)
136 t.sample_rate = t2.sample_rate;
140 t.sample_rate = t1.sample_rate;
143 t.sample_offset = (t.sample_rate * (t1.seconds - t2.seconds)) + (uint64_t)((
double)t.sample_rate * (t1.fractional_seconds - t2.fractional_seconds));
148 bool send_pending_msg(
void);
149 void set_burst_length(
int length);
157 burst_time d_last_burst_time;
158 int d_burst_message_sample_index;
162 bool d_last_burst_system_time_valid;
164 uint64_t d_current_burst_length;
165 char* d_message_buffer;
166 int d_message_buffer_length;
167 int d_system_time_ticks_per_second;
169 char d_dummy_zero_last;
173 boost::system_time d_system_time;
174 boost::system_time d_last_burst_system_time;
177 gr::message::sptr d_pending_msg;
178 std::vector<gr::tag_t> d_incoming_time_tags;
184 void forecast(
int noutput_items, gr_vector_int &ninput_items_required);
185 int general_work (
int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
#define BAZ_API
Definition: api.h:19
class BAZ_API baz_burster
Definition: baz_burster.h:44
BAZ_API baz_burster_sptr baz_make_burster(const baz_burster_config &config)
Return a shared_ptr to a new instance of baz_burster.
burster a stream of floats.
Definition: baz_burster.h:75
int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
char d_dummy_zero_first
Definition: baz_burster.h:152
burst_time d_stream_time
Definition: baz_burster.h:154
friend BAZ_API baz_burster_sptr baz_make_burster(const baz_burster_config &config)
Return a shared_ptr to a new instance of baz_burster.
void forecast(int noutput_items, gr_vector_int &ninput_items_required)
Definition: baz_burster_config.h:32