Esempio n. 1
0
void
UpdateInfoBoxSpeed(InfoBoxData &data)
{
  const NMEAInfo &basic = CommonInterface::Basic();
  if (!basic.airspeed_available) {
    data.SetInvalid();
    return;
  }

  data.SetValueFromSpeed(basic.true_airspeed, false);
}
Esempio n. 2
0
void
UpdateInfoBoxFinalGR(InfoBoxData &data)
{
  const TaskStats &task_stats = CommonInterface::Calculated().task_stats;
  if (!task_stats.task_valid) {
    data.SetInvalid();
    return;
  }

  auto gradient = task_stats.total.gradient;

  if (gradient <= 0) {
    data.SetValue(_T("+++"));
    return;
  }
  if (::GradientValid(gradient))
    data.SetValueFromGlideRatio(gradient);
  else
    data.SetInvalid();
}
Esempio n. 3
0
void
InfoBoxContentSpeedGround::Update(InfoBoxData &data)
{
  const NMEAInfo &basic = CommonInterface::Basic();
  if (!basic.ground_speed_available) {
    data.SetInvalid();
    return;
  }

  data.SetValueFromSpeed(basic.ground_speed);
}
Esempio n. 4
0
void
UpdateInfoBoxGLoad(InfoBoxData &data)
{
  if (!CommonInterface::Basic().acceleration.available) {
    data.SetInvalid();
    return;
  }

  // Set Value
  data.SetValue(_T("%2.2f"), CommonInterface::Basic().acceleration.g_load);
}
Esempio n. 5
0
void
InfoBoxContentGLoad::Update(InfoBoxData &data)
{
  if (!XCSoarInterface::Basic().acceleration.available) {
    data.SetInvalid();
    return;
  }

  // Set Value
  data.SetValue(_T("%2.2f"), XCSoarInterface::Basic().acceleration.g_load);
}
Esempio n. 6
0
void
InfoBoxContentHorizon::Update(InfoBoxData &data)
{
  if (!CommonInterface::Basic().attitude.IsBankAngleUseable() &&
      !CommonInterface::Basic().attitude.IsPitchAngleUseable()) {
    data.SetInvalid();
    return;
  }

  data.SetCustom();
}
Esempio n. 7
0
void
InfoBoxContentThermalLastGain::Update(InfoBoxData &data)
{
  const OneClimbInfo &thermal = CommonInterface::Calculated().last_thermal;
  if (!thermal.IsDefined()) {
    data.SetInvalid();
    return;
  }

  data.SetValueFromAltitude(thermal.gain);
}
Esempio n. 8
0
void
InfoBoxContentThermalLastAvg::Update(InfoBoxData &data)
{
  const OneClimbInfo &thermal = CommonInterface::Calculated().last_thermal;
  if (!thermal.IsDefined()) {
    data.SetInvalid();
    return;
  }

  SetVSpeed(data, thermal.lift_rate);
}
Esempio n. 9
0
void
InfoBoxContentNextLegEqThermal::Update(InfoBoxData &data)
{
  const fixed next_leg_eq_thermal = CommonInterface::Calculated().next_leg_eq_thermal;
  if (negative(next_leg_eq_thermal)) {
    data.SetInvalid();
    return;
  }

  SetVSpeed(data, next_leg_eq_thermal);
}
Esempio n. 10
0
void
InfoBoxContentThermalAllAvg::Update(InfoBoxData &data)
{
  if (!positive(XCSoarInterface::Calculated().time_climb)) {
    data.SetInvalid();
    return;
  }

  SetVSpeed(data, XCSoarInterface::Calculated().total_height_gain /
            XCSoarInterface::Calculated().time_climb);
}
Esempio n. 11
0
void
InfoBoxContentFinalGR::Update(InfoBoxData &data)
{
  const TaskStats &task_stats = XCSoarInterface::Calculated().task_stats;
  if (!task_stats.task_valid) {
    data.SetInvalid();
    return;
  }

  fixed gradient = task_stats.total.gradient;

  if (!positive(gradient)) {
    data.SetValue(_T("+++"));
    return;
  }
  if (::GradientValid(gradient)) {
    data.UnsafeFormatValue(_T("%d"), (int)gradient);
  } else {
    data.SetInvalid();
  }
}
Esempio n. 12
0
void
UpdateInfoBoxFinalAltitudeRequire(InfoBoxData &data)
{
  const TaskStats &task_stats = CommonInterface::Calculated().task_stats;
  if (!task_stats.task_valid ||
      !task_stats.total.solution_remaining.IsOk()) {
    data.SetInvalid();
    return;
  }

  data.SetValueFromAltitude(task_stats.total.solution_remaining.GetRequiredAltitude());
}
Esempio n. 13
0
void
InfoBoxContentNextMC0AltitudeDiff::Update(InfoBoxData &data)
{
  const TaskStats &task_stats = XCSoarInterface::Calculated().task_stats;
  const GlideResult &next_solution = task_stats.current_leg.solution_mc0;
  if (!task_stats.task_valid || !next_solution.IsDefined()) {
    data.SetInvalid();
    return;
  }

  data.SetValueFromArrival(next_solution.altitude_difference);
}
Esempio n. 14
0
void
InfoBoxContentNearestAirspaceVertical::Update(InfoBoxData &data)
{
  NearestAirspace nearest = FindNearestVerticalAirspace();
  if (!nearest.IsDefined()) {
    data.SetInvalid();
    return;
  }

  data.SetValueFromArrival(nearest.distance);
  data.SetComment(nearest.airspace->GetName());
}
Esempio n. 15
0
void
UpdateInfoBoxCruiseEfficiency(InfoBoxData &data)
{
  const TaskStats &task_stats = CommonInterface::Calculated().task_stats;
  if (!task_stats.task_valid || !task_stats.start.task_started) {
    data.SetInvalid();
    return;
  }

  data.UnsafeFormatValue(_T("%d"), (int) (task_stats.cruise_efficiency * 100));
  data.SetCommentFromVerticalSpeed(task_stats.effective_mc, false);
}
Esempio n. 16
0
void
UpdateInfoBoxTerrainHeight(InfoBoxData &data)
{
  const TerrainInfo &calculated = CommonInterface::Calculated();
  if (!calculated.terrain_valid){
    data.SetInvalid();
    return;
  }

  data.SetValueFromAltitude(calculated.terrain_altitude);
  data.SetCommentFromAlternateAltitude(calculated.terrain_altitude);
}
Esempio n. 17
0
void
InfoBoxContentFinalAltitudeDiff::Update(InfoBoxData &data)
{
  const TaskStats &task_stats = XCSoarInterface::Calculated().task_stats;
  if (!task_stats.task_valid ||
      !task_stats.total.solution_remaining.IsOk()) {
    data.SetInvalid();
    return;
  }

  data.SetValueFromArrival(task_stats.total.solution_remaining.altitude_difference);
}
Esempio n. 18
0
void
UpdateInfoBoxHumidity(InfoBoxData &data)
{
  const NMEAInfo &basic = CommonInterface::Basic();
  if (!basic.humidity_available) {
    data.SetInvalid();
    return;
  }

  // Set Value
  data.UnsafeFormatValue( _T("%d"), (int)basic.humidity);
}
Esempio n. 19
0
void
InfoBoxContentHumidity::Update(InfoBoxData &data)
{
  const NMEAInfo &basic = XCSoarInterface::Basic();
  if (!basic.humidity_available) {
    data.SetInvalid();
    return;
  }

  // Set Value
  data.UnsafeFormatValue( _T("%d"), (int)basic.humidity);
}
Esempio n. 20
0
void
InfoBoxContentAltitudeGPS::Update(InfoBoxData &data)
{
  const NMEAInfo &basic = CommonInterface::Basic();

  if (!basic.gps_altitude_available) {
    data.SetInvalid();
    return;
  }

  data.SetValueFromAltitude(basic.gps_altitude);
  data.SetCommentFromAlternateAltitude(basic.gps_altitude);
}
Esempio n. 21
0
void
InfoBoxContentAlternateName::Update(InfoBoxData &data)
{
  if (protected_task_manager == NULL) {
    data.SetInvalid();
    return;
  }

  ProtectedTaskManager::Lease lease(*protected_task_manager);
  const AlternateList &alternates = lease->GetAlternates();

  const AlternatePoint *alternate;
  if (!alternates.empty()) {
    if (index >= alternates.size())
      index = alternates.size() - 1;

    alternate = &alternates[index];
  } else {
    alternate = NULL;
  }

  data.FormatTitle(_("Altn %d"), index + 1);

  if (alternate == NULL || !CommonInterface::Basic().track_available) {
    data.SetInvalid();
    return;
  }

  data.SetComment(alternate->waypoint.name.c_str());

  // Set Value
  Angle Value = alternate->solution.vector.bearing -
    CommonInterface::Basic().track;

  data.SetValueFromBearingDifference(Value);

  // Set Color (blue/black)
  data.SetValueColor(alternate->solution.IsFinalGlide() ? 2 : 0);
}
Esempio n. 22
0
void
UpdateInfoBoxGRInstant(InfoBoxData &data)
{
  const auto gr = CommonInterface::Calculated().gr;

  if (!::GradientValid(gr)) {
    data.SetInvalid();
    return;
  }

  // Set Value
  data.SetValueFromGlideRatio(gr);
}
Esempio n. 23
0
void
InfoBoxContentThermalAssistant::Update(InfoBoxData &data)
{
  if (!CommonInterface::Calculated().circling) {
    data.SetInvalid();
    return;
  }

  data.SetCustom();

  renderer.Update(CommonInterface::Basic().attitude,
                  CommonInterface::Calculated());
}
Esempio n. 24
0
void
InfoBoxContentOLC::Update(InfoBoxData &data)
{
  if (!XCSoarInterface::GetComputerSettings().task.enable_olc ||
      !protected_task_manager) {
    data.SetInvalid();
    return;
  }

  const ContestResult& result_olc = 
    XCSoarInterface::Calculated().contest_stats.GetResult();

  if (result_olc.score < fixed_one) {
    data.SetInvalid();
    return;
  }

  // Set Value
  data.SetValueFromDistance(result_olc.distance);

  data.UnsafeFormatComment(_T("%.1f pts"), (double)result_olc.score);
}
Esempio n. 25
0
void
InfoBoxContentLDVario::Update(InfoBoxData &data)
{
  if (XCSoarInterface::Calculated().ld_vario == fixed(999) ||
      !XCSoarInterface::Basic().total_energy_vario_available ||
      !XCSoarInterface::Basic().airspeed_available) {
    data.SetInvalid();
    return;
  }

  // Set Value
  SetValueFromFixed(data, _T("%2.0f"), XCSoarInterface::Calculated().ld_vario);
}
Esempio n. 26
0
void
UpdateInfoBoxCircleDiameter(InfoBoxData &data)
{
  if (!CommonInterface::Basic().airspeed_available.IsValid()) {
    data.SetInvalid();
    return;
  }

  const Angle turn_rate =
    CommonInterface::Calculated().turn_rate_heading_smoothed.Absolute();

  // deal with div zero and small turn rates
  if (turn_rate < Angle::Degrees(1)) {
    data.SetInvalid();
    return;
  }

  const fixed circle_diameter = CommonInterface::Basic().true_airspeed
     / turn_rate.Radians()
     * fixed(2); // convert turn rate to radians/s and double it to get estimated circle diameter

  if (circle_diameter > fixed (2000)){ // arbitrary estimated that any diameter bigger than 2km will not be interesting
    data.SetInvalid();
    return;
  }

  TCHAR buffer[32];
  Unit unit = FormatSmallUserDistance(buffer, circle_diameter, false, 0);
  data.SetValue (buffer);
  data.SetValueUnit(unit);

  const fixed circle_duration =
    Angle::FullCircle().Native() / turn_rate.Native();

  StaticString<16> duration_buffer;
  duration_buffer.Format(_T("%u s"), int(circle_duration));
  _tcscpy (buffer, duration_buffer);
  data.SetComment (buffer);
}
Esempio n. 27
0
void
UpdateInfoBoxTaskSpeedHour(InfoBoxData &data)
{
  const WindowStats &window =
    CommonInterface::Calculated().task_stats.last_hour;
  if (negative(window.duration)) {
    data.SetInvalid();
    return;
  }

  data.SetValue(_T("%2.0f"), Units::ToUserTaskSpeed(window.speed));
  data.SetValueUnit(Units::current.task_speed_unit);
}
Esempio n. 28
0
void
UpdateInfoBoxNextAltitudeRequire(InfoBoxData &data)
{
  // pilots want this to be assuming terminal flight to this wp

  const TaskStats &task_stats = CommonInterface::Calculated().task_stats;
  const GlideResult &next_solution = task_stats.current_leg.solution_remaining;
  if (!task_stats.task_valid || !next_solution.IsAchievable()) {
    data.SetInvalid();
    return;
  }

  data.SetValueFromAltitude(next_solution.GetRequiredAltitude());
}
Esempio n. 29
0
void
UpdateInfoBoxTaskAADistanceMin(InfoBoxData &data)
{
  const auto &calculated = CommonInterface::Calculated();
  const TaskStats &task_stats = calculated.ordered_task_stats;

  if (!task_stats.has_targets) {
    data.SetInvalid();
    return;
  }

  // Set Value
  data.SetValueFromDistance(task_stats.distance_min);
}
Esempio n. 30
0
void
UpdateInfoBoxNextGR(InfoBoxData &data)
{
  // pilots want this to be assuming terminal flight to this wp, and this
  // is what current_leg gradient does.

  if (!CommonInterface::Calculated().task_stats.task_valid) {
    data.SetInvalid();
    return;
  }

  fixed gradient = CommonInterface::Calculated().task_stats.current_leg.gradient;

  if (!positive(gradient)) {
    data.SetValue(_T("+++"));
    return;
  }
  if (::GradientValid(gradient)) {
    data.SetValueFromGlideRatio(gradient);
  } else {
    data.SetInvalid();
  }
}