Updated FSF address in all files. Fixes ticket:51
[debian/gnuradio] / ezdop / src / host / hunter / src / doppler.h
1 /*
2  Copyright 2006 Johnathan Corgan.
3  
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License version 2
6  as published by the Free Software Foundation.
7  
8  This software is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  GNU General Public License for more details.
12  
13  You should have received a copy of the GNU General Public License
14  along with GNU Radio; see the file COPYING.  If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street,
16  Boston, MA 02110-1301, USA.
17 */
18
19 #ifndef __DOPPLER_H__
20 #define __DOPPLER_H__
21
22 // Autoconf generated configure options
23 #if HAVE_CONFIG_H
24     #include "config.h"
25 #endif
26
27 // Application level includes
28 #include <ezdop.h>
29 #include <boost/shared_ptr.hpp>
30 #include <wx/event.h>
31
32 // TODO: Read this from ezdop.h
33 #define NUM_RATES   6   
34
35 class EZDoppler;
36
37 class DopplerBackground : public wxThread
38 {
39 public:
40         DopplerBackground(wxWindow *window, EZDoppler *doppler);
41         virtual ExitCode Entry();
42         bool IsRunning() { return m_running; }
43
44 private:
45         bool m_running;
46         wxWindow *m_dest;
47         EZDoppler *m_doppler;
48 };
49
50 class EZDopplerUpdate : public wxNotifyEvent
51 {
52 public:
53     EZDopplerUpdate(const wxEventType &event, float &in_phase, float &quadrature,
54                     float &volume); 
55     virtual wxEvent *Clone() const { return new EZDopplerUpdate(*this); }
56
57     float m_in_phase;
58     float m_quadrature;
59     float m_volume;
60 };
61
62 extern const wxEventType wxEVT_DOPPLER_UPDATE;
63
64 typedef void(wxEvtHandler::*EZDopplerUpdateFunction)(EZDopplerUpdate&);
65
66 #define EVT_DOPPLER_UPDATE(fn) \
67         DECLARE_EVENT_TABLE_ENTRY( \
68             wxEVT_DOPPLER_UPDATE, -1, -1, \
69             (wxObjectEventFunction)(wxEventFunction)(EZDopplerUpdateFunction)&fn, \
70             (wxObject *)NULL \
71         ),
72
73 typedef boost::shared_ptr<ezdop> ezdop_sptr;
74
75 class EZDoppler
76 {
77 public:
78     EZDoppler(wxWindow *gui);
79     ~EZDoppler();
80
81     // Control commands
82     bool Initialize();
83     bool Finalize();
84     bool IsOnline();
85     bool Start();
86     bool Stop();
87     bool SetFilter(int n);
88     bool SelectRotationRate(int n);
89     int  GetRotationRate();
90     bool Reset();
91     bool Sample(float &in_phase, float &quadrature, float &volume);
92     bool Calibrate(float phase);
93     bool SetCalibration(int rate, float offset);
94     float GetCalibration(int rate);
95     bool SetOffset(float offset = 0.0);
96     bool Nudge(float amount);
97     bool NudgeAll(float amount);
98             
99 private:
100     ezdop_sptr m_ezdop;
101     int m_selected_rate;
102     wxWindow *m_gui;
103     DopplerBackground *m_thread;
104
105     complex<float> m_phase;         // Actual phase of doppler before calibration
106     complex<float> m_output;        // Calibrated output phase
107     complex<float> m_alpha;         // Exponential average constant
108     complex<float> m_beta;          // Exponential average constant
109     
110     float m_angle;                  // Actual angle of doppler before calibration
111     float m_offset;                 // Global calibration angle
112     float m_calibration[NUM_RATES]; // Individual rotation rate offset
113 };    
114
115 #endif // __DOPPLER_H__