00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
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 
00042 class gr_oscope_guts {
00043 private:
00044   static const int      MAX_CHANNELS = 16;
00045   enum scope_state      { HOLD_OFF, LOOK_FOR_TRIGGER, POST_TRIGGER };
00046 
00047   int                   d_nchannels;            
00048   int                   d_output_fd;            
00049   gr_trigger_mode       d_trigger_mode;         
00050   int                   d_trigger_channel;      
00051   double                d_sample_rate;          
00052   double                d_update_rate;          
00053   double                d_trigger_level;
00054 
00055   int                   d_obi;                  
00056   float                *d_buffer[MAX_CHANNELS];
00057 
00058   scope_state           d_state;
00059   int                   d_decimator_count;
00060   int                   d_decimator_count_init;
00061   int                   d_hold_off_count;
00062   int                   d_hold_off_count_init;
00063   int                   d_post_trigger_count;
00064   int                   d_post_trigger_count_init;
00065   float                 d_prev_sample;                  
00066 
00067   
00068   gr_oscope_guts (const gr_oscope_guts &rhs);                   
00069   gr_oscope_guts &operator= (const gr_oscope_guts &rhs);        
00070 
00071   void trigger_changed ();
00072   void update_rate_or_decimation_changed ();
00073   int  found_trigger (float sample);    
00074   void write_output_records ();
00075 
00076   void enter_hold_off ();                       
00077   void enter_look_for_trigger ();
00078   void enter_post_trigger ();
00079 
00080 public:
00081   
00082   gr_oscope_guts (int nchannels, double sample_rate, int output_fd);
00083   ~gr_oscope_guts ();
00084 
00085   
00086 
00091   void process_sample (const float *channel_data);
00092 
00093   bool set_update_rate (double update_rate);
00094   bool set_decimation_count (int decimation_count);
00095   bool set_trigger_channel (int channel);
00096   bool set_trigger_mode (gr_trigger_mode mode);
00097   bool set_trigger_level (double trigger_level);
00098   bool set_trigger_level_auto ();                               
00099 
00100 
00101   
00102   int num_channels () const;
00103   double sampling_rate () const;
00104   double update_rate () const;
00105   int get_decimation_count () const;
00106   int get_trigger_channel () const;
00107   gr_trigger_mode get_trigger_mode () const;
00108   double get_trigger_level () const;
00109 
00110   
00111   int get_samples_per_output_record () const;
00112 };
00113 
00114 #endif