_edited = fgGetNode(RM "signals/edited", true);
_finished = fgGetNode(RM "signals/finished", true);
+ _flightplanChanged = fgGetNode(RM "signals/flightplan-changed", true);
_currentWpt = fgGetNode(RM "current-wp", true);
_currentWpt->tie(SGRawValueMethods<FGRouteMgr, int>
}
weightOnWheels = fgGetNode("/gear/gear[0]/wow", true);
+ groundSpeed = fgGetNode("/velocities/groundspeed-kt", true);
+
// check airbone flag agrees with presets
}
_plan = plan;
_plan->setDelegate(this);
+ _flightplanChanged->fireValueChanged();
+
// fire all the callbacks!
departureChanged();
arrivalChanged();
return; // paused, nothing to do here
}
- double groundSpeed = fgGetDouble("/velocities/groundspeed-kt", 0.0);
+ double gs = groundSpeed->getDoubleValue();
if (airborne->getBoolValue()) {
time_t now = time(NULL);
elapsedFlightTime->setDoubleValue(difftime(now, _takeoffTime));
+
+ if (weightOnWheels->getBoolValue()) {
+ // touch down
+ destination->setIntValue("touchdown-time", time(NULL));
+ airborne->setBoolValue(false);
+ }
} else { // not airborne
- if (weightOnWheels->getBoolValue() || (groundSpeed < 40)) {
+ if (weightOnWheels->getBoolValue() || (gs < 40)) {
return;
}
return;
}
+ if (checkFinished()) {
+ // maybe we're done
+ }
+
// basic course/distance information
SGGeod currentPos = globals->get_aircraft_position();
distanceToGo->setDoubleValue(totalDistanceRemaining);
wpn->setDoubleValue("dist", totalDistanceRemaining);
- ete->setDoubleValue(totalDistanceRemaining / groundSpeed * 3600.0);
+ ete->setDoubleValue(totalDistanceRemaining / gs * 3600.0);
setETAPropertyFromDistance(wpn->getChild("eta"), totalDistanceRemaining);
}
void FGRouteMgr::buildArrival(WayptRef enroute, WayptVec& wps)
{
- FGAirportRef apt = _plan->departureAirport();
+ FGAirportRef apt = _plan->destinationAirport();
if (!apt.valid()) {
return;
}
return true;
}
- if (_plan->currentIndex() < _plan->numLegs()) {
- return false;
+ bool done = false;
+// done if we're stopped on the destination runway
+ if (_plan->currentLeg() &&
+ (_plan->currentLeg()->waypoint()->source() == _plan->destinationRunway()))
+ {
+ double gs = groundSpeed->getDoubleValue();
+ done = weightOnWheels->getBoolValue() && (gs < 25);
}
- SG_LOG(SG_AUTOPILOT, SG_INFO, "reached end of active route");
- _finished->fireValueChanged();
- active->setBoolValue(false);
- return true;
+// also done if we hit the final waypoint
+ if (_plan->currentIndex() >= _plan->numLegs()) {
+ done = true;
+ }
+
+ if (done) {
+ SG_LOG(SG_AUTOPILOT, SG_INFO, "reached end of active route");
+ _finished->fireValueChanged();
+ active->setBoolValue(false);
+ }
+
+ return done;
}
void FGRouteMgr::jumpToIndex(int index)
_fp(fp)
{
SGPropertyNode* routeEdited = fgGetNode("/autopilot/route-manager/signals/edited", true);
+ SGPropertyNode* flightplanChanged = fgGetNode("/autopilot/route-manager/signals/flightplan-changed", true);
routeEdited->addChangeListener(this);
+ flightplanChanged->addChangeListener(this);
}
~FlightPlanWaypointModel()
{
SGPropertyNode* routeEdited = fgGetNode("/autopilot/route-manager/signals/edited", true);
+ SGPropertyNode* flightplanChanged = fgGetNode("/autopilot/route-manager/signals/flightplan-changed", true);
routeEdited->removeChangeListener(this);
+ flightplanChanged->removeChangeListener(this);
}
// implement WaypointList::Model
// implement SGPropertyChangeListener
void valueChanged(SGPropertyNode *prop)
{
- if (_cb) {
- (*_cb)();
+ if (prop->getNameString() == "edited") {
+ if (_cb) {
+ (*_cb)();
+ }
+ }
+
+ if (prop->getNameString() == "flightplan-changed") {
+ _fp =
+ static_cast<FGRouteMgr*>(globals->get_subsystem("route-manager"))->flightPlan();
}
}
private:
if (wp->flag(WPT_MISS)) {
drawBox = true;
puSetColor(col, 1.0, 0.0, 0.0, 0.3); // red
- } else if (wp->flag(WPT_ARRIVAL)) {
+ } else if (wp->flag(WPT_ARRIVAL) || wp->flag(WPT_DEPARTURE)) {
drawBox = true;
puSetColor(col, 0.0, 0.0, 0.0, 0.3);
- } else if (wp->flag(WPT_DEPARTURE)) {
+ } else if (wp->flag(WPT_APPROACH)) {
drawBox = true;
- puSetColor(col, 0.0, 0.0, 0.0, 0.3);
+ puSetColor(col, 0.0, 0.0, 0.1, 0.3);
}
if (isDragSource) {