]> git.mxchange.org Git - flightgear.git/blob - src/ATC/transmission.hxx
Moved some of the low level scene graph construction code over to simgear.
[flightgear.git] / src / ATC / 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., 675 Mass Ave, Cambridge, MA 02139, 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 #ifdef SG_HAVE_STD_INCLUDES
38 #  include <istream>
39 #include <iomanip>
40 #elif defined( SG_HAVE_NATIVE_SGI_COMPILERS )
41 #  include <iostream.h>
42 #elif defined( __BORLANDC__ )
43 #  include <iostream>
44 #else
45 #  include <istream.h>
46 #include <iomanip.h>
47 #endif
48
49 #if ! defined( SG_HAVE_NATIVE_SGI_COMPILERS )
50 SG_USING_STD(istream);
51 #endif
52
53 SG_USING_STD(string);
54
55 struct TransCode {
56   int c1;
57   int c2;
58   int c3;
59 };
60
61 // TransPar - a representation of the logic of a parsed speech transmission
62 struct TransPar {
63   string  station;
64   string  callsign;
65   string  airport;
66   string  intention;      // landing, crossing
67   string  intid;          // (airport) ID for intention
68   bool    request;        // is the transmission a request or an answer?
69   int     tdir;           // turning direction: 1=left, 2=right
70   double  heading;
71   int     VDir;           // vertical direction: 1=descent, 2=maintain, 3=climb
72   double  alt;
73   double  miles;
74   string  runway;
75   double  freq;
76   double  time;
77 };
78
79 // FGTransmission - a class to encapsulate a speech transmission
80 class FGTransmission {
81
82   int       StationType;             // Type of ATC station: 1 Approach
83   TransCode Code;
84   string    TransText;
85   string    MenuText;
86
87 public:
88
89   FGTransmission(void);
90   ~FGTransmission(void);
91
92   void Init();
93
94   inline int       get_station()   const { return StationType; }
95   inline TransCode get_code()     { return Code; }
96   inline string    get_transtext() { return TransText; }
97   inline string    get_menutext()  { return MenuText; }
98
99   // Return the parsed logic of the transmission  
100   TransPar Parse();
101
102 private:
103
104   friend istream& operator>> ( istream&, FGTransmission& );
105
106 };
107
108
109 inline istream&
110 operator >> ( istream& in, FGTransmission& a ) {
111         char ch;
112         
113         static bool first_time = true;
114         static double julian_date = 0;
115         static const double MJD0    = 2415020.0;
116         if ( first_time ) {
117                 julian_date = sgTimeCurrentMJD(0, 0) + MJD0;
118                 first_time = false;
119         }
120         in >> a.StationType;
121         in >> a.Code.c1;
122         in >> a.Code.c2;
123         in >> a.Code.c3;
124         a.TransText = "";
125         in >> ch;
126         if ( ch != '"' ) a.TransText += ch;
127         while(1) {
128                 //in >> noskipws
129                 in.unsetf(ios::skipws);
130                 in >> ch;
131                 if ( ch != '"' ) a.TransText += ch;
132                 if((ch == '"') || (ch == 0x0A)) {
133                         break;
134                 }   // we shouldn't need the 0x0A but it makes a nice safely in case someone leaves off the "
135         }
136         in.setf(ios::skipws);
137         
138         a.MenuText = "";
139         in >> ch;
140         if ( ch != '"' ) a.MenuText += ch;
141         while(1) {
142                 //in >> noskipws
143                 in.unsetf(ios::skipws);
144                 in >> ch;
145                 if ( ch != '"' ) a.MenuText += ch;
146                 if((ch == '"') || (ch == 0x0A)) {
147                         break;
148                 }   // we shouldn't need the 0x0A but it makes a nice safely in case someone leaves off the "
149         }
150         in.setf(ios::skipws);
151         
152         //cout << "Code = " << a.Code << "   Transmission text = " << a.TransText 
153         //     << "   Menu text = " << a.MenuText << endl;
154         
155         return in >> skipeol;
156 }
157
158
159 #endif // _FG_TRANSMISSION_HXX