Exemplo n.º 1
0
int
main(int argc, char **argv)
{
  if (argc != 2) {
    fprintf(stderr, "Usage: %s FILE.igc\n", argv[0]);
    return 1;
  }

#ifdef _UNICODE
  TCHAR path[PATH_MAX];
  int length = ::MultiByteToWideChar(CP_ACP, 0, argv[1], -1, path, PATH_MAX);
  if (length == 0)
    return 2;
#else
  const char *path = argv[1];
#endif

  GRecord g;
  g.Init();
  g.SetFileName(path);

  if (!g.LoadFileToBuffer()) {
    fprintf(stderr, "Failed to read file\n");
    return 2;
  }

  g.FinalizeBuffer();

  if (!g.AppendGRecordToFile(true)) {
    fprintf(stderr, "Failed to write file\n");
    return 2;
  }

  return 0;
}
Exemplo n.º 2
0
int
main(int argc, char **argv)
{
  if (argc != 2) {
    fprintf(stderr, "Usage: %s FILE.igc\n", argv[0]);
    return 1;
  }

#ifdef _UNICODE
  TCHAR path[PATH_MAX];
  int length = ::MultiByteToWideChar(CP_ACP, 0, argv[1], -1, path, PATH_MAX);
  if (length == 0)
    return 2;
#else
  const char *path = argv[1];
#endif

  GRecord g;
  g.Init();
  g.SetFileName(path);

  char data[1024];
  if (!g.ReadGRecordFromFile(data, ARRAY_SIZE(data))) {
    fprintf(stderr, "Error\n");
    return 2;
  }

  puts(data);
  return 0;
}
Exemplo n.º 3
0
int main(int argc, char **argv)
{
  const TCHAR *path = _T("output/test/test.igc");
  File::Delete(path);

  static const GeoPoint home(Angle::degrees(fixed(7.7061111111111114)),
                             Angle::degrees(fixed(51.051944444444445)));
  static const GeoPoint tp(Angle::degrees(fixed(10.726111111111111)),
                           Angle::degrees(fixed(50.632222222222225)));

  static NMEA_INFO i;
  i.DateTime.year = 2010;
  i.DateTime.month = 9;
  i.DateTime.day = 4;
  i.DateTime.hour = 11;
  i.DateTime.minute = 22;
  i.DateTime.second = 33;
  i.Location = home;
  i.GPSAltitude = fixed(487);
  i.BaroAltitude = fixed(490);

  IGCWriter writer(path, i);

  writer.header(i.DateTime, _T("Pilot Name"), _T("ASK-21"), _T("D-1234"),
                _T("foo"), _T("bar"));
  writer.StartDeclaration(i.DateTime, 3);
  writer.AddDeclaration(home, _T("Bergneustadt"));
  writer.AddDeclaration(tp, _T("Suhl"));
  writer.AddDeclaration(home, _T("Bergneustadt"));
  writer.EndDeclaration();

  i.DateTime.second += 5;
  writer.LogPoint(i);
  i.DateTime.second += 5;
  writer.LogEvent(i, "my_event");
  i.DateTime.second += 5;
  writer.LoggerNote(_T("my_note"));

  i.DateTime.second += 5;
  i.Location = GeoPoint(Angle::degrees(fixed(-7.7061111111111114)),
                        Angle::degrees(fixed(-51.051944444444445)));
  writer.LogPoint(i);

  writer.finish(i);
  writer.sign();

  CheckTextFile(path, expect);

  GRecord grecord;
  grecord.Init();
  grecord.SetFileName(path);
  assert(grecord.VerifyGRecordInFile());

  return 0;
}
Exemplo n.º 4
0
int main(int argc, char **argv)
{
  plan_tests(45);

  const TCHAR *path = _T("output/test/test.igc");
  File::Delete(path);

  static const GeoPoint home(Angle::degrees(fixed(7.7061111111111114)),
                             Angle::degrees(fixed(51.051944444444445)));
  static const GeoPoint tp(Angle::degrees(fixed(10.726111111111111)),
                           Angle::degrees(fixed(50.6322)));

  static NMEAInfo i;
  i.clock = fixed_one;
  i.time = fixed(1);
  i.time_available.Update(i.clock);
  i.date_time_utc.year = 2010;
  i.date_time_utc.month = 9;
  i.date_time_utc.day = 4;
  i.date_time_utc.hour = 11;
  i.date_time_utc.minute = 22;
  i.date_time_utc.second = 33;
  i.location = home;
  i.location_available.Update(i.clock);
  i.gps_altitude = fixed(487);
  i.gps_altitude_available.Update(i.clock);
  i.ProvideBaroAltitudeTrue(fixed(490));

  IGCWriter writer(path, i);

  writer.header(i.date_time_utc, _T("Pilot Name"), _T("ASK-21"), _T("D-1234"),
                _T("foo"), _T("bar"));
  writer.StartDeclaration(i.date_time_utc, 3);
  writer.AddDeclaration(home, _T("Bergneustadt"));
  writer.AddDeclaration(tp, _T("Suhl"));
  writer.AddDeclaration(home, _T("Bergneustadt"));
  writer.EndDeclaration();

  i.date_time_utc.second += 5;
  writer.LogPoint(i);
  i.date_time_utc.second += 5;
  writer.LogEvent(i, "my_event");
  i.date_time_utc.second += 5;
  writer.LoggerNote(_T("my_note"));

  i.date_time_utc.second += 5;
  i.location = GeoPoint(Angle::degrees(fixed(-7.7061111111111114)),
                        Angle::degrees(fixed(-51.051944444444445)));
  writer.LogPoint(i);

  writer.finish(i);
  writer.sign();

  CheckTextFile(path, expect);

  GRecord grecord;
  grecord.Init();
  grecord.SetFileName(path);
  ok1(grecord.VerifyGRecordInFile());

  return exit_status();
}