3 XCSoar Glide Computer - http://www.xcsoar.org/
4 Copyright (C) 2000-2013 The XCSoar Project
5 A detailed list of copyright holders can be found in the file "AUTHORS".
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "IGC/IGCWriter.hpp"
24 #include "OS/FileUtil.hpp"
25 #include "NMEA/Info.hpp"
26 #include "IO/FileLineReader.hpp"
27 #include "TestUtil.hpp"
33 CheckTextFile(const TCHAR
*path
, const char *const* expect
)
35 FileLineReaderA
reader(path
);
39 while ((line
= reader
.ReadLine()) != NULL
) {
45 if (strncmp(*expect
, "HFFTYFRTYPE:", 12) == 0) {
46 ok1(strncmp(line
, "HFFTYFRTYPE:", 12) == 0);
48 if (strcmp(line
, *expect
)) {
49 printf("# \"%s\" fails to match with \"%s\"\n", line
, *expect
);
51 ok1(strcmp(line
, *expect
) == 0);
60 static const char *const expect
[] = {
64 "HFPLTPILOT:Pilot Name",
65 "HFGTYGLIDERTYPE:ASK-21",
66 "HFGIDGLIDERID:D-1234",
67 "HFCIDCOMPETITIONID:34",
68 "HFFTYFRTYPE:XCSOAR XCSOAR",
70 "HFDTM100DATUM:WGS-84",
72 "C040910112233000000000001",
73 "C0000000N00000000ETAKEOFF",
74 "C5103117N00742367EBERGNEUSTADT",
75 "C5037932N01043567ESUHL",
76 "C5103117N00742367EBERGNEUSTADT",
77 "C0000000N00000000ELANDING",
79 "B1122385103117N00742367EA004900048700000",
81 "B1122435103117N00742367EA004900048700000",
84 "B1122535103117S00742367WA004900048700000",
89 Run(IGCWriter
&writer
)
91 static const GeoPoint
home(Angle::Degrees(7.7061111111111114),
92 Angle::Degrees(51.051944444444445));
93 static const GeoPoint
tp(Angle::Degrees(10.726111111111111),
94 Angle::Degrees(50.6322));
99 i
.time_available
.Update(i
.clock
);
100 i
.date_time_utc
.year
= 2010;
101 i
.date_time_utc
.month
= 9;
102 i
.date_time_utc
.day
= 4;
103 i
.date_time_utc
.hour
= 11;
104 i
.date_time_utc
.minute
= 22;
105 i
.date_time_utc
.second
= 33;
107 i
.location_available
.Update(i
.clock
);
108 i
.gps_altitude
= fixed(487);
109 i
.gps_altitude_available
.Update(i
.clock
);
110 i
.ProvidePressureAltitude(fixed(490));
111 i
.ProvideBaroAltitudeTrue(fixed(400));
113 writer
.WriteHeader(i
.date_time_utc
, _T("Pilot Name"), _T("ASK-21"),
114 _T("D-1234"), _T("34"), "FOO", _T("bar"), false);
115 writer
.StartDeclaration(i
.date_time_utc
, 3);
116 writer
.AddDeclaration(home
, _T("Bergneustadt"));
117 writer
.AddDeclaration(tp
, _T("Suhl"));
118 writer
.AddDeclaration(home
, _T("Bergneustadt"));
119 writer
.EndDeclaration();
121 writer
.LogEmptyFRecord(i
.date_time_utc
);
123 i
.date_time_utc
.second
+= 5;
125 i
.date_time_utc
.second
+= 5;
126 writer
.LogEvent(i
, "my_event");
127 i
.date_time_utc
.second
+= 5;
128 writer
.LoggerNote(_T("my_note"));
130 int satellites
[GPSState::MAXSATELLITES
];
131 for (unsigned i
= 0; i
< GPSState::MAXSATELLITES
; ++i
)
138 i
.date_time_utc
.second
+= 5;
139 writer
.LogFRecord(i
.date_time_utc
, satellites
);
141 i
.location
= GeoPoint(Angle::Degrees(-7.7061111111111114),
142 Angle::Degrees(-51.051944444444445));
150 Run(const TCHAR
*path
)
152 IGCWriter
writer(path
);
156 int main(int argc
, char **argv
)
160 const TCHAR
*path
= _T("output/test/test.igc");
165 CheckTextFile(path
, expect
);
168 grecord
.Initialize();
169 ok1(grecord
.VerifyGRecordInFile(path
));
171 return exit_status();