Exemplo n.º 1
0
void
OrderedTaskPointLabel(TaskPointType type, const TCHAR *name,
                      unsigned index, TCHAR* buffer)
{
  switch (type) {
  case TaskPointType::START:
    StringFormatUnsafe(buffer, _T("S: %s"), name);
    break;

  case TaskPointType::AST:
    StringFormatUnsafe(buffer, _T("T%d: %s"), index, name);
    break;

  case TaskPointType::AAT:
    StringFormatUnsafe(buffer, _T("A%d: %s"), index, name);
    break;

  case TaskPointType::FINISH:
    StringFormatUnsafe(buffer, _T("F: %s"), name);
    break;

  default:
    break;
  }
}
Exemplo n.º 2
0
void
AirspaceFormatter::FormatAltitudeShort(TCHAR *buffer,
                                       const AirspaceAltitude &altitude)
{
  switch (altitude.reference) {
  case AltitudeReference::AGL:
    if (!positive(altitude.altitude_above_terrain))
      _tcscpy(buffer, _T("GND"));
    else
      StringFormatUnsafe(buffer, _T("%d %s AGL"),
                         iround(Units::ToUserAltitude(altitude.altitude_above_terrain)),
                         Units::GetAltitudeName());
    break;

  case AltitudeReference::STD:
    StringFormatUnsafe(buffer, _T("FL%d"), iround(altitude.flight_level));
    break;

  case AltitudeReference::MSL:
    StringFormatUnsafe(buffer, _T("%d %s"),
                       iround(Units::ToUserAltitude(altitude.altitude)),
                       Units::GetAltitudeName());
    break;

  case AltitudeReference::NONE:
    *buffer = _T('\0');
    break;
  }
}
Exemplo n.º 3
0
void
OrderedTaskSummary(const OrderedTask *task, TCHAR *text, bool linebreaks)
{
  const TaskStats &stats = task->GetStats();
  TCHAR summary_shape[100];
  bool FAIShape = TaskSummaryShape(task, summary_shape);
  if (FAIShape || task->GetFactoryType() == TaskFactoryType::FAI_GENERAL) {
    if (!task->GetFactory().ValidateFAIOZs()) {
      _tcscat(summary_shape, _T("/ "));
      _tcscat(summary_shape, getTaskValidationErrors(
          task->GetFactory().GetValidationErrors()));
    }
  }


  TCHAR linebreak[3];
  if (linebreaks) {
    linebreak[0] = '\n';
    linebreak[1] = 0;
  } else {
    linebreak[0] = ',';
    linebreak[1] = ' ';
    linebreak[2] = 0;
  }

  if (!task->TaskSize()) {
    StringFormatUnsafe(text, _("Task is empty (%s)"),
                       OrderedTaskFactoryName(task->GetFactoryType()));
  } else {
    if (task->HasTargets())
      StringFormatUnsafe(text, _T("%s%s%.0f %s%s%s %.0f %s%s%s %.0f %s (%s)"),
                         summary_shape,
                         linebreak,
                         (double)Units::ToUserDistance(stats.distance_nominal),
                         Units::GetDistanceName(),
                         linebreak,
                         _("max."),
                         (double)Units::ToUserDistance(stats.distance_max),
                         Units::GetDistanceName(),
                         linebreak,
                         _("min."),
                         (double)Units::ToUserDistance(stats.distance_min),
                         Units::GetDistanceName(),
                         OrderedTaskFactoryName(task->GetFactoryType()));
    else
      StringFormatUnsafe(text, _T("%s%s%s %.0f %s (%s)"),
                         summary_shape,
                         linebreak,
                         _("dist."),
                         (double)Units::ToUserDistance(stats.distance_nominal),
                         Units::GetDistanceName(),
                         OrderedTaskFactoryName(task->GetFactoryType()));
  }
}
Exemplo n.º 4
0
void
FormatTemperature(TCHAR *buffer, fixed value, Unit unit,
                  bool include_unit)
{
  value = Units::ToUserUnit(value, unit);

  if (include_unit)
    StringFormatUnsafe(buffer, _T("%.0f %s"),
                       (double)value, Units::GetUnitName(unit));
  else
    StringFormatUnsafe(buffer, _T("%.0f"), (double)value);
}
Exemplo n.º 5
0
void
FormatDistance(TCHAR *buffer, fixed value, Unit unit,
               bool include_unit, int precision)
{
  value = Units::ToUserUnit(value, unit);

  if (include_unit)
    StringFormatUnsafe(buffer, _T("%.*f %s"), precision, (double)value,
                       Units::GetUnitName(unit));
  else
    StringFormatUnsafe(buffer, _T("%.*f"), precision, (double)value);
}
Exemplo n.º 6
0
void
FormatSpeed(TCHAR *buffer,
            fixed value, const Unit unit, bool include_unit, bool precision)
{
  value = Units::ToUserUnit(value, unit);

  const int prec = precision && value < fixed(100);
  if (include_unit)
    StringFormatUnsafe(buffer, _T("%.*f %s"), prec, (double)value,
                       Units::GetUnitName(unit));
  else
    StringFormatUnsafe(buffer, _T("%.*f"), prec, (double)value);
}
Exemplo n.º 7
0
void
FormatPressure(TCHAR *buffer, AtmosphericPressure pressure,
               Unit unit, bool include_unit)
{
  auto _pressure = Units::ToUserUnit(pressure.GetHectoPascal(), unit);

  if (include_unit)
    StringFormatUnsafe(buffer, GetPressureFormat(unit, include_unit),
                       (double)_pressure,
                       Units::GetUnitName(unit));
  else
    StringFormatUnsafe(buffer, GetPressureFormat(unit, include_unit),
                       (double)_pressure);
}
Exemplo n.º 8
0
static void
FormatInteger(TCHAR *buffer,
              const fixed value, const Unit unit, bool include_unit,
              bool include_sign)
{
  const auto uvalue = Units::ToUserUnit(value, unit);
  const int ivalue = iround(uvalue);

  if (include_unit)
    StringFormatUnsafe(buffer, include_sign ? _T("%+d %s") : _T("%d %s"),
                       ivalue, Units::GetUnitName(unit));
  else
    StringFormatUnsafe(buffer, include_sign ? _T("%+d") : _T("%d"), ivalue);
}
Exemplo n.º 9
0
void
FormatVerticalSpeed(TCHAR *buffer, fixed value, Unit unit,
                    bool include_unit, bool include_sign)
{
  value = Units::ToUserUnit(value, unit);

  if (include_unit)
    StringFormatUnsafe(buffer,
                       GetVerticalSpeedFormat(unit, include_unit, include_sign),
                       (double)value, Units::GetUnitName(unit));
  else
    StringFormatUnsafe(buffer,
                       GetVerticalSpeedFormat(unit, include_unit, include_sign),
                       (double)value);
}
Exemplo n.º 10
0
Unit
FormatSmallDistance(TCHAR *buffer, fixed value, Unit unit,
                    bool include_unit, int precision)
{
  unit = GetSmallerDistanceUnit(unit);
  value = Units::ToUserUnit(value, unit);

  if (include_unit)
    StringFormatUnsafe(buffer, _T("%.*f %s"), precision, (double)value,
                       Units::GetUnitName(unit));
  else
    StringFormatUnsafe(buffer, _T("%.*f"), precision, (double)value);

  return unit;
}
Exemplo n.º 11
0
void
AltairProDevice::PutTurnPoint(const TCHAR *propertyName,
                              const Waypoint *waypoint,
                              OperationEnvironment &env)
{

    TCHAR Name[DECELWPNAMESIZE];
    TCHAR Buffer[DECELWPSIZE*2];

    int DegLat, DegLon;
    double tmp, MinLat, MinLon;
    char NoS, EoW;

    if (waypoint != nullptr) {

        CopyString(Name, waypoint->name.c_str(), ARRAY_SIZE(Name));

        tmp = (double)waypoint->location.latitude.Degrees();

        if(tmp < 0) {
            NoS = 'S';
            tmp *= -1;
        } else NoS = 'N';

        DegLat = (int)tmp;
        MinLat = tmp - DegLat;
        MinLat *= 60;
        MinLat *= 1000;

        tmp = (double)waypoint->location.longitude.Degrees();

        if (tmp < 0) {
            EoW = 'W';
            tmp *= -1;
        } else EoW = 'E';

        DegLon = (int)tmp;
        MinLon = tmp  - DegLon;
        MinLon *= 60;
        MinLon *= 1000;

    } else {

        Name[0] = '\0';
        DegLat = 0;
        MinLat = 0;
        DegLon = 0;
        MinLon = 0;
        NoS = 'N';
        EoW = 'E';
    }

    StringFormatUnsafe(Buffer, _T("PDVSC,S,%s,%02d%05.0f%c%03d%05.0f%c%s"),
                       propertyName,
                       DegLat, MinLat, NoS, DegLon, MinLon, EoW, Name);

    PropertySetGet(Buffer, ARRAY_SIZE(Buffer), env);

}
Exemplo n.º 12
0
void
DataFieldTime::AppendComboValue(ComboList &combo_list, int value) const
{
  TCHAR buffer[128], buffer2[32];
  FormatTimespanSmart(buffer, value, max_tokens);
  StringFormatUnsafe(buffer2, _T("%d"), value);
  combo_list.Append(value, buffer2, buffer);
}
Exemplo n.º 13
0
gcc_pure
static const TCHAR *
GetHeadingString(TCHAR *buffer)
{
  TCHAR heading[32];
  FormatBearing(heading, ARRAY_SIZE(heading),
                CommonInterface::Basic().attitude.heading);

  StringFormatUnsafe(buffer, _T("%s (%s)"), _("Heading"), heading);
  return buffer;
}
Exemplo n.º 14
0
void
AirspaceFormatter::FormatAltitude(TCHAR *buffer,
                                  const AirspaceAltitude &altitude)
{
  FormatAltitudeShort(buffer, altitude);

  if ((altitude.reference == AltitudeReference::MSL ||
       altitude.reference == AltitudeReference::AGL) &&
      Units::GetUserAltitudeUnit() == Unit::METER)
    /* additionally show airspace altitude in feet, because aviation
       charts usually print altitudes in feet */
    StringFormatUnsafe(buffer + _tcslen(buffer), _T(" (%d %s)"),
                       iround(Units::ToUserUnit(altitude.altitude, Unit::FEET)),
                       Units::GetUnitName(Unit::FEET));

  if (altitude.reference != AltitudeReference::MSL &&
      positive(altitude.altitude))
    StringFormatUnsafe(buffer + _tcslen(buffer), _T(" %d %s"),
                       iround(Units::ToUserAltitude(altitude.altitude)),
                       Units::GetAltitudeName());
}
Exemplo n.º 15
0
void
ClimbChartCaption(TCHAR *sTmp,
                  const FlightStatistics &fs)
{
  ScopeLock lock(fs.mutex);
  if (fs.thermal_average.IsEmpty()) {
    sTmp[0] = _T('\0');
  } else if (fs.thermal_average.GetCount() == 1) {
    StringFormatUnsafe(sTmp, _T("%s:\r\n  %3.1f %s"),
                       _("Avg. climb"),
                       (double)Units::ToUserVSpeed(fixed(fs.thermal_average.GetAverageY())),
                       Units::GetVerticalSpeedName());
  } else {
    StringFormatUnsafe(sTmp, _T("%s:\r\n  %3.1f %s\r\n\r\n%s:\r\n  %3.2f %s"),
                       _("Avg. climb"),
                       (double)Units::ToUserVSpeed(fixed(fs.thermal_average.GetAverageY())),
                       Units::GetVerticalSpeedName(),
                       _("Climb trend"),
                       (double)Units::ToUserVSpeed(fixed(fs.thermal_average.GetGradient())),
                       Units::GetVerticalSpeedName());
  }
}
Exemplo n.º 16
0
void
BarographCaption(TCHAR *sTmp, const FlightStatistics &fs)
{
  ScopeLock lock(fs.mutex);
  if (!fs.altitude_ceiling.HasResult()) {
    sTmp[0] = _T('\0');
  } else if (fs.altitude_ceiling.GetCount() < 4) {
    StringFormatUnsafe(sTmp, _T("%s:\r\n  %.0f-%.0f %s"),
                       _("Working band"),
                       (double)Units::ToUserAltitude(fs.altitude_base.GetAverageY()),
                       (double)Units::ToUserAltitude(fs.altitude_ceiling.GetAverageY()),
                       Units::GetAltitudeName());
  } else {
    StringFormatUnsafe(sTmp, _T("%s:\r\n  %.0f-%.0f %s\r\n\r\n%s:\r\n  %.0f %s/hr"),
                       _("Working band"),
                       (double)Units::ToUserAltitude(fs.altitude_base.GetAverageY()),
                       (double)Units::ToUserAltitude(fs.altitude_ceiling.GetAverageY()),
                       Units::GetAltitudeName(),
                       _("Ceiling trend"),
                       (double)Units::ToUserAltitude(fs.altitude_ceiling.GetGradient()),
                       Units::GetAltitudeName());
  }
}
Exemplo n.º 17
0
static TCHAR *
GetDirectionData(TCHAR *buffer, size_t size, int direction_filter_index)
{
  if (direction_filter_index == 0)
    _tcscpy(buffer, _T("*"));
  else if (direction_filter_index == 1) {
    TCHAR bearing[8];
    FormatBearing(bearing, ARRAY_SIZE(bearing), last_heading);
    StringFormatUnsafe(buffer, _T("HDG(%s)"), bearing);
  } else
    FormatBearing(buffer, size, direction_filter_items[direction_filter_index]);

  return buffer;
}
Exemplo n.º 18
0
static void
Draw(Canvas &canvas, const PixelRect rc,
     const LocationMapItem &item,
     const TwoTextRowsRenderer &row_renderer)
{
  TCHAR info_buffer[256];
  if (item.vector.IsValid())
    StringFormatUnsafe(info_buffer, _T("%s: %s, %s: %s"),
                       _("Distance"),
                       FormatUserDistanceSmart(item.vector.distance).c_str(),
                       _("Direction"),
                       FormatBearing(item.vector.bearing).c_str());
  else
    StringFormatUnsafe(info_buffer, _T("%s: %s, %s: %s"),
                       _("Distance"), _T("???"), _("Direction"), _T("???"));

  row_renderer.DrawFirstRow(canvas, rc, info_buffer);

  StringFormatUnsafe(info_buffer, _T("%s: %s"), _("Elevation"),
                     item.HasElevation()
                     ? FormatUserAltitude(item.elevation).c_str()
                     : _T("???"));
  row_renderer.DrawSecondRow(canvas, rc, info_buffer);
}
Exemplo n.º 19
0
/**
 *
 * @param task
 * @param text
 * @return True if FAI shape
 */
