Beispiel #1
0
bool
BallastDumpManager::Update(GlidePolar &glide_polar, unsigned dump_time)
{
  assert(IsEnabled());

  // We don't know how fast the water is flowing so don't pretend that we do
  if (dump_time == 0) {
    Stop();
    return false;
  }

  // Milliseconds since last ballast_clock.Update() call
  int dt = ballast_clock.Elapsed();

  // Update ballast_clock for the next call to BallastDumpManager::Update()
  ballast_clock.Update();

  // How many percent of the max. ballast do we dump in one millisecond
  auto percent_per_millisecond = 1. / (1000 * dump_time);

  // Calculate the new ballast percentage
  auto ballast = glide_polar.GetBallast() - dt * percent_per_millisecond;

  // Check if the plane is dry now
  if (ballast < 0) {
    Stop();
    glide_polar.SetBallastLitres(0);
    return false;
  }

  // Set new ballast
  glide_polar.SetBallast(ballast);
  return true;
}
Beispiel #2
0
void
GlidePolarTest::TestBallast()
{
  polar.SetBallast(fixed(0.25));

  ok1(equals(polar.GetBallastLitres(), 25));
  ok1(equals(polar.GetBallast(), 0.25));

  polar.SetBallastLitres(fixed(50));

  ok1(equals(polar.GetBallastLitres(), 50));
  ok1(equals(polar.GetBallast(), 0.5));
  ok1(equals(polar.GetTotalMass(), 368));
  ok1(equals(polar.GetWingLoading(), 37.551020408));
  ok1(polar.HasBallast());

  fixed loading_factor = sqrt(polar.GetTotalMass() / polar.reference_mass);
  ok1(equals(polar.polar.a, polar.ideal_polar.a / loading_factor));
  ok1(equals(polar.polar.b, polar.ideal_polar.b));
  ok1(equals(polar.polar.c, polar.ideal_polar.c * loading_factor));

  ok1(equals(polar.SinkRate(Units::ToSysUnit(fixed(80), Unit::KILOMETER_PER_HOUR)),
             0.640739));
  ok1(equals(polar.SinkRate(Units::ToSysUnit(fixed(120), Unit::KILOMETER_PER_HOUR)),
             0.928976));
  ok1(equals(polar.SinkRate(Units::ToSysUnit(fixed(160), Unit::KILOMETER_PER_HOUR)),
             1.722908));

  ok1(equals(polar.GetVMin(), 21.44464));
  ok1(equals(polar.GetVBestLD(), 27.78703));

  polar.SetBallast(fixed(0));
  ok1(!polar.HasBallast());
}
Beispiel #3
0
static void
OnBallastData(DataField *Sender, DataField::DataAccessKind_t Mode)
{
  DataFieldFloat &df = *(DataFieldFloat *)Sender;

  switch (Mode) {
  case DataField::daSpecial:
    SetBallastTimer(glide_polar.HasBallast() &&
                    !XCSoarInterface::GetComputerSettings().ballast_timer_active);
    break;
  case DataField::daChange:
    glide_polar.SetBallastLitres(df.GetAsFixed());
    changed = true;
    SetButtons();
    SetBallast();
    break;
  }
}