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 "DebugReplay.hpp"
25 #include "DebugReplayIGC.hpp"
26 #include "DebugReplayNMEA.hpp"
27 #include "OS/Args.hpp"
28 #include "IO/FileLineReader.hpp"
29 #include "OS/PathName.hpp"
30 #include "Device/Register.hpp"
31 #include "Computer/Settings.hpp"
33 DebugReplay::DebugReplay(NLineReader
*_reader
)
34 :reader(_reader
), glide_polar(fixed(1))
37 computed_basic
.Reset();
40 flying_computer
.Reset();
43 DebugReplay::~DebugReplay()
49 DebugReplay::Size() const
51 return reader
->GetSize();
55 DebugReplay::Tell() const
57 return reader
->Tell();
61 DebugReplay::Compute()
63 computed_basic
.Reset();
64 (NMEAInfo
&)computed_basic
= raw_basic
;
66 FeaturesSettings features
;
67 features
.nav_baro_altitude_enabled
= true;
68 computer
.Fill(computed_basic
, AtmosphericPressure::Standard(), features
);
70 computer
.Compute(computed_basic
, last_basic
, last_basic
, calculated
);
71 flying_computer
.Compute(glide_polar
.GetVTakeoff(),
72 computed_basic
, calculated
,
77 CreateDebugReplay(Args
&args
)
79 if (!args
.IsEmpty() && MatchesExtension(args
.PeekNext(), ".igc")) {
80 const char *input_file
= args
.ExpectNext();
82 FileLineReaderA
*reader
= new FileLineReaderA(input_file
);
83 if (reader
->error()) {
85 fprintf(stderr
, "Failed to open %s\n", input_file
);
89 return new DebugReplayIGC(reader
);
92 const tstring driver_name
= args
.ExpectNextT();
94 const struct DeviceRegister
*driver
= FindDriverByName(driver_name
.c_str());
96 _ftprintf(stderr
, _T("No such driver: %s\n"), driver_name
.c_str());
100 const char *input_file
= args
.ExpectNext();
102 FileLineReaderA
*reader
= new FileLineReaderA(input_file
);
103 if (reader
->error()) {
105 fprintf(stderr
, "Failed to open %s\n", input_file
);
109 return new DebugReplayNMEA(reader
, driver
);