4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #if !defined(XCSOAR_GLIDECOMPUTER_AIRDATA_HPP)
25 #define XCSOAR_GLIDECOMPUTER_AIRDATA_HPP
27 #include "AutoQNH.hpp"
28 #include "GlideRatioComputer.hpp"
29 #include "FlyingComputer.hpp"
30 #include "CirclingComputer.hpp"
31 #include "ThermalBandComputer.hpp"
32 #include "Wind/Computer.hpp"
33 #include "LiftDatabaseComputer.hpp"
34 #include "AverageVarioComputer.hpp"
35 #include "ThermalLocator.hpp"
36 #include "Math/WindowFilter.hpp"
41 struct ThermalLocatorInfo
;
42 struct ThermalBandInfo
;
47 class ProtectedAirspaceWarningManager
;
49 // TODO: replace copy constructors so copies of these structures
50 // do not replicate the large items or items that should be singletons
51 // OR: just make them static?
53 class GlideComputerAirData
{
54 const Waypoints
&waypoints
;
55 const RasterTerrain
*terrain
;
59 GlideRatioComputer gr_computer
;
61 FlyingComputer flying_computer
;
62 CirclingComputer circling_computer
;
63 ThermalBandComputer thermal_band_computer
;
64 WindComputer wind_computer
;
65 LiftDatabaseComputer lift_database_computer
;
67 ThermalLocator thermallocator
;
69 AverageVarioComputer average_vario
;
72 GlideComputerAirData(const Waypoints
&way_points
);
74 void SetTerrain(const RasterTerrain
* _terrain
) {
78 const WindStore
&GetWindStore() const {
79 return wind_computer
.GetWindStore();
82 void ResetFlight(DerivedInfo
&calculated
, const bool full
=true);
85 circling_computer
.ResetStats();
89 * Calculates some basic values
91 void ProcessBasic(const MoreData
&basic
, DerivedInfo
&calculated
,
92 const ComputerSettings
&settings
);
95 * Calculates some other values
97 void ProcessVertical(const MoreData
&basic
, const MoreData
&last_basic
,
98 DerivedInfo
&calculated
,
99 const ComputerSettings
&settings
);
102 * 1. Detects time retreat and calls ResetFlight if GPS lost
103 * 2. Detects change in replay status and calls ResetFlight if so
104 * 3. Calls DetectStartTime and saves the time of flight
105 * @return true as default, false if something is wrong in time
107 bool FlightTimes(const NMEAInfo
&basic
, const NMEAInfo
&last_basic
,
108 DerivedInfo
&calculated
,
109 const ComputerSettings
&settings
);
112 void NettoVario(const NMEAInfo
&basic
, const FlyingState
&flight
,
113 VarioInfo
&vario
, const ComputerSettings
&settings_computer
);
114 void AverageClimbRate(const NMEAInfo
&basic
, DerivedInfo
&calculated
);
115 void Average30s(const MoreData
&basic
, const NMEAInfo
&last_basic
,
116 DerivedInfo
&calculated
, bool last_circling
);
117 void CurrentThermal(const MoreData
&basic
, const CirclingInfo
&circling
,
118 OneClimbInfo
¤t_thermal
);
119 void GR(const MoreData
&basic
, const FlyingState
&flying
,
120 VarioInfo
&vario_info
);
121 void CruiseGR(const MoreData
&basic
, DerivedInfo
&calculated
);
123 void TerrainHeight(const MoreData
&basic
, TerrainInfo
&calculated
);
124 void FlightState(const NMEAInfo
&basic
,
125 const DerivedInfo
&calculated
, FlyingState
&flying
,
126 const GlidePolar
&glide_polar
);
128 void ThermalSources(const MoreData
&basic
, const DerivedInfo
&calculated
,
129 ThermalLocatorInfo
&thermal_locator
);
132 * Updates stats during transition from climb mode to cruise mode
133 * Sets last thermal stats if Circling state has changed
138 * Basic().EnergyHeight
143 * LastThermalAverageSmooth
145 void LastThermalStats(const MoreData
&basic
, DerivedInfo
&calculated
,
149 * Calculates the turn rate and the derived features.
150 * Determines the current flight mode (cruise/circling).
152 void Turning(const MoreData
&basic
,
153 DerivedInfo
&calculated
, const ComputerSettings
&settings
);
154 void ProcessSun(const NMEAInfo
&basic
, DerivedInfo
&calculated
,
155 const ComputerSettings
&settings
);
158 * Calculates the thermal value of next leg that is equivalent (gives the
159 * same average speed) to the current MacCready setting.
161 void NextLegEqThermal(const NMEAInfo
&basic
, DerivedInfo
&calculated
,
162 const ComputerSettings
&settings
);