From 52b0baace1d3ef636b4e1c8f8f1bd047f8d0b023 Mon Sep 17 00:00:00 2001 From: Durk Talsma Date: Sun, 3 Apr 2011 17:58:16 +0200 Subject: [PATCH] adding changed files for previous commit. --- src/AIModel/AIAircraft.cxx | 12 ++++---- src/ATC/CMakeLists.txt | 1 + src/ATC/Makefile.am | 2 ++ src/ATC/trafficcontrol.cxx | 27 +++++++++++------ src/ATC/trafficcontrol.hxx | 20 +++++++------ src/ATCDCL/ATCDialog.cxx | 55 +++++++++++++++++----------------- src/Airports/groundnetwork.cxx | 6 ++-- src/Airports/groundnetwork.hxx | 2 +- src/Main/fg_init.cxx | 11 ++++++- 9 files changed, 80 insertions(+), 56 deletions(-) diff --git a/src/AIModel/AIAircraft.cxx b/src/AIModel/AIAircraft.cxx index d0e319705..6a4ce077b 100644 --- a/src/AIModel/AIAircraft.cxx +++ b/src/AIModel/AIAircraft.cxx @@ -1088,12 +1088,12 @@ string FGAIAircraft::atGate() { void FGAIAircraft::handleATCRequests() { //TODO implement NullController for having no ATC to save the conditionals if (controller) { - controller->update(getID(), - pos.getLatitudeDeg(), - pos.getLongitudeDeg(), - hdg, - speed, - altitude_ft, dt); + controller->updateAircraftInformation(getID(), + pos.getLatitudeDeg(), + pos.getLongitudeDeg(), + hdg, + speed, + altitude_ft, dt); processATC(controller->getInstruction(getID())); } } diff --git a/src/ATC/CMakeLists.txt b/src/ATC/CMakeLists.txt index 60c18e996..d7822c987 100644 --- a/src/ATC/CMakeLists.txt +++ b/src/ATC/CMakeLists.txt @@ -2,6 +2,7 @@ include(FlightGearComponent) set(SOURCES atis_mgr.cxx + atc_mgr.cxx trafficcontrol.cxx ) diff --git a/src/ATC/Makefile.am b/src/ATC/Makefile.am index e3e522737..fd5302aac 100644 --- a/src/ATC/Makefile.am +++ b/src/ATC/Makefile.am @@ -2,6 +2,8 @@ noinst_LIBRARIES = libATC.a libATC_a_SOURCES = \ atis_mgr.cxx atis_mgr.hxx \ + atcdialog.cxx atcdialog.hxx \ + atc_mgr.cxx atc_mgr.hxx \ trafficcontrol.cxx trafficcontrol.hxx INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src diff --git a/src/ATC/trafficcontrol.cxx b/src/ATC/trafficcontrol.cxx index 8079933b1..664929bfc 100644 --- a/src/ATC/trafficcontrol.cxx +++ b/src/ATC/trafficcontrol.cxx @@ -27,6 +27,7 @@ #include #include "trafficcontrol.hxx" +#include "atc_mgr.hxx" #include #include #include @@ -447,9 +448,17 @@ bool FGATCInstruction::hasInstruction() FGATCController::FGATCController() { + cerr << "running FGATController constructor" << endl; dt_count = 0; available = true; lastTransmission = 0; + FGATCManager *mgr = (FGATCManager*) globals->get_subsystem("ATC"); + mgr->addController(this); +} + +FGATCController::~FGATCController() +{ + cerr << "running FGATController destructor" << endl; } string FGATCController::getGateName(FGAIAircraft * ref) @@ -709,9 +718,9 @@ void FGTowerController::announcePosition(int id, } } -void FGTowerController::update(int id, double lat, double lon, - double heading, double speed, double alt, - double dt) +void FGTowerController::updateAircraftInformation(int id, double lat, double lon, + double heading, double speed, double alt, + double dt) { TrafficVectorIterator i = activeTraffic.begin(); // Search whether the current id has an entry @@ -978,9 +987,9 @@ void FGStartupController::signOff(int id) } } -void FGStartupController::update(int id, double lat, double lon, - double heading, double speed, double alt, - double dt) +void FGStartupController::updateAircraftInformation(int id, double lat, double lon, + double heading, double speed, double alt, + double dt) { TrafficVectorIterator i = activeTraffic.begin(); // Search search if the current id has an entry @@ -1160,9 +1169,9 @@ void FGApproachController::announcePosition(int id, } } -void FGApproachController::update(int id, double lat, double lon, - double heading, double speed, double alt, - double dt) +void FGApproachController::updateAircraftInformation(int id, double lat, double lon, + double heading, double speed, double alt, + double dt) { TrafficVectorIterator i = activeTraffic.begin(); // Search search if the current id has an entry diff --git a/src/ATC/trafficcontrol.hxx b/src/ATC/trafficcontrol.hxx index 7e83a72b4..2550f7cb6 100644 --- a/src/ATC/trafficcontrol.hxx +++ b/src/ATC/trafficcontrol.hxx @@ -31,6 +31,8 @@ // There is probably a better include than sg_geodesy to get the SG_NM_TO_METER... #include #include +#include +#include @@ -257,14 +259,14 @@ public: ATC_AIR_TO_GROUND, ATC_GROUND_TO_AIR } AtcMsgDir; FGATCController(); - virtual ~FGATCController() {}; + virtual ~FGATCController(); 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) = 0; + double lat, double lon, + double hdg, double spd, double alt, double radius, int leg, + FGAIAircraft *aircraft) = 0; virtual void signOff(int id) = 0; - virtual void update(int id, double lat, double lon, - double heading, double speed, double alt, double dt) = 0; + virtual void updateAircraftInformation(int id, double lat, double lon, + double heading, double speed, double alt, double dt) = 0; virtual bool hasInstruction(int id) = 0; virtual FGATCInstruction getInstruction(int id) = 0; @@ -291,7 +293,7 @@ public: double hdg, double spd, double alt, double radius, int leg, FGAIAircraft *aircraft); virtual void signOff(int id); - virtual void update(int id, double lat, double lon, + 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); @@ -319,7 +321,7 @@ public: double hdg, double spd, double alt, double radius, int leg, FGAIAircraft *aircraft); virtual void signOff(int id); - virtual void update(int id, double lat, double lon, + 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); @@ -346,7 +348,7 @@ public: double hdg, double spd, double alt, double radius, int leg, FGAIAircraft *aircraft); virtual void signOff(int id); - virtual void update(int id, double lat, double lon, + 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); diff --git a/src/ATCDCL/ATCDialog.cxx b/src/ATCDCL/ATCDialog.cxx index f5f5ec935..a1c3c5e84 100644 --- a/src/ATCDCL/ATCDialog.cxx +++ b/src/ATCDCL/ATCDialog.cxx @@ -46,6 +46,7 @@ FGATCDialog *current_atcdialog; // For the command manager - maybe eventually this should go in the built in command list static bool do_ATC_dialog(const SGPropertyNode* arg) { + cerr << "Running ATCDCL do_ATC_dialog" << endl; current_atcdialog->PopupDialog(); return(true); } @@ -101,39 +102,39 @@ FGATCDialog::~FGATCDialog() { void FGATCDialog::Init() { // Add ATC-dialog to the command list - globals->get_commands()->addCommand("ATC-dialog", do_ATC_dialog); + //globals->get_commands()->addCommand("ATC-dialog", do_ATC_dialog); // Add ATC-freq-search to the command list - globals->get_commands()->addCommand("ATC-freq-search", do_ATC_freq_search); + //globals->get_commands()->addCommand("ATC-freq-search", do_ATC_freq_search); // initialize properties polled in Update() - globals->get_props()->setStringValue("/sim/atc/freq-airport", ""); - globals->get_props()->setIntValue("/sim/atc/transmission-num", -1); + //globals->get_props()->setStringValue("/sim/atc/freq-airport", ""); + //globals->get_props()->setIntValue("/sim/atc/transmission-num", -1); } void FGATCDialog::Update(double dt) { - static SGPropertyNode_ptr airport = globals->get_props()->getNode("/sim/atc/freq-airport", true); - string s = airport->getStringValue(); - if (!s.empty()) { - airport->setStringValue(""); - FreqDisplay(s); - } - - static SGPropertyNode_ptr trans_num = globals->get_props()->getNode("/sim/atc/transmission-num", true); - int n = trans_num->getIntValue(); - if (n >= 0) { - trans_num->setIntValue(-1); - PopupCallback(n); - } - - if(_callbackPending) { - if(_callbackTimer > _callbackWait) { - _callbackPtr->ReceiveUserCallback(_callbackCode); - _callbackPtr->NotifyTransmissionFinished(fgGetString("/sim/user/callsign")); - _callbackPending = false; - } else { - _callbackTimer += dt; - } - } + //static SGPropertyNode_ptr airport = globals->get_props()->getNode("/sim/atc/freq-airport", true); + //string s = airport->getStringValue(); + //if (!s.empty()) { + // airport->setStringValue(""); + // FreqDisplay(s); + //} + + //static SGPropertyNode_ptr trans_num = globals->get_props()->getNode("/sim/atc/transmission-num", true); + //int n = trans_num->getIntValue(); + //if (n >= 0) { + // trans_num->setIntValue(-1); + // PopupCallback(n); + //} + + //if(_callbackPending) { + // if(_callbackTimer > _callbackWait) { + // _callbackPtr->ReceiveUserCallback(_callbackCode); + // _callbackPtr->NotifyTransmissionFinished(fgGetString("/sim/user/callsign")); + // _callbackPending = false; + // } else { + // _callbackTimer += dt; + // } + //} } // Add an entry diff --git a/src/Airports/groundnetwork.cxx b/src/Airports/groundnetwork.cxx index 2fb8127a5..3ba650158 100644 --- a/src/Airports/groundnetwork.cxx +++ b/src/Airports/groundnetwork.cxx @@ -510,9 +510,9 @@ void FGGroundNetwork::signOff(int id) } } -void FGGroundNetwork::update(int id, double lat, double lon, - double heading, double speed, double alt, - double dt) +void FGGroundNetwork::updateAircraftInformation(int id, double lat, double lon, + double heading, double speed, double alt, + double dt) { // Check whether aircraft are on hold due to a preceding pushback. If so, make sure to // Transmit air-to-ground "Ready to taxi request: diff --git a/src/Airports/groundnetwork.hxx b/src/Airports/groundnetwork.hxx index fe83d4df2..06ed98b12 100644 --- a/src/Airports/groundnetwork.hxx +++ b/src/Airports/groundnetwork.hxx @@ -269,7 +269,7 @@ public: double lat, double lon, double hdg, double spd, double alt, double radius, int leg, FGAIAircraft *aircraft); virtual void signOff(int id); - virtual void update(int id, double lat, double lon, double heading, double speed, double alt, double dt); + 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); diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 9eb8ae7a9..7d3e6ce28 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -77,6 +77,7 @@ #include #include #include +#include #include #include @@ -1384,6 +1385,10 @@ bool fgInitSubsystems() { //////////////////////////////////////////////////////////////////// // Initialise the ATC Manager + // Note that this is old stuff, but might be necessesary for the + // current ATIS implementation. Therefore, leave it in here + // until the ATIS system is ported over to make use of the ATIS + // sub system infrastructure. //////////////////////////////////////////////////////////////////// SG_LOG(SG_GENERAL, SG_INFO, " ATC Manager"); @@ -1391,7 +1396,11 @@ bool fgInitSubsystems() { globals->get_ATC_mgr()->init(); //////////////////////////////////////////////////////////////////// - // Initialise the ATIS Manager + // Initialize the ATC subsystem + //////////////////////////////////////////////////////////////////// + globals->add_subsystem("ATC", new FGATCManager, SGSubsystemMgr::POST_FDM); + //////////////////////////////////////////////////////////////////// + // Initialise the ATIS Subsystem //////////////////////////////////////////////////////////////////// globals->add_subsystem("atis", new FGAtisManager, SGSubsystemMgr::POST_FDM); -- 2.39.2