Exemple #1
0
void
PlaneGlue::ToProfile(const Plane &plane)
{
  StaticString<MAX_PATH> plane_path;
  if (Profile::GetPath(_T("PlanePath"), plane_path.buffer())) {
    PlaneGlue::WriteFile(plane, plane_path.c_str());
    return;
  }

  Profile::Set(ProfileKeys::AircraftReg, plane.registration);
  Profile::Set(ProfileKeys::CompetitionId, plane.competition_id);
  Profile::Set(ProfileKeys::AircraftType, plane.type);

  Profile::Set(ProfileKeys::PolarName, plane.polar_name);

  PolarInfo polar;
  polar.shape = plane.polar_shape;
  polar.reference_mass = plane.reference_mass;
  polar.max_ballast = plane.max_ballast;
  polar.v_no = plane.max_speed;
  polar.wing_area = plane.wing_area;

  TCHAR polar_string[255];
  FormatPolar(polar, polar_string, 255, true);
  Profile::Set(ProfileKeys::Polar, polar_string);
  Profile::Set(ProfileKeys::DryMass, plane.dry_mass);

  Profile::Set(ProfileKeys::BallastSecsToEmpty, plane.dump_time);
  Profile::Set(ProfileKeys::Handicap, plane.handicap);
}
Exemple #2
0
bool
PolarGlue::SaveToFile(const PolarInfo &polar, TextWriter &writer)
{
  char buffer[256];
  FormatPolar(polar, buffer, 256);
  return writer.WriteLine(buffer);
}
Exemple #3
0
static void
TestBasic()
{
  // Test ReadString()
  PolarInfo polar;
  ParsePolar(polar, "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.shape[0].v), 22.2222222));
  ok1(equals(fixed(polar.shape[0].w), -0.606));
  ok1(equals(fixed(polar.shape[1].v), 33.3333333));
  ok1(equals(fixed(polar.shape[1].w), -0.99));
  ok1(equals(fixed(polar.shape[2].v), 44.4444444));
  ok1(equals(fixed(polar.shape[2].w), -1.918));
  ok1(equals(fixed(polar.wing_area), 0.0));

  ParsePolar(polar, "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.shape[0].v), 22.2222222));
  ok1(equals(fixed(polar.shape[0].w), -0.606));
  ok1(equals(fixed(polar.shape[1].v), 33.3333333));
  ok1(equals(fixed(polar.shape[1].w), -0.99));
  ok1(equals(fixed(polar.shape[2].v), 44.4444444));
  ok1(equals(fixed(polar.shape[2].w), -1.918));
  ok1(equals(fixed(polar.wing_area), 9.8));

  // Test GetString()
  char polar_string[255];
  FormatPolar(polar, polar_string, 255);
  ok(strcmp("318,100,80.000,-0.606,120.000,-0.990,160.000,-1.918,9.800",
            polar_string) == 0, "GetString()");
}