ComputerSettings: move to src/Computer/
[xcsoar.git] / src / Computer / GlideComputerBlackboard.cpp
blob2adb65ed721794b19c6e4364ccf11e691a361501
1 /*
2 Copyright_License {
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()
33 /**
34 * Resets the GlideComputerBlackboard
35 * @param full Reset all data?
37 void
38 GlideComputerBlackboard::ResetFlight(const bool full)
40 gps_info.Reset();
41 calculated_info.Reset();
44 /**
45 * Starts the task on the GlideComputerBlackboard
47 void
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);
63 void
64 GlideComputerBlackboard::SaveFinish()
66 // JMW save calculated data at finish
67 Finish_Derived_Info = calculated_info;
70 void
71 GlideComputerBlackboard::RestoreFinish()
73 calculated_info = Finish_Derived_Info;
75 // \todo restore flying state
76 // SetBasic().flying_state = flying_state;
79 /**
80 * Retrieves GPS data from the DeviceBlackboard
81 * @param nmea_info New GPS data
83 void
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;
97 gps_info = nmea_info;
99 // if time hasn't advanced, don't copy last calculated
103 * Retrieves settings from the DeviceBlackboard
104 * @param settings New settings
106 void
107 GlideComputerBlackboard::ReadComputerSettings(const ComputerSettings &settings)
109 computer_settings = settings;