/* * Used by Alternates and BestAlternate * Colors VGR are used by DrawNearest &c. */ void DoAlternates(NMEA_INFO *Basic, DERIVED_INFO *Calculated, int AltWaypoint) { CScopeLock(LockTaskData, UnlockTaskData); #ifdef GTL2 // If flying an AAT and working on the RESWP_OPTIMIZED waypoint, then use // this "optimized" waypoint to store data for the AAT virtual waypoint. if ((AltWaypoint == RESWP_OPTIMIZED) && (!ISPARAGLIDER || (AATEnabled && !DoOptimizeRoute()))) { WayPointList[RESWP_OPTIMIZED].Latitude = Task[ActiveWayPoint].AATTargetLat; WayPointList[RESWP_OPTIMIZED].Longitude = Task[ActiveWayPoint].AATTargetLon; WayPointList[RESWP_OPTIMIZED].Altitude = WayPointList[Task[ActiveWayPoint].Index].Altitude; WaypointAltitudeFromTerrain(&WayPointList[RESWP_OPTIMIZED]); _stprintf(WayPointList[RESWP_OPTIMIZED].Name, _T("!%s"),WayPointList[Task[ActiveWayPoint].Index].Name); } #endif // handle virtual wps as alternates if (AltWaypoint<=RESWP_END) { if (!ValidResWayPoint(AltWaypoint)) return; } else { if (!ValidWayPoint(AltWaypoint)) return; } double *altwp_dist = &WayPointCalc[AltWaypoint].Distance; double *altwp_gr = &WayPointCalc[AltWaypoint].GR; double *altwp_arrival = &WayPointCalc[AltWaypoint].AltArriv[AltArrivMode]; DistanceBearing(WayPointList[AltWaypoint].Latitude, WayPointList[AltWaypoint].Longitude, Basic->Latitude, Basic->Longitude, altwp_dist, NULL); *altwp_gr = CalculateGlideRatio( *altwp_dist, Calculated->NavAltitude - WayPointList[AltWaypoint].Altitude - GetSafetyAltitude(AltWaypoint)); // We need to calculate arrival also for BestAlternate, since the last "reachable" could be // even 60 seconds old and things may have changed drastically *altwp_arrival = CalculateWaypointArrivalAltitude(Basic, Calculated, AltWaypoint); WayPointCalc[AltWaypoint].VGR = GetVisualGlideRatio(*altwp_arrival, *altwp_gr); }
// return current overtarget waypoint index, or -1 if not available int GetOvertargetIndex(void) { int index; switch (OvertargetMode) { case OVT_TASK: // task if ( ValidTaskPoint(ActiveWayPoint) != false ) { if (DoOptimizeRoute()) index=RESWP_OPTIMIZED; else { index = Task[ActiveWayPoint].Index; } if ( index >=0 ) return index; } return -1; break; case OVT_ALT1: // alternate 1 if ( ValidWayPoint(Alternate1) != false ) { index = Alternate1; if ( index >=0 ) return index; } return -1; break; case OVT_ALT2: // alternate 2 if ( ValidWayPoint(Alternate2) != false ) { index = Alternate2; if ( index >=0 ) return index; } return -1; break; case OVT_BALT: // bestalternate if ( ValidWayPoint(BestAlternate) != false ) { index = BestAlternate; if ( index >=0 ) return index; } return -1; break; case OVT_HOME: // home waypoint if (ValidWayPoint(HomeWaypoint)) { index = HomeWaypoint; if ( index >=0 ) return index; } return -1; break; case OVT_THER: index=RESWP_LASTTHERMAL; if (ValidResWayPoint(index)) return index; return -1; break; case OVT_MATE: index=RESWP_TEAMMATE; if (ValidResWayPoint(index)) return index; return -1; break; case OVT_FLARM: index=RESWP_FLARMTARGET; if (ValidResWayPoint(index)) return index; return -1; break; // 4: home, 5: traffic, 6: mountain pass, last thermal, etc. default: return -1; break; } }
void RotateOvertarget(void) { _tryagain: OvertargetMode++; // For PG/HG, skip BALT overtarget if nothing valid. // We assume that this means no landables ever seen around, because // the BA function would keep the old one even if invalid. if (ISPARAGLIDER && OvertargetMode==OVT_BALT) { if (!ValidWayPoint(BestAlternate)) goto _tryagain; } // Skip F rotation if no flarm or no valid flarm target if (OvertargetMode==OVT_FLARM) { if ( (!GPS_INFO.FLARM_Available)|| (!ValidResWayPoint(RESWP_FLARMTARGET)) ) goto _tryagain; } if (OvertargetMode==OVT_MATE) { if (!ValidResWayPoint(RESWP_TEAMMATE)) goto _tryagain; } if (OvertargetMode>OVT_ROTATE) { OvertargetMode=OVT_TASK; } #ifndef DISABLEAUDIO if (EnableSoundModes) { switch(OvertargetMode) { case 0: PlayResource(TEXT("IDR_WAV_OVERTONE7")); break; case 1: PlayResource(TEXT("IDR_WAV_OVERTONE0")); break; case 2: PlayResource(TEXT("IDR_WAV_OVERTONE1")); break; case 3: PlayResource(TEXT("IDR_WAV_OVERTONE2")); break; case 4: PlayResource(TEXT("IDR_WAV_OVERTONE3")); break; case 5: PlayResource(TEXT("IDR_WAV_OVERTONE4")); break; case 6: PlayResource(TEXT("IDR_WAV_OVERTONE5")); break; case 7: PlayResource(TEXT("IDR_WAV_OVERTONE6")); break; case 8: PlayResource(TEXT("IDR_WAV_OVERTONE7")); break; default: PlayResource(TEXT("IDR_WAV_OVERTONE5")); break; } } #endif return; }