예제 #1
0
void
GlideComputerAirData::ProcessVertical(const MoreData &basic,
                                      const MoreData &last_basic,
                                      DerivedInfo &calculated,
                                      const ComputerSettings &settings)
{
  /* the "circling" flag may be modified by
     CirclingComputer::Turning(); remember the old state so this
     method can check for modifications */
  const bool last_circling = calculated.circling;

  auto_qnh.Process(basic, calculated, settings, waypoints);

  circling_computer.TurnRate(calculated, basic,
                             calculated.flight);
  Turning(basic, calculated, settings);

  wind_computer.Compute(settings.wind, settings.polar.glide_polar_task,
                        basic, calculated);
  wind_computer.Select(settings.wind, basic, calculated);
  wind_computer.ComputeHeadWind(basic, calculated);

  thermallocator.Process(calculated.circling,
                         basic.time, basic.location,
                         basic.netto_vario,
                         calculated.GetWindOrZero(),
                         calculated.thermal_locator);

  LastThermalStats(basic, calculated, last_circling);

  gr_computer.Compute(basic, last_basic, calculated,
                      calculated,
                      settings);

  GR(basic, calculated.flight, calculated);
  CruiseGR(basic, calculated);

  average_vario.Compute(basic, calculated.circling, last_circling,
                        calculated);
  AverageClimbRate(basic, calculated);

  if (calculated.circling)
    CurrentThermal(basic, calculated, calculated.current_thermal);

  lift_database_computer.Compute(calculated.lift_database,
                                 calculated.trace_history.CirclingAverage,
                                 basic, calculated);
  circling_computer.MaxHeightGain(basic, calculated.flight, calculated);
  NextLegEqThermal(basic, calculated, settings);
}
예제 #2
0
bool DoCalculations(NMEA_INFO *Basic, DERIVED_INFO *Calculated)
{

  // first thing: assign navaltitude!
  EnergyHeightNavAltitude(Basic, Calculated);

  // second thing: if available, get external wind precalculated!
  if ( (Basic->ExternalWindAvailable==TRUE) && (AutoWindMode==D_AUTOWIND_EXTERNAL)) {
	if (Basic->ExternalWindSpeed>0 && Basic->ExternalWindSpeed<35) {
		Calculated->WindSpeed = Basic->ExternalWindSpeed;
		Calculated->WindBearing = Basic->ExternalWindDirection;
	}
  }

  Heading(Basic, Calculated);
  DistanceToNext(Basic, Calculated);
  DistanceToHome(Basic, Calculated);
  DetectFreeFlying(Basic,Calculated);	// check ongoing powerless flight
  DoLogging(Basic, Calculated);
  TerrainHeight(Basic, Calculated);
  AltitudeRequired(Basic, Calculated, MACCREADY);
  DoAlternates(Basic,Calculated,TASKINDEX); 
  if (IsMultiMapShared()) {
    DoAlternates(Basic,Calculated,RESWP_LASTTHERMAL);
    DoAlternates(Basic,Calculated,RESWP_TEAMMATE);
    DoAlternates(Basic,Calculated,RESWP_FLARMTARGET);
    DoAlternates(Basic,Calculated,HomeWaypoint);

    if (DoOptimizeRoute() || ACTIVE_WP_IS_AAT_AREA) {
      DoAlternates(Basic, Calculated, RESWP_OPTIMIZED);
    }

    for (int i=RESWP_FIRST_MARKER; i<=RESWP_LAST_MARKER; i++) {
      if (WayPointList[i].Latitude==RESWP_INVALIDNUMBER) continue;
      DoAlternates(Basic,Calculated,i);
    }
  } else {
    // The following is needed only for the next-WP glide terrain line,
    // not for the main/primary glide terrain line.

    if ((FinalGlideTerrain > 2) && (DoOptimizeRoute() || ACTIVE_WP_IS_AAT_AREA))
      DoAlternates(Basic, Calculated, RESWP_OPTIMIZED);
  }

  if (!TargetDialogOpen) {
    // don't calculate these if optimise function being invoked or
    // target is being adjusted
    TaskStatistics(Basic, Calculated, MACCREADY);
    AATStats(Basic, Calculated);  
    TaskSpeed(Basic, Calculated, MACCREADY);
  }

  if (!FlightTimes(Basic, Calculated)) {
    // time hasn't advanced, so don't do calculations requiring an advance
    // or movement
    return false;
  }

  Turning(Basic, Calculated);
  LD(Basic,Calculated);
  CruiseLD(Basic,Calculated);

  // We calculate flaps settings only if the polar is extended.
  // We do assume that GA planes will NOT use extended polars
  if (GlidePolar::FlapsPosCount >0) Flaps(Basic,Calculated);

  Calculated->AverageLD=CalculateLDRotary(&rotaryLD,Basic,Calculated); 
  Average30s(Basic,Calculated);
  AverageThermal(Basic,Calculated);
  AverageClimbRate(Basic,Calculated);
  ThermalGain(Basic,Calculated);
  LastThermalStats(Basic, Calculated);
  //  ThermalBand(Basic, Calculated); moved to % circling function
  MaxHeightGain(Basic,Calculated);

  PredictNextPosition(Basic, Calculated);

  if (Orbiter) CalculateOrbiter(Basic,Calculated);

  CalculateOwnTeamCode(Basic, Calculated);
  CalculateTeammateBearingRange(Basic, Calculated);

  BallastDump();

  // reminder: Paragliders have AAT always on
  CalculateOptimizedTargetPos(Basic,Calculated);

  if (ValidTaskPoint(ActiveTaskPoint)) {
	// only if running a real task
	if (ValidTaskPoint(1)) InSector(Basic, Calculated);
	DoAutoMacCready(Basic, Calculated);
	#ifdef DEBUGTASKSPEED
	DebugTaskCalculations(Basic, Calculated);
	#endif
  } else { // 101002
	DoAutoMacCready(Basic, Calculated); // will set only EqMC 
  }

  DoAlternates(Basic, Calculated,Alternate1); 
  DoAlternates(Basic, Calculated,Alternate2); 
  DoAlternates(Basic, Calculated,BestAlternate); 

  // Calculate nearest waypoints when needed
  if ( !MapWindow::mode.AnyPan() && DrawBottom && (MapSpaceMode>MSM_MAP) ) {
	switch(MapSpaceMode) {
		case MSM_LANDABLE:
		case MSM_AIRPORTS:
		case MSM_NEARTPS: // 101222
			DoNearest(Basic,Calculated);
			break;
		case MSM_COMMON:
			DoCommon(Basic,Calculated);
			break;
		case MSM_RECENT:
			DoRecent(Basic,Calculated);
			break;
		case MSM_VISUALGLIDE:
			// Only if visualglide is really painted: topview is not fullscreen.
			if (Current_Multimap_SizeY<SIZE4) {
				DoNearest(Basic,Calculated);
			}
			break;
	}
  }

  CalculateHeadWind(Basic,Calculated);

  ConditionMonitorsUpdate(Basic, Calculated);

  return true;
}