static bool
TaskSummaryShape(const OrderedTask *task, TCHAR *text)
{
  bool FAIShape = false;
  switch (task->TaskSize()) {
  case 0:
    text[0] = '\0';
    break;

  case 1:
    _tcscpy(text, _("Unknown"));
    break;

  case 2:
    _tcscpy(text, _("Goal"));
    FAIShape = true;

    break;

  case 3:
    if (task->GetFactory().IsClosed()) {
      _tcscpy(text, _("Out and return"));
      FAIShape = true;
    }
    else
      _tcscpy(text, _("Two legs"));
    break;

  case 4:
    if (!task->GetFactory().IsUnique() ||!task->GetFactory().IsClosed())
      _tcscpy(text, _("Three legs"));
    else if (FAITriangleValidator::Validate(*task)) {
      _tcscpy(text, _("FAI triangle"));
      FAIShape = true;
    }
    else
      _tcscpy(text, _("non-FAI triangle"));
    break;

  default:
    StringFormatUnsafe(text, _("%d legs"), task->TaskSize() - 1);
    break;
  }
  return FAIShape;
}
Exemplo n.º 20
0
static void
FillDistanceEnum(DataFieldEnum &df)
{
  df.AddChoice(0, _T("*"));

  static constexpr unsigned distances[] = {
    25, 50, 75, 100, 150, 250, 500, 1000
  };

  TCHAR buffer[64];
  const TCHAR *unit = Units::GetDistanceName();
  for (unsigned i = 0; i < ARRAY_SIZE(distances); ++i) {
    StringFormatUnsafe(buffer, _T("%u %s"), distances[i], unit);
    df.AddChoice(distances[i], buffer);
  }

  df.Set(0u);
}
Exemplo n.º 21
0
static void
FillAndroidIOIOPorts(DataFieldEnum &df, const DeviceConfig &config)
{
#if defined(ANDROID)
  df.EnableItemHelp(true);

  TCHAR tempID[4];
  TCHAR tempName[15];
  for (unsigned i = 0; i < AndroidIOIOUartPort::getNumberUarts(); i++) {
    StringFormatUnsafe(tempID, _T("%u"), i);
    StringFormat(tempName, sizeof(tempName), _T("IOIO Uart %u"), i);
    unsigned id = AddPort(df, DeviceConfig::PortType::IOIOUART,
                          tempID, tempName,
                          AndroidIOIOUartPort::getPortHelp(i));
    if (config.port_type == DeviceConfig::PortType::IOIOUART &&
        config.ioio_uart_id == i)
      df.Set(id);
  }
#endif
}
Exemplo n.º 22
0
void
RenderTaskLegs(ChartRenderer &chart,
               const TaskManager &task_manager,
               const NMEAInfo& basic,
               const DerivedInfo& calculated,
               const double y)
{
  const TaskStats &task_stats = calculated.ordered_task_stats;

  if (!task_stats.start.task_started)
    return;

  TCHAR sTmp[5];

  const OrderedTask &task = task_manager.GetOrderedTask();
  for (unsigned i = 0, n = task.TaskSize(); i < n; ++i) {
    const OrderedTaskPoint &tp = task.GetTaskPoint(i);
    if (!IsTaskLegVisible(tp))
      continue;

    auto x = tp.GetEnteredState().time - calculated.flight.takeoff_time;
    if (x >= 0) {
      x /= 3600;
      if (y>=0) {
        if (i==0) {
          chart.DrawBlankRectangle(chart.GetXMin(), chart.GetYMin(),
                                   x, chart.GetYMax());
        } else if (i+1 == task.TaskSize()) {
          chart.DrawBlankRectangle(x, chart.GetYMin(),
                                   chart.GetXMax(), chart.GetYMax());
        }
        chart.DrawLine(x, chart.GetYMin(), x, chart.GetYMax(),
                       ChartLook::STYLE_GRIDZERO);
      }
      if (y>=0) {
        StringFormatUnsafe(sTmp, _T("%d"), i);
        chart.DrawLabel(sTmp, x, chart.GetYMax()*y + chart.GetYMin()*(1-y));
      }
    }
  }
}
Exemplo n.º 23
0
  void FormatLabel(TCHAR *buffer, size_t buffer_size,
                   const Waypoint &way_point,
                   WaypointRenderer::Reachability reachable,
                   const ReachResult &reach) const {
    FormatTitle(buffer, buffer_size - 20, way_point);

    if (!way_point.IsLandable() && !way_point.flags.watched)
      return;

    if (settings.arrival_height_display == WaypointRendererSettings::ArrivalHeightDisplay::REQUIRED_GR) {
      if (!basic.location_available || !basic.NavAltitudeAvailable())
        return;

      const auto safety_height = task_behaviour.safety_height_arrival;
      const auto target_altitude = way_point.elevation + safety_height;
      const auto delta_h = basic.nav_altitude - target_altitude;
      if (delta_h <= 0)
        /* no L/D if below waypoint */
        return;

      const auto distance = basic.location.DistanceS(way_point.location);
      const auto gr = distance / delta_h;
      if (!GradientValid(gr))
        return;

      size_t length = _tcslen(buffer);
      if (length > 0)
        buffer[length++] = _T(':');
      StringFormatUnsafe(buffer + length, _T("%.1f"), (double) gr);
      return;
    }

    if (reachable == WaypointRenderer::Invalid)
      return;

    if (!reach.IsReachableDirect() && !way_point.flags.watched)
      return;

    if (settings.arrival_height_display == WaypointRendererSettings::ArrivalHeightDisplay::NONE)
      return;

    size_t length = _tcslen(buffer);
    int uah_glide = (int)Units::ToUserAltitude(reach.direct);
    int uah_terrain = (int)Units::ToUserAltitude(reach.terrain);

    if (settings.arrival_height_display == WaypointRendererSettings::ArrivalHeightDisplay::TERRAIN) {
      if (reach.IsReachableTerrain()) {
        if (length > 0)
          buffer[length++] = _T(':');
        StringFormatUnsafe(buffer + length, _T("%d%s"),
                           uah_terrain, altitude_unit);
      }
      return;
    }

    if (length > 0)
      buffer[length++] = _T(':');

    if (settings.arrival_height_display == WaypointRendererSettings::ArrivalHeightDisplay::GLIDE_AND_TERRAIN &&
        reach.IsReachableDirect() && reach.IsReachableTerrain() &&
        reach.IsDeltaConsiderable()) {
      StringFormatUnsafe(buffer + length, _T("%d/%d%s"), uah_glide,
                         uah_terrain, altitude_unit);
      return;
    }

    StringFormatUnsafe(buffer + length, _T("%d%s"), uah_glide, altitude_unit);
  }
