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()));
}
}
set(SOURCES
atis_mgr.cxx
+ atc_mgr.cxx
trafficcontrol.cxx
)
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
#include <algorithm>
#include "trafficcontrol.hxx"
+#include "atc_mgr.hxx"
#include <AIModel/AIAircraft.hxx>
#include <AIModel/AIFlightPlan.hxx>
#include <AIModel/performancedata.hxx>
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)
}
}
-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
}
}
-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
}
}
-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
// There is probably a better include than sg_geodesy to get the SG_NM_TO_METER...
#include <simgear/math/sg_geodesy.hxx>
#include <simgear/debug/logstream.hxx>
+#include <simgear/structure/SGReferenced.hxx>
+#include <simgear/structure/SGSharedPtr.hxx>
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;
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);
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);
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);
// 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);
}
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
}
}
-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:
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);
#include <ATCDCL/ATCmgr.hxx>
#include <ATCDCL/commlist.hxx>
#include <ATC/atis_mgr.hxx>
+#include <ATC/atc_mgr.hxx>
#include <Autopilot/route_mgr.hxx>
#include <Autopilot/autopilotgroup.hxx>
////////////////////////////////////////////////////////////////////
// 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");
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);