#ifndef _FG_ATCMGR_HXX
#define _FG_ATCMGR_HXX
-#include <Main/fgfs.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
+
#include <Main/fg_props.hxx>
-#include <Sound/soundmgr.hxx>
#include <GUI/gui.h>
#include <string>
#include "ground.hxx"
#include "ATC.hxx"
#include "ATCVoice.hxx"
+#include "transmissionlist.hxx"
SG_USING_STD(string);
SG_USING_STD(list);
SG_USING_STD(map);
// Structure for holding details of the ATC frequencies at a given airport, and whether they are in the active list or not.
-// These can then be cross referenced with the [atis][tower][etc]lists which are stored by frequency.
+// These can then be cross referenced with the commlists which are stored by frequency or bucket.
// Non-available services are denoted by a frequency of zero.
-// Eventually the whole ATC data structures may have to be rethought if we turn out to be massive memory hogs!!
+// These structures are only intended to be created for in-use airports, and removed when no longer needed.
struct AirportATC {
+ AirportATC();
+
float lon;
float lat;
float elev;
//bool approach_active;
//float departure_freq;
//bool departure_active;
+
+ // NOTE - the *_active flags determine whether the service is active in atc_list,
+ // *NOT* whether the tower etc is closed or not!!!!
// Flags to ensure the stations don't get wrongly deactivated
bool set_by_AI; // true when the AI manager has activated this station
- bool set_by_comm_search; // true when the comm_search has activated this station
+ unsigned int numAI; // Ref count of the number of AI planes registered
+ bool set_by_comm[2][ATC_NUM_TYPES]; // true when the relevant comm_freq has activated this station and type
};
-class FGATCMgr : public FGSubsystem
+class FGATCMgr : public SGSubsystem
{
private:
+ bool initDone; // Hack - guard against update getting called before init
+
// A map of airport ID vs frequencies and ATC provision
typedef map < string, AirportATC* > airport_atc_map_type;
typedef airport_atc_map_type::iterator airport_atc_map_iterator;
double comm_range[2], comm_effective_range[2];
bool comm_valid[2];
- const char* comm_ident[2];
- const char* last_comm_ident[2];
-
- const char* approach_ident;
+ string comm_ident[2];
+ //string last_comm_ident[2];
+ //string approach_ident;
bool last_in_range;
//FGATIS atis;
FGTower tower;
FGApproach approach;
//FGDeparture departure;
-
- // Rendering related stuff
+
+ // Voice related stuff
bool voice; // Flag - true if we are using voice
- bool playing; // Indicates a message in progress
#ifdef ENABLE_AUDIO_SUPPORT
bool voiceOK; // Flag - true if at least one voice has loaded OK
- FGATCVoice v1;
+ FGATCVoice* v1;
#endif
public:
bool GetAirportATCDetails(string icao, AirportATC* a);
// Return a pointer to a given sort of ATC at a given airport and activate if necessary
+ // Returns NULL if service doesn't exist - calling function should check for this.
FGATC* GetATCPointer(string icao, atc_type type);
- // Render a transmission
- // Outputs the transmission either on screen or as audio depending on user preference
- // The refname is a string to identify this sample to the sound manager
- // The repeating flag indicates whether the message should be repeated continuously or played once.
- void Render(string msg, string refname, bool repeating);
-
- // Cease rendering a transmission.
- // Requires the sound manager refname if audio, else "".
- void NoRender(string refname);
-
- // Display a dialog box with options relevant to the currently tuned ATC service.
- void doStandardDialog();
+ // Return a pointer to an appropriate voice for a given type of ATC
+ // creating the voice if necessary - ie. make sure exactly one copy
+ // of every voice in use exists in memory.
+ //
+ // TODO - in the future this will get more complex and dole out country/airport
+ // specific voices, and possible make sure that the same voice doesn't get used
+ // at different airports in quick succession if a large enough selection are available.
+ FGATCVoice* GetVoicePointer(atc_type type);
atc_type GetComm1ATCType() { return(comm_type[0]); }
FGATC* GetComm1ATCPointer() { return(comm_atc_ptr[0]); }
atc_type GetComm2ATCType() { return(comm_type[1]); }
FGATC* GetComm2ATCPointer() { return(comm_atc_ptr[1]); }
+ // Get the frequency of a given service at a given airport
+ // Returns zero if not found
+ unsigned short int GetFrequency(string ident, atc_type tp);
+
+ // Register the fact that the AI system wants to activate an airport
+ bool AIRegisterAirport(string ident);
+
+ // Register the fact that the comm radio is tuned to an airport
+ bool CommRegisterAirport(string ident, int chan, atc_type tp);
+
private:
// Remove a class from the atc_list and delete it from memory
// *if* no other comm channel or AI plane is using it.
- void CommRemoveFromList(const char* id, atc_type tp, int chan);
+ void CommRemoveFromList(string id, atc_type tp, int chan);
// Remove a class from the atc_list and delete it from memory
// Should be called from the above - not directly!!
- void RemoveFromList(const char* id, atc_type tp);
+ void RemoveFromList(string id, atc_type tp);
// Return a pointer to a class in the list given ICAO code and type
// (external interface to this is through GetATCPointer)
// Return NULL if the given service is not in the list
// - *** THE CALLING FUNCTION MUST CHECK FOR THIS ***
- FGATC* FindInList(const char* id, atc_type tp);
+ FGATC* FindInList(string id, atc_type tp);
// Search the specified channel for stations on the same frequency and in range.
void FreqSearch(int channel);