From 348ac42c90e1d3534453be607c1ab23189f932c3 Mon Sep 17 00:00:00 2001 From: curt Date: Fri, 1 Mar 2002 17:39:52 +0000 Subject: [PATCH] Attached is a reasonably large patch to add a proper ATC subsystem to Flightgear. No more functionality is implemented than at present (apart from an ATIS bug-fix - station wouldn't change if the radio was switched directly from one station to another) but it is much neater than the current hack and should be easily extendable. Some cruft is still probably left over in radiostack.[ch]xx such as the bindings to the comm frequencies but I'll leave removing those until I'm sure they're not needed there. --- src/ATC/ATC.cxx | 42 +++++++++++ src/ATC/ATC.hxx | 59 ++++++++++++++++ src/ATC/ATCdisplay.cxx | 18 ++--- src/ATC/ATCdisplay.hxx | 17 +++-- src/ATC/ATCmgr.cxx | 139 +++++++++++++++++++++++++++++++++++++ src/ATC/ATCmgr.hxx | 115 ++++++++++++++++++++++++++++++ src/ATC/Makefile.am | 7 +- src/ATC/atis.cxx | 102 +++++++++++++++------------ src/ATC/atis.hxx | 41 +++++++++-- src/ATC/atislist.cxx | 3 +- src/ATC/atislist.hxx | 3 +- src/Cockpit/radiostack.cxx | 79 --------------------- src/Cockpit/radiostack.hxx | 3 - src/Main/fg_init.cxx | 16 +++-- src/Main/globals.hxx | 16 ++++- src/Main/main.cxx | 6 +- 16 files changed, 507 insertions(+), 159 deletions(-) create mode 100644 src/ATC/ATC.cxx create mode 100644 src/ATC/ATC.hxx create mode 100644 src/ATC/ATCmgr.cxx create mode 100644 src/ATC/ATCmgr.hxx diff --git a/src/ATC/ATC.cxx b/src/ATC/ATC.cxx new file mode 100644 index 000000000..519ff06b7 --- /dev/null +++ b/src/ATC/ATC.cxx @@ -0,0 +1,42 @@ +// 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 diff --git a/src/ATC/ATC.hxx b/src/ATC/ATC.hxx new file mode 100644 index 000000000..5a8b8397d --- /dev/null +++ b/src/ATC/ATC.hxx @@ -0,0 +1,59 @@ +// 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 diff --git a/src/ATC/ATCdisplay.cxx b/src/ATC/ATCdisplay.cxx index 26e66c685..cf00f911c 100644 --- a/src/ATC/ATCdisplay.cxx +++ b/src/ATC/ATCdisplay.cxx @@ -31,11 +31,8 @@ #include "ATCdisplay.hxx" -FGATCDisplay *current_atcdisplay; - - // Constructor -FGATCDisplay::FGATCDisplay( void ) { +FGATCDisplay::FGATCDisplay() { rep_msg = false; change_msg_flag = false; dsp_offset1 = 0; @@ -44,18 +41,23 @@ FGATCDisplay::FGATCDisplay( void ) { // 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 = ""; diff --git a/src/ATC/ATCdisplay.hxx b/src/ATC/ATCdisplay.hxx index 5667a9d16..86ffca109 100644 --- a/src/ATC/ATCdisplay.hxx +++ b/src/ATC/ATCdisplay.hxx @@ -1,6 +1,6 @@ // 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. // @@ -27,6 +27,8 @@ # include #endif +#include
+ #include #include @@ -43,7 +45,8 @@ struct atcMessage { typedef vector 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 @@ -60,13 +63,17 @@ public: 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 @@ -79,6 +86,4 @@ public: void CancelRepeatingMessage(); }; -extern FGATCDisplay *current_atcdisplay; - #endif // _FG_ATC_DISPLAY_HXX diff --git a/src/ATC/ATCmgr.cxx b/src/ATC/ATCmgr.cxx new file mode 100644 index 000000000..858de8b13 --- /dev/null +++ b/src/ATC/ATCmgr.cxx @@ -0,0 +1,139 @@ +// 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