Beispiel #1
0
void
IGCFileVisitor::Visit(Path path, Path filename)
{
  Error error;
  FileLineReaderA reader(path, error);
  if (reader.error()) {
    fprintf(stderr, "%s\n", error.GetMessage());
    return;
  }

  IGCExtensions extensions;
  extensions.clear();

  FlightCheck flight(filename.c_str());
  char *line;
  while ((line = reader.ReadLine()) != NULL) {
    unsigned day, month, year;

    IGCFix fix;
    if (IGCParseFix(line, extensions, fix))
      flight.fix(fix);
    else if (sscanf(line, "HFDTE%02u%02u%02u", &day, &month, &year)) {
      /* damn you, Y2K bug! */
      if (year > 80)
        year += 1900;
      else
        year += 2000;

      flight.date(year, month, day);
    }
  }

  flight.finish();
}
Beispiel #2
0
void
IGCFileVisitor::Visit(const TCHAR *path, const TCHAR *filename)
{
  FileLineReaderA reader(path);
  if (reader.error()) {
    _ftprintf(stderr, _T("Failed to open %s\n"), path);
    return;
  }

  IGCExtensions extensions;
  extensions.clear();

  FlightCheck flight(filename);
  char *line;
  while ((line = reader.ReadLine()) != NULL) {
    unsigned day, month, year;

    IGCFix fix;
    if (IGCParseFix(line, extensions, fix))
      flight.fix(fix);
    else if (sscanf(line, "HFDTE%02u%02u%02u", &day, &month, &year)) {
      /* damn you, Y2K bug! */
      if (year > 80)
        year += 1900;
      else
        year += 2000;

      flight.date(year, month, day);
    }
  }

  flight.finish();
}
Beispiel #3
0
bool
DebugReplayIGC::Next()
{
    last_basic = computed_basic;

    const char *line;
    while ((line = reader->ReadLine()) != NULL) {
        if (line[0] == 'B') {
            IGCFix fix;
            if (IGCParseFix(line, extensions, fix)) {
                CopyFromFix(fix);

                Compute();
                return true;
            }
        } else if (line[0] == 'H') {
            BrokenDate date;
            if (memcmp(line, "HFDTE", 5) == 0 &&
                    IGCParseDateRecord(line, date)) {
                (BrokenDate &)raw_basic.date_time_utc = date;
                raw_basic.time_available.Clear();
            }
        } else if (line[0] == 'I') {
            IGCParseExtensions(line, extensions);
        }
    }

    if (computed_basic.time_available)
        flying_computer.Finish(calculated.flight, computed_basic.time);

    return false;
}
Beispiel #4
0
static bool
TestTrace(const char *filename, unsigned ntrace, bool output=false)
{
  FileLineReaderA reader(filename);
  if (reader.error()) {
    fprintf(stderr, "Failed to open %s\n", filename);
    return false;
  }

  printf("# %d", ntrace);  
  Trace trace(1000, ntrace);

  char *line;
  int i = 0;
  for (; (line = reader.read()) != NULL; i++) {
    if (output && (i % 500 == 0)) {
      putchar('.');
      fflush(stdout);
    }

    IGCFix fix;
    if (!IGCParseFix(line, fix))
      continue;

    on_advance(trace,
               fix.location, fixed(30), Angle::zero(),
               fix.gps_altitude, fix.pressure_altitude,
               fixed(fix.time.GetSecondOfDay()));
  }
  putchar('\n');
  printf("# samples %d\n", i);
  return true;
}
Beispiel #5
0
static bool
TestTrace(Path filename, unsigned ntrace, bool output=false)
{
  FileLineReaderA reader(filename);

  printf("# %d", ntrace);  
  Trace trace(1000, ntrace);

  IGCExtensions extensions;
  extensions.clear();

  char *line;
  int i = 0;
  for (; (line = reader.ReadLine()) != NULL; i++) {
    if (output && (i % 500 == 0)) {
      putchar('.');
      fflush(stdout);
    }

    IGCFix fix;
    if (!IGCParseFix(line, extensions, fix) || !fix.gps_valid)
      continue;

    OnAdvance(trace,
               fix.location,
               fix.gps_altitude,
               fix.time.GetSecondOfDay());
  }
  putchar('\n');
  printf("# samples %d\n", i);
  return true;
}
Beispiel #6
0
bool
DebugReplayIGC::Next()
{
  last_basic = basic;
  last_calculated = calculated;

  const char *line;
  while ((line = reader->read()) != NULL) {
    if (line[0] == 'B') {
      IGCFix fix;
      if (IGCParseFix(line, extensions, fix) && fix.gps_valid) {
        CopyFromFix(fix);

        Compute();
        return true;
      }
    } else if (line[0] == 'H') {
      BrokenDate date;
      if (memcmp(line, "HFDTE", 5) == 0 &&
          IGCParseDateRecord(line, date)) {
        (BrokenDate &)basic.date_time_utc = date;
        basic.date_available = true;
      }
    } else if (line[0] == 'I') {
      IGCParseExtensions(line, extensions);
    }
  }

  return false;
}
Beispiel #7
0
inline bool
IgcReplay::ScanBuffer(const char *buffer, IGCFix &fix, NMEAInfo &basic)
{
  if (IGCParseFix(buffer, extensions, fix) && fix.gps_valid)
    return true;

  BrokenDate date;
  if (IGCParseDateRecord(buffer, date))
    basic.ProvideDate(date);
  else
    IGCParseExtensions(buffer, extensions);

  return false;
}
Beispiel #8
0
bool
DebugReplayIGC::Next()
{
  last_basic = basic;
  last_calculated = calculated;

  const char *line;
  while ((line = reader->read()) != NULL) {
    if (line[0] == 'B') {
      IGCFix fix;
      if (IGCParseFix(line, fix)) {
        CopyFromFix(fix);

        Compute();
        return true;
      }
    }
  }

  return false;
}
Beispiel #9
0
static void
TestFix()
{
  IGCExtensions extensions;
  extensions.clear();

  IGCFix fix;
  ok1(!IGCParseFix("", extensions, fix));
  ok1(!IGCParseFix("B1122385103117N00742367EA", extensions, fix));

  ok1(!IGCParseFix("B1122385103117X00742367EA0049000487", extensions, fix));
  ok1(!IGCParseFix("B1122385103117N00742367XA0049000487", extensions, fix));
  ok1(!IGCParseFix("B1122389003117N00742367EA0049000487", extensions, fix));
  ok1(!IGCParseFix("B1122385103117N18042367EA0049000487", extensions, fix));
  ok1(!IGCParseFix("B1122385163117N00742367EA0049000487", extensions, fix));
  ok1(!IGCParseFix("B1122385103117N00762367EA0049000487", extensions, fix));

  ok1(IGCParseFix("B1122385103117N00742367EA0049000487", extensions, fix));
  ok1(fix.time == BrokenTime(11, 22, 38));
  ok1(equals(fix.location, 51.05195, 7.70611667));
  ok1(fix.gps_valid);
  ok1(fix.pressure_altitude == 490);
  ok1(fix.gps_altitude == 487);

  ok1(IGCParseFix("B1122385103117N00742367EV0049000487", extensions, fix));
  ok1(fix.time == BrokenTime(11, 22, 38));
  ok1(equals(fix.location, 51.05195, 7.70611667));
  ok1(!fix.gps_valid);
  ok1(fix.pressure_altitude == 490);
  ok1(fix.gps_altitude == 487);

  ok1(!IGCParseFix("B1122385103117N00742367EX0049000487", extensions, fix));

  ok1(IGCParseFix("B1122435103117N00742367EA004900000000000",
                  extensions, fix));
  ok1(fix.time == BrokenTime(11, 22, 43));
  ok1(fix.gps_valid);
  ok1(fix.pressure_altitude == 490);
  ok1(fix.gps_altitude == 0);

  ok1(IGCParseFix("B1122535103117S00742367WA104900000700000",
                  extensions, fix));
  ok1(fix.time == BrokenTime(11, 22, 53));
  ok1(fix.gps_valid);
  ok1(equals(fix.location, -51.05195, -7.70611667));
  ok1(fix.pressure_altitude == 10490);
  ok1(fix.gps_altitude == 7);
}