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 #ifndef XCSOAR_NMEA_DERIVED_H
25 #define XCSOAR_NMEA_DERIVED_H
27 #include "Math/fixed.hpp"
28 #include "Geo/GeoPoint.hpp"
29 #include "Geo/SpeedVector.hpp"
30 #include "Task/Stats/TaskStats.hpp"
31 #include "Task/Stats/CommonStats.hpp"
32 #include "Contest/ContestStatistics.hpp"
33 #include "FlyingState.hpp"
34 #include "NMEA/VarioInfo.hpp"
35 #include "NMEA/ClimbInfo.hpp"
36 #include "NMEA/CirclingInfo.hpp"
37 #include "NMEA/ThermalBand.hpp"
38 #include "NMEA/ThermalLocator.hpp"
39 #include "NMEA/Validity.hpp"
40 #include "NMEA/ClimbHistory.hpp"
41 #include "TeamCode/TeamCode.hpp"
42 #include "Engine/Navigation/TraceHistory.hpp"
43 #include "Time/BrokenDateTime.hpp"
44 #include "Engine/GlideSolvers/GlidePolar.hpp"
45 #include "Atmosphere/Pressure.hpp"
46 #include "Engine/Route/Route.hpp"
47 #include "Util/TypeTraits.hpp"
49 /** Derived terrain altitude information, including glide range */
52 /** True if terrain is valid, False otherwise */
55 /** Does the attribute #TerrainBase have a valid value? */
56 bool terrain_base_valid
;
58 /** Does the attribute #AltitudeAGL have a valid value? */
59 bool altitude_agl_valid
;
63 /** Terrain altitude */
64 fixed terrain_altitude
;
66 /** Lowest height within glide range */
69 /** Altitude over terrain */
72 GeoPoint terrain_warning_location
;
77 * Returns the terrain base, and falls back for terrain altitude if
78 * the base is not known.
80 fixed
GetTerrainBaseFallback() const {
81 return terrain_base_valid
87 static_assert(std::is_trivial
<TerrainInfo
>::value
, "type is not trivial");
89 /** Derived team code information */
92 /** Are #teammate_vector and #TeammateLocation available? */
93 bool teammate_available
;
95 /** is #flarm_teammate_code current or did we lose him? */
96 bool flarm_teammate_code_current
;
99 TeamCode own_teammate_code
;
101 /** Vector to the chosen team mate */
102 GeoVector teammate_vector
;
104 /** Position of the chosen team mate */
105 GeoPoint teammate_location
;
108 * The team code of the FLARM teammate. Check TeamCode::IsDefined()
109 * before using this attribute.
111 TeamCode flarm_teammate_code
;
116 static_assert(std::is_trivial
<TeamInfo
>::value
, "type is not trivial");
118 struct AirspaceWarningsInfo
{
120 * The time stamp of the most recent airspace warning. Check if
121 * this value gets increased to see if there's a new warning.
128 static_assert(std::is_trivial
<AirspaceWarningsInfo
>::value
, "type is not trivial");
131 * A struct that holds all the calculated values derived from the data in the
141 /** GPS date and time (local) */
142 BrokenDateTime date_time_local
;
144 /** Speed to fly block/dolphin (m/s) */
147 /** Auto QNH calculation result. */
148 AtmosphericPressure pressure
;
149 Validity pressure_available
;
151 ClimbHistory climb_history
;
153 /** Does #estimated_wind have a meaningful value? */
154 Validity estimated_wind_available
;
156 /** Wind speed, direction */
157 SpeedVector estimated_wind
;
159 /** Is the wind available? */
160 Validity wind_available
;
163 * The effective wind vector; depending on the settings, this is
164 * either ExternalWind, calculated wind or manual wind.
169 * Where did we obtain the effective wind vector?
171 enum class WindSource
: uint8_t {
173 * No wind vector available. This should be kept in sync with
179 * The user has entered a wind vector manually.
184 * XCSoar has calculated the wind vector automatically.
189 * The wind vector was received from an external device.
194 Validity head_wind_available
;
197 /** Distance to zoom to for autozoom */
198 fixed auto_zoom_distance
;
200 Validity sun_data_available
;
201 /** Sun's azimuth at the current location and time */
204 /** Copy of task statistics data for active task */
205 TaskStats task_stats
;
207 /** Copy of task statistics data for ordered task */
208 TaskStats ordered_task_stats
;
210 /** Copy of common task statistics data */
211 CommonStats common_stats
;
212 /** Copy of contest statistics data */
213 ContestStatistics contest_stats
;
217 ThermalBandInfo thermal_band
;
219 ThermalLocatorInfo thermal_locator
;
221 /** Store of short term history of variables */
222 TraceHistory trace_history
;
224 Validity auto_mac_cready_available
;
225 fixed auto_mac_cready
;
227 /** Glide polar used for safety calculations */
228 GlidePolar glide_polar_safety
;
230 AirspaceWarningsInfo airspace_warnings
;
232 /** Route plan for current leg avoiding airspace */
233 StaticRoute planned_route
;
236 * Thermal value of next leg that is equivalent (gives the same average
237 * speed) to the current MacCready setting. A negative value should be
238 * treated as invalid.
240 fixed next_leg_eq_thermal
;
243 * @todo Reset to cleared state
247 void Expire(fixed Time
);
250 * Return the current wind vector, or the null vector if no wind is
254 SpeedVector
GetWindOrZero() const {
255 return wind_available
257 : SpeedVector::Zero();
260 void ProvideAutoMacCready(fixed clock
, fixed mc
) {
261 if (auto_mac_cready_available
&&
262 fabs(auto_mac_cready
- mc
) < fixed(0.05))
263 /* change is too small, ignore the new value to limit the rate */
266 auto_mac_cready
= mc
;
267 auto_mac_cready_available
.Update(clock
);
271 static_assert(is_trivial_ndebug
<DerivedInfo
>::value
, "type is not trivial");