Beispiel #1
0
bool
LXDevice::PutQNH(const AtmosphericPressure &pres)
{
  fixed altitude_offset =
    pres.StaticPressureToQNHAltitude(AtmosphericPressure::Standard());
  char buffer[100];
  sprintf(buffer, "PFLX3,%.2f,,,,,,,,,,,,", (double)altitude_offset / 0.3048);
  PortWriteNMEA(port, buffer);
  return true;
}
Beispiel #2
0
static bool
test_qnh_round2()
{
  AtmosphericPressure pres;
  pres.FindQNH(fixed(100), fixed(120));
  fixed p0 = pres.get_QNH()*100;
  fixed h0 = pres.StaticPressureToQNHAltitude(p0);
  if (verbose) {
    printf("%g %g\n",FIXED_DOUBLE(p0),FIXED_DOUBLE(h0));
  }
  return fabs(h0)<fixed(1);
}
Beispiel #3
0
static bool
test_qnh_round2()
{
  AtmosphericPressure sp = AtmosphericPressure::Standard().QNHAltitudeToStaticPressure(fixed(100));
  AtmosphericPressure pres =
    AtmosphericPressure::FindQNHFromPressure(sp, fixed(120));
  fixed h0 = pres.StaticPressureToQNHAltitude(pres);
  if (verbose) {
    printf("%g %g\n", FIXED_DOUBLE(pres.GetPascal()), FIXED_DOUBLE(h0));
  }
  return fabs(h0)<fixed(1);
}
Beispiel #4
0
static void
ComputePressure(NMEAInfo &basic, const AtmosphericPressure qnh)
{
  const bool qnh_available = qnh.IsPlausible();
  const bool static_pressure_available = basic.static_pressure_available;
  const bool pressure_altitude_available = basic.pressure_altitude_available;

  if (!static_pressure_available) {
    if (pressure_altitude_available) {
      basic.static_pressure =
        AtmosphericPressure::PressureAltitudeToStaticPressure(basic.pressure_altitude);
      basic.static_pressure_available = basic.pressure_altitude_available;
    } else if (basic.baro_altitude_available && qnh_available) {
      basic.static_pressure =
        qnh.QNHAltitudeToStaticPressure(basic.baro_altitude);
      basic.static_pressure_available = basic.baro_altitude_available;
    }
  }

  if (!pressure_altitude_available) {
    if (static_pressure_available) {
      basic.pressure_altitude =
        AtmosphericPressure::StaticPressureToPressureAltitude(basic.static_pressure);
      basic.pressure_altitude_available = basic.static_pressure_available;
    } else if (basic.baro_altitude_available && qnh_available) {
      basic.pressure_altitude =
        qnh.QNHAltitudeToPressureAltitude(basic.baro_altitude);
      basic.pressure_altitude_available = basic.baro_altitude_available;
    }
  }

  if (qnh_available) {
    /* if the current pressure and the QNH is known, then true baro
       altitude should be discarded, because the external device which
       provided it may have a different QNH setting */

    if (static_pressure_available) {
      basic.baro_altitude =
        qnh.StaticPressureToQNHAltitude(basic.static_pressure);
      basic.baro_altitude_available = basic.static_pressure_available;
    } else if (pressure_altitude_available) {
      basic.baro_altitude =
        qnh.PressureAltitudeToQNHAltitude(basic.pressure_altitude);
      basic.baro_altitude_available = basic.pressure_altitude_available;
    }
  } else if (!basic.baro_altitude_available && pressure_altitude_available)
    /* no QNH, but let's fill in the best fallback value we can get,
       without setting BaroAltitudeAvailable */
    basic.baro_altitude = basic.pressure_altitude;
}
Beispiel #5
0
bool
LXDevice::PutQNH(const AtmosphericPressure &pres, OperationEnvironment &env)
{
  if (!EnableNMEA(env))
    return false;

  double altitude_offset =
    (double)pres.StaticPressureToQNHAltitude(AtmosphericPressure::Standard()) / 0.3048;

  char buffer[100];
  if (IsV7())
    sprintf(buffer, "PLXV0,QNH,W,%.2f", altitude_offset);
  else
    sprintf(buffer, "PFLX3,%.2f,,,,,,,,,,,,", altitude_offset);
  return PortWriteNMEA(port, buffer, env);
}