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 #include "DebugReplayIGC.hpp"
25 #include "IO/FileLineReader.hpp"
26 #include "IGC/IGCParser.hpp"
27 #include "IGC/IGCFix.hpp"
28 #include "Units/System.hpp"
31 DebugReplayIGC::Next()
33 last_basic
= computed_basic
;
36 while ((line
= reader
->ReadLine()) != NULL
) {
39 if (IGCParseFix(line
, extensions
, fix
)) {
45 } else if (line
[0] == 'H') {
47 if (memcmp(line
, "HFDTE", 5) == 0 &&
48 IGCParseDateRecord(line
, date
)) {
49 (BrokenDate
&)raw_basic
.date_time_utc
= date
;
50 raw_basic
.date_available
= true;
51 raw_basic
.time_available
.Clear();
53 } else if (line
[0] == 'I') {
54 IGCParseExtensions(line
, extensions
);
58 if (computed_basic
.time_available
)
59 flying_computer
.Finish(calculated
.flight
, computed_basic
.time
);
65 DebugReplayIGC::CopyFromFix(const IGCFix
&fix
)
67 NMEAInfo
&basic
= raw_basic
;
69 if (basic
.time_available
&& basic
.date_time_utc
.hour
>= 23 &&
71 /* midnight roll-over */
73 raw_basic
.date_time_utc
.IncrementDay();
76 basic
.clock
= basic
.time
=
77 fixed(day
* 24 * 3600 + fix
.time
.GetSecondOfDay());
78 basic
.time_available
.Update(basic
.clock
);
79 basic
.date_time_utc
.hour
= fix
.time
.hour
;
80 basic
.date_time_utc
.minute
= fix
.time
.minute
;
81 basic
.date_time_utc
.second
= fix
.time
.second
;
82 basic
.alive
.Update(basic
.clock
);
83 basic
.location
= fix
.location
;
86 basic
.location_available
.Update(basic
.clock
);
88 basic
.location_available
.Clear();
90 if (fix
.gps_altitude
!= 0) {
91 basic
.gps_altitude
= fixed(fix
.gps_altitude
);
94 basic
.gps_altitude_available
.Update(basic
.clock
);
96 basic
.gps_altitude_available
.Clear();
98 basic
.gps_altitude_available
.Clear();
100 if (fix
.pressure_altitude
!= 0) {
101 basic
.pressure_altitude
= basic
.baro_altitude
= fixed(fix
.pressure_altitude
);
102 basic
.pressure_altitude_available
.Update(basic
.clock
);
103 basic
.baro_altitude_available
.Update(basic
.clock
);
107 basic
.engine_noise_level
= fix
.enl
;
108 basic
.engine_noise_level_available
.Update(basic
.clock
);
112 basic
.track
= Angle::Degrees(fixed(fix
.trt
));
113 basic
.track_available
.Update(basic
.clock
);
117 basic
.ground_speed
= Units::ToSysUnit(fixed(fix
.gsp
),
118 Unit::KILOMETER_PER_HOUR
);
119 basic
.ground_speed_available
.Update(basic
.clock
);
123 fixed ias
= Units::ToSysUnit(fixed(fix
.ias
), Unit::KILOMETER_PER_HOUR
);
125 basic
.ProvideBothAirspeeds(ias
,
126 Units::ToSysUnit(fixed(fix
.tas
),
127 Unit::KILOMETER_PER_HOUR
));
129 basic
.ProvideIndicatedAirspeedWithAltitude(ias
, basic
.pressure_altitude
);
130 } else if (fix
.tas
>= 0)
131 basic
.ProvideTrueAirspeed(Units::ToSysUnit(fixed(fix
.tas
),
132 Unit::KILOMETER_PER_HOUR
));
135 basic
.gps
.satellites_used
= fix
.siu
;
136 basic
.gps
.satellites_used_available
.Update(basic
.clock
);