]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATC/transmission.hxx
Alex Romosan:
[flightgear.git] / src / ATC / transmission.hxx
index 2b46becdd473a5f844cd200e711eb84232dd74c8..fafc885b79e5f34f69ea429a18c237763f2933e3 100644 (file)
-// transmission.hxx -- Transmission class\r
-//\r
-// Written by Alexander Kappes, started March 2002.\r
-// Based on nav.hxx by Curtis Olson, started April 2000.\r
-//\r
-// Copyright (C) 2001  David C. Luff - david.luff@nottingham.ac.uk\r
-//\r
-// This program is free software; you can redistribute it and/or\r
-// modify it under the terms of the GNU General Public License as\r
-// published by the Free Software Foundation; either version 2 of the\r
-// License, or (at your option) any later version.\r
-//\r
-// This program is distributed in the hope that it will be useful, but\r
-// WITHOUT ANY WARRANTY; without even the implied warranty of\r
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
-// General Public License for more details.\r
-//\r
-// You should have received a copy of the GNU General Public License\r
-// along with this program; if not, write to the Free Software\r
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
-\r
-\r
-#ifndef _FG_TRANSMISSION_HXX\r
-#define _FG_TRANSMISSION_HXX\r
-\r
-#include <stdio.h>\r
-\r
-#include <simgear/compiler.h>\r
-#include <simgear/math/sg_geodesy.hxx>\r
-#include <simgear/misc/sgstream.hxx>\r
-#include <simgear/magvar/magvar.hxx>\r
-#include <simgear/timing/sg_time.hxx>\r
-#include <simgear/bucket/newbucket.hxx>\r
-\r
-#include <Main/fg_props.hxx>\r
-\r
-#ifdef SG_HAVE_STD_INCLUDES\r
-#  include <istream>\r
-#include <iomanip>\r
-#elif defined( SG_HAVE_NATIVE_SGI_COMPILERS )\r
-#  include <iostream.h>\r
-#elif defined( __BORLANDC__ )\r
-#  include <iostream>\r
-#else\r
-#  include <istream.h>\r
-#include <iomanip.h>\r
-#endif\r
-\r
-#if ! defined( SG_HAVE_NATIVE_SGI_COMPILERS )\r
-SG_USING_STD(istream);\r
-#endif\r
-\r
-SG_USING_STD(string);\r
-\r
-struct TransCode {\r
-  int c1;\r
-  int c2;\r
-  int c3;\r
-};\r
-\r
-// TransPar - a representation of the logic of a parsed speech transmission\r
-struct TransPar {\r
-  string  station;\r
-  string  callsign;\r
-  string  airport;\r
-  string  intention;      // landing, crossing\r
-  string  intid;          // (airport) ID for intention\r
-  bool    request;        // is the transmission a request or an answer?\r
-  int     tdir;           // turning direction: 1=left, 2=right\r
-  double  heading;\r
-  int     VDir;           // vertical direction: 1=descent, 2=maintain, 3=climb\r
-  double  alt;\r
-  double  miles;\r
-  string  runway;\r
-  double  freq;\r
-  double  time;\r
-};\r
-\r
-// FGTransmission - a class to encapsulate a speech transmission\r
-class FGTransmission {\r
-\r
-  int       StationType;             // Type of ATC station: 1 Approach\r
-  TransCode Code;\r
-  string    TransText;\r
-  string    MenuText;\r
-\r
-public:\r
-\r
-  FGTransmission(void);\r
-  ~FGTransmission(void);\r
-\r
-  void Init();\r
-\r
-  inline int       get_station()   const { return StationType; }\r
-  inline TransCode get_code()     { return Code; }\r
-  inline string    get_transtext() { return TransText; }\r
-  inline string    get_menutext()  { return MenuText; }\r
-\r
-  // Return the parsed logic of the transmission  \r
-  TransPar Parse();\r
-\r
-private:\r
-\r
-  friend istream& operator>> ( istream&, FGTransmission& );\r
-\r
-};\r
-\r
-\r
-inline istream&\r
-operator >> ( istream& in, FGTransmission& a ) {\r
-       char ch;\r
-       \r
-       static bool first_time = true;\r
-       static double julian_date = 0;\r
-       static const double MJD0    = 2415020.0;\r
-       if ( first_time ) {\r
-               julian_date = sgTimeCurrentMJD(0, 0) + MJD0;\r
-               first_time = false;\r
-       }\r
-       in >> a.StationType;\r
-       in >> a.Code.c1;\r
-       in >> a.Code.c2;\r
-       in >> a.Code.c3;\r
-       a.TransText = "";\r
-       in >> ch;\r
-       if ( ch != '"' ) a.TransText += ch;\r
-       while(1) {\r
-               //in >> noskipws\r
-               in.unsetf(ios::skipws);\r
-               in >> ch;\r
-               if ( ch != '"' ) a.TransText += ch;\r
-               if((ch == '"') || (ch == 0x0A)) {\r
-                       break;\r
-               }   // we shouldn't need the 0x0A but it makes a nice safely in case someone leaves off the "\r
-       }\r
-       in.setf(ios::skipws);\r
-       \r
-       a.MenuText = "";\r
-       in >> ch;\r
-       if ( ch != '"' ) a.MenuText += ch;\r
-       while(1) {\r
-               //in >> noskipws\r
-               in.unsetf(ios::skipws);\r
-               in >> ch;\r
-               if ( ch != '"' ) a.MenuText += ch;\r
-               if((ch == '"') || (ch == 0x0A)) {\r
-                       break;\r
-               }   // we shouldn't need the 0x0A but it makes a nice safely in case someone leaves off the "\r
-       }\r
-       in.setf(ios::skipws);\r
-       \r
-       //cout << "Code = " << a.Code << "   Transmission text = " << a.TransText \r
-       //     << "   Menu text = " << a.MenuText << endl;\r
-       \r
-       return in >> skipeol;\r
-}\r
-\r
-\r
-#endif // _FG_TRANSMISSION_HXX\r
+// transmission.hxx -- Transmission class
+//
+// Written by Alexander Kappes, started March 2002.
+// Based on nav.hxx by Curtis Olson, started April 2000.
+//
+// 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
+// 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_TRANSMISSION_HXX
+#define _FG_TRANSMISSION_HXX
+
+#include <stdio.h>
+
+#include <simgear/compiler.h>
+#include <simgear/math/sg_geodesy.hxx>
+#include <simgear/misc/sgstream.hxx>
+#include <simgear/magvar/magvar.hxx>
+#include <simgear/timing/sg_time.hxx>
+#include <simgear/bucket/newbucket.hxx>
+
+#include <Main/fg_props.hxx>
+
+#ifdef SG_HAVE_STD_INCLUDES
+#  include <istream>
+#include <iomanip>
+#elif defined( SG_HAVE_NATIVE_SGI_COMPILERS )
+#  include <iostream.h>
+#elif defined( __BORLANDC__ )
+#  include <iostream>
+#else
+#  include <istream.h>
+#include <iomanip.h>
+#endif
+
+#include "ATC.hxx"
+
+#if ! defined( SG_HAVE_NATIVE_SGI_COMPILERS )
+SG_USING_STD(istream);
+#endif
+
+SG_USING_STD(string);
+
+struct TransCode {
+  int c1;
+  int c2;
+  int c3;
+};
+
+// TransPar - a representation of the logic of a parsed speech transmission
+struct TransPar {
+  string  station;
+  string  callsign;
+  string  airport;
+  string  intention;      // landing, crossing
+  string  intid;          // (airport) ID for intention
+  bool    request;        // is the transmission a request or an answer?
+  int     tdir;           // turning direction: 1=left, 2=right
+  double  heading;
+  int     VDir;           // vertical direction: 1=descent, 2=maintain, 3=climb
+  double  alt;
+  double  miles;
+  string  runway;
+  double  freq;
+  double  time;
+};
+
+// FGTransmission - a class to encapsulate a speech transmission
+class FGTransmission {
+
+  //int       StationType;    // Type of ATC station: 1 Approach
+  atc_type  StationType;
+  TransCode Code;           // DCL - no idea what this is.
+  string    TransText;      // The text of the spoken transmission
+  string    MenuText;       // An abbreviated version of the text for the menu entry
+
+public:
+
+  FGTransmission(void);
+  ~FGTransmission(void);
+
+  void Init();
+
+  inline atc_type  get_station()   const { return StationType; }
+  inline const TransCode& get_code()      { return Code; }
+  inline const string&    get_transtext() { return TransText; }
+  inline const string&    get_menutext()  { return MenuText; }
+
+  // Return the parsed logic of the transmission  
+  TransPar Parse();
+
+private:
+
+  friend istream& operator>> ( istream&, FGTransmission& );
+
+};
+
+
+inline istream&
+operator >> ( istream& in, FGTransmission& a ) {
+       char ch;
+       int tmp;
+       
+       static bool first_time = true;
+       static double julian_date = 0;
+       static const double MJD0    = 2415020.0;
+       if ( first_time ) {
+               julian_date = sgTimeCurrentMJD(0, 0) + MJD0;
+               first_time = false;
+       }
+       // Ugly hack alert - eventually we'll use xml format for the transmissions file
+       in >> tmp;
+       if(tmp == 1) {
+               a.StationType = APPROACH;
+       } else {
+               a.StationType = INVALID;
+       }
+       in >> a.Code.c1;
+       in >> a.Code.c2;
+       in >> a.Code.c3;
+       a.TransText = "";
+       in >> ch;
+       if ( ch != '"' ) a.TransText += ch;
+       while(1) {
+               //in >> noskipws
+               in.unsetf(ios::skipws);
+               in >> ch;
+               if ( ch != '"' ) a.TransText += ch;
+               if((ch == '"') || (ch == 0x0A)) {
+                       break;
+               }   // we shouldn't need the 0x0A but it makes a nice safely in case someone leaves off the "
+       }
+       in.setf(ios::skipws);
+       
+       a.MenuText = "";
+       in >> ch;
+       if ( ch != '"' ) a.MenuText += ch;
+       while(1) {
+               //in >> noskipws
+               in.unsetf(ios::skipws);
+               in >> ch;
+               if ( ch != '"' ) a.MenuText += ch;
+               if((ch == '"') || (ch == 0x0A)) {
+                       break;
+               }   // we shouldn't need the 0x0A but it makes a nice safely in case someone leaves off the "
+       }
+       in.setf(ios::skipws);
+       
+       //cout << "Code = " << a.Code << "   Transmission text = " << a.TransText 
+       //     << "   Menu text = " << a.MenuText << endl;
+       
+       return in >> skipeol;
+}
+
+
+#endif // _FG_TRANSMISSION_HXX