Example #1
0
void
AutoQNH::Process(const NMEAInfo &basic, DerivedInfo &calculated,
                 const ComputerSettings &settings_computer, const Waypoints &way_points)
{
    if (!calculated.flight.on_ground // must be on ground
            || IsFinished()    // only do it once
            || !basic.gps.real // never in replay mode / simulator
            || !basic.location_available // Reject if no valid GPS fix
            || !basic.static_pressure_available // Reject if no pressure
            || settings_computer.pressure_available // Reject if QNH already known
       ) {
        if (!IsFinished())
            Reset(); // restart if havent performed

        return;
    }

    if (!IsFinished())
        countdown_autoqnh--;

    if (!countdown_autoqnh) {
        if (CalculateQNH(basic, calculated, way_points))
            countdown_autoqnh = UINT_MAX; // disable after performing once
        else
            Reset();
    }
}
Example #2
0
bool
AutoQNH::CalculateQNH(const NMEAInfo &basic, DerivedInfo &calculated,
                      const Waypoints &way_points)
{
    const Waypoint *next_wp;
    next_wp = way_points.LookupLocation(basic.location, fixed(1000));

    if (next_wp && next_wp->IsAirport())
        CalculateQNH(basic, calculated, next_wp->altitude);
    else if (calculated.terrain_valid)
        CalculateQNH(basic, calculated, calculated.terrain_altitude);
    else
        return false;

    return true;
}
Example #3
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/// Parses LXWP0 sentence.
///
/// @param d         device descriptor
/// @param sentence  received NMEA sentence
/// @param info      GPS info to be updated
///
/// @retval true if the sentence has been parsed
///
//static
bool DevLXMiniMap::LXWP0(PDeviceDescriptor_t d, const TCHAR* sentence, NMEA_INFO* info)
{
  // $LXWP0,logger_stored, airspeed, airaltitude,
  //   v1[0],v1[1],v1[2],v1[3],v1[4],v1[5], hdg, windspeed*CS<CR><LF>
  //
  // 0 loger_stored : [Y|N] (not used in LX1600)
  // 1 IAS [km/h] ----> Condor uses TAS!
  // 2 baroaltitude [m]
  // 3-8 vario values [m/s] (last 6 measurements in last second)
  // 9 heading of plane (not used in LX1600)
  // 10 windcourse [deg] (not used in LX1600)
  // 11 windspeed [km/h] (not used in LX1600)
  //
  // e.g.:
  // $LXWP0,Y,222.3,1665.5,1.71,,,,,,239,174,10.1

  TICKER = GetTickCount();

  double alt, airspeed;

  if (ParToDouble(sentence, 1, &airspeed))
  {
    airspeed /= TOKPH;
    info->TrueAirspeed = airspeed;
    info->AirspeedAvailable = TRUE;


  }

  if (ParToDouble(sentence, 2, &alt))
  {
    info->IndicatedAirspeed = airspeed / AirDensityRatio(alt);

    if (d == pDevPrimaryBaroSource)
    {
      UpdateQNH(CalculateQNH(alt, alt + AltOffset));
      UpdateBaroSource(info, 0, d, alt + AltOffset);


     /* if(FirstCheckBaroAlt)
      {
      FirstCheckBaroAlt = false;
      InputEvents::eventSetup(_T("Basic"));
      }*/
    }
  }

  if (ParToDouble(sentence, 3, &info->Vario))
    info->VarioAvailable = TRUE;

  if (ParToDouble(sentence, 10, &info->ExternalWindDirection) &&
      ParToDouble(sentence, 11, &info->ExternalWindSpeed))
    info->ExternalWindAvailable = TRUE;

  TriggerVarioUpdate();

  return(true);
} // LXWP0()