]> git.mxchange.org Git - flightgear.git/blob - src/ATC/transmission.cxx
Make sure the ATIS reports surface winds at airports above sea-level
[flightgear.git] / src / ATC / transmission.cxx
1 // FGTransmission - a class to provide transmission control at larger airports.
2 //
3 // Written by Alexander Kappes, started March 2002.
4 // Based on ground.cxx by David Luff, started March 2002.
5 //
6 // Copyright (C) 2002  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 #include "transmission.hxx"
23
24 #include <simgear/misc/sg_path.hxx>
25
26
27 //Constructor
28 FGTransmission::FGTransmission(){
29 }
30
31 //Destructor
32 FGTransmission::~FGTransmission(){
33 }
34
35 void FGTransmission::Init() {
36 }
37
38 // ============================================================================
39 // extract parameters from transmission
40 // ============================================================================
41 TransPar FGTransmission::Parse() {
42   TransPar   tpar;
43   string     tokens[20];
44   int        msglen,toklen;
45   //char       dum;
46   int        i,j,k;
47   const char *capl = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
48
49   msglen = strlen( TransText.c_str() );
50
51   int tkn  = 0;
52   for ( i=0; i < msglen; ++i ) {
53     if ( TransText.c_str()[i] != ' ' ) {
54       if ( TransText.c_str()[i] != ',' ) tokens[tkn] += TransText.c_str()[i];
55     } else if ( !tokens[tkn].empty() ) {
56       if ( tkn <= 20 ) {
57         tkn += 1;
58       } else {
59         cout << "Too many tokens" << endl;
60       }
61     }
62   }
63
64   for ( i=0; i<20; ++i) {
65     
66     if ( tokens[i] == "request" ) {
67       tpar.request = true;
68     } else if ( tokens[i] == "approach"  ) { 
69       tpar.station = "approach";
70       tpar.airport = tokens[i-1];
71     } else if ( tokens[i] == "landing"  ) { 
72       tpar.intention = "landing";
73       for ( j=i+1; j<=i+2; ++j ) {
74         if ( !tokens[j].empty() ) {
75           toklen = strlen( tokens[j].c_str() );
76           bool aid = true;
77           for ( k=0; k<toklen; ++k )
78             if ( ! strpbrk( &tokens[j].c_str()[k], capl )) {
79               aid = false;
80               break;
81             }
82           if ( aid ) tpar.intid = tokens[j];
83         }
84       }
85     } else if ( tokens[i] == "Player"  ) { 
86       tpar.callsign = tokens[i];
87     }
88   }
89
90   //cout << tpar.airport << endl;
91   //cout << tpar.request << endl;
92   //cout << tpar.intention << endl;
93   //cout << tpar.intid << endl;
94
95   return tpar;
96 }