X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FInstrumentation%2Fgps.cxx;h=e9a91dcaafb3e10328c477427362c70805304e9f;hb=805c4cbba15c6922e511b3a20ba5a9cb56ceed4f;hp=667ff2c36b50daf7e9f63a773cab5da52d96e2ef;hpb=cc020fe9df98e7218b34dd970a92d432ef733343;p=flightgear.git diff --git a/src/Instrumentation/gps.cxx b/src/Instrumentation/gps.cxx index 667ff2c36..e9a91dcaa 100644 --- a/src/Instrumentation/gps.cxx +++ b/src/Instrumentation/gps.cxx @@ -29,6 +29,7 @@ #include #include #include +#include using std::auto_ptr; using std::string; @@ -200,7 +201,6 @@ GPS::Config::Config() : _turnRate(3.0), // degrees-per-second, so 180 degree turn takes 60 seconds _overflightArmDistance(1.0), _waypointAlertTime(30.0), - _minRunwayLengthFt(0.0), _requireHardSurface(true), _cdiMaxDeflectionNm(3.0), // linear mode, 3nm at the peg _driveAutopilot(true), @@ -214,7 +214,6 @@ void GPS::Config::bind(GPS* aOwner, SGPropertyNode* aCfg) aOwner->tie(aCfg, "turn-rate-deg-sec", SGRawValuePointer(&_turnRate)); aOwner->tie(aCfg, "turn-anticipation", SGRawValuePointer(&_enableTurnAnticipation)); aOwner->tie(aCfg, "wpt-alert-time", SGRawValuePointer(&_waypointAlertTime)); - aOwner->tie(aCfg, "min-runway-length-ft", SGRawValuePointer(&_minRunwayLengthFt)); aOwner->tie(aCfg, "hard-surface-runways-only", SGRawValuePointer(&_requireHardSurface)); aOwner->tie(aCfg, "cdi-max-deflection-nm", SGRawValuePointer(&_cdiMaxDeflectionNm)); aOwner->tie(aCfg, "drive-autopilot", SGRawValuePointer(&_driveAutopilot)); @@ -231,6 +230,11 @@ GPS::GPS ( SGPropertyNode *node) : _mode("init"), _name(node->getStringValue("name", "gps")), _num(node->getIntValue("number", 0)), + _searchResultIndex(0), + _searchExact(true), + _searchIsRoute(false), + _searchHasNext(false), + _searchNames(false), _computeTurnData(false), _anticipateTurn(false), _inTurn(false) @@ -332,10 +336,11 @@ void GPS::bind() { _config.bind(this, _gpsNode->getChild("config", 0, true)); + // basic GPS outputs tie(_gpsNode, "selected-course-deg", SGRawValueMethods (*this, &GPS::getSelectedCourse, &GPS::setSelectedCourse)); - + tie(_gpsNode, "desired-course-deg", SGRawValueMethods (*this, &GPS::getDesiredCourse, NULL)); _desiredCourseNode = _gpsNode->getChild("desired-course-deg", 0, true); @@ -352,7 +357,7 @@ GPS::bind() tie(_gpsNode, "indicated-ground-speed-kt", SGRawValueMethods (*this, &GPS::getGroundspeedKts, NULL)); -// command system +// command system tie(_gpsNode, "mode", SGRawValueMethods(*this, &GPS::getMode, NULL)); tie(_gpsNode, "command", SGRawValueMethods(*this, &GPS::getCommand, &GPS::setCommand)); @@ -405,10 +410,7 @@ GPS::bind() void GPS::unbind() { - for (unsigned int t=0; t<_tiedNodes.size(); ++t) { - _tiedNodes[t]->untie(); - } - _tiedNodes.clear(); + _tiedProperties.Untie(); } void @@ -476,8 +478,6 @@ GPS::update (double delta_time_sec) } if (_dataValid && (_mode == "init")) { - // allow a realistic delay in the future, here - SG_LOG(SG_INSTR, SG_INFO, "GPS initialisation complete"); if (_route_active_node->getBoolValue()) { // GPS init with active route @@ -494,6 +494,12 @@ GPS::update (double delta_time_sec) selectOBSMode(); } } + + if (_mode != "init") + { + // allow a realistic delay in the future, here + SG_LOG(SG_INSTR, SG_INFO, "GPS initialisation complete"); + } } // of init mode check _last_pos = _indicated_pos; @@ -716,7 +722,7 @@ void GPS::routeManagerSequenced() SG_LOG(SG_INSTR, SG_INFO, "GPS waypoint index is now " << index); if (index > 0) { - _prevWaypt = _routeMgr->previousWaypt(); + _prevWaypt = _routeMgr->wayptAtIndex(index - 1); if (_prevWaypt->flag(WPT_DYNAMIC)) { _wp0_position = _indicated_pos; } else { @@ -821,7 +827,7 @@ void GPS::updateOverflight() // check for wp1 being on active route - resume leg mode if (_routeMgr->isRouteActive()) { - int index = _routeMgr->findWayptIndex(_currentWaypt->position()); + int index = _routeMgr->flightPlan()->findWayptIndex(_currentWaypt->position()); if (index >= 0) { SG_LOG(SG_INSTR, SG_INFO, "GPS DTO, resuming LEG mode at wp:" << index); _mode = "leg"; @@ -873,7 +879,7 @@ void GPS::computeTurnData() return; } - WayptRef next = _routeMgr->nextWaypt(); + WayptRef next = _routeMgr->wayptAtIndex(_routeMgr->currentIndex() + 1); if (!next || next->flag(WPT_DYNAMIC)) { _anticipateTurn = false; return; @@ -1431,7 +1437,7 @@ FGPositioned::Type GPS::SearchFilter::maxType() const FGPositioned::Filter* GPS::createFilter(FGPositioned::Type aTy) { if (aTy == FGPositioned::AIRPORT) { - return new FGAirport::HardSurfaceFilter(_config.minRunwayLengthFt()); + return new FGAirport::HardSurfaceFilter(); } // if we were passed INVALID, assume it means 'all types interesting to a GPS' @@ -1676,7 +1682,7 @@ void GPS::insertWaypointAtIndex(int aIndex) string ident = _scratchNode->getStringValue("ident"); WayptRef wpt = new BasicWaypt(_scratchPos, ident, NULL); - _routeMgr->insertWayptAtIndex(wpt, aIndex); + _routeMgr->flightPlan()->insertWayptAtIndex(wpt, aIndex); } void GPS::removeWaypointAtIndex(int aIndex) @@ -1685,7 +1691,7 @@ void GPS::removeWaypointAtIndex(int aIndex) throw sg_range_exception("GPS::removeWaypointAtIndex: index out of bounds"); } - _routeMgr->removeWayptAtIndex(aIndex); + _routeMgr->removeLegAtIndex(aIndex); } void GPS::tieSGGeod(SGPropertyNode* aNode, SGGeod& aRef,