Beispiel #1
0
static void
TestBasic()
{
  // Test ReadString()
  PolarInfo polar;
  polar.ReadString(_T("318, 100, 80, -0.606, 120, -0.99, 160, -1.918"));
  ok1(equals(fixed(polar.reference_mass), 318));
  ok1(equals(fixed(polar.max_ballast), 100));
  ok1(equals(fixed(polar.v1), 22.2222222));
  ok1(equals(fixed(polar.w1), -0.606));
  ok1(equals(fixed(polar.v2), 33.3333333));
  ok1(equals(fixed(polar.w2), -0.99));
  ok1(equals(fixed(polar.v3), 44.4444444));
  ok1(equals(fixed(polar.w3), -1.918));
  ok1(equals(fixed(polar.wing_area), 0.0));

  polar.ReadString(_T("318, 100, 80, -0.606, 120, -0.99, 160, -1.918, 9.8"));
  ok1(equals(fixed(polar.reference_mass), 318));
  ok1(equals(fixed(polar.max_ballast), 100));
  ok1(equals(fixed(polar.v1), 22.2222222));
  ok1(equals(fixed(polar.w1), -0.606));
  ok1(equals(fixed(polar.v2), 33.3333333));
  ok1(equals(fixed(polar.w2), -0.99));
  ok1(equals(fixed(polar.v3), 44.4444444));
  ok1(equals(fixed(polar.w3), -1.918));
  ok1(equals(fixed(polar.wing_area), 9.8));

  // Test GetString()
  TCHAR polar_string[255];
  polar.GetString(polar_string, 255);
  ok(_tcscmp(_T("318,100,80.000,-0.606,120.000,-0.990,160.000,-1.918,9.800"),
             polar_string) == 0, "GetString()");
}
Beispiel #2
0
static void
TestBuiltInPolars()
{
  unsigned count = PolarStore::Count();
  for(unsigned i = 0; i < count; i++) {
    PolarInfo polar = PolarStore::GetItem(i).ToPolarInfo();

    WideToUTF8Converter narrow(PolarStore::GetItem(i).name);
    ok(polar.IsValid(), narrow);
  }
}
Beispiel #3
0
PolarInfo
PolarGlue::LoadFromProfile()
{
  PolarInfo polar;
  if (!LoadFromProfile(polar) || !polar.IsValid()) {
    if (Profile::Exists(ProfileKeys::Polar) || Profile::Exists(ProfileKeys::PolarID))
      ShowMessageBox(_("Polar has invalid coefficients.\nUsing LS8 polar instead!"),
                  _("Warning"), MB_OK);
    polar = GetDefault();
  }

  return polar;
}
Beispiel #4
0
static void
TestBuiltInPolars()
{
  unsigned count = PolarStore::Count();
  for(unsigned i = 0; i < count; i++) {
    PolarInfo polar = PolarStore::GetItem(i).ToPolarInfo();
#ifdef _UNICODE
  size_t wide_length = _tcslen(PolarStore::GetItem(i).name);
  char narrow[wide_length * 4 + 1];
  int narrow_length =
      ::WideCharToMultiByte(CP_ACP, 0, PolarStore::GetItem(i).name, wide_length,
                            narrow, sizeof(narrow), NULL, NULL);
  narrow[narrow_length] = 0;

  ok(polar.IsValid(), narrow);
#else
  ok(polar.IsValid(), PolarStore::GetItem(i).name);
#endif
  }
}
Beispiel #5
0
bool
PolarGlue::LoadFromProfile(PolarInfo &polar)
{
  const TCHAR *polar_string = Profile::Get(szProfilePolar);
  if (polar_string != NULL && !StringIsEmpty(polar_string) &&
      polar.ReadString(polar_string)) {
    return true;
  }

  return LoadFromOldProfile(polar);
}
Beispiel #6
0
static void
TestBuiltInPolarsPlausibility()
{
  for(unsigned i = 0; i < ARRAY_SIZE(performanceData); i++) {
    assert(i < PolarStore::Count());
    unsigned si = performanceData[i].storeIndex;
    PolarInfo polar = PolarStore::GetItem(si).ToPolarInfo();
    PolarCoefficients pc = polar.CalculateCoefficients();

    WideToUTF8Converter polarName(PolarStore::GetItem(i).name);

    ok(pc.IsValid(), polarName);

    GlidePolar gp(fixed(0));
    gp.SetCoefficients(pc, false);

    // Glider empty weight
    gp.SetReferenceMass(polar.reference_mass, false);
    gp.SetBallastRatio(polar.max_ballast / polar.reference_mass);
    gp.SetWingArea(polar.wing_area);

    gp.Update();

    fprintf(stderr, " LD: ");
    ok(!performanceData[i].check_best_LD ||
      ValuePlausible(performanceData[i].best_LD, gp.GetBestLD()),
      polarName);
    fprintf(stderr, "VLD: ");
    ok(!performanceData[i].check_best_LD_speed ||
       ValuePlausible(performanceData[i].best_LD_speed, gp.GetVBestLD() * fixed(3.6)),
       polarName);
    fprintf(stderr, " MS: ");
    ok(!performanceData[i].check_min_sink ||
       ValuePlausible(performanceData[i].min_sink, gp.GetSMin()),
       polarName);
    fprintf(stderr, "VMS: ");
    ok(!performanceData[i].check_min_sink_speed ||
       ValuePlausible(performanceData[i].min_sink_speed, gp.GetVMin() * fixed(3.6)),
       polarName);
  }
}