2 Copyright 2006 Johnathan Corgan.
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.
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.
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.
22 // Application level includes
23 #include "spherical.h"
24 #include "samplelog.h"
25 #include "histogram.h"
30 // System level includes
33 // Forward declarations
36 class TransmitterSearch;
38 class SearchUpdate : public wxNotifyEvent
41 SearchUpdate(const wxEventType &event, bool done);
42 virtual wxEvent *Clone() const { return new SearchUpdate(*this); }
46 extern const wxEventType wxEVT_SEARCH_UPDATE;
48 typedef void(wxEvtHandler::*SearchUpdateFunction)(SearchUpdate&);
50 #define EVT_SEARCH_UPDATE(fn) \
51 DECLARE_EVENT_TABLE_ENTRY( \
52 wxEVT_SEARCH_UPDATE, -1, -1, \
53 (wxObjectEventFunction)(wxEventFunction)(SearchUpdateFunction)&fn, \
57 class TransmitterSearch : public wxThreadHelper
60 TransmitterSearch(wxEvtHandler *dest);
63 void Solve(SampleLog *log);
64 bool HasSolution() { return m_log ? m_log->Count() > 1 : false; }
67 bool Busy() const { return m_busy; }
68 int Mode() const { return m_histogram.Mode(); }
69 float Mean() const { return m_histogram.Mean(); }
70 float Concentration() { return m_histogram.Concentration(); }
72 const ErrorHistogram &Histogram() { return m_histogram; }
73 Spherical GetEstimatedLocation() { return m_solution; }
75 virtual void *Entry();
78 static const int MaxIterations = 20; // TODO: make configurable
80 bool hillclimb(std::vector<Sample> &samples);
81 float calc_trial_error(const std::vector<Sample> &samples, const Spherical &trial,
82 float &solution_error);
84 void background_solve();
85 void post_update(bool done);
87 // Background processing
90 wxCondition m_condition;
103 // Estimated solution histogram
104 ErrorHistogram m_histogram;