#include <simgear/sg_inlines.h>
#include <simgear/math/sg_geodesy.hxx>
#include <simgear/structure/exception.hxx>
+#include <simgear/scene/util/OsgMath.hxx>
using std::auto_ptr;
using std::string;
_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),
aOwner->tie(aCfg, "turn-rate-deg-sec", SGRawValuePointer<double>(&_turnRate));
aOwner->tie(aCfg, "turn-anticipation", SGRawValuePointer<bool>(&_enableTurnAnticipation));
aOwner->tie(aCfg, "wpt-alert-time", SGRawValuePointer<double>(&_waypointAlertTime));
- aOwner->tie(aCfg, "min-runway-length-ft", SGRawValuePointer<double>(&_minRunwayLengthFt));
aOwner->tie(aCfg, "hard-surface-runways-only", SGRawValuePointer<bool>(&_requireHardSurface));
aOwner->tie(aCfg, "cdi-max-deflection-nm", SGRawValuePointer<double>(&_cdiMaxDeflectionNm));
aOwner->tie(aCfg, "drive-autopilot", SGRawValuePointer<bool>(&_driveAutopilot));
_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)
GPS::bind()
{
_config.bind(this, _gpsNode->getChild("config", 0, true));
+
// basic GPS outputs
tie(_gpsNode, "selected-course-deg", SGRawValueMethods<GPS, double>
(*this, &GPS::getSelectedCourse, &GPS::setSelectedCourse));
-
+
tie(_gpsNode, "desired-course-deg", SGRawValueMethods<GPS, double>
(*this, &GPS::getDesiredCourse, NULL));
_desiredCourseNode = _gpsNode->getChild("desired-course-deg", 0, true);
tie(_gpsNode, "indicated-ground-speed-kt", SGRawValueMethods<GPS, double>
(*this, &GPS::getGroundspeedKts, NULL));
-// command system
+// command system
tie(_gpsNode, "mode", SGRawValueMethods<GPS, const char*>(*this, &GPS::getMode, NULL));
tie(_gpsNode, "command", SGRawValueMethods<GPS, const char*>(*this, &GPS::getCommand, &GPS::setCommand));
void
GPS::unbind()
{
- for (unsigned int t=0; t<_tiedNodes.size(); ++t) {
- _tiedNodes[t]->untie();
- }
- _tiedNodes.clear();
+ _tiedProperties.Untie();
}
void
}
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
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;
if (!_ref_navaid_set) {
_ref_navaid_elapsed += dt;
if (_ref_navaid_elapsed > 5.0) {
- _ref_navaid_elapsed = 0.0;
FGPositioned::TypeFilter vorFilter(FGPositioned::VOR);
FGPositionedRef nav = FGPositioned::findClosest(_indicated_pos, 400.0, &vorFilter);
if (!nav) {
- SG_LOG(SG_INSTR, SG_INFO, "GPS couldn't find a reference navid");
+ SG_LOG(SG_INSTR, SG_INFO, "GPS couldn't find a reference navaid");
_ref_navaid_id_node->setStringValue("");
_ref_navaid_name_node->setStringValue("");
_ref_navaid_bearing_node->setDoubleValue(0.0);
}
_ref_navaid = nav;
+ // reset elapsed time (do not do that before updating the properties above, since their
+ // listeners may request another update (_ref_navaid_elapsed = 9999), which results in
+ // excessive load (FGPositioned::findClosest called in every update loop...)
+ _ref_navaid_elapsed = 0.0;
}
}
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 {
// 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";
return;
}
- WayptRef next = _routeMgr->nextWaypt();
+ WayptRef next = _routeMgr->wayptAtIndex(_routeMgr->currentIndex() + 1);
if (!next || next->flag(WPT_DYNAMIC)) {
_anticipateTurn = false;
return;
double GPS::getWP1MagBearing() const
{
- if (!_dataValid) {
+ if (!_dataValid || !_wayptController.get()) {
return -9999.0;
}
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'
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)
throw sg_range_exception("GPS::removeWaypointAtIndex: index out of bounds");
}
- _routeMgr->removeWayptAtIndex(aIndex);
+ _routeMgr->removeLegAtIndex(aIndex);
}
void GPS::tieSGGeod(SGPropertyNode* aNode, SGGeod& aRef,