1 /******************************************************************************
3 * Written by Durk Talsma, started August 1, 2010.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 **************************************************************************/
29 #include <simgear/math/SGMath.hxx>
30 #include <Airports/dynamics.hxx>
31 #include <Airports/simple.hxx>
33 #include "atc_mgr.hxx"
36 FGATCManager::FGATCManager() {
40 FGATCManager::~FGATCManager() {
44 void FGATCManager::init() {
46 currentATCDialog = new FGATCDialogNew;
47 currentATCDialog->init();
49 // find a reasonable controller for our user's aircraft..
50 // Let's start by working out the following three scenarios:
51 // Starting on ground at a parking position
52 // Starting on ground at the runway.
53 // Starting in the Air
54 bool onGround = fgGetBool("/sim/presets/onground");
55 string runway = fgGetString("/sim/atc/runway");
56 string airport = fgGetString("/sim/presets/airport-id");
57 string parking = fgGetString("/sim/presets/parkpos");
59 FGAirport *apt = FGAirport::findByIdent(airport);
60 cerr << "found information: " << runway << " " << airport << ": parking = " << parking << endl;
62 if (parking.empty()) {
63 controller = apt->getDynamics()->getTowerController();
64 int stationFreq = apt->getDynamics()->getTowerFrequency(2);
65 cerr << "Setting radio frequency to in airfrequency: " << stationFreq << endl;
66 fgSetDouble("/instrumentation/comm[0]/frequencies/selected-mhz", ((double) stationFreq / 100.0));
69 controller = apt->getDynamics()->getGroundNetwork();
70 int stationFreq = apt->getDynamics()->getGroundFrequency(2);
71 cerr << "Setting radio frequency to : " << stationFreq << endl;
72 fgSetDouble("/instrumentation/comm[0]/frequencies/selected-mhz", ((double) stationFreq / 100.0));
83 void FGATCManager::addController(FGATCController *controller) {
84 activeStations.push_back(controller);
87 void FGATCManager::update ( double time ) {
88 //cerr << "ATC update code is running at time: " << time << endl;
89 currentATCDialog->update(time);