]> git.mxchange.org Git - flightgear.git/blob - src/ATC/transmission.cxx
First draft of work by Alexander Kappes to add dynamically driven menu entries to...
[flightgear.git] / src / ATC / transmission.cxx
1 // FGTransmission - a class to provide transmission control at larger airports.\r
2 //\r
3 // Written by Alexander Kappes, started March 2002.\r
4 // Based on ground.cxx by David Luff, started March 2002.\r
5 //\r
6 // Copyright (C) 2002  David C. Luff - david.luff@nottingham.ac.uk\r
7 //\r
8 // This program is free software; you can redistribute it and/or\r
9 // modify it under the terms of the GNU General Public License as\r
10 // published by the Free Software Foundation; either version 2 of the\r
11 // License, or (at your option) any later version.\r
12 //\r
13 // This program is distributed in the hope that it will be useful, but\r
14 // WITHOUT ANY WARRANTY; without even the implied warranty of\r
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
16 // General Public License for more details.\r
17 //\r
18 // You should have received a copy of the GNU General Public License\r
19 // along with this program; if not, write to the Free Software\r
20 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
21 \r
22 #include "transmission.hxx"\r
23 \r
24 #include <simgear/misc/sg_path.hxx>\r
25 \r
26 \r
27 //Constructor\r
28 FGTransmission::FGTransmission(){\r
29 }\r
30 \r
31 //Destructor\r
32 FGTransmission::~FGTransmission(){\r
33 }\r
34 \r
35 void FGTransmission::Init() {\r
36 }\r
37 \r
38 // ============================================================================\r
39 // extract parameters from transmission\r
40 // ============================================================================\r
41 TransPar FGTransmission::Parse() {\r
42   TransPar   tpar;\r
43   string     tokens[20];\r
44   int        msglen,toklen;\r
45   char       dum;\r
46   int        i,j,k;\r
47   const char *capl = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";\r
48 \r
49   msglen = strlen( TransText.c_str() );\r
50 \r
51   int tkn  = 0;\r
52   for ( i=0; i < msglen; ++i ) {\r
53     if ( TransText.c_str()[i] != ' ' ) {\r
54       if ( TransText.c_str()[i] != ',' ) tokens[tkn] += TransText.c_str()[i];\r
55     } else if ( tokens[tkn] != "" ) {\r
56       if ( tkn <= 20 ) {\r
57         tkn += 1;\r
58       } else {\r
59         cout << "Too many tokens" << endl;\r
60       }\r
61     }\r
62   }\r
63 \r
64   for ( i=0; i<20; ++i) {\r
65     \r
66     if ( tokens[i] == "request" ) {\r
67       tpar.request = true;\r
68     } else if ( tokens[i] == "approach"  ) { \r
69       tpar.station = "approach";\r
70       tpar.airport = tokens[i-1];\r
71     } else if ( tokens[i] == "landing"  ) { \r
72       tpar.intention = "landing";\r
73       for ( j=i+1; j<=i+2; ++j ) {\r
74         if ( tokens[j] != "" ) {\r
75           toklen = strlen( tokens[j].c_str() );\r
76           bool aid = true;\r
77           for ( k=0; k<toklen; ++k )\r
78             if ( ! strpbrk( &tokens[j].c_str()[k], capl )) {\r
79               aid = false;\r
80               break;\r
81             }\r
82           if ( aid ) tpar.intid = tokens[j];\r
83         }\r
84       }\r
85     } else if ( tokens[i] == "Player"  ) { \r
86       tpar.callsign = tokens[i];\r
87     }\r
88   }\r
89 \r
90   //cout << tpar.airport << endl;\r
91   //cout << tpar.request << endl;\r
92   //cout << tpar.intention << endl;\r
93   //cout << tpar.intid << endl;\r
94 \r
95   return tpar;\r
96 }\r