Split GroundNetwork class down the middle
- ATC functions move to GroundController, which layers above remaining GroundNetwork functionality - dynamics owns both the groundNetwork and the ground controller.
This commit is contained in:
parent
8b49ed08cc
commit
6446d67431
10 changed files with 1225 additions and 1018 deletions
|
@ -581,8 +581,8 @@ void FGAIAircraft::announcePositionToController() {
|
|||
controller = trafficRef->getDepartureAirport()->getDynamics()->getStartupController();
|
||||
break;
|
||||
case 2: // Taxiing to runway
|
||||
if (trafficRef->getDepartureAirport()->getDynamics()->getGroundNetwork()->exists())
|
||||
controller = trafficRef->getDepartureAirport()->getDynamics()->getGroundNetwork();
|
||||
if (trafficRef->getDepartureAirport()->getDynamics()->getGroundController()->exists())
|
||||
controller = trafficRef->getDepartureAirport()->getDynamics()->getGroundController();
|
||||
break;
|
||||
case 3: //Take off tower controller
|
||||
if (trafficRef->getDepartureAirport()->getDynamics()) {
|
||||
|
@ -593,13 +593,13 @@ void FGAIAircraft::announcePositionToController() {
|
|||
}
|
||||
break;
|
||||
case 6:
|
||||
if (trafficRef->getDepartureAirport()->getDynamics()) {
|
||||
if (trafficRef->getArrivalAirport()->getDynamics()) {
|
||||
controller = trafficRef->getArrivalAirport()->getDynamics()->getApproachController();
|
||||
}
|
||||
break;
|
||||
case 8: // Taxiing for parking
|
||||
if (trafficRef->getArrivalAirport()->getDynamics()->getGroundNetwork()->exists())
|
||||
controller = trafficRef->getArrivalAirport()->getDynamics()->getGroundNetwork();
|
||||
if (trafficRef->getArrivalAirport()->getDynamics()->getGroundController()->exists())
|
||||
controller = trafficRef->getArrivalAirport()->getDynamics()->getGroundController();
|
||||
break;
|
||||
default:
|
||||
controller = 0;
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include <Airports/airport.hxx>
|
||||
#include <Airports/runways.hxx>
|
||||
#include <Airports/dynamics.hxx>
|
||||
#include <Airports/groundnetwork.hxx>
|
||||
|
||||
#include "AIAircraft.hxx"
|
||||
#include "performancedata.hxx"
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <Airports/airport.hxx>
|
||||
#include <Airports/runways.hxx>
|
||||
#include <Airports/dynamics.hxx>
|
||||
#include <Airports/groundnetwork.hxx>
|
||||
|
||||
#include <Environment/environment_mgr.hxx>
|
||||
#include <Environment/environment.hxx>
|
||||
|
@ -56,7 +57,7 @@ bool FGAIFlightPlan::createPushBack(FGAIAircraft *ac,
|
|||
// must be reset.
|
||||
activeRunway.clear();
|
||||
|
||||
if (!(dep->getDynamics()->getGroundNetwork()->exists())) {
|
||||
if (!(dep->getDynamics()->getGroundController()->exists())) {
|
||||
//cerr << "Push Back fallback" << endl;
|
||||
createPushBackFallBack(ac, firstFlight, dep,
|
||||
radius, fltType, aircraftType, airline);
|
||||
|
|
|
@ -8,6 +8,7 @@ set(SOURCES
|
|||
ATISEncoder.cxx
|
||||
MetarPropertiesATISInformationProvider.cxx
|
||||
CurrentWeatherATISInformationProvider.cxx
|
||||
GroundController.cxx
|
||||
)
|
||||
|
||||
set(HEADERS
|
||||
|
@ -18,6 +19,7 @@ set(HEADERS
|
|||
ATISEncoder.hxx
|
||||
MetarPropertiesATISInformationProvider.hxx
|
||||
CurrentWeatherATISInformationProvider.hxx
|
||||
GroundController.hxx
|
||||
)
|
||||
|
||||
flightgear_component(ATC "${SOURCES}" "${HEADERS}")
|
||||
|
|
1059
src/ATC/GroundController.cxx
Normal file
1059
src/ATC/GroundController.cxx
Normal file
File diff suppressed because it is too large
Load diff
99
src/ATC/GroundController.hxx
Normal file
99
src/ATC/GroundController.hxx
Normal file
|
@ -0,0 +1,99 @@
|
|||
// GroundController.hxx - forked from groundnetwork.cxx
|
||||
//
|
||||
// Written by Durk Talsma, started June 2005.
|
||||
//
|
||||
// Copyright (C) 2004 Durk Talsma.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// $Id$
|
||||
|
||||
#ifndef ATC_GROUND_CONTROLLER_HXX
|
||||
#define ATC_GROUND_CONTROLLER_HXX
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <ATC/trafficcontrol.hxx>
|
||||
|
||||
class FGAirportDynamics;
|
||||
|
||||
/**************************************************************************************
|
||||
* class FGGroundNetWork
|
||||
*************************************************************************************/
|
||||
class FGGroundController : public FGATCController
|
||||
{
|
||||
private:
|
||||
|
||||
bool hasNetwork;
|
||||
bool networkInitialized;
|
||||
int count;
|
||||
int version;
|
||||
|
||||
|
||||
TrafficVector activeTraffic;
|
||||
TrafficVectorIterator currTraffic;
|
||||
|
||||
FGTowerController *towerController;
|
||||
FGAirport *parent;
|
||||
FGAirportDynamics* dynamics;
|
||||
|
||||
|
||||
void checkSpeedAdjustment(int id, double lat, double lon,
|
||||
double heading, double speed, double alt);
|
||||
void checkHoldPosition(int id, double lat, double lon,
|
||||
double heading, double speed, double alt);
|
||||
|
||||
|
||||
void updateStartupTraffic(TrafficVectorIterator i, int& priority, time_t now);
|
||||
void updateActiveTraffic(TrafficVectorIterator i, int& priority, time_t now);
|
||||
public:
|
||||
FGGroundController();
|
||||
~FGGroundController();
|
||||
|
||||
void setVersion (int v) { version = v;};
|
||||
int getVersion() { return version; };
|
||||
|
||||
void init(FGAirportDynamics* pr);
|
||||
bool exists() {
|
||||
return hasNetwork;
|
||||
};
|
||||
void setTowerController(FGTowerController *twrCtrlr) {
|
||||
towerController = twrCtrlr;
|
||||
};
|
||||
|
||||
|
||||
|
||||
virtual void announcePosition(int id, FGAIFlightPlan *intendedRoute, int currentRoute,
|
||||
double lat, double lon, double hdg, double spd, double alt,
|
||||
double radius, int leg, FGAIAircraft *aircraft);
|
||||
virtual void signOff(int id);
|
||||
virtual void updateAircraftInformation(int id, double lat, double lon, double heading, double speed, double alt, double dt);
|
||||
virtual bool hasInstruction(int id);
|
||||
virtual FGATCInstruction getInstruction(int id);
|
||||
|
||||
bool checkTransmissionState(int minState, int MaxState, TrafficVectorIterator i, time_t now, AtcMsgId msgId,
|
||||
AtcMsgDir msgDir);
|
||||
bool checkForCircularWaits(int id);
|
||||
virtual void render(bool);
|
||||
virtual std::string getName();
|
||||
virtual void update(double dt);
|
||||
|
||||
void addVersion(int v) {version = v; };
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -40,6 +40,7 @@
|
|||
#include <Main/fg_props.hxx>
|
||||
#include <Main/locale.hxx>
|
||||
#include <Airports/runways.hxx>
|
||||
#include <Airports/groundnetwork.hxx>
|
||||
#include <Navaids/NavDataCache.hxx>
|
||||
|
||||
#include "airport.hxx"
|
||||
|
@ -159,6 +160,7 @@ FGAirportDynamics::FGAirportDynamics(FGAirport * ap):
|
|||
|
||||
{
|
||||
lastUpdate = 0;
|
||||
groundNetwork.reset(new FGGroundNetwork);
|
||||
}
|
||||
|
||||
// Destructor
|
||||
|
@ -171,16 +173,17 @@ FGAirportDynamics::~FGAirportDynamics()
|
|||
// Initialization required after XMLRead
|
||||
void FGAirportDynamics::init()
|
||||
{
|
||||
groundNetwork.init(this);
|
||||
groundNetwork.setTowerController(&towerController);
|
||||
|
||||
|
||||
groundNetwork->init(this);
|
||||
groundController.setTowerController(&towerController);
|
||||
groundController.init(this);
|
||||
}
|
||||
|
||||
FGParking* FGAirportDynamics::innerGetAvailableParking(double radius, const string & flType,
|
||||
const string & airline,
|
||||
bool skipEmptyAirlineCode)
|
||||
{
|
||||
const FGParkingList& parkings(groundNetwork.allParkings());
|
||||
const FGParkingList& parkings(groundNetwork->allParkings());
|
||||
FGParkingList::const_iterator it;
|
||||
for (it = parkings.begin(); it != parkings.end(); ++it) {
|
||||
FGParkingRef parking = *it;
|
||||
|
@ -230,7 +233,7 @@ ParkingAssignment FGAirportDynamics::getAvailableParking(double radius, const st
|
|||
|
||||
ParkingAssignment FGAirportDynamics::getParkingByName(const std::string& name) const
|
||||
{
|
||||
const FGParkingList& parkings(groundNetwork.allParkings());
|
||||
const FGParkingList& parkings(groundNetwork->allParkings());
|
||||
FGParkingList::const_iterator it;
|
||||
for (it = parkings.begin(); it != parkings.end(); ++it) {
|
||||
if ((*it)->name() == name) {
|
||||
|
@ -292,7 +295,7 @@ public:
|
|||
|
||||
FGParkingList FGAirportDynamics::getParkings(bool onlyAvailable, const std::string &type) const
|
||||
{
|
||||
FGParkingList result(groundNetwork.allParkings());
|
||||
FGParkingList result(groundNetwork->allParkings());
|
||||
|
||||
GetParkingsPredicate pred(onlyAvailable, type, this);
|
||||
FGParkingList::iterator it = std::remove_if(result.begin(), result.end(), pred);
|
||||
|
|
|
@ -27,9 +27,10 @@
|
|||
#include <simgear/structure/SGReferenced.hxx>
|
||||
|
||||
#include <ATC/trafficcontrol.hxx>
|
||||
#include <ATC/GroundController.hxx>
|
||||
|
||||
#include "airports_fwd.hxx"
|
||||
#include "parking.hxx"
|
||||
#include "groundnetwork.hxx"
|
||||
#include "runwayprefs.hxx"
|
||||
|
||||
class ParkingAssignment
|
||||
|
@ -66,12 +67,13 @@ private:
|
|||
ParkingSet occupiedParkings;
|
||||
|
||||
|
||||
std::auto_ptr<FGGroundNetwork> groundNetwork;
|
||||
|
||||
FGRunwayPreference rwyPrefs;
|
||||
FGStartupController startupController;
|
||||
FGGroundNetwork groundNetwork;
|
||||
FGTowerController towerController;
|
||||
FGApproachController approachController;
|
||||
FGGroundController groundController;
|
||||
|
||||
time_t lastUpdate;
|
||||
std::string prevTrafficType;
|
||||
|
@ -98,7 +100,7 @@ private:
|
|||
bool skipEmptyAirlineCode);
|
||||
public:
|
||||
FGAirportDynamics(FGAirport* ap);
|
||||
~FGAirportDynamics();
|
||||
virtual ~FGAirportDynamics();
|
||||
|
||||
void addAwosFreq (int val) {
|
||||
freqAwos.push_back(val);
|
||||
|
@ -158,8 +160,8 @@ public:
|
|||
FGStartupController *getStartupController() {
|
||||
return &startupController;
|
||||
};
|
||||
FGGroundNetwork *getGroundNetwork() {
|
||||
return &groundNetwork;
|
||||
FGGroundController *getGroundController() {
|
||||
return &groundController;
|
||||
};
|
||||
FGTowerController *getTowerController() {
|
||||
return &towerController;
|
||||
|
@ -168,6 +170,11 @@ public:
|
|||
return &approachController;
|
||||
};
|
||||
|
||||
FGGroundNetwork* getGroundNetwork() const
|
||||
{
|
||||
return groundNetwork.get();
|
||||
}
|
||||
|
||||
int getGroundFrequency(unsigned leg);
|
||||
int getTowerFrequency (unsigned nr);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -30,10 +30,12 @@
|
|||
|
||||
#include "gnnode.hxx"
|
||||
#include "parking.hxx"
|
||||
#include <ATC/trafficcontrol.hxx>
|
||||
|
||||
class FGAirportDynamicsXMLLoader;
|
||||
|
||||
typedef std::vector<int> intVec;
|
||||
typedef std::vector<int>::iterator intVecIterator;
|
||||
|
||||
class Block
|
||||
{
|
||||
private:
|
||||
|
@ -172,7 +174,7 @@ public:
|
|||
/**************************************************************************************
|
||||
* class FGGroundNetWork
|
||||
*************************************************************************************/
|
||||
class FGGroundNetwork : public FGATCController
|
||||
class FGGroundNetwork
|
||||
{
|
||||
private:
|
||||
friend class FGAirportDynamicsXMLLoader;
|
||||
|
@ -180,18 +182,11 @@ private:
|
|||
FGAirportDynamics* dynamics; // weak back-pointer to our owner
|
||||
bool hasNetwork;
|
||||
bool networkInitialized;
|
||||
time_t nextSave;
|
||||
//int maxDepth;
|
||||
int count;
|
||||
|
||||
int version;
|
||||
|
||||
FGTaxiSegmentVector segments;
|
||||
|
||||
TrafficVector activeTraffic;
|
||||
TrafficVectorIterator currTraffic;
|
||||
|
||||
double totalDistance, maxDistance;
|
||||
FGTowerController *towerController;
|
||||
FGAirport *parent;
|
||||
|
||||
FGParkingList m_parkings;
|
||||
|
@ -223,15 +218,14 @@ public:
|
|||
bool exists() {
|
||||
return hasNetwork;
|
||||
};
|
||||
void setTowerController(FGTowerController *twrCtrlr) {
|
||||
towerController = twrCtrlr;
|
||||
};
|
||||
|
||||
FGTaxiNodeRef findNearestNode(const SGGeod& aGeod) const;
|
||||
FGTaxiNodeRef findNearestNodeOnRunway(const SGGeod& aGeod, FGRunway* aRunway = NULL) const;
|
||||
|
||||
FGTaxiSegment *findSegment(unsigned int idx) const;
|
||||
|
||||
FGTaxiSegment* findOppositeSegment(unsigned int index) const;
|
||||
|
||||
const FGParkingList& allParkings() const;
|
||||
|
||||
/**
|
||||
|
@ -244,22 +238,12 @@ public:
|
|||
|
||||
FGTaxiRoute findShortestRoute(FGTaxiNode* start, FGTaxiNode* end, bool fullSearch=true);
|
||||
|
||||
virtual void announcePosition(int id, FGAIFlightPlan *intendedRoute, int currentRoute,
|
||||
double lat, double lon, double hdg, double spd, double alt,
|
||||
double radius, int leg, FGAIAircraft *aircraft);
|
||||
virtual void signOff(int id);
|
||||
virtual void updateAircraftInformation(int id, double lat, double lon, double heading, double speed, double alt, double dt);
|
||||
virtual bool hasInstruction(int id);
|
||||
virtual FGATCInstruction getInstruction(int id);
|
||||
|
||||
bool checkTransmissionState(int minState, int MaxState, TrafficVectorIterator i, time_t now, AtcMsgId msgId,
|
||||
AtcMsgDir msgDir);
|
||||
bool checkForCircularWaits(int id);
|
||||
virtual void render(bool);
|
||||
virtual std::string getName();
|
||||
virtual void update(double dt);
|
||||
void blockSegmentsEndingAt(FGTaxiSegment* seg, int blockId,
|
||||
time_t blockTime, time_t now);
|
||||
|
||||
void addVersion(int v) {version = v; };
|
||||
void unblockAllSegments(time_t now);
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue