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 "OS/Args.hpp"
25 #include "DebugReplay.hpp"
26 #include "Formatter/TimeFormatter.hpp"
27 #include "Formatter/GeoPointFormatter.hpp"
28 #include "Util/Macros.hpp"
33 LogEvent(const TCHAR
*event
, fixed time
, const GeoPoint
&location
)
35 TCHAR time_buffer
[32], location_buffer
[64];
36 FormatTime(time_buffer
, time
);
38 _tprintf(_T("%s %s %s\n"), time_buffer
,
39 FormatGeoPoint(location
,
40 location_buffer
, ARRAY_SIZE(location_buffer
),
41 CoordinateFormat::DDMMSS
),
45 int main(int argc
, char **argv
)
47 Args
args(argc
, argv
, "DRIVER FILE");
48 DebugReplay
*replay
= CreateDebugReplay(args
);
54 bool last_flying
= false, last_released
= false;
56 while (replay
->Next()) {
57 const FlyingState
&flight
= replay
->Calculated().flight
;
59 if (flight
.flying
&& !last_flying
)
60 LogEvent(_T("take-off"), flight
.takeoff_time
, flight
.takeoff_location
);
61 else if (!flight
.flying
&& last_flying
)
62 LogEvent(_T("landing"), flight
.landing_time
, flight
.landing_location
);
63 else if (!negative(flight
.release_time
) && !last_released
)
64 LogEvent(_T("release"), flight
.release_time
, flight
.release_location
);
66 last_flying
= flight
.flying
;
67 last_released
= !negative(flight
.release_time
);
70 const FlyingState
&flight
= replay
->Calculated().flight
;
71 if (!negative(flight
.far_distance
)) {
72 TCHAR location_buffer
[64];
74 _tprintf(_T("far %u km at %s\n"), unsigned(flight
.far_distance
/ 1000),
75 FormatGeoPoint(flight
.far_location
,
76 location_buffer
, ARRAY_SIZE(location_buffer
),
77 CoordinateFormat::DDMMSS
));