GPS::GPS ( SGPropertyNode *node) :
_selectedCourse(0.0),
+ _desiredCourse(0.0),
_dataValid(false),
_lastPosValid(false),
_mode("init"),
_name(node->getStringValue("name", "gps")),
_num(node->getIntValue("number", 0)),
+ _searchResultsCached(false),
_computeTurnData(false),
_anticipateTurn(false),
_inTurn(false)
fromFlag->alias(wp1_node->getChild("from-flag"));
// autopilot drive properties
+ _apDrivingFlag = fgGetNode("/autopilot/settings/gps-driving-true-heading", true);
_apTrueHeading = fgGetNode("/autopilot/settings/true-heading-deg",true);
_apTargetAltitudeFt = fgGetNode("/autopilot/settings/target-altitude-ft", true);
_apAltitudeLock = fgGetNode("/autopilot/locks/altitude", true);
void GPS::driveAutopilot()
{
if (!_config.driveAutopilot() || !_realismSimpleGps->getBoolValue()) {
+ _apDrivingFlag->setBoolValue(false);
return;
}
// compatability feature - allow the route-manager / GPS to drive the
// generic autopilot heading hold *in leg mode only*
- if (_mode == "leg") {
+
+ bool drive = _mode == "leg";
+ _apDrivingFlag->setBoolValue(drive);
+
+ if (drive) {
// FIXME: we want to set desired track, not heading, here
_apTrueHeading->setDoubleValue(getWP1Bearing());
}
void GPS::directTo()
{
- if (!isScratchPositionValid()) {
- SG_LOG(SG_INSTR, SG_WARN, "invalid DTO lat/lon");
- return;
+ _wp0_position = _indicated_pos;
+
+ if (isScratchPositionValid()) {
+ _wp1Ident = _scratchNode->getStringValue("ident");
+ _wp1Name = _scratchNode->getStringValue("name");
+ _wp1_position = _scratchPos;
}
- _wp0_position = _indicated_pos;
- _wp1Ident = _scratchNode->getStringValue("ident");
- _wp1Name = _scratchNode->getStringValue("name");
- _wp1_position = _scratchPos;
-
_mode = "dto";
_desiredCourse = getLegMagCourse();
_desiredCourseNode->fireValueChanged();
clearScratch();
-
wp1Changed();
}
void GPS::selectOBSMode()
{
- if (!isScratchPositionValid()) {
- SG_LOG(SG_INSTR, SG_WARN, "invalid OBS lat/lon");
- return;
+ if (isScratchPositionValid()) {
+ _wp1Ident = _scratchNode->getStringValue("ident");
+ _wp1Name = _scratchNode->getStringValue("name");
+ _wp1_position = _scratchPos;
}
SG_LOG(SG_INSTR, SG_INFO, "GPS switching to OBS mode");
_mode = "obs";
-
- _wp1Ident = _scratchNode->getStringValue("ident");
- _wp1Name = _scratchNode->getStringValue("name");
- _wp1_position = _scratchPos;
_wp0_position = _indicated_pos;
wp1Changed();
}