Exemplo n.º 24
0
void
AnalysisWidget::Update()
{
  TCHAR sTmp[1000];

  const ComputerSettings &settings_computer = blackboard.GetComputerSettings();
  const DerivedInfo &calculated = blackboard.Calculated();

  switch (page) {
  case AnalysisPage::BAROGRAPH:
    StringFormatUnsafe(sTmp, _T("%s: %s"), _("Analysis"),
                       _("Barograph"));
    dialog.SetCaption(sTmp);
    BarographCaption(sTmp, glide_computer.GetFlightStats());
    info.SetText(sTmp);
    SetCalcCaption(_("Settings"));
    break;

  case AnalysisPage::CLIMB:
    StringFormatUnsafe(sTmp, _T("%s: %s"), _("Analysis"),
                       _("Climb"));
    dialog.SetCaption(sTmp);
    ClimbChartCaption(sTmp, glide_computer.GetFlightStats());
    info.SetText(sTmp);
    SetCalcCaption(_("Task Calc"));
    break;

  case AnalysisPage::THERMAL_BAND:
    StringFormatUnsafe(sTmp, _T("%s: %s"), _("Analysis"),
                       _("Thermal Band"));
    dialog.SetCaption(sTmp);
    ClimbChartCaption(sTmp, glide_computer.GetFlightStats());
    info.SetText(sTmp);
    SetCalcCaption(_T(""));
    break;

  case AnalysisPage::WIND:
    StringFormatUnsafe(sTmp, _T("%s: %s"), _("Analysis"),
                       _("Wind at Altitude"));
    dialog.SetCaption(sTmp);
    info.SetText(_T(""));
    SetCalcCaption(_("Set Wind"));
    break;

  case AnalysisPage::POLAR:
    StringFormatUnsafe(sTmp, _T("%s: %s (%s %d kg)"), _("Analysis"),
                       _("Glide Polar"), _("Mass"),
                       (int)settings_computer.polar.glide_polar_task.GetTotalMass());
    dialog.SetCaption(sTmp);
    GlidePolarCaption(sTmp, settings_computer.polar.glide_polar_task);
    info.SetText(sTmp);
    SetCalcCaption(_("Settings"));
    break;

  case AnalysisPage::TEMPTRACE:
    StringFormatUnsafe(sTmp, _T("%s: %s"), _("Analysis"),
                       _("Temp Trace"));
    dialog.SetCaption(sTmp);
    TemperatureChartCaption(sTmp, glide_computer.GetCuSonde());
    info.SetText(sTmp);
    SetCalcCaption(_("Settings"));
    break;

  case AnalysisPage::TASK_SPEED:
    StringFormatUnsafe(sTmp, _T("%s: %s"), _("Analysis"),
                       _("Task Speed"));
    dialog.SetCaption(sTmp);
    info.SetText(_T(""));
    SetCalcCaption(_("Task Calc"));
    break;

  case AnalysisPage::TASK:
    StringFormatUnsafe(sTmp, _T("%s: %s"), _("Analysis"),
                       _("Task"));
    dialog.SetCaption(sTmp);
    FlightStatisticsRenderer::CaptionTask(sTmp, calculated);
    info.SetText(sTmp);
    SetCalcCaption(_("Task calc"));
    break;

  case AnalysisPage::OLC:
    StringFormatUnsafe(sTmp, _T("%s: %s"), _("Analysis"),
                       ContestToString(settings_computer.contest.contest));
    dialog.SetCaption(sTmp);
    SetCalcCaption(_T(""));
    FlightStatisticsRenderer::CaptionOLC(sTmp, settings_computer.contest,
                                         calculated);
    info.SetText(sTmp);
    break;

  case AnalysisPage::AIRSPACE:
    StringFormatUnsafe(sTmp, _T("%s: %s"), _("Analysis"),
                       _("Airspace"));
    dialog.SetCaption(sTmp);
    info.SetText(_T(""));
    SetCalcCaption(_("Warnings"));
    break;

  case AnalysisPage::COUNT:
    gcc_unreachable();
  }

  if (page == AnalysisPage::AIRSPACE)
    chart.UpdateCrossSection(blackboard.Basic(), calculated,
                             settings_computer.task.glide,
                             settings_computer.polar.glide_polar_task,
                             blackboard.GetMapSettings());


  chart.Invalidate();
}
Exemplo n.º 25
0
const TCHAR *
DataFieldTime::GetAsString() const
{
  StringFormatUnsafe(string_buffer, _T("%d"), value);
  return string_buffer;
}
Exemplo n.º 26
0
 void UnsafeFormat(const T *fmt, Args&&... args) {
   StringFormatUnsafe(data, fmt, args...);
 }
