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