]> git.mxchange.org Git - flightgear.git/blob - src/ATCDCL/transmission.hxx
Remove confusing default (missing) path from 2D panel code.
[flightgear.git] / src / ATCDCL / transmission.hxx
1 // transmission.hxx -- Transmission class
2 //
3 // Written by Alexander Kappes, started March 2002.
4 // Based on nav.hxx by Curtis Olson, started April 2000.
5 //
6 // Copyright (C) 2001  David C. Luff - david.luff@nottingham.ac.uk
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21
22
23 #ifndef _FG_TRANSMISSION_HXX
24 #define _FG_TRANSMISSION_HXX
25
26 #include <stdio.h>
27
28 #include <simgear/compiler.h>
29 #include <simgear/math/sg_geodesy.hxx>
30 #include <simgear/misc/sgstream.hxx>
31 #include <simgear/magvar/magvar.hxx>
32 #include <simgear/timing/sg_time.hxx>
33 #include <simgear/bucket/newbucket.hxx>
34
35 #include <Main/fg_props.hxx>
36
37 #  include <istream>
38
39 #include "ATC.hxx"
40
41 struct TransCode {
42   int c1;
43   int c2;
44   int c3;
45 };
46
47 // TransPar - a representation of the logic of a parsed speech transmission
48 struct TransPar {
49   std::string  station;
50   std::string  callsign;
51   std::string  airport;
52   std::string  intention;      // landing, crossing
53   std::string  intid;          // (airport) ID for intention
54   bool    request;        // is the transmission a request or an answer?
55   int     tdir;           // turning direction: 1=left, 2=right
56   double  heading;
57   int     VDir;           // vertical direction: 1=descent, 2=maintain, 3=climb
58   double  alt;
59   double  miles;
60   std::string  runway;
61   double  freq;
62   double  time;
63 };
64
65 // FGTransmission - a class to encapsulate a speech transmission
66 class FGTransmission {
67
68   //int       StationType;    // Type of ATC station: 1 Approach
69   atc_type  StationType;
70   TransCode Code;           // DCL - no idea what this is.
71   std::string    TransText;      // The text of the spoken transmission
72   std::string    MenuText;       // An abbreviated version of the text for the menu entry
73
74 public:
75
76   FGTransmission(void);
77   ~FGTransmission(void);
78
79   void Init();
80
81   inline atc_type  get_station()   const { return StationType; }
82   inline const TransCode& get_code()      { return Code; }
83   inline const std::string&    get_transtext() { return TransText; }
84   inline const std::string&    get_menutext()  { return MenuText; }
85
86   // Return the parsed logic of the transmission  
87   TransPar Parse();
88
89 private:
90
91   friend std::istream& operator>> ( std::istream&, FGTransmission& );
92
93 };
94
95
96 inline std::istream&
97 operator >> ( std::istream& in, FGTransmission& a ) {
98         char ch;
99         int tmp;
100         
101         static bool first_time = true;
102         static double julian_date = 0;
103         static const double MJD0    = 2415020.0;
104         if ( first_time ) {
105                 julian_date = sgTimeCurrentMJD(0, 0) + MJD0;
106                 first_time = false;
107         }
108         // Ugly hack alert - eventually we'll use xml format for the transmissions file
109         in >> tmp;
110         if(tmp == 1) {
111                 a.StationType = APPROACH;
112         } else {
113                 a.StationType = INVALID;
114         }
115         in >> a.Code.c1;
116         in >> a.Code.c2;
117         in >> a.Code.c3;
118         a.TransText = "";
119         in >> ch;
120         if ( ch != '"' ) a.TransText += ch;
121         while(1) {
122                 //in >> noskipws
123                 in.unsetf(ios::skipws);
124                 in >> ch;
125                 if ( ch != '"' ) a.TransText += ch;
126                 if((ch == '"') || (ch == 0x0A)) {
127                         break;
128                 }   // we shouldn't need the 0x0A but it makes a nice safely in case someone leaves off the "
129         }
130         in.setf(ios::skipws);
131         
132         a.MenuText = "";
133         in >> ch;
134         if ( ch != '"' ) a.MenuText += ch;
135         while(1) {
136                 //in >> noskipws
137                 in.unsetf(ios::skipws);
138                 in >> ch;
139                 if ( ch != '"' ) a.MenuText += ch;
140                 if((ch == '"') || (ch == 0x0A)) {
141                         break;
142                 }   // we shouldn't need the 0x0A but it makes a nice safely in case someone leaves off the "
143         }
144         in.setf(ios::skipws);
145         
146         //cout << "Code = " << a.Code << "   Transmission text = " << a.TransText 
147         //     << "   Menu text = " << a.MenuText << endl;
148         
149         return in >> skipeol;
150 }
151
152
153 #endif // _FG_TRANSMISSION_HXX