From 10d4799058bade270d3a43068db6bf0f0e9f8743 Mon Sep 17 00:00:00 2001 From: jmt Date: Sun, 10 Jan 2010 23:35:53 +0000 Subject: [PATCH] GPS: improve reliability (at the expense of some in-development features) for pending release. - default to an invalid altitude in routes, instead of cruise altitude (temporarily) - only set an altitude on the autopilot, if valid - only add departure airport/runway to the route, if not airborne --- src/Autopilot/route_mgr.cxx | 13 ++++++++++--- src/Instrumentation/gps.cxx | 4 +--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Autopilot/route_mgr.cxx b/src/Autopilot/route_mgr.cxx index 45e3c922f..c83e80ec9 100644 --- a/src/Autopilot/route_mgr.cxx +++ b/src/Autopilot/route_mgr.cxx @@ -340,9 +340,9 @@ void FGRouteMgr::new_waypoint( const string& target, int n ) { SGWayPoint* FGRouteMgr::make_waypoint(const string& tgt ) { string target(boost::to_upper_copy(tgt)); - // extract altitude - double alt = cruise->getDoubleValue("altitude-ft") * SG_FEET_TO_METER; + double alt = -9999.0; + // extract altitude size_t pos = target.find( '@' ); if ( pos != string::npos ) { alt = atof( target.c_str() + pos + 1 ); @@ -490,7 +490,14 @@ void FGRouteMgr::InputListener::valueChanged(SGPropertyNode *prop) bool FGRouteMgr::activate() { - if (_departure) { + if (isRouteActive()) { + SG_LOG(SG_AUTOPILOT, SG_WARN, "duplicate route-activation, no-op"); + return false; + } + + // only add departure waypoint if we're not airborne, so that + // in-air route activation doesn't confuse matters. + if (weightOnWheels->getBoolValue() && _departure) { string runwayId(departure->getStringValue("runway")); FGRunway* runway = NULL; if (_departure->hasRunwayWithIdent(runwayId)) { diff --git a/src/Instrumentation/gps.cxx b/src/Instrumentation/gps.cxx index bb15a34db..2c6f36495 100644 --- a/src/Instrumentation/gps.cxx +++ b/src/Instrumentation/gps.cxx @@ -1021,9 +1021,7 @@ void GPS::wp1Changed() } double altFt = _wp1_position.getElevationFt(); - if (altFt < -9990.0) { - _apTargetAltitudeFt->setDoubleValue(0.0); - } else { + if (altFt > -9990.0) { _apTargetAltitudeFt->setDoubleValue(altFt); } }