GNU Radio Manual and C++ API Reference 3.7.14.0
The Free & Open Software Radio Ecosystem
oscope_guts.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2003,2005,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#ifndef INCLUDED_GR_OSCOPE_GUTS_H
25#define INCLUDED_GR_OSCOPE_GUTS_H
26
27#include <gnuradio/msg_queue.h>
28#include <gnuradio/wxgui/api.h>
30
31namespace gr {
32namespace wxgui {
33
34/*!
35 * \brief guts of oscilloscope trigger and buffer module
36 *
37 * This module processes sets of samples provided the \p
38 * process_sample method. When appropriate given the updateRate,
39 * sampleRate and trigger conditions, process_sample will
40 * periodically write output records of captured data to
41 * output_fd. For each trigger event, nchannels records will be
42 * written. Each record consists of get_samples_per_output_record
43 * binary floats. The trigger instant occurs at the 1/2 way point
44 * in the buffer. Thus, output records consist of 50% pre-trigger
45 * data and 50% post-trigger data.
46 */
47
49{
50public:
51 static const int MAX_CHANNELS = 8;
52
53private:
54 enum scope_state { HOLD_OFF, LOOK_FOR_TRIGGER, POST_TRIGGER };
55
56 int d_nchannels; // how many channels
57 msg_queue::sptr d_msgq; // message queue we stuff output records into
58 trigger_mode d_trigger_mode;
59 trigger_slope d_trigger_slope;
60 int d_trigger_channel; // which channel to watch for trigger condition
61 double d_sample_rate; // input sample rate in Hz
62 double d_update_rate; // approx freq to produce an output record (Hz)
63 double d_trigger_level;
64
65 int d_obi; // output buffer index
66 float* d_buffer[MAX_CHANNELS];
67
68 scope_state d_state;
69 int d_decimator_count;
70 int d_decimator_count_init;
71 int d_hold_off_count;
72 int d_hold_off_count_init;
73 int d_pre_trigger_count;
74 int d_post_trigger_count;
75 int d_post_trigger_count_init;
76 float d_trigger_off; //%sample trigger is off
77
78 // NOT IMPLEMENTED
79 oscope_guts(const oscope_guts& rhs); // no copy constructor
80 oscope_guts& operator=(const oscope_guts& rhs); // no assignment operator
81
82 void trigger_changed();
83 void update_rate_or_decimation_changed();
84 bool found_trigger(); // returns true if found
85 void write_output_records();
86
87 void enter_hold_off(); // called on state entry
88 void enter_look_for_trigger();
89 void enter_post_trigger();
90
91public:
92 // CREATORS
93 oscope_guts(double sample_rate, msg_queue::sptr msgq);
95
96 // MANIPULATORS
97
98 /*!
99 * \param channel_data points to nchannels float values. These
100 * are the values for each channel at this sample time.
101 */
102 void process_sample(const float* channel_data);
103
104 bool set_update_rate(double update_rate);
105 bool set_decimation_count(int decimation_count);
106 bool set_trigger_channel(int channel);
109 bool set_trigger_level(double trigger_level);
110 bool set_trigger_level_auto(); // set to 50% level
111 bool set_sample_rate(double sample_rate);
112 bool set_num_channels(int nchannels);
113
114 // ACCESSORS
115 int num_channels() const;
116 double sample_rate() const;
117 double update_rate() const;
122 double get_trigger_level() const;
123
124 // # of samples written to each output record.
126};
127
128} /* namespace wxgui */
129} /* namespace gr */
130
131#endif /* INCLUDED_GR_OSCOPE_GUTS_H */
boost::shared_ptr< msg_queue > sptr
Definition: msg_queue.h:47
guts of oscilloscope trigger and buffer module
Definition: oscope_guts.h:49
int num_channels() const
void process_sample(const float *channel_data)
bool set_update_rate(double update_rate)
trigger_mode get_trigger_mode() const
double sample_rate() const
bool set_trigger_mode(trigger_mode mode)
int get_samples_per_output_record() const
bool set_trigger_level(double trigger_level)
int get_trigger_channel() const
int get_decimation_count() const
oscope_guts(double sample_rate, msg_queue::sptr msgq)
trigger_slope get_trigger_slope() const
bool set_decimation_count(int decimation_count)
bool set_trigger_channel(int channel)
bool set_num_channels(int nchannels)
double update_rate() const
bool set_sample_rate(double sample_rate)
bool set_trigger_slope(trigger_slope slope)
double get_trigger_level() const
#define WXGUI_API
Definition: gr-wxgui/include/gnuradio/wxgui/api.h:30
trigger_slope
Definition: gr-wxgui/include/gnuradio/wxgui/trigger_mode.h:36
trigger_mode
Definition: gr-wxgui/include/gnuradio/wxgui/trigger_mode.h:29
Include this header to use the message passing features.
Definition: basic_block.h:45