1
0
Fork 0

Enforce separation of ground-net and dynamics.

This ensures ground-network is retrieved through the airport only, and
hence can be done safely early in init, when ATC/AI/dynamics don’t
exist yet.
This commit is contained in:
James Turner 2016-11-13 14:05:20 +00:00
parent a6f1c93a2b
commit 1c4656512a
6 changed files with 21 additions and 27 deletions

View file

@ -252,7 +252,7 @@ bool FGAIFlightPlan::createTakeoffTaxi(FGAIAircraft * ac, bool firstFlight,
assert( rwy != NULL );
SGGeod runwayTakeoff = rwy->pointOnCenterline(5.0);
FGGroundNetwork *gn = apt->getDynamics()->getGroundNetwork();
FGGroundNetwork *gn = apt->groundNetwork();
if (!gn->exists()) {
createDefaultTakeoffTaxi(ac, apt, rwy);
return true;
@ -389,7 +389,7 @@ bool FGAIFlightPlan::createLandingTaxi(FGAIAircraft * ac, FGAirport * apt,
acType, airline);
SGGeod lastWptPos = waypoints.back()->getPos();
FGGroundNetwork *gn = apt->getDynamics()->getGroundNetwork();
FGGroundNetwork *gn = apt->groundNetwork();
// Find a route from runway end to parking/gate.
if (!gn->exists()) {
@ -647,8 +647,8 @@ bool FGAIFlightPlan::createDescent(FGAIAircraft * ac, FGAirport * apt,
double dAlt = 0; // = alt - (apt->getElevation() + 2000);
FGTaxiNodeRef tn;
if (apt->getDynamics()->getGroundNetwork()) {
tn = apt->getDynamics()->getGroundNetwork()->findNearestNode(refPoint);
if (apt->groundNetwork()) {
tn = apt->groundNetwork()->findNearestNode(refPoint);
}
if (tn) {
@ -969,7 +969,7 @@ bool FGAIFlightPlan::createLanding(FGAIAircraft * ac, FGAirport * apt,
wpt->setSpeed(vTaxi);
double mindist = (1.1 * rolloutDistance) + touchdownDistance;
FGGroundNetwork *gn = apt->getDynamics()->getGroundNetwork();
FGGroundNetwork *gn = apt->groundNetwork();
if (!gn) {
return true;
}

View file

@ -91,7 +91,7 @@ bool FGAIFlightPlan::createPushBack(FGAIAircraft *ac,
}
FGGroundNetwork* groundNet = dep->getDynamics()->getGroundNetwork();
FGGroundNetwork* groundNet = dep->groundNetwork();
FGParking *parking = gate.parking();
if (parking && parking->getPushBackPoint() > 0) {
FGTaxiRoute route = groundNet->findShortestRoute(parking, parking->getPushBackPoint(), false);
@ -134,7 +134,7 @@ bool FGAIFlightPlan::createPushBack(FGAIAircraft *ac,
ac->setTaxiClearanceRequest(false);
double az2 = 0.0;
FGTaxiSegment* pushForwardSegment = dep->getDynamics()->getGroundNetwork()->findSegment(parking, 0);
FGTaxiSegment* pushForwardSegment = dep->groundNetwork()->findSegment(parking, 0);
// there aren't any routes for this parking.
if (!pushForwardSegment) {
SG_LOG(SG_AI, SG_ALERT, "Gate " << parking->ident() << "doesn't seem to have routes associated with it.");

View file

@ -455,7 +455,7 @@ void FGGroundController::checkHoldPosition(int id, double lat,
double lon, double heading,
double speed, double alt)
{
FGGroundNetwork* network = dynamics->getGroundNetwork();
FGGroundNetwork* network = dynamics->parent()->groundNetwork();
TrafficVectorIterator current;
TrafficVectorIterator i = activeTraffic.begin();
if (activeTraffic.size()) {
@ -762,7 +762,7 @@ static void WorldCoordinate(osg::Matrix& obj_pos, double lat,
void FGGroundController::render(bool visible)
{
SGMaterialLib *matlib = globals->get_matlib();
FGGroundNetwork* network = dynamics->getGroundNetwork();
FGGroundNetwork* network = dynamics->parent()->groundNetwork();
if (group) {
//int nr = ;
@ -956,7 +956,7 @@ string FGGroundController::getName() {
void FGGroundController::update(double dt)
{
time_t now = globals->get_time_params()->get_cur_time();
FGGroundNetwork* network = dynamics->getGroundNetwork();
FGGroundNetwork* network = dynamics->parent()->groundNetwork();
network->unblockAllSegments(now);
int priority = 1;
@ -1000,7 +1000,7 @@ void FGGroundController::updateStartupTraffic(TrafficVectorIterator i,
return;
}
FGGroundNetwork* network = dynamics->getGroundNetwork();
FGGroundNetwork* network = dynamics->parent()->groundNetwork();
if (!network) {
SG_LOG(SG_ATC, SG_ALERT, "updateStartupTraffic: missing ground network");
@ -1068,7 +1068,7 @@ bool FGGroundController::updateActiveTraffic(TrafficVectorIterator i,
double length = 0;
double vTaxi = (i->getAircraft()->getPerformance()->vTaxi() * SG_NM_TO_METER) / 3600;
FGGroundNetwork* network = dynamics->getGroundNetwork();
FGGroundNetwork* network = dynamics->parent()->groundNetwork();
if (!network) {
SG_LOG(SG_ATC, SG_ALERT, "updateActiveTraffic: missing ground network");

View file

@ -1416,6 +1416,7 @@ void FGStartupController::render(bool visible)
//double elevation_meters = 0.0;
//double elevation_feet = 0.0;
FGGroundNetwork* groundNet = parent->parent()->groundNetwork();
//for ( FGTaxiSegmentVectorIterator i = segments.begin(); i != segments.end(); i++) {
double dx = 0;
@ -1427,7 +1428,7 @@ void FGStartupController::render(bool visible)
int pos = i->getCurrentPosition();
//cerr << "rendering for " << i->getAircraft()->getCallSign() << "pos = " << pos << endl;
if (pos > 0) {
FGTaxiSegment *segment = parent->getGroundNetwork()->findSegment(pos);
FGTaxiSegment *segment = groundNet->findSegment(pos);
SGGeod start(SGGeod::fromDeg((i->getLongitude()), (i->getLatitude())));
SGGeod end (segment->getEnd()->geod());
@ -1512,7 +1513,7 @@ void FGStartupController::render(bool visible)
//cerr << "rendering for " << i->getAircraft()->getCallSign() << "intention = " << k << endl;
osg::MatrixTransform *obj_trans = new osg::MatrixTransform;
obj_trans->setDataVariance(osg::Object::STATIC);
FGTaxiSegment *segment = parent->getGroundNetwork()->findSegment(k);
FGTaxiSegment *segment = groundNet->findSegment(k);
double elevationStart = segment->getStart()->getElevationM();
double elevationEnd = segment->getEnd ()->getElevationM();

View file

@ -182,7 +182,7 @@ FGParking* FGAirportDynamics::innerGetAvailableParking(double radius, const stri
const string & airline,
bool skipEmptyAirlineCode)
{
const FGParkingList& parkings(getGroundNetwork()->allParkings());
const FGParkingList& parkings(parent()->groundNetwork()->allParkings());
FGParkingList::const_iterator it;
for (it = parkings.begin(); it != parkings.end(); ++it) {
FGParkingRef parking = *it;
@ -209,7 +209,7 @@ FGParking* FGAirportDynamics::innerGetAvailableParking(double radius, const stri
bool FGAirportDynamics::hasParkings() const
{
return !getGroundNetwork()->allParkings().empty();
return !parent()->groundNetwork()->allParkings().empty();
}
ParkingAssignment FGAirportDynamics::getAvailableParking(double radius, const string & flType,
@ -237,7 +237,7 @@ ParkingAssignment FGAirportDynamics::getAvailableParking(double radius, const st
ParkingAssignment FGAirportDynamics::getParkingByName(const std::string& name) const
{
const FGParkingList& parkings(getGroundNetwork()->allParkings());
const FGParkingList& parkings(parent()->groundNetwork()->allParkings());
FGParkingList::const_iterator it;
for (it = parkings.begin(); it != parkings.end(); ++it) {
if ((*it)->name() == name) {
@ -248,11 +248,6 @@ ParkingAssignment FGAirportDynamics::getParkingByName(const std::string& name) c
return ParkingAssignment();
}
FGGroundNetwork *FGAirportDynamics::getGroundNetwork() const
{
return _ap->groundNetwork();
}
void FGAirportDynamics::setParkingAvailable(FGParking* park, bool available)
{
if (available) {
@ -304,7 +299,7 @@ public:
FGParkingList FGAirportDynamics::getParkings(bool onlyAvailable, const std::string &type) const
{
FGParkingList result(getGroundNetwork()->allParkings());
FGParkingList result(parent()->groundNetwork()->allParkings());
GetParkingsPredicate pred(onlyAvailable, type, this);
FGParkingList::iterator it = std::remove_if(result.begin(), result.end(), pred);
@ -777,7 +772,7 @@ int FGAirportDynamics::getGroundFrequency(unsigned leg)
"Leg value is smaller than one at " << SG_ORIGIN);
}
const intVec& freqGround(getGroundNetwork()->getGroundFrequencies());
const intVec& freqGround(parent()->groundNetwork()->getGroundFrequencies());
if (freqGround.size() == 0) {
return 0;
@ -803,7 +798,7 @@ int FGAirportDynamics::getTowerFrequency(unsigned nr)
"Leg value is smaller than two at " << SG_ORIGIN);
}
const intVec& freqTower(getGroundNetwork()->getTowerFrequencies());
const intVec& freqTower(parent()->groundNetwork()->getTowerFrequencies());
if (freqTower.size() == 0) {
return 0;

View file

@ -154,8 +154,6 @@ public:
return &approachController;
};
FGGroundNetwork* getGroundNetwork() const;
int getGroundFrequency(unsigned leg);
int getTowerFrequency (unsigned nr);