Exemplo n.º 27
0
/**
 * Updates all the dialogs fields.
 * Should be called on dialog opening as it closes the dialog when the
 * target does not exist.
 */
void
FlarmTrafficDetailsWidget::Update()
{
  TCHAR tmp[200], tmp_id[7];
  const TCHAR *value;

  // Set the dialog caption
  StringFormatUnsafe(tmp, _T("%s (%s)"),
                     _("FLARM Traffic Details"), target_id.Format(tmp_id));
  dialog.SetCaption(tmp);

  // Try to find the target in the FLARMnet database
  /// @todo: make this code a little more usable
  const FlarmNetRecord *record = FlarmDetails::LookupRecord(target_id);
  if (record) {
    // Fill the pilot name field
    SetText(PILOT, record->pilot);

    // Fill the frequency field
    if (!StringIsEmpty(record->frequency))
      value = UnsafeBuildString(tmp, record->frequency.c_str(), _T(" MHz"));
    else
      value = _T("--");
    SetText(RADIO, value);

    // Fill the home airfield field
    SetText(AIRPORT, record->airfield);

    // Fill the plane type field
    SetText(PLANE, record->plane_type);
  } else {
    // Fill the pilot name field
    SetText(PILOT, _T("--"));

    // Fill the frequency field
    SetText(RADIO, _T("--"));

    // Fill the home airfield field
    SetText(AIRPORT, _T("--"));

    // Fill the plane type field
    const FlarmTraffic* target =
      CommonInterface::Basic().flarm.traffic.FindTraffic(target_id);

    const TCHAR* actype;
    if (target == nullptr ||
        (actype = FlarmTraffic::GetTypeString(target->type)) == nullptr)
      actype = _T("--");

    SetText(PLANE, actype);
  }

  // Fill the callsign field (+ registration)
  // note: don't use target->Name here since it is not updated
  //       yet if it was changed
  const TCHAR* cs = FlarmDetails::LookupCallsign(target_id);
  if (cs != nullptr && cs[0] != 0) {
    StringBuilder<TCHAR> builder(tmp, ARRAY_SIZE(tmp));
    builder.Append(cs);
    if (record)
      builder.Append(_T(" ("), record->registration.c_str(), _T(")"));
    value = tmp;
  } else
    value = _T("--");
  SetText(CALLSIGN, value);

  // Update the frequently changing fields too
  UpdateChanging(CommonInterface::Basic());
}
Exemplo n.º 28
0
void
OrderedTaskPointRadiusLabel(const ObservationZonePoint &ozp, TCHAR* buffer)
{
  switch (ozp.GetShape()) {
  case ObservationZone::Shape::FAI_SECTOR:
    _tcscpy(buffer, _("FAI quadrant"));
    return;

  case ObservationZone::Shape::SECTOR:
  case ObservationZone::Shape::ANNULAR_SECTOR:
    StringFormatUnsafe(buffer,_T("%s - %s: %.1f%s"), _("Sector"), _("Radius"),
                       (double)Units::ToUserDistance(((const SectorZone &)ozp).GetRadius()),
                       Units::GetDistanceName());
    return;

  case ObservationZone::Shape::LINE:
    StringFormatUnsafe(buffer,_T("%s - %s: %.1f%s"), _("Line"), _("Gate width"),
                       (double)Units::ToUserDistance(((const LineSectorZone &)ozp).GetLength()),
                       Units::GetDistanceName());
    return;

  case ObservationZone::Shape::CYLINDER:
    StringFormatUnsafe(buffer,_T("%s - %s: %.1f%s"), _("Cylinder"), _("Radius"),
                       (double)Units::ToUserDistance(((const CylinderZone &)ozp).GetRadius()),
                       Units::GetDistanceName());
    return;

  case ObservationZone::Shape::MAT_CYLINDER:
    _tcscpy(buffer, _("MAT cylinder"));
    return;

  case ObservationZone::Shape::CUSTOM_KEYHOLE:
    StringFormatUnsafe(buffer,_T("%s - %s: %.1f%s"), _("Keyhole"), _("Radius"),
                       (double)Units::ToUserDistance(((const KeyholeZone &)ozp).GetRadius()),
                       Units::GetDistanceName());
    return;

  case ObservationZone::Shape::DAEC_KEYHOLE:
    _tcscpy(buffer, _("DAeC Keyhole"));
    return;

  case ObservationZone::Shape::BGAFIXEDCOURSE:
    _tcscpy(buffer, _("BGA Fixed Course"));
    return;

  case ObservationZone::Shape::BGAENHANCEDOPTION:
    _tcscpy(buffer, _("BGA Enhanced Option"));
    return;

  case ObservationZone::Shape::BGA_START:
    _tcscpy(buffer, _("BGA Start Sector"));
    return;

  case ObservationZone::Shape::SYMMETRIC_QUADRANT:
    _tcscpy(buffer, _("Symmetric quadrant"));
    return;
  }

  gcc_unreachable();
  assert(false);
}
Exemplo n.º 29
0
bool
AltairProDevice::DeclareInternal(const struct Declaration &declaration,
                                 OperationEnvironment &env)
{
    TCHAR Buffer[256];

    StringFormatUnsafe(Buffer, _T("PDVSC,S,Pilot,%s"),
                       declaration.pilot_name.c_str());
    if (!PropertySetGet(Buffer, ARRAY_SIZE(Buffer), env))
        return false;

    StringFormatUnsafe(Buffer, _T("PDVSC,S,GliderID,%s"),
                       declaration.aircraft_registration.c_str());
    if (!PropertySetGet(Buffer, ARRAY_SIZE(Buffer), env))
        return false;

    StringFormatUnsafe(Buffer, _T("PDVSC,S,GliderType,%s"),
                       declaration.aircraft_type.c_str());
    if (!PropertySetGet(Buffer, ARRAY_SIZE(Buffer), env))
        return false;

    /* TODO currently not supported by XCSOAR
     * Pilot2
     * CompetitionID
     * CompetitionClass
     * ObserverID
     * DeclDescription
     * DeclFlightDate
     */

    if (declaration.Size() > 1) {
        PutTurnPoint(_T("DeclTakeoff"), nullptr, env);
        PutTurnPoint(_T("DeclLanding"), nullptr, env);

        PutTurnPoint(_T("DeclStart"), &declaration.GetFirstWaypoint(), env);
        PutTurnPoint(_T("DeclFinish"), &declaration.GetLastWaypoint(), env);

        for (unsigned int index=1; index <= 10; index++) {
            TCHAR TurnPointPropertyName[32];
            StringFormatUnsafe(TurnPointPropertyName, _T("DeclTurnPoint%d"), index);

            if (index < declaration.Size() - 1) {
                PutTurnPoint(TurnPointPropertyName, &declaration.GetWaypoint(index),
                             env);
            } else {
                PutTurnPoint(TurnPointPropertyName, nullptr, env);
            }
        }
    }

    UnsafeCopyString(Buffer, _T("PDVSC,S,DeclAction,DECLARE"));
    if (!PropertySetGet(Buffer, ARRAY_SIZE(Buffer), env))
        return false;

    if (StringIsEqual(&Buffer[9], _T("LOCKED")))
        // FAILED! try to declare a task on a airborn recorder
        return false;

    // Buffer holds the declaration ticket.
    // but no one is intresting in that
    // eg "2010-11-21 13:01:43 (1)"

    return true;
}