GNU Radio 3.7.1 C++ API
|
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2003,2005,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 #ifndef INCLUDED_GR_OSCOPE_GUTS_H 00025 #define INCLUDED_GR_OSCOPE_GUTS_H 00026 00027 #include <gnuradio/wxgui/api.h> 00028 #include <gnuradio/wxgui/trigger_mode.h> 00029 #include <gnuradio/msg_queue.h> 00030 00031 namespace gr { 00032 namespace wxgui { 00033 00034 /*! 00035 * \brief guts of oscilloscope trigger and buffer module 00036 * 00037 * This module processes sets of samples provided the \p 00038 * process_sample method. When appropriate given the updateRate, 00039 * sampleRate and trigger conditions, process_sample will 00040 * periodically write output records of captured data to 00041 * output_fd. For each trigger event, nchannels records will be 00042 * written. Each record consists of get_samples_per_output_record 00043 * binary floats. The trigger instant occurs at the 1/2 way point 00044 * in the buffer. Thus, output records consist of 50% pre-trigger 00045 * data and 50% post-trigger data. 00046 */ 00047 00048 class WXGUI_API oscope_guts 00049 { 00050 public: 00051 static const int MAX_CHANNELS = 8; 00052 00053 private: 00054 enum scope_state { HOLD_OFF, LOOK_FOR_TRIGGER, POST_TRIGGER }; 00055 00056 int d_nchannels; // how many channels 00057 msg_queue::sptr d_msgq; // message queue we stuff output records into 00058 trigger_mode d_trigger_mode; 00059 trigger_slope d_trigger_slope; 00060 int d_trigger_channel; // which channel to watch for trigger condition 00061 double d_sample_rate; // input sample rate in Hz 00062 double d_update_rate; // approx freq to produce an output record (Hz) 00063 double d_trigger_level; 00064 00065 int d_obi; // output buffer index 00066 float *d_buffer[MAX_CHANNELS]; 00067 00068 scope_state d_state; 00069 int d_decimator_count; 00070 int d_decimator_count_init; 00071 int d_hold_off_count; 00072 int d_hold_off_count_init; 00073 int d_pre_trigger_count; 00074 int d_post_trigger_count; 00075 int d_post_trigger_count_init; 00076 float d_trigger_off; //%sample trigger is off 00077 00078 // NOT IMPLEMENTED 00079 oscope_guts(const oscope_guts &rhs); // no copy constructor 00080 oscope_guts &operator= (const oscope_guts &rhs); // no assignment operator 00081 00082 void trigger_changed(); 00083 void update_rate_or_decimation_changed(); 00084 bool found_trigger(); // returns true if found 00085 void write_output_records(); 00086 00087 void enter_hold_off(); // called on state entry 00088 void enter_look_for_trigger(); 00089 void enter_post_trigger(); 00090 00091 public: 00092 // CREATORS 00093 oscope_guts(double sample_rate, msg_queue::sptr msgq); 00094 ~oscope_guts(); 00095 00096 // MANIPULATORS 00097 00098 /*! 00099 * \param channel_data points to nchannels float values. These 00100 * are the values for each channel at this sample time. 00101 */ 00102 void process_sample(const float *channel_data); 00103 00104 bool set_update_rate(double update_rate); 00105 bool set_decimation_count(int decimation_count); 00106 bool set_trigger_channel(int channel); 00107 bool set_trigger_mode(trigger_mode mode); 00108 bool set_trigger_slope(trigger_slope slope); 00109 bool set_trigger_level(double trigger_level); 00110 bool set_trigger_level_auto(); // set to 50% level 00111 bool set_sample_rate(double sample_rate); 00112 bool set_num_channels(int nchannels); 00113 00114 // ACCESSORS 00115 int num_channels() const; 00116 double sample_rate() const; 00117 double update_rate() const; 00118 int get_decimation_count() const; 00119 int get_trigger_channel() const; 00120 trigger_mode get_trigger_mode() const; 00121 trigger_slope get_trigger_slope() const; 00122 double get_trigger_level() const; 00123 00124 // # of samples written to each output record. 00125 int get_samples_per_output_record() const; 00126 }; 00127 00128 } /* namespace wxgui */ 00129 } /* namespace gr */ 00130 00131 #endif /* INCLUDED_GR_OSCOPE_GUTS_H */