1 // FGTransmission - a class to provide transmission control at larger airports.
3 // Written by Alexander Kappes, started March 2002.
4 // Based on ground.cxx by David Luff, started March 2002.
6 // Copyright (C) 2002 David C. Luff - david.luff@nottingham.ac.uk
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.
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.
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.
26 #include "transmission.hxx"
28 #include <simgear/debug/logstream.hxx>
29 #include <simgear/misc/sg_path.hxx>
33 FGTransmission::FGTransmission(){
37 FGTransmission::~FGTransmission(){
40 void FGTransmission::Init() {
43 // ============================================================================
44 // extract parameters from transmission
45 // ============================================================================
46 TransPar FGTransmission::Parse() {
52 const char *capl = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
54 msglen = strlen( TransText.c_str() );
57 for ( i=0; i < msglen; ++i ) {
58 if ( TransText.c_str()[i] != ' ' ) {
59 if ( TransText.c_str()[i] != ',' ) tokens[tkn] += TransText.c_str()[i];
60 } else if ( !tokens[tkn].empty() ) {
64 SG_LOG(SG_ATC, SG_WARN,"Too many tokens");
69 for ( i=0; i<20; ++i) {
71 if ( tokens[i] == "request" ) {
73 } else if ( tokens[i] == "approach" ) {
74 tpar.station = "approach";
75 tpar.airport = tokens[i-1];
76 } else if ( tokens[i] == "landing" ) {
77 tpar.intention = "landing";
78 for ( j=i+1; j<=i+2; ++j ) {
79 if ( !tokens[j].empty() ) {
80 toklen = strlen( tokens[j].c_str() );
82 for ( k=0; k<toklen; ++k )
83 if ( ! strpbrk( &tokens[j].c_str()[k], capl )) {
87 if ( aid ) tpar.intid = tokens[j];
90 } else if ( tokens[i] == "Player" ) {
91 tpar.callsign = tokens[i];
95 //cout << tpar.airport << endl;
96 //cout << tpar.request << endl;
97 //cout << tpar.intention << endl;
98 //cout << tpar.intid << endl;