]> git.mxchange.org Git - flightgear.git/blob - src/ATCDCL/transmission.cxx
Remove confusing default (missing) path from 2D panel code.
[flightgear.git] / src / ATCDCL / 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21
22 #ifdef HAVE_CONFIG_H
23 #  include <config.h>
24 #endif
25
26 #include "transmission.hxx"
27
28 #include <cstring>
29
30 #include <simgear/debug/logstream.hxx>
31 #include <simgear/misc/sg_path.hxx>
32
33
34 //Constructor
35 FGTransmission::FGTransmission(){
36 }
37
38 //Destructor
39 FGTransmission::~FGTransmission(){
40 }
41
42 void FGTransmission::Init() {
43 }
44
45 // ============================================================================
46 // extract parameters from transmission
47 // ============================================================================
48 TransPar FGTransmission::Parse() {
49   TransPar   tpar;
50   string     tokens[20];
51   int        msglen,toklen;
52   //char       dum;
53   int        i,j,k;
54   const char *capl = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
55
56   msglen = strlen( TransText.c_str() );
57
58   int tkn  = 0;
59   for ( i=0; i < msglen; ++i ) {
60     if ( TransText.c_str()[i] != ' ' ) {
61       if ( TransText.c_str()[i] != ',' ) tokens[tkn] += TransText.c_str()[i];
62     } else if ( !tokens[tkn].empty() ) {
63       if ( tkn <= 20 ) {
64         tkn += 1;
65       } else {
66         SG_LOG(SG_ATC, SG_WARN,"Too many tokens");
67       }
68     }
69   }
70
71   for ( i=0; i<20; ++i) {
72     
73     if ( tokens[i] == "request" ) {
74       tpar.request = true;
75     } else if ( tokens[i] == "approach"  ) { 
76       tpar.station = "approach";
77       tpar.airport = tokens[i-1];
78     } else if ( tokens[i] == "landing"  ) { 
79       tpar.intention = "landing";
80       for ( j=i+1; j<=i+2; ++j ) {
81         if ( !tokens[j].empty() ) {
82           toklen = strlen( tokens[j].c_str() );
83           bool aid = true;
84           for ( k=0; k<toklen; ++k )
85             if ( ! strpbrk( &tokens[j].c_str()[k], capl )) {
86               aid = false;
87               break;
88             }
89           if ( aid ) tpar.intid = tokens[j];
90         }
91       }
92     } else if ( tokens[i] == "Player"  ) { 
93       tpar.callsign = tokens[i];
94     }
95   }
96
97   //cout << tpar.airport << endl;
98   //cout << tpar.request << endl;
99   //cout << tpar.intention << endl;
100   //cout << tpar.intid << endl;
101
102   return tpar;
103 }