--- /dev/null
+// Implementation of FGATC - ATC subsystem abstract base class.
+// Nothing in here should ever get called.
+//
+// Written by David Luff, started February 2002.
+//
+// Copyright (C) 2002 David C Luff - david.luff@nottingham.ac.uk
+//
+// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include "ATC.hxx"
+
+FGATC::~FGATC() {
+}
+
+void FGATC::Update() {
+}
+
+void FGATC::SetDisplay() {
+}
+
+void FGATC::SetNoDisplay() {
+}
+
+const char* FGATC::GetIdent() {
+ return("Error - base class function called in FGATC...");
+}
+
+atc_type FGATC::GetType() {
+ return INVALID;
+}
\ No newline at end of file
--- /dev/null
+// FGATC - abstract base class for the various actual atc classes
+// such as FGATIS, FGTower etc.
+//
+// Written by David Luff, started Feburary 2002.
+//
+// Copyright (C) 2002 David C. Luff - david.luff@nottingham.ac.uk
+//
+// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#ifndef _FG_ATC_HXX
+#define _FG_ATC_HXX
+
+// Possible types of ATC type that the radios may be tuned to.
+// INVALID implies not tuned in to anything.
+typedef enum atc_type {
+ INVALID,
+ ATIS,
+ GROUND,
+ TOWER,
+ APPROACH,
+ DEPARTURE,
+ ENROUTE
+};
+
+class FGATC {
+
+public:
+
+ virtual ~FGATC();
+
+ // Run the internal calculations
+ virtual void Update();
+
+ // Indicate that this instance should output to the display if appropriate
+ virtual void SetDisplay();
+
+ // Indicate that this instance should not output to the display
+ virtual void SetNoDisplay();
+
+ // Return the ATC station ident (generally the ICAO code of the airport)
+ virtual const char* GetIdent();
+
+ // Return the type of ATC station that the class represents
+ virtual atc_type GetType();
+};
+
+#endif // _FG_ATC_HXX
\ No newline at end of file
#include "ATCdisplay.hxx"
-FGATCDisplay *current_atcdisplay;
-
-
// Constructor
-FGATCDisplay::FGATCDisplay( void ) {
+FGATCDisplay::FGATCDisplay() {
rep_msg = false;
change_msg_flag = false;
dsp_offset1 = 0;
// Destructor
-FGATCDisplay::~FGATCDisplay( void ) {
+FGATCDisplay::~FGATCDisplay() {
}
-void FGATCDisplay::init( void ) {
+void FGATCDisplay::init() {
}
+void FGATCDisplay::bind() {
+}
+
+void FGATCDisplay::unbind() {
+}
// update - this actually draws the visuals and should be called from the main Flightgear rendering loop.
-void FGATCDisplay::update() {
+void FGATCDisplay::update(int dt) {
// These strings are used for temporary storage of the transmission string in order
- // that the string we view only changes when the next repitition starts scrolling
+ // that the string we view only changes when the next repetition starts scrolling
// even though the master string (rep_msg_str) may change at any time.
static string msg1 = "";
static string msg2 = "";
// ATCdisplay.hxx - class to manage the graphical display of ATC messages.
// - The idea is to separate the display of ATC messages from their
-// - generation so that the generation may come from any source.
+// - generation so that the generation may come from any source.
//
// Written by David Luff, started October 2001.
//
# include <config.h>
#endif
+#include <Main/fgfs.hxx>
+
#include <vector>
#include <string>
typedef vector<atcMessage> atcMessageList;
typedef atcMessageList::iterator atcMessageListIterator;
-class FGATCDisplay {
+class FGATCDisplay : public FGSubsystem
+{
private:
bool rep_msg; // Flag to indicate there is a repeating transmission to display
void init();
+ void bind();
+
+ void unbind();
+
// Display any registered messages
- void update();
+ void update(int dt);
// Register a single message for display when possible
void RegisterSingleMessage(string msg); // OK - I know passing a string in and out is probably not good but it will have to do for now.
-/* For now we will assume only one repeating message at once */
+ // For now we will assume only one repeating message at once
// This is not really robust
// Register a continuously repeating message
void CancelRepeatingMessage();
};
-extern FGATCDisplay *current_atcdisplay;
-
#endif // _FG_ATC_DISPLAY_HXX
--- /dev/null
+// ATCmgr.cxx - Implementation of FGATCMgr - a global Flightgear ATC manager.
+//
+// Written by David Luff, started February 2002.
+//
+// Copyright (C) 2002 David C Luff - david.luff@nottingham.ac.uk
+//
+// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+//#include <Time/event.hxx>
+
+#include "ATCmgr.hxx"
+#include "atislist.hxx"
+
+/*
+// periodic radio station search wrapper
+static void fgATCSearch( void ) {
+ globals->get_ATC_mgr()->Search();
+}
+*/ //This wouldn't compile - including Time/event.hxx breaks it :-(
+
+FGATCMgr::FGATCMgr() {
+}
+
+FGATCMgr::~FGATCMgr() {
+}
+
+void FGATCMgr::bind() {
+}
+
+void FGATCMgr::unbind() {
+}
+
+void FGATCMgr::init() {
+ comm1_node = fgGetNode("/radios/comm[0]/frequencies/selected-mhz", true);
+ comm2_node = fgGetNode("/radios/comm[1]/frequencies/selected-mhz", true);
+ lon_node = fgGetNode("/position/longitude-deg", true);
+ lat_node = fgGetNode("/position/latitude-deg", true);
+ elev_node = fgGetNode("/position/altitude-ft", true);
+ atc_list_itr = atc_list.begin();
+ // Search for connected ATC stations once per 0.8 seconds or so
+ // global_events.Register( "fgATCSearch()", fgATCSearch,
+ // fgEVENT::FG_EVENT_READY, 800);
+ // For some reason the above doesn't compile - including Time/event.hxx stops compilation.
+}
+
+void FGATCMgr::update(int dt) {
+ //Traverse the list of active stations.
+ //Only update one class per update step to avoid the whole ATC system having to calculate between frames.
+ //Eventually we should only update every so many steps.
+ if(atc_list.size()) {
+ if(atc_list_itr == atc_list.end()) {
+ atc_list_itr = atc_list.begin();
+ }
+ (*atc_list_itr)->Update();
+ ++atc_list_itr;
+ }
+
+ // Search the tuned frequencies every now and then - this should be done with the event scheduler
+ static int i = 0;
+ if(i == 30) {
+ Search();
+ i = 0;
+ }
+ ++i;
+}
+
+void FGATCMgr::RemoveFromList(const char* id, atc_type tp) {
+ atc_list_itr = atc_list.begin();
+ while(atc_list_itr != atc_list.end()) {
+ if( (!strcmp((*atc_list_itr)->GetIdent(), id))
+ && ((*atc_list_itr)->GetType() == tp) ) {
+ //Before removing it stop it transmitting!!
+ (*atc_list_itr)->SetNoDisplay();
+ (*atc_list_itr)->Update();
+ delete (*atc_list_itr);
+ atc_list_itr = atc_list.erase(atc_list_itr);
+ break;
+ } // Note that that can upset where we are in the list but that doesn't really matter
+ ++atc_list_itr;
+ }
+}
+
+void FGATCMgr::Search() {
+
+ ////////////////////////////////////////////////////////////////////////
+ // Comm1.
+ ////////////////////////////////////////////////////////////////////////
+
+ comm1_freq = comm1_node->getDoubleValue();
+ double lon = lon_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
+ double lat = lat_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
+ double elev = elev_node->getDoubleValue() * SG_FEET_TO_METER;
+
+ //Search for ATIS first
+ if(current_atislist->query(lon, lat, elev, comm1_freq, &atis)) {
+ //cout << "atis found in radiostack search !!!!" << endl;
+ comm1_ident = atis.GetIdent();
+ comm1_valid = true;
+ if(last_comm1_ident != comm1_ident) {
+ if(last_comm1_ident != "") {
+ RemoveFromList(last_comm1_ident, ATIS);
+ }
+ last_comm1_ident = comm1_ident;
+ comm1_elev = atis.get_elev();
+ comm1_range = FG_ATIS_DEFAULT_RANGE;
+ comm1_effective_range = comm1_range;
+ comm1_x = atis.get_x();
+ comm1_y = atis.get_y();
+ comm1_z = atis.get_z();
+ FGATIS* a = new FGATIS;
+ *a = atis;
+ a->SetDisplay();
+ atc_list.push_back(a);
+ //cout << "Found a new atis station in range" << endl;
+ //cout << " id = " << atis.GetIdent() << endl;
+ }
+ } else {
+ if(comm1_valid) {
+ RemoveFromList(comm1_ident, ATIS);
+ comm1_valid = false;
+ comm1_ident = "";
+ //comm1_trans_ident = "";
+ last_comm1_ident = "";
+ }
+ //cout << "not picking up atis" << endl;
+ }
+}
\ No newline at end of file
--- /dev/null
+// ATCMgr.hxx - definition of FGATCMgr
+// - a global management class for FlightGear generated ATC
+//
+// Written by David Luff, started February 2002.
+//
+// Copyright (C) 2002 David C Luff - david.luff@nottingham.ac.uk
+//
+// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#ifndef _FG_ATCMGR_HXX
+#define _FG_ATCMGR_HXX
+
+#include <Main/fgfs.hxx>
+#include <Main/fg_props.hxx>
+
+#include <list>
+
+#include "atis.hxx"
+#include "ATC.hxx"
+
+SG_USING_STD(list);
+
+class FGATCMgr : public FGSubsystem
+{
+
+private:
+
+ // A list of pointers to all currently active ATC classes
+ typedef list <FGATC*> atc_list_type;
+ typedef atc_list_type::iterator atc_list_iterator;
+ typedef atc_list_type::const_iterator atc_list_const_iterator;
+
+ // Everything put in this list should be created dynamically
+ // on the heap and ***DELETED WHEN REMOVED!!!!!***
+ atc_list_type atc_list;
+ atc_list_iterator atc_list_itr;
+ // Any member function of FGATCMgr is permitted to leave this iterator pointing
+ // at any point in or at the end of the list.
+ // Hence any new access must explicitly first check for atc_list.end() before dereferencing.
+
+ // Position of the Users Aircraft
+ double lon;
+ double lat;
+ double elev;
+
+ atc_type comm1_type;
+ atc_type comm2_type;
+
+ double comm1_freq;
+ double comm2_freq;
+
+ // Pointers to users current communication frequencies.
+ SGPropertyNode *comm1_node;
+ SGPropertyNode *comm2_node;
+
+ // Pointers to current users position
+ SGPropertyNode *lon_node;
+ SGPropertyNode *lat_node;
+ SGPropertyNode *elev_node;
+
+ // Position of the ATC that the comm radios are tuned to in order to decide whether transmission
+ // will be received
+ double comm1_x, comm1_y, comm1_z, comm1_elev;
+ double comm1_range, comm1_effective_range;
+ bool comm1_valid;
+ const char* comm1_ident;
+ const char* last_comm1_ident;
+ double comm2_x, comm2_y, comm2_z, comm2_elev;
+ double comm2_range, comm2_effective_range;
+ bool comm2_valid;
+ const char* comm2_ident;
+ const char* last_comm2_ident;
+
+ FGATIS atis;
+ //FGTower tower;
+ //FGGround ground;
+ //FGApproach approach;
+ //FGDeparture departure;
+
+public:
+
+ FGATCMgr();
+ ~FGATCMgr();
+
+ void init();
+
+ void bind();
+
+ void unbind();
+
+ void update(int dt);
+
+private:
+
+ // Remove a class from the atc_list and delete it from memory
+ void RemoveFromList(const char* id, atc_type tp);
+
+ // Search a specified freq for matching stations
+ void Search();
+
+};
+
+#endif // _FG_ATCMGR_HXX
\ No newline at end of file
noinst_LIBRARIES = libATC.a
libATC_a_SOURCES = \
- atis.cxx atis.hxx atislist.hxx atislist.cxx \
- ATCdisplay.hxx ATCdisplay.cxx
+ ATC.hxx ATC.cxx \
+ ATCdisplay.hxx ATCdisplay.cxx \
+ ATCmgr.hxx ATCmgr.cxx \
+ atis.cxx atis.hxx \
+ atislist.hxx atislist.cxx
if OLD_AUTOMAKE
INCLUDES += -I$(top_srcdir) -I$(top_srcdir)/src
// atis.cxx - routines to generate the ATIS info string
+// This is the implementation of the FGATIS class
//
// Written by David Luff, started October 2001.
//
//#endif
#include <Main/fg_props.hxx>
+#include <Main/globals.hxx>
#include <Airports/runways.hxx>
#include "atis.hxx"
#include "atislist.hxx"
+#include "ATCdisplay.hxx"
string GetPhoneticIdent(int i) {
// TODO - Check i is between 1 and 26 and wrap if necessary
// Constructor
FGATIS::FGATIS() {
+ transmission = "";
+ display = false;
+ displaying = false;
}
// Destructor
FGATIS::~FGATIS() {
}
-string FGATIS::get_transmission() {
-//void FGATIS::get_transmission() {
-#if !defined(FG_NEW_ENVIRONMENT)
+// Main update function - checks whether we are displaying or not the correct message.
+void FGATIS::Update() {
+ if(display) {
+ if(displaying) {
+ // Check if we need to update the message
+ // - basically every hour and if the weather changes significantly at the station
+ //globals->get_ATC_display()->ChangeRepeatingMessage(transmission);
+ } else {
+ // We need to get and display the message
+ UpdateTransmission();
+ globals->get_ATC_display()->RegisterRepeatingMessage(transmission);
+ displaying = true;
+ }
+ } else {
+ // We shouldn't be displaying
+ if(displaying) {
+ globals->get_ATC_display()->CancelRepeatingMessage();
+ displaying = false;
+ }
+ }
+}
- string transmission = "";
+// Sets the actual broadcast ATIS transmission.
+void FGATIS::UpdateTransmission() {
+#if !defined(FG_NEW_ENVIRONMENT)
double visibility;
char buf[10];
int phonetic_id;
sgVec3 position = { lat, lon, elev };
FGPhysicalProperty stationweather = WeatherDatabase->get(position);
-// Only update every so-many loops - FIXME - possibly register this with the event scheduler
-// Ack this doesn't work since the static counter is shared between all instances of FGATIS
-// OK, for now the radiostack is handling only calling this every-so-often but that is not really
-// a proper solution since the atis knows when the transmission is going to change not the radio.
- //static int i=0;
- //if(i == 0) {
- transmission = "";
-
- // Start with the transmitted station name.
- transmission += name;
- // Add "Information"
- transmission += " Information";
-
- //cout << "In atis.cxx, time_str = " << time_str << '\n';
- // Add the recording identifier
- // For now we will assume we only transmit every hour
- hours = atoi((time_str.substr(1,2)).c_str()); //Warning - this is fragile if the
- //time string format changes
- //cout << "In atis.cxx, hours = " << hours << endl;
- phonetic_id = current_atislist->GetCallSign(ident, hours, 0);
- phonetic_id_string = GetPhoneticIdent(phonetic_id);
- transmission += " ";
- transmission += phonetic_id_string;
+ transmission = "";
- // Output the recording time. - we'll just output the last whole hour for now.
- // FIXME - this only gets GMT time but that appears to be all the clock outputs for now
- //cout << "in atis.cxx, time = " << time_str << endl;
- transmission = transmission + " Weather " + time_str.substr(0,3) + "00 hours Zulu";
+ // Start with the transmitted station name.
+ transmission += name;
+ // Add "Information"
+ transmission += " Information";
- // Get the temperature
- // (Hardwire it for now since the global property returns the temperature at the current altitude
- //temperature = fgGetDouble("/environment/weather/temperature-K");
- sprintf(buf, "%i", int(stationweather.Temperature - 273.15));
- transmission += " Temperature ";
- transmission += buf;
- transmission += " degrees Celsius";
+ //cout << "In atis.cxx, time_str = " << time_str << '\n';
+ // Add the recording identifier
+ // For now we will assume we only transmit every hour
+ hours = atoi((time_str.substr(1,2)).c_str()); //Warning - this is fragile if the
+ //time string format changes
+ //cout << "In atis.cxx, hours = " << hours << endl;
+ phonetic_id = current_atislist->GetCallSign(ident, hours, 0);
+ phonetic_id_string = GetPhoneticIdent(phonetic_id);
+ transmission += " ";
+ transmission += phonetic_id_string;
+
+ // Output the recording time. - we'll just output the last whole hour for now.
+ // FIXME - this only gets GMT time but that appears to be all the clock outputs for now
+ //cout << "in atis.cxx, time = " << time_str << endl;
+ transmission = transmission + " Weather " + time_str.substr(0,3) + "00 hours Zulu";
+
+ // Get the temperature
+ // (Hardwire it for now since the global property returns the temperature at the current altitude
+ //temperature = fgGetDouble("/environment/weather/temperature-K");
+ sprintf(buf, "%i", int(stationweather.Temperature - 273.15));
+ transmission += " Temperature ";
+ transmission += buf;
+ transmission += " degrees Celsius";
// Get the pressure / altimeter
// pressure is: stationweather.AirPressure in Pascal
// Anything else?
- // TODO - unhardwire the identifier
transmission += " Advise controller on initial contact you have ";
transmission += phonetic_id_string;
- //}
-
-// i++;
-// if(i == 600) {
-// i=0;
-// }
-
- return(transmission);
#else
- return "Station unavailable (not supported by FG_NEW_ENVIRONMENT)";
+ transmission = "Station unavailable (not supported by FG_NEW_ENVIRONMENT)";
+ //return "Station unavailable (not supported by FG_NEW_ENVIRONMENT)";
#endif // FG_NEW_ENVIRONMENT
}
// atis.hxx -- ATIS class
//
-// Written by Curtis Olson, started April 2000.
+// Written by David Luff, started October 2001.
+// Based on nav.hxx by Curtis Olson, started April 2000.
//
-// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
+// Copyright (C) 2001 David C. Luff - david.luff@nottingham.ac.uk
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
SG_USING_STD(string);
+#include "ATC.hxx"
+
//DCL - a complete guess for now.
#define FG_ATIS_DEFAULT_RANGE 30
-class FGATIS {
+class FGATIS : public FGATC {
char type;
double lon, lat;
double x, y, z;
int freq;
int range;
+ bool display; // Flag to indicate whether we should be outputting to the ATC display.
+ bool displaying; // Flag to indicate whether we are outputting to the ATC display.
string ident; // Code of the airport its at.
string name; // Name transmitted in the broadcast.
- string info; // The actual ATIS transmission
+ string transmission; // The actual ATIS transmission
// This is not stored in default.atis but is generated
// from the prevailing conditions when required.
string trans_ident; // transmitted ident
bool atis_failed; // atis failed?
+ // Aircraft position
+ // ATIS is actually a special case in that unlike other ATC eg.tower it doesn't actually know about
+ // or the whereabouts of the aircraft it is transmitting to. However, to ensure consistancy of
+ // operation with the other ATC classes the ATIS class must calculate range to the aircraft in order
+ // to decide whether to render the transmission - hence the users plane details must be stored.
+ //SGPropertyNode *airplane_lon_node;
+ //SGPropertyNode *airplane_lat_node;
+ //SGPropertyNode *airplane_elev_node;
+
public:
FGATIS(void);
~FGATIS(void);
+ //run the ATIS instance
+ void Update(void);
+
+ //Indicate that this instance should be outputting to the ATC display
+ inline void SetDisplay(void) {display = true;}
+
+ //Indicate that this instance should not be outputting to the ATC display
+ inline void SetNoDisplay(void) {display = false;}
+
inline char get_type() const { return type; }
inline double get_lon() const { return lon; }
inline double get_lat() const { return lat; }
inline double get_z() const { return z; }
inline int get_freq() const { return freq; }
inline int get_range() const { return range; }
- inline const char *get_ident() { return ident.c_str(); }
+ inline const char* GetIdent() { return ident.c_str(); }
inline string get_trans_ident() { return trans_ident; }
- string get_transmission(void);
-// void get_transmission();
+ inline atc_type GetType() { return ATIS; }
+
+private:
+
+ //Update the transmission string
+ void UpdateTransmission(void);
/* inline void set_type( char t ) { type = t; }
inline void set_lon( double l ) { lon = l; }
// atislist.cxx -- navaids management class
//
-// Written by Curtis Olson, started April 2000.
+// Written by David Luff, started October 2001.
+// Based on navlist.cxx by Curtis Olson, started April 2000.
//
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
//
// atislist.hxx -- atis management class
//
-// Written by Curtis Olson, started April 2000.
+// Written by David Luff, started October 2001.
+// Based on navlist.hxx by Curtis Olson, started April 2000.
//
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
//
#include <simgear/math/sg_random.h>
#include <Aircraft/aircraft.hxx>
-#include <ATC/ATCdisplay.hxx>
-//#include <Navaids/atis.hxx>
#include <Navaids/ilslist.hxx>
#include <Navaids/mkrbeacons.hxx>
#include <Navaids/navlist.hxx>
void
FGRadioStack::update(int dt)
{
- //DCL
- string transmission;
-
double lon = lon_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
double lat = lat_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
double elev = alt_node->getDoubleValue() * SG_FEET_TO_METER;
Point3D station;
double az1, az2, s;
- ////////////////////////////////////////////////////////////////////////
- // Comm1.
- ////////////////////////////////////////////////////////////////////////
-
- static bool repeating_message_registered = false;
- static int dcl_i = 0; //Hack to only call the transmission now and then - should use the event scheduler
- if ( comm1_valid ) {
- station = Point3D( comm1_x, comm1_y, comm1_z );
- comm1_dist = aircraft.distance3D( station );
- if ( comm1_dist < comm1_effective_range * SG_NM_TO_METER ) {
- comm1_inrange = true;
- // TODO - only get the transmission and register every now and then
- if(dcl_i == 0) {
- transmission = atis.get_transmission();
- current_atcdisplay->ChangeRepeatingMessage(transmission);
- }
- if(!repeating_message_registered) {
- current_atcdisplay->RegisterRepeatingMessage(transmission);
- repeating_message_registered = true;
- }
- dcl_i++;
- if(dcl_i == 2000) {
- dcl_i = 0;
- }
- } else {
- comm1_inrange = false;
- if(repeating_message_registered) {
- current_atcdisplay->CancelRepeatingMessage();
- repeating_message_registered = false;
- }
- dcl_i = 0;
- }
- } else {
- comm1_inrange = false;
- if(repeating_message_registered) {
- current_atcdisplay->CancelRepeatingMessage();
- repeating_message_registered = false;
- }
- dcl_i = 0;
- // cout << "not picking up comm1. :-(" << endl;
- }
-
////////////////////////////////////////////////////////////////////////
// Nav1.
////////////////////////////////////////////////////////////////////////
FGILS ils;
FGNav nav;
- static string last_comm1_ident = "";
- static string last_comm2_ident = "";
static string last_nav1_ident = "";
static string last_nav2_ident = "";
static string last_adf_ident = "";
static bool last_nav1_vor = false;
static bool last_nav2_vor = false;
-
- ////////////////////////////////////////////////////////////////////////
- // Comm1.
- ////////////////////////////////////////////////////////////////////////
-
- if ( current_atislist->query( lon, lat, elev, comm1_freq, &atis ) ) {
- //cout << "atis found in radiostack search !!!!" << endl;
- comm1_ident = atis.get_ident();
- comm1_valid = true;
- if ( last_comm1_ident != comm1_ident ) {
- //nav1_trans_ident = ils.get_trans_ident();
- last_comm1_ident = comm1_ident;
- comm1_elev = atis.get_elev();
- comm1_range = FG_ATIS_DEFAULT_RANGE;
- comm1_effective_range = comm1_range;
- comm1_x = atis.get_x();
- comm1_y = atis.get_y();
- comm1_z = atis.get_z();
- //cout << "Found a new atis station in range" << endl;
- //cout << " id = " << atis.get_ident() << endl;
- }
- } else {
- comm1_valid = false;
- comm1_ident = "";
- //comm1_trans_ident = "";
- last_comm1_ident = "";
- // cout << "not picking up atis" << endl;
- }
-
////////////////////////////////////////////////////////////////////////
// Nav1.
////////////////////////////////////////////////////////////////////////
return false;
}
}
-
#include <Navaids/ilslist.hxx>
#include <Navaids/navlist.hxx>
-#include <ATC/atislist.hxx>
#include <Sound/beacon.hxx>
#include <Sound/morse.hxx>
bool need_update;
- FGATIS atis;
-
string comm1_ident;
bool comm1_valid;
bool comm1_inrange;
#include <Airports/runways.hxx>
#include <Airports/simple.hxx>
#include <ATC/ATCdisplay.hxx>
+#include <ATC/ATCmgr.hxx>
+#include <ATC/atislist.hxx>
#include <Autopilot/auto_gui.hxx>
#include <Autopilot/newauto.hxx>
#include <Cockpit/cockpit.hxx>
// Initialize ATC list management and query systems
////////////////////////////////////////////////////////////////////
- //DCL
SG_LOG(SG_GENERAL, SG_INFO, " ATIS");
current_atislist = new FGATISList;
SGPath p_atis( globals->get_fg_root() );
// Initialise ATC display system
////////////////////////////////////////////////////////////////////
- //DCL
SG_LOG(SG_GENERAL, SG_INFO, " ATC Display");
- current_atcdisplay = new FGATCDisplay;
- current_atcdisplay->init();
+ globals->set_ATC_display(new FGATCDisplay);
+ globals->get_ATC_display()->init();
+
+ ////////////////////////////////////////////////////////////////////
+ // Initialise the ATC Manager
+ ////////////////////////////////////////////////////////////////////
+
+ SG_LOG(SG_GENERAL, SG_INFO, " ATC Manager");
+ globals->set_ATC_mgr(new FGATCMgr);
+ globals->get_ATC_mgr()->init();
////////////////////////////////////////////////////////////////////
// Initialize the built-in commands.
class FGFX;
class FGViewMgr;
class FGViewer;
+class FGATCMgr;
+class FGATCDisplay;
class FGGlobals {
// environment information
FGEnvironmentMgr * environment_mgr;
+ // ATC manager
+ FGATCMgr *ATC_mgr;
+
+ // ATC Renderer
+ FGATCDisplay *ATC_display;
+
// control input state
FGControls *controls;
const FGEnvironment * get_environment(double lat, double lon,
double alt) const;
+ inline FGATCMgr *get_ATC_mgr() const { return ATC_mgr; }
+ inline void set_ATC_mgr( FGATCMgr *a ) {ATC_mgr = a; }
+
+ inline FGATCDisplay *get_ATC_display() const { return ATC_display; }
+ inline void set_ATC_display( FGATCDisplay *d ) {ATC_display = d; }
+
inline FGSoundMgr *get_soundmgr() const { return soundmgr; }
inline void set_soundmgr( FGSoundMgr *sm ) { soundmgr = sm; }
#endif // _GLOBALS_HXX
-
-
#include <Aircraft/aircraft.hxx>
+#include <ATC/ATCmgr.hxx>
#include <ATC/ATCdisplay.hxx>
#include <Autopilot/newauto.hxx>
// Use the hud_and_panel ssgSimpleState for rendering the ATC output
// This only works properly if called before the panel call
- current_atcdisplay->update();
+ globals->get_ATC_display()->update(1); // FIXME: use real dt
// update the panel subsystem
if ( current_panel != NULL ) {
++frames;
#endif
+ // Run ATC subsystem
+ globals->get_ATC_mgr()->update(1); // FIXME: use real dt
+
// Run flight model
// Calculate model iterations needed for next frame