コード例 #1
0
void RefreshTaskStatistics(void) {
  LockTaskData();
  TaskStatistics(&GPS_INFO, &CALCULATED_INFO, MACCREADY);
  AATStats(&GPS_INFO, &CALCULATED_INFO);
  TaskSpeed(&GPS_INFO, &CALCULATED_INFO, MACCREADY);
  UnlockTaskData();
}
コード例 #2
0
ファイル: DoCalculations.cpp プロジェクト: lshachar/LK8000
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;
}