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