2002-03-01 17:39:52 +00:00
|
|
|
// 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>
|
2002-12-04 20:07:12 +00:00
|
|
|
#include <Sound/soundmgr.hxx>
|
2002-12-17 17:19:14 +00:00
|
|
|
#include <GUI/gui.h>
|
2002-03-01 17:39:52 +00:00
|
|
|
|
2002-04-03 23:54:44 +00:00
|
|
|
#include <string>
|
2002-03-01 17:39:52 +00:00
|
|
|
#include <list>
|
2002-04-03 23:54:44 +00:00
|
|
|
#include <map>
|
2002-03-01 17:39:52 +00:00
|
|
|
|
|
|
|
#include "atis.hxx"
|
2002-04-03 23:54:44 +00:00
|
|
|
#include "tower.hxx"
|
|
|
|
#include "approach.hxx"
|
2002-12-04 20:07:12 +00:00
|
|
|
#include "ground.hxx"
|
2002-03-01 17:39:52 +00:00
|
|
|
#include "ATC.hxx"
|
2002-12-04 20:07:12 +00:00
|
|
|
#include "ATCVoice.hxx"
|
2002-03-01 17:39:52 +00:00
|
|
|
|
2002-04-03 23:54:44 +00:00
|
|
|
SG_USING_STD(string);
|
2002-03-01 17:39:52 +00:00
|
|
|
SG_USING_STD(list);
|
2002-04-03 23:54:44 +00:00
|
|
|
SG_USING_STD(map);
|
|
|
|
|
|
|
|
const int max_app = 20;
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
// 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!!
|
|
|
|
struct AirportATC {
|
|
|
|
float lon;
|
|
|
|
float lat;
|
|
|
|
float elev;
|
|
|
|
float atis_freq;
|
|
|
|
bool atis_active;
|
|
|
|
float tower_freq;
|
|
|
|
bool tower_active;
|
|
|
|
float ground_freq;
|
|
|
|
bool ground_active;
|
|
|
|
//float approach_freq;
|
|
|
|
//bool approach_active;
|
|
|
|
//float departure_freq;
|
|
|
|
//bool departure_active;
|
|
|
|
|
|
|
|
// 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
|
|
|
|
};
|
2002-03-01 17:39:52 +00:00
|
|
|
|
|
|
|
class FGATCMgr : public FGSubsystem
|
|
|
|
{
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2002-04-03 23:54:44 +00:00
|
|
|
// 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;
|
|
|
|
typedef airport_atc_map_type::const_iterator airport_atc_map_const_iterator;
|
|
|
|
|
|
|
|
airport_atc_map_type airport_atc_map;
|
|
|
|
airport_atc_map_iterator airport_atc_map_itr;
|
|
|
|
|
2002-03-01 17:39:52 +00:00
|
|
|
// 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;
|
|
|
|
|
2002-04-03 23:54:44 +00:00
|
|
|
// Type of ATC control that the user's radios are tuned to.
|
2002-03-01 17:39:52 +00:00
|
|
|
atc_type comm1_type;
|
|
|
|
atc_type comm2_type;
|
2002-12-17 17:19:14 +00:00
|
|
|
|
|
|
|
// Pointer to the ATC station that the user is currently tuned into.
|
2003-01-07 13:11:00 +00:00
|
|
|
FGATC* comm1_atc_ptr;
|
|
|
|
FGATC* comm2_atc_ptr;
|
2002-03-01 17:39:52 +00:00
|
|
|
|
|
|
|
double comm1_freq;
|
|
|
|
double comm2_freq;
|
|
|
|
|
|
|
|
// Pointers to users current communication frequencies.
|
2002-12-04 20:07:12 +00:00
|
|
|
SGPropertyNode* comm1_node;
|
|
|
|
SGPropertyNode* comm2_node;
|
2002-03-01 17:39:52 +00:00
|
|
|
|
|
|
|
// Pointers to current users position
|
2002-12-04 20:07:12 +00:00
|
|
|
SGPropertyNode* lon_node;
|
|
|
|
SGPropertyNode* lat_node;
|
|
|
|
SGPropertyNode* elev_node;
|
2002-03-01 17:39:52 +00:00
|
|
|
|
2003-01-07 13:11:00 +00:00
|
|
|
// Position of the ATC that the comm radios are tuned to in order to decide
|
|
|
|
// whether transmission will be received.
|
2002-03-01 17:39:52 +00:00
|
|
|
double comm1_x, comm1_y, comm1_z, comm1_elev;
|
2003-01-07 13:11:00 +00:00
|
|
|
double comm2_x, comm2_y, comm2_z, comm2_elev;
|
|
|
|
|
2002-03-01 17:39:52 +00:00
|
|
|
double comm1_range, comm1_effective_range;
|
|
|
|
bool comm1_valid;
|
2002-04-03 23:54:44 +00:00
|
|
|
bool comm1_atis_valid;
|
|
|
|
bool comm1_tower_valid;
|
|
|
|
bool comm1_approach_valid;
|
2002-03-01 17:39:52 +00:00
|
|
|
const char* comm1_ident;
|
2002-04-03 23:54:44 +00:00
|
|
|
const char* comm1_atis_ident;
|
|
|
|
const char* comm1_tower_ident;
|
|
|
|
const char* comm1_approach_ident;
|
2002-03-01 17:39:52 +00:00
|
|
|
const char* last_comm1_ident;
|
2002-04-03 23:54:44 +00:00
|
|
|
const char* last_comm1_atis_ident;
|
|
|
|
const char* last_comm1_tower_ident;
|
|
|
|
const char* last_comm1_approach_ident;
|
2003-01-07 13:11:00 +00:00
|
|
|
|
2002-03-01 17:39:52 +00:00
|
|
|
double comm2_range, comm2_effective_range;
|
|
|
|
bool comm2_valid;
|
2003-01-07 13:11:00 +00:00
|
|
|
bool comm2_atis_valid;
|
|
|
|
bool comm2_tower_valid;
|
|
|
|
bool comm2_approach_valid;
|
2002-03-01 17:39:52 +00:00
|
|
|
const char* comm2_ident;
|
2003-01-07 13:11:00 +00:00
|
|
|
const char* comm2_atis_ident;
|
|
|
|
const char* comm2_tower_ident;
|
|
|
|
const char* comm2_approach_ident;
|
2002-03-01 17:39:52 +00:00
|
|
|
const char* last_comm2_ident;
|
2003-01-07 13:11:00 +00:00
|
|
|
const char* last_comm2_atis_ident;
|
|
|
|
const char* last_comm2_tower_ident;
|
|
|
|
const char* last_comm2_approach_ident;
|
|
|
|
|
|
|
|
const char* approach_ident;
|
|
|
|
bool last_in_range;
|
2002-03-01 17:39:52 +00:00
|
|
|
|
|
|
|
FGATIS atis;
|
|
|
|
//FGGround ground;
|
2002-04-03 23:54:44 +00:00
|
|
|
FGTower tower;
|
|
|
|
FGApproach approaches[max_app];
|
|
|
|
FGApproach approach;
|
2002-03-01 17:39:52 +00:00
|
|
|
//FGDeparture departure;
|
|
|
|
|
2002-12-04 20:07:12 +00:00
|
|
|
// Rendering 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;
|
|
|
|
#endif
|
|
|
|
|
2002-03-01 17:39:52 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
FGATCMgr();
|
|
|
|
~FGATCMgr();
|
|
|
|
|
|
|
|
void init();
|
|
|
|
|
|
|
|
void bind();
|
|
|
|
|
|
|
|
void unbind();
|
|
|
|
|
2002-05-11 16:28:50 +00:00
|
|
|
void update(double dt);
|
2002-03-01 17:39:52 +00:00
|
|
|
|
2002-04-03 23:54:44 +00:00
|
|
|
// Returns true if the airport is found in the map
|
|
|
|
bool GetAirportATCDetails(string icao, AirportATC* a);
|
|
|
|
|
|
|
|
// Return a pointer to a given sort of ATC at a given airport and activate if necessary
|
|
|
|
FGATC* GetATCPointer(string icao, atc_type type);
|
2002-12-04 20:07:12 +00:00
|
|
|
|
|
|
|
// Render a transmission
|
|
|
|
// Outputs the transmission either on screen or as audio depending on user preference
|
2003-01-07 13:11:00 +00:00
|
|
|
// The refname is a string to identify this sample to the sound manager
|
2002-12-04 20:07:12 +00:00
|
|
|
// The repeating flag indicates whether the message should be repeated continuously or played once.
|
2003-01-07 13:11:00 +00:00
|
|
|
void Render(string msg, string refname, bool repeating);
|
2002-12-04 20:07:12 +00:00
|
|
|
|
|
|
|
// Cease rendering a transmission.
|
2003-01-07 13:11:00 +00:00
|
|
|
// Requires the sound manager refname if audio, else "".
|
|
|
|
void NoRender(string refname);
|
2002-12-04 20:07:12 +00:00
|
|
|
|
2002-12-17 17:19:14 +00:00
|
|
|
// Display a dialog box with options relevant to the currently tuned ATC service.
|
|
|
|
void doStandardDialog();
|
|
|
|
|
2003-01-07 13:11:00 +00:00
|
|
|
atc_type GetComm1ATCType() { return(comm1_type); }
|
|
|
|
FGATC* GetComm1ATCPointer() { return(comm1_atc_ptr); }
|
|
|
|
atc_type GetComm2ATCType() { return(comm2_type); }
|
|
|
|
FGATC* GetComm2ATCPointer() { return(comm2_atc_ptr); }
|
2002-12-17 17:19:14 +00:00
|
|
|
|
2002-03-01 17:39:52 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
// Remove a class from the atc_list and delete it from memory
|
|
|
|
void RemoveFromList(const char* id, atc_type tp);
|
|
|
|
|
2002-10-02 15:27:49 +00:00
|
|
|
// Return a pointer to a class in the list (external interface to this is through GetATCPointer)
|
2003-01-03 15:01:16 +00:00
|
|
|
FGATC* FindInList(const char* id, atc_type tp);
|
2002-10-02 15:27:49 +00:00
|
|
|
|
2003-01-07 13:11:00 +00:00
|
|
|
// Search the specified channel for stations on the same frequency and in range.
|
|
|
|
void Search(int chan);
|
2002-03-01 17:39:52 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2002-03-03 22:47:06 +00:00
|
|
|
#endif // _FG_ATCMGR_HXX
|