Ejemplo n.º 1
0
static void
WriteEvent(JSON::ObjectWriter &object, const char *name,
           const BrokenDateTime &time, const GeoPoint &location)
{
  if (time.Plausible() || location.IsValid())
    object.WriteElement(name, WriteEventAttributes, time, location);
}
Ejemplo n.º 2
0
fixed
SunEphemeris::FNday(const BrokenDateTime &date_time)
{
  assert(date_time.Plausible());

  long int luku = -7 * (date_time.year + (date_time.month + 9) / 12) / 4 +
                  275 * date_time.month / 9 + date_time.day +
                  (long int)date_time.year * 367;

  return fixed(luku) - fixed(730531.5) + fixed(date_time.hour % 24) / 24;
}
Ejemplo n.º 3
0
void
IGCWriter::WriteHeader(const BrokenDateTime &date_time,
                       const TCHAR *pilot_name, const TCHAR *aircraft_model,
                       const TCHAR *aircraft_registration,
                       const TCHAR *competition_id,
                       const char *logger_id, const TCHAR *driver_name,
                       bool simulator)
{
    /*
     * HFDTE141203  <- should be UTC, same as time in filename
     * HFFXA100
     * HFPLTPILOT:JOHN WHARINGTON
     * HFGTYGLIDERTYPE:LS 3
     * HFGIDGLIDERID:VH-WUE
     * HFDTM100GPSDATUM:WGS84
     * HFRFWFIRMWAREVERSION:3.6
     * HFRHWHARDWAREVERSION:3.4
     * HFFTYFR TYPE:GARRECHT INGENIEURGESELLSCHAFT,VOLKSLOGGER 1.0
     * HFCIDCOMPETITIONID:WUE
     * HFCCLCOMPETITIONCLASS:FAI
     */

    assert(date_time.Plausible());
    assert(logger_id != NULL);
    assert(strlen(logger_id) == 3);

    char buffer[100];

    // Flight recorder ID number MUST go first..
    sprintf(buffer, "AXCS%s", logger_id);
    WriteLine(buffer);

    sprintf(buffer, "HFDTE%02u%02u%02u",
            date_time.day, date_time.month, date_time.year % 100);
    WriteLine(buffer);

    if (!simulator)
        WriteLine(GetHFFXARecord());

    WriteLine("HFPLTPILOT:", pilot_name);
    WriteLine("HFGTYGLIDERTYPE:", aircraft_model);
    WriteLine("HFGIDGLIDERID:", aircraft_registration);
    WriteLine("HFCIDCOMPETITIONID:", competition_id);
    WriteLine("HFFTYFRTYPE:XCSOAR,XCSOAR ", XCSoar_VersionStringOld);
    WriteLine("HFGPS:", driver_name);

    WriteLine("HFDTM100DATUM:WGS-84");

    WriteLine(GetIRecord());
}
Ejemplo n.º 4
0
static void
WriteEventAttributes(TextWriter &writer,
                     const BrokenDateTime &time, const GeoPoint &location)
{
  JSON::ObjectWriter object(writer);

  if (time.Plausible()) {
    NarrowString<64> buffer;
    FormatISO8601(buffer.buffer(), time);
    object.WriteElement("time", JSON::WriteString, buffer);
  }

  if (location.IsValid())
    JSON::WriteGeoPointAttributes(object, location);
}
Ejemplo n.º 5
0
static bool
RawLoggerStart()
{
  if (RawLoggerWriter != NULL)
    return true;

  BrokenDateTime dt = XCSoarInterface::Basic().DateTime;
  assert(dt.Plausible());

  TCHAR path[MAX_PATH];
  LocalPath(path, _T("logs"));
  unsigned len = _tcslen(path);
  _sntprintf(path+len, MAX_PATH-len,
             _T(DIR_SEPARATOR_S "%04u-%02u-%02u_%02u-%02u.nmea"),
             dt.year, dt.month, dt.day,
             dt.hour, dt.minute);

  RawLoggerWriter = new BatchTextWriter(path, false);
  return RawLoggerWriter != NULL;
}
Ejemplo n.º 6
0
Angle
SunEphemeris::CalcAzimuth(const GeoPoint &location,
                          const BrokenDateTime &date_time,
                          const fixed time_zone)
{
  assert(date_time.Plausible());

  fixed days_to_j2000 = FNday(date_time);

  Angle l = GetMeanSunLongitude(days_to_j2000);

  // Use GetEclipticLongitude to find the ecliptic longitude of the Sun
  Angle lambda = GetEclipticLongitude(days_to_j2000, l);

  // Obliquity of the ecliptic
  Angle obliquity = Angle::Degrees(fixed(23.439) - fixed(.0000004) * days_to_j2000);

  // Find the DEC of the Sun
  Angle delta = Angle::asin(obliquity.sin() * lambda.sin());

  return CalculateAzimuth(location, date_time, time_zone, delta);
}
Ejemplo n.º 7
0
bool
NMEALogger::Start()
{
  if (writer != NULL)
    return true;

  BrokenDateTime dt = XCSoarInterface::Basic().date_time_utc;
  assert(dt.Plausible());

  StaticString<64> name;
  name.Format(_T("%04u-%02u-%02u_%02u-%02u.nmea"),
              dt.year, dt.month, dt.day,
              dt.hour, dt.minute);

  TCHAR path[MAX_PATH];
  LocalPath(path, _T("logs"));
  Directory::Create(path);

  LocalPath(path, _T("logs"), name);

  writer = new BatchTextWriter(path, false);
  return writer != NULL;
}
Ejemplo n.º 8
0
void
IGCWriter::StartDeclaration(const BrokenDateTime &date_time,
                            const int number_of_turnpoints)
{
    assert(date_time.Plausible());

    // IGC GNSS specification 3.6.1
    char buffer[100];
    sprintf(buffer, "C%02u%02u%02u%02u%02u%02u0000000000%02d",
            // DD  MM  YY  HH  MM  SS  DD  MM  YY IIII TT
            date_time.day,
            date_time.month,
            date_time.year % 100,
            date_time.hour,
            date_time.minute,
            date_time.second,
            number_of_turnpoints - 2);

    WriteLine(buffer);

    // takeoff line
    // IGC GNSS specification 3.6.3
    WriteLine("C0000000N00000000ETAKEOFF");
}
Ejemplo n.º 9
0
SunEphemeris::Result
SunEphemeris::CalcSunTimes(const GeoPoint &location,
                           const BrokenDateTime &date_time,
                           const fixed time_zone)
{
  Result result;

  assert(date_time.Plausible());

  fixed days_to_j2000 = FNday(date_time);

  Angle l = GetMeanSunLongitude(days_to_j2000);

  // Use GetEclipticLongitude to find the ecliptic longitude of the Sun
  Angle lambda = GetEclipticLongitude(days_to_j2000, l);

  // Obliquity of the ecliptic
  Angle obliquity = Angle::Degrees(fixed(23.439) - fixed(.0000004) * days_to_j2000);

  // Find the RA and DEC of the Sun
  Angle alpha = Angle::FromXY(lambda.cos(), obliquity.cos() * lambda.sin());
  Angle delta = Angle::asin(obliquity.sin() * lambda.sin());

  // Find the Equation of Time in minutes
  // Correction suggested by David Smith
  fixed ll = (l - alpha).Radians();
  if (l.Radians() < fixed_pi)
    ll += fixed_two_pi;

  fixed equation = fixed(1440) * (fixed(1) - ll / fixed_two_pi);

  Angle hour_angle = GetHourAngle(location.latitude, delta);
  Angle hour_angle_twilight = GetHourAngleTwilight(location.latitude, delta);

  result.azimuth = CalculateAzimuth(location, date_time, time_zone, delta);

  // length of twilight in hours
  fixed twilight_hours = (hour_angle_twilight - hour_angle).Hours();

  // Conversion of angle to hours and minutes
  result.day_length = Double(hour_angle.Hours());

  if (result.day_length < fixed(0.0001))
    // arctic winter
    result.day_length = fixed(0);

  result.time_of_sunrise = fixed(12) - hour_angle.Hours() + time_zone
    - location.longitude.Degrees() / 15 + equation / 60;

  if (result.time_of_sunrise > fixed(24))
    result.time_of_sunrise -= fixed(24);

  result.time_of_sunset = result.time_of_sunrise + result.day_length;
  result.time_of_noon = result.time_of_sunrise + hour_angle.Hours();

  // morning twilight begin
  result.morning_twilight = result.time_of_sunrise - twilight_hours;
  // evening twilight end
  result.evening_twilight = result.time_of_sunset + twilight_hours;

  return result;
}