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.
25 #include "GlideComputerBlackboard.hpp"
26 #include "NMEA/Info.hpp"
27 #include "NMEA/Derived.hpp"
29 GlideComputerBlackboard::GlideComputerBlackboard()
34 * Resets the GlideComputerBlackboard
35 * @param full Reset all data?
38 GlideComputerBlackboard::ResetFlight(const bool full
)
41 calculated_info
.Reset();
45 * Starts the task on the GlideComputerBlackboard
48 GlideComputerBlackboard::StartTask()
50 calculated_info
.cruise_start_location
= gps_info
.location
;
51 calculated_info
.cruise_start_altitude
= gps_info
.nav_altitude
;
52 calculated_info
.cruise_start_time
= gps_info
.time
;
54 // JMW reset time cruising/time circling stats on task start
55 calculated_info
.time_climb
= fixed(0);
56 calculated_info
.time_cruise
= fixed(0);
57 calculated_info
.total_height_gain
= fixed(0);
59 // reset max height gain stuff on task start
60 calculated_info
.max_height_gain
= fixed(0);
64 GlideComputerBlackboard::SaveFinish()
66 // JMW save calculated data at finish
67 Finish_Derived_Info
= calculated_info
;
71 GlideComputerBlackboard::RestoreFinish()
73 calculated_info
= Finish_Derived_Info
;
75 // \todo restore flying state
76 // SetBasic().flying_state = flying_state;
80 * Retrieves GPS data from the DeviceBlackboard
81 * @param nmea_info New GPS data
84 GlideComputerBlackboard::ReadBlackboard(const MoreData
&nmea_info
)
86 _time_retreated
= nmea_info
.HasTimeRetreatedSince(gps_info
);
88 if (_time_retreated
) {
89 // backwards in time, so reset last
90 last_gps_info
= nmea_info
;
91 _time_retreated
= true;
92 } else if (nmea_info
.time
> gps_info
.time
) {
93 // forwards in time, so save state
94 last_gps_info
= gps_info
;
99 // if time hasn't advanced, don't copy last calculated
103 * Retrieves settings from the DeviceBlackboard
104 * @param settings New settings
107 GlideComputerBlackboard::ReadComputerSettings(const ComputerSettings
&settings
)
109 computer_settings
= settings
;