1
0
Fork 0

Removed DOS line endings

This commit is contained in:
daveluff 2003-03-03 10:38:13 +00:00
parent dbf7218c63
commit b308e92bd6
6 changed files with 1624 additions and 1624 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,238 +1,238 @@
// approach.hxx -- Approach class // approach.hxx -- Approach class
// //
// Written by Alexander Kappes, started March 2002. // Written by Alexander Kappes, started March 2002.
// //
// Copyright (C) 2002 Alexander Kappes // Copyright (C) 2002 Alexander Kappes
// //
// This program is free software; you can redistribute it and/or // This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the // published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, but // This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef _FG_APPROACH_HXX #ifndef _FG_APPROACH_HXX
#define _FG_APPROACH_HXX #define _FG_APPROACH_HXX
#include <stdio.h> #include <stdio.h>
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <simgear/math/sg_geodesy.hxx> #include <simgear/math/sg_geodesy.hxx>
#include <simgear/misc/sgstream.hxx> #include <simgear/misc/sgstream.hxx>
#include <simgear/magvar/magvar.hxx> #include <simgear/magvar/magvar.hxx>
#include <simgear/timing/sg_time.hxx> #include <simgear/timing/sg_time.hxx>
#include <simgear/bucket/newbucket.hxx> #include <simgear/bucket/newbucket.hxx>
#include <Main/fg_props.hxx> #include <Main/fg_props.hxx>
#ifdef SG_HAVE_STD_INCLUDES #ifdef SG_HAVE_STD_INCLUDES
# include <istream> # include <istream>
#include <iomanip> #include <iomanip>
#elif defined( SG_HAVE_NATIVE_SGI_COMPILERS ) #elif defined( SG_HAVE_NATIVE_SGI_COMPILERS )
# include <iostream.h> # include <iostream.h>
#elif defined( __BORLANDC__ ) #elif defined( __BORLANDC__ )
# include <iostream> # include <iostream>
#else #else
# include <istream.h> # include <istream.h>
#include <iomanip.h> #include <iomanip.h>
#endif #endif
#if ! defined( SG_HAVE_NATIVE_SGI_COMPILERS ) #if ! defined( SG_HAVE_NATIVE_SGI_COMPILERS )
SG_USING_STD(istream); SG_USING_STD(istream);
#endif #endif
SG_USING_STD(string); SG_USING_STD(string);
#include "ATC.hxx" #include "ATC.hxx"
#include "transmission.hxx" #include "transmission.hxx"
//DCL - a complete guess for now. //DCL - a complete guess for now.
#define FG_APPROACH_DEFAULT_RANGE 100 #define FG_APPROACH_DEFAULT_RANGE 100
// Contains all the information about a plane that the approach control needs // Contains all the information about a plane that the approach control needs
const int max_planes = 20; // max number of planes on the stack const int max_planes = 20; // max number of planes on the stack
const int max_wp = 10; // max number of waypoints for approach phase const int max_wp = 10; // max number of waypoints for approach phase
const double max_ta = 130; // max turning angle for plane during approach const double max_ta = 130; // max turning angle for plane during approach
const double tbm = 20000.0; // min time (in ms) between two messages const double tbm = 20000.0; // min time (in ms) between two messages
const double lfl = 10.0; // length of final leg const double lfl = 10.0; // length of final leg
struct PlaneApp { struct PlaneApp {
// variables for plane if it's on the radar // variables for plane if it's on the radar
string ident; // indentification of plane string ident; // indentification of plane
double lon; // longitude in degrees double lon; // longitude in degrees
double lat; // latitude in degrees double lat; // latitude in degrees
double alt; // Altitute above sea level in feet double alt; // Altitute above sea level in feet
double hdg; // heading of plane in degrees double hdg; // heading of plane in degrees
double dist; // distance to airport in miles double dist; // distance to airport in miles
double brg; // bearing relative to airport in degrees double brg; // bearing relative to airport in degrees
double spd; // speed above ground double spd; // speed above ground
int contact; // contact with approach established? int contact; // contact with approach established?
// 0 = no contact yet // 0 = no contact yet
// 1 = in contact // 1 = in contact
// 2 = handed off to tower // 2 = handed off to tower
double turn_rate; // standard turning rate of the plane in seconds per degree double turn_rate; // standard turning rate of the plane in seconds per degree
double desc_rate; // standard descent rate of the plane in feets per minute double desc_rate; // standard descent rate of the plane in feets per minute
double clmb_rate; // standard climb rate of the plane in feets per minute double clmb_rate; // standard climb rate of the plane in feets per minute
// additional variables if contact has been established // additional variables if contact has been established
int wpn; // number of waypoints int wpn; // number of waypoints
double wpts[max_wp][6]; // assigned waypoints for approach phase double wpts[max_wp][6]; // assigned waypoints for approach phase
// first wp in list is airport // first wp in list is airport
// last waypoint point at which contact was established // last waypoint point at which contact was established
// second index: 0 = bearing to airport // second index: 0 = bearing to airport
// second index: 1 = distance to airport // second index: 1 = distance to airport
// second index: 2 = alt // second index: 2 = alt
// second index: 3 = ETA // second index: 3 = ETA
// second index: 4 = heading to next waypoint // second index: 4 = heading to next waypoint
// second index: 5 = distance to next waypoint // second index: 5 = distance to next waypoint
double dnwp; // distance to next waypoint double dnwp; // distance to next waypoint
double dcc; // closest distance to current assigned course double dcc; // closest distance to current assigned course
double dnc; // closest distance to course from next to next to next wp double dnc; // closest distance to course from next to next to next wp
double aalt; // assigned altitude double aalt; // assigned altitude
double ahdg; // assigned heading double ahdg; // assigned heading
bool on_crs; // is the plane on course? bool on_crs; // is the plane on course?
bool wp_change; // way point has changed bool wp_change; // way point has changed
double tlm; // time when last message was sent double tlm; // time when last message was sent
TransCode lmc; // code of last message TransCode lmc; // code of last message
}; };
class FGApproach : public FGATC { class FGApproach : public FGATC {
int bucket; int bucket;
string active_runway; string active_runway;
double active_rw_hdg; double active_rw_hdg;
double active_rw_lon; double active_rw_lon;
double active_rw_lat; double active_rw_lat;
double active_rw_len; double active_rw_len;
bool display; // Flag to indicate whether we should be outputting to the display. bool display; // Flag to indicate whether we should be outputting to the display.
bool displaying; // Flag to indicate whether we are outputting to the display. bool displaying; // Flag to indicate whether we are outputting to the display.
int num_planes; // number of planes on the stack int num_planes; // number of planes on the stack
PlaneApp planes[max_planes]; // Array of planes PlaneApp planes[max_planes]; // Array of planes
string transmission; string transmission;
bool first; bool first;
SGPropertyNode *comm1_node; SGPropertyNode *comm1_node;
SGPropertyNode *comm2_node; SGPropertyNode *comm2_node;
SGPropertyNode *atcmenu_node; SGPropertyNode *atcmenu_node;
SGPropertyNode *atcopt0_node; SGPropertyNode *atcopt0_node;
SGPropertyNode *atcopt1_node; SGPropertyNode *atcopt1_node;
SGPropertyNode *atcopt2_node; SGPropertyNode *atcopt2_node;
SGPropertyNode *atcopt3_node; SGPropertyNode *atcopt3_node;
SGPropertyNode *atcopt4_node; SGPropertyNode *atcopt4_node;
SGPropertyNode *atcopt5_node; SGPropertyNode *atcopt5_node;
SGPropertyNode *atcopt6_node; SGPropertyNode *atcopt6_node;
SGPropertyNode *atcopt7_node; SGPropertyNode *atcopt7_node;
SGPropertyNode *atcopt8_node; SGPropertyNode *atcopt8_node;
SGPropertyNode *atcopt9_node; SGPropertyNode *atcopt9_node;
// for failure modeling // for failure modeling
string trans_ident; // transmitted ident string trans_ident; // transmitted ident
bool approach_failed; // approach failed? bool approach_failed; // approach failed?
public: public:
FGApproach(void); FGApproach(void);
~FGApproach(void); ~FGApproach(void);
void Init(); void Init();
void Update(); void Update();
// Add new plane to stack if not already registered // Add new plane to stack if not already registered
// Input: pid - id of plane (name) // Input: pid - id of plane (name)
// Output: "true" if added; "false" if already existend // Output: "true" if added; "false" if already existend
void AddPlane(string pid); void AddPlane(string pid);
// Remove plane from stack if out of range // Remove plane from stack if out of range
int RemovePlane(); int RemovePlane();
//Indicate that this instance should be outputting to the ATC display //Indicate that this instance should be outputting to the ATC display
inline void SetDisplay(void) {display = true;} inline void SetDisplay(void) {display = true;}
//Indicate that this instance should not be outputting to the ATC display //Indicate that this instance should not be outputting to the ATC display
inline void SetNoDisplay(void) {display = false;} inline void SetNoDisplay(void) {display = false;}
inline double get_bucket() const { return bucket; } inline double get_bucket() const { return bucket; }
inline int get_pnum() const { return num_planes; } inline int get_pnum() const { return num_planes; }
inline string get_trans_ident() { return trans_ident; } inline string get_trans_ident() { return trans_ident; }
inline atc_type GetType() { return APPROACH; } inline atc_type GetType() { return APPROACH; }
private: private:
void calc_wp( const int &i); void calc_wp( const int &i);
void update_plane_dat(); void update_plane_dat();
void get_active_runway(); void get_active_runway();
void update_param(const int &i); void update_param(const int &i);
double round_alt( bool hl, double alt ); double round_alt( bool hl, double alt );
double angle_diff_deg( const double &a1, const double &a2); double angle_diff_deg( const double &a1, const double &a2);
// ======================================================================== // ========================================================================
// get point2 given starting point1 and course and distance // get point2 given starting point1 and course and distance
// input: point1 = heading in degrees, distance // input: point1 = heading in degrees, distance
// input: course in degrees, distance // input: course in degrees, distance
// output: point2 = heading in degrees, distance // output: point2 = heading in degrees, distance
// ======================================================================== // ========================================================================
void calc_cd_head_dist(const double &h1, const double &d1, void calc_cd_head_dist(const double &h1, const double &d1,
const double &course, const double &dist, const double &course, const double &dist,
double *h2, double *d2); double *h2, double *d2);
// ======================================================================== // ========================================================================
// get heading and distance between two points; point2 ---> point1 // get heading and distance between two points; point2 ---> point1
// input: point1 = heading in degrees, distance // input: point1 = heading in degrees, distance
// input: point2 = heading in degrees, distance // input: point2 = heading in degrees, distance
// output: course in degrees, distance // output: course in degrees, distance
// ======================================================================== // ========================================================================
void calc_hd_course_dist(const double &h1, const double &d1, void calc_hd_course_dist(const double &h1, const double &d1,
const double &h2, const double &d2, const double &h2, const double &d2,
double *course, double *dist); double *course, double *dist);
// ======================================================================== // ========================================================================
// closest distance between a point and a straigt line in 2 dim. // closest distance between a point and a straigt line in 2 dim.
// the input variables are given in (heading, distance) // the input variables are given in (heading, distance)
// relative to a common point // relative to a common point
// input: point = heading in degrees, distance // input: point = heading in degrees, distance
// input: straigt line = anker vector (heading in degrees, distance), // input: straigt line = anker vector (heading in degrees, distance),
// heading of direction vector // heading of direction vector
// output: distance // output: distance
// ======================================================================== // ========================================================================
double calc_psl_dist(const double &h1, const double &d1, double calc_psl_dist(const double &h1, const double &d1,
const double &h2, const double &d2, const double &h2, const double &d2,
const double &h3); const double &h3);
// Pointers to current users position // Pointers to current users position
SGPropertyNode *lon_node; SGPropertyNode *lon_node;
SGPropertyNode *lat_node; SGPropertyNode *lat_node;
SGPropertyNode *elev_node; SGPropertyNode *elev_node;
SGPropertyNode *hdg_node; SGPropertyNode *hdg_node;
SGPropertyNode *speed_node; SGPropertyNode *speed_node;
SGPropertyNode *etime_node; SGPropertyNode *etime_node;
//Update the transmission string //Update the transmission string
void UpdateTransmission(void); void UpdateTransmission(void);
friend istream& operator>> ( istream&, FGApproach& ); friend istream& operator>> ( istream&, FGApproach& );
}; };
#endif // _FG_APPROACH_HXX #endif // _FG_APPROACH_HXX

View file

@ -1,96 +1,96 @@
// FGTransmission - a class to provide transmission control at larger airports. // FGTransmission - a class to provide transmission control at larger airports.
// //
// Written by Alexander Kappes, started March 2002. // Written by Alexander Kappes, started March 2002.
// Based on ground.cxx by David Luff, started March 2002. // Based on ground.cxx by David Luff, started March 2002.
// //
// Copyright (C) 2002 David C. Luff - david.luff@nottingham.ac.uk // Copyright (C) 2002 David C. Luff - david.luff@nottingham.ac.uk
// //
// This program is free software; you can redistribute it and/or // This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the // published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, but // This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "transmission.hxx" #include "transmission.hxx"
#include <simgear/misc/sg_path.hxx> #include <simgear/misc/sg_path.hxx>
//Constructor //Constructor
FGTransmission::FGTransmission(){ FGTransmission::FGTransmission(){
} }
//Destructor //Destructor
FGTransmission::~FGTransmission(){ FGTransmission::~FGTransmission(){
} }
void FGTransmission::Init() { void FGTransmission::Init() {
} }
// ============================================================================ // ============================================================================
// extract parameters from transmission // extract parameters from transmission
// ============================================================================ // ============================================================================
TransPar FGTransmission::Parse() { TransPar FGTransmission::Parse() {
TransPar tpar; TransPar tpar;
string tokens[20]; string tokens[20];
int msglen,toklen; int msglen,toklen;
char dum; char dum;
int i,j,k; int i,j,k;
const char *capl = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; const char *capl = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
msglen = strlen( TransText.c_str() ); msglen = strlen( TransText.c_str() );
int tkn = 0; int tkn = 0;
for ( i=0; i < msglen; ++i ) { for ( i=0; i < msglen; ++i ) {
if ( TransText.c_str()[i] != ' ' ) { if ( TransText.c_str()[i] != ' ' ) {
if ( TransText.c_str()[i] != ',' ) tokens[tkn] += TransText.c_str()[i]; if ( TransText.c_str()[i] != ',' ) tokens[tkn] += TransText.c_str()[i];
} else if ( tokens[tkn] != "" ) { } else if ( tokens[tkn] != "" ) {
if ( tkn <= 20 ) { if ( tkn <= 20 ) {
tkn += 1; tkn += 1;
} else { } else {
cout << "Too many tokens" << endl; cout << "Too many tokens" << endl;
} }
} }
} }
for ( i=0; i<20; ++i) { for ( i=0; i<20; ++i) {
if ( tokens[i] == "request" ) { if ( tokens[i] == "request" ) {
tpar.request = true; tpar.request = true;
} else if ( tokens[i] == "approach" ) { } else if ( tokens[i] == "approach" ) {
tpar.station = "approach"; tpar.station = "approach";
tpar.airport = tokens[i-1]; tpar.airport = tokens[i-1];
} else if ( tokens[i] == "landing" ) { } else if ( tokens[i] == "landing" ) {
tpar.intention = "landing"; tpar.intention = "landing";
for ( j=i+1; j<=i+2; ++j ) { for ( j=i+1; j<=i+2; ++j ) {
if ( tokens[j] != "" ) { if ( tokens[j] != "" ) {
toklen = strlen( tokens[j].c_str() ); toklen = strlen( tokens[j].c_str() );
bool aid = true; bool aid = true;
for ( k=0; k<toklen; ++k ) for ( k=0; k<toklen; ++k )
if ( ! strpbrk( &tokens[j].c_str()[k], capl )) { if ( ! strpbrk( &tokens[j].c_str()[k], capl )) {
aid = false; aid = false;
break; break;
} }
if ( aid ) tpar.intid = tokens[j]; if ( aid ) tpar.intid = tokens[j];
} }
} }
} else if ( tokens[i] == "Player" ) { } else if ( tokens[i] == "Player" ) {
tpar.callsign = tokens[i]; tpar.callsign = tokens[i];
} }
} }
//cout << tpar.airport << endl; //cout << tpar.airport << endl;
//cout << tpar.request << endl; //cout << tpar.request << endl;
//cout << tpar.intention << endl; //cout << tpar.intention << endl;
//cout << tpar.intid << endl; //cout << tpar.intid << endl;
return tpar; return tpar;
} }

View file

@ -1,159 +1,159 @@
// transmission.hxx -- Transmission class // transmission.hxx -- Transmission class
// //
// Written by Alexander Kappes, started March 2002. // Written by Alexander Kappes, started March 2002.
// Based on nav.hxx by Curtis Olson, started April 2000. // Based on nav.hxx by Curtis Olson, started April 2000.
// //
// Copyright (C) 2001 David C. Luff - david.luff@nottingham.ac.uk // Copyright (C) 2001 David C. Luff - david.luff@nottingham.ac.uk
// //
// This program is free software; you can redistribute it and/or // This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the // published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, but // This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef _FG_TRANSMISSION_HXX #ifndef _FG_TRANSMISSION_HXX
#define _FG_TRANSMISSION_HXX #define _FG_TRANSMISSION_HXX
#include <stdio.h> #include <stdio.h>
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <simgear/math/sg_geodesy.hxx> #include <simgear/math/sg_geodesy.hxx>
#include <simgear/misc/sgstream.hxx> #include <simgear/misc/sgstream.hxx>
#include <simgear/magvar/magvar.hxx> #include <simgear/magvar/magvar.hxx>
#include <simgear/timing/sg_time.hxx> #include <simgear/timing/sg_time.hxx>
#include <simgear/bucket/newbucket.hxx> #include <simgear/bucket/newbucket.hxx>
#include <Main/fg_props.hxx> #include <Main/fg_props.hxx>
#ifdef SG_HAVE_STD_INCLUDES #ifdef SG_HAVE_STD_INCLUDES
# include <istream> # include <istream>
#include <iomanip> #include <iomanip>
#elif defined( SG_HAVE_NATIVE_SGI_COMPILERS ) #elif defined( SG_HAVE_NATIVE_SGI_COMPILERS )
# include <iostream.h> # include <iostream.h>
#elif defined( __BORLANDC__ ) #elif defined( __BORLANDC__ )
# include <iostream> # include <iostream>
#else #else
# include <istream.h> # include <istream.h>
#include <iomanip.h> #include <iomanip.h>
#endif #endif
#if ! defined( SG_HAVE_NATIVE_SGI_COMPILERS ) #if ! defined( SG_HAVE_NATIVE_SGI_COMPILERS )
SG_USING_STD(istream); SG_USING_STD(istream);
#endif #endif
SG_USING_STD(string); SG_USING_STD(string);
struct TransCode { struct TransCode {
int c1; int c1;
int c2; int c2;
int c3; int c3;
}; };
// TransPar - a representation of the logic of a parsed speech transmission // TransPar - a representation of the logic of a parsed speech transmission
struct TransPar { struct TransPar {
string station; string station;
string callsign; string callsign;
string airport; string airport;
string intention; // landing, crossing string intention; // landing, crossing
string intid; // (airport) ID for intention string intid; // (airport) ID for intention
bool request; // is the transmission a request or an answer? bool request; // is the transmission a request or an answer?
int tdir; // turning direction: 1=left, 2=right int tdir; // turning direction: 1=left, 2=right
double heading; double heading;
int VDir; // vertical direction: 1=descent, 2=maintain, 3=climb int VDir; // vertical direction: 1=descent, 2=maintain, 3=climb
double alt; double alt;
double miles; double miles;
string runway; string runway;
double freq; double freq;
double time; double time;
}; };
// FGTransmission - a class to encapsulate a speech transmission // FGTransmission - a class to encapsulate a speech transmission
class FGTransmission { class FGTransmission {
int StationType; // Type of ATC station: 1 Approach int StationType; // Type of ATC station: 1 Approach
TransCode Code; TransCode Code;
string TransText; string TransText;
string MenuText; string MenuText;
public: public:
FGTransmission(void); FGTransmission(void);
~FGTransmission(void); ~FGTransmission(void);
void Init(); void Init();
inline int get_station() const { return StationType; } inline int get_station() const { return StationType; }
inline TransCode get_code() { return Code; } inline TransCode get_code() { return Code; }
inline string get_transtext() { return TransText; } inline string get_transtext() { return TransText; }
inline string get_menutext() { return MenuText; } inline string get_menutext() { return MenuText; }
// Return the parsed logic of the transmission // Return the parsed logic of the transmission
TransPar Parse(); TransPar Parse();
private: private:
friend istream& operator>> ( istream&, FGTransmission& ); friend istream& operator>> ( istream&, FGTransmission& );
}; };
inline istream& inline istream&
operator >> ( istream& in, FGTransmission& a ) { operator >> ( istream& in, FGTransmission& a ) {
char ch; char ch;
static bool first_time = true; static bool first_time = true;
static double julian_date = 0; static double julian_date = 0;
static const double MJD0 = 2415020.0; static const double MJD0 = 2415020.0;
if ( first_time ) { if ( first_time ) {
julian_date = sgTimeCurrentMJD(0, 0) + MJD0; julian_date = sgTimeCurrentMJD(0, 0) + MJD0;
first_time = false; first_time = false;
} }
in >> a.StationType; in >> a.StationType;
in >> a.Code.c1; in >> a.Code.c1;
in >> a.Code.c2; in >> a.Code.c2;
in >> a.Code.c3; in >> a.Code.c3;
a.TransText = ""; a.TransText = "";
in >> ch; in >> ch;
if ( ch != '"' ) a.TransText += ch; if ( ch != '"' ) a.TransText += ch;
while(1) { while(1) {
//in >> noskipws //in >> noskipws
in.unsetf(ios::skipws); in.unsetf(ios::skipws);
in >> ch; in >> ch;
if ( ch != '"' ) a.TransText += ch; if ( ch != '"' ) a.TransText += ch;
if((ch == '"') || (ch == 0x0A)) { if((ch == '"') || (ch == 0x0A)) {
break; break;
} // we shouldn't need the 0x0A but it makes a nice safely in case someone leaves off the " } // we shouldn't need the 0x0A but it makes a nice safely in case someone leaves off the "
} }
in.setf(ios::skipws); in.setf(ios::skipws);
a.MenuText = ""; a.MenuText = "";
in >> ch; in >> ch;
if ( ch != '"' ) a.MenuText += ch; if ( ch != '"' ) a.MenuText += ch;
while(1) { while(1) {
//in >> noskipws //in >> noskipws
in.unsetf(ios::skipws); in.unsetf(ios::skipws);
in >> ch; in >> ch;
if ( ch != '"' ) a.MenuText += ch; if ( ch != '"' ) a.MenuText += ch;
if((ch == '"') || (ch == 0x0A)) { if((ch == '"') || (ch == 0x0A)) {
break; break;
} // we shouldn't need the 0x0A but it makes a nice safely in case someone leaves off the " } // we shouldn't need the 0x0A but it makes a nice safely in case someone leaves off the "
} }
in.setf(ios::skipws); in.setf(ios::skipws);
//cout << "Code = " << a.Code << " Transmission text = " << a.TransText //cout << "Code = " << a.Code << " Transmission text = " << a.TransText
// << " Menu text = " << a.MenuText << endl; // << " Menu text = " << a.MenuText << endl;
return in >> skipeol; return in >> skipeol;
} }
#endif // _FG_TRANSMISSION_HXX #endif // _FG_TRANSMISSION_HXX

View file

@ -1,288 +1,288 @@
// transmissionlist.cxx -- transmission management class // transmissionlist.cxx -- transmission management class
// //
// Written by Alexander Kappes, started March 2002. // Written by Alexander Kappes, started March 2002.
// Based on navlist.cxx by Curtis Olson, started April 2000. // Based on navlist.cxx by Curtis Olson, started April 2000.
// //
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org // Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
// //
// This program is free software; you can redistribute it and/or // This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the // published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, but // This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
// //
// $Id$ // $Id$
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include <config.h> # include <config.h>
#endif #endif
#include <simgear/debug/logstream.hxx> #include <simgear/debug/logstream.hxx>
#include <simgear/misc/sgstream.hxx> #include <simgear/misc/sgstream.hxx>
#include <simgear/math/sg_geodesy.hxx> #include <simgear/math/sg_geodesy.hxx>
#include "transmissionlist.hxx" #include "transmissionlist.hxx"
#include <GUI/gui.h> #include <GUI/gui.h>
static puDialogBox *ATCMenuBox = 0; static puDialogBox *ATCMenuBox = 0;
static puFrame *ATCMenuFrame = 0; static puFrame *ATCMenuFrame = 0;
static puText *ATCMenuBoxMessage = 0; static puText *ATCMenuBoxMessage = 0;
FGTransmissionList *current_transmissionlist; FGTransmissionList *current_transmissionlist;
// Constructor // Constructor
FGTransmissionList::FGTransmissionList( void ) { FGTransmissionList::FGTransmissionList( void ) {
} }
// Destructor // Destructor
FGTransmissionList::~FGTransmissionList( void ) { FGTransmissionList::~FGTransmissionList( void ) {
} }
/* /*
// ============================================================================ // ============================================================================
// init menu window // init menu window
// ============================================================================ // ============================================================================
void mkATCMenuInit (void) void mkATCMenuInit (void)
{ {
int dx = 400; int dx = 400;
int dy = 100; int dy = 100;
int y = (fgGetInt("/sim/startup/ysize") - 10 - dy); int y = (fgGetInt("/sim/startup/ysize") - 10 - dy);
ATCMenuBox = new puDialogBox (10, y); ATCMenuBox = new puDialogBox (10, y);
{ {
ATCMenuFrame = new puFrame (0,0,400,100); ATCMenuFrame = new puFrame (0,0,400,100);
ATCMenuBoxMessage = new puText (10, 70); ATCMenuBoxMessage = new puText (10, 70);
ATCMenuBoxMessage -> setLabel (""); ATCMenuBoxMessage -> setLabel ("");
} }
fgSetBool("/sim/atc/menu",false); fgSetBool("/sim/atc/menu",false);
fgSetBool("/sim/atc/opt1",false); fgSetBool("/sim/atc/opt1",false);
fgSetBool("/sim/atc/opt2",false); fgSetBool("/sim/atc/opt2",false);
fgSetBool("/sim/atc/opt3",false); fgSetBool("/sim/atc/opt3",false);
fgSetBool("/sim/atc/opt4",false); fgSetBool("/sim/atc/opt4",false);
fgSetBool("/sim/atc/opt5",false); fgSetBool("/sim/atc/opt5",false);
fgSetBool("/sim/atc/opt6",false); fgSetBool("/sim/atc/opt6",false);
fgSetBool("/sim/atc/opt7",false); fgSetBool("/sim/atc/opt7",false);
fgSetBool("/sim/atc/opt8",false); fgSetBool("/sim/atc/opt8",false);
fgSetBool("/sim/atc/opt9",false); fgSetBool("/sim/atc/opt9",false);
fgSetBool("/sim/atc/opt0",false); fgSetBool("/sim/atc/opt0",false);
} }
// ATC Menu Message Box // ATC Menu Message Box
void mkATCMenu ( const char *txt ) void mkATCMenu ( const char *txt )
{ {
ATCMenuBoxMessage = new puText (10, 70); ATCMenuBoxMessage = new puText (10, 70);
ATCMenuBoxMessage->setLabel( txt ); ATCMenuBoxMessage->setLabel( txt );
FG_PUSH_PUI_DIALOG( ATCMenuBox ); FG_PUSH_PUI_DIALOG( ATCMenuBox );
} }
*/ */
// load default.transmissions // load default.transmissions
bool FGTransmissionList::init( SGPath path ) { bool FGTransmissionList::init( SGPath path ) {
FGTransmission a; FGTransmission a;
transmissionlist_station.erase( transmissionlist_station.begin(), transmissionlist_station.end() ); transmissionlist_station.erase( transmissionlist_station.begin(), transmissionlist_station.end() );
sg_gzifstream in( path.str() ); sg_gzifstream in( path.str() );
if ( !in.is_open() ) { if ( !in.is_open() ) {
SG_LOG( SG_GENERAL, SG_ALERT, "Cannot open file: " << path.str() ); SG_LOG( SG_GENERAL, SG_ALERT, "Cannot open file: " << path.str() );
exit(-1); exit(-1);
} }
// read in each line of the file // read in each line of the file
// in >> skipeol; // in >> skipeol;
// in >> skipcomment; // in >> skipcomment;
#ifdef __MWERKS__ #ifdef __MWERKS__
char c = 0; char c = 0;
while ( in.get(c) && c != '\0' ) { while ( in.get(c) && c != '\0' ) {
in.putback(c); in.putback(c);
in >> a; in >> a;
if ( a.get_type() != '[' ) { if ( a.get_type() != '[' ) {
transmissionlist_code[a.get_station()].push_back(a); transmissionlist_code[a.get_station()].push_back(a);
} }
in >> skipcomment; in >> skipcomment;
} }
#else #else
double min = 100000; double min = 100000;
double max = 0; double max = 0;
while ( ! in.eof() ) { while ( ! in.eof() ) {
in >> a; in >> a;
transmissionlist_station[a.get_station()].push_back(a); transmissionlist_station[a.get_station()].push_back(a);
in >> skipcomment; in >> skipcomment;
if ( a.get_station() < min ) { if ( a.get_station() < min ) {
min = a.get_station(); min = a.get_station();
} }
if ( a.get_station() > max ) { if ( a.get_station() > max ) {
max = a.get_station(); max = a.get_station();
} }
cout << a.get_station() << " " << a.get_code().c1 << " " << a.get_code().c2 << " " cout << a.get_station() << " " << a.get_code().c1 << " " << a.get_code().c2 << " "
<< a.get_code().c3 << " " << a.get_transtext() << a.get_code().c3 << " " << a.get_transtext()
<< " " << a.get_menutext() << endl; << " " << a.get_menutext() << endl;
} }
#endif #endif
// init ATC menu // init ATC menu
fgSetBool("/sim/atc/menu",false); fgSetBool("/sim/atc/menu",false);
return true; return true;
} }
// query the database for the specified station type; // query the database for the specified station type;
// for station see FlightGear/ATC/default.transmissions // for station see FlightGear/ATC/default.transmissions
bool FGTransmissionList::query_station( const int &station, FGTransmission *t, bool FGTransmissionList::query_station( const int &station, FGTransmission *t,
int max_trans, int &num_trans ) int max_trans, int &num_trans )
{ {
transmission_list_type tmissions = transmissionlist_station[station]; transmission_list_type tmissions = transmissionlist_station[station];
transmission_list_iterator current = tmissions.begin(); transmission_list_iterator current = tmissions.begin();
transmission_list_iterator last = tmissions.end(); transmission_list_iterator last = tmissions.end();
for ( ; current != last ; ++current ) { for ( ; current != last ; ++current ) {
if (num_trans < max_trans) { if (num_trans < max_trans) {
t[num_trans] = *current; t[num_trans] = *current;
num_trans += 1; num_trans += 1;
} }
else { else {
cout << "Transmissionlist error: Too many transmissions" << endl; cout << "Transmissionlist error: Too many transmissions" << endl;
} }
} }
if ( num_trans != 0 ) return true; if ( num_trans != 0 ) return true;
else { else {
cout << "No transmission with station " << station << "found." << endl; cout << "No transmission with station " << station << "found." << endl;
string empty; string empty;
return false; return false;
} }
} }
string FGTransmissionList::gen_text(const int &station, const TransCode code, string FGTransmissionList::gen_text(const int &station, const TransCode code,
const TransPar &tpars, const bool ttext ) const TransPar &tpars, const bool ttext )
{ {
const int cmax = 100; const int cmax = 100;
string message; string message;
char tag[4]; char tag[4];
char crej = '@'; char crej = '@';
char mes[cmax]; char mes[cmax];
char dum[cmax]; char dum[cmax];
char buf[10]; char buf[10];
char *pos; char *pos;
int len; int len;
FGTransmission t; FGTransmission t;
// if (current_transmissionlist->query_station( station, &t ) ) { // if (current_transmissionlist->query_station( station, &t ) ) {
transmission_list_type tmissions = transmissionlist_station[station]; transmission_list_type tmissions = transmissionlist_station[station];
transmission_list_iterator current = tmissions.begin(); transmission_list_iterator current = tmissions.begin();
transmission_list_iterator last = tmissions.end(); transmission_list_iterator last = tmissions.end();
for ( ; current != last ; ++current ) { for ( ; current != last ; ++current ) {
if ( current->get_code().c1 == code.c1 && if ( current->get_code().c1 == code.c1 &&
current->get_code().c2 == code.c2 && current->get_code().c2 == code.c2 &&
current->get_code().c3 == code.c3 ) { current->get_code().c3 == code.c3 ) {
if ( ttext ) message = current->get_transtext(); if ( ttext ) message = current->get_transtext();
else message = current->get_menutext(); else message = current->get_menutext();
strcpy( &mes[0], message.c_str() ); strcpy( &mes[0], message.c_str() );
while ( strchr(&mes[0], crej) != NULL ) { while ( strchr(&mes[0], crej) != NULL ) {
pos = strchr( &mes[0], crej ); pos = strchr( &mes[0], crej );
bcopy(pos, &tag, 3); bcopy(pos, &tag, 3);
tag[3] = '\0'; tag[3] = '\0';
int i; int i;
len = 0; len = 0;
for ( i=0; i<cmax; i++ ) { for ( i=0; i<cmax; i++ ) {
if ( mes[i] == crej ) { if ( mes[i] == crej ) {
len = i; len = i;
break; break;
} }
} }
strncpy( &dum[0], &mes[0], len ); strncpy( &dum[0], &mes[0], len );
dum[len] = '\0'; dum[len] = '\0';
if ( strcmp ( tag, "@ST" ) == 0 ) if ( strcmp ( tag, "@ST" ) == 0 )
strcat( &dum[0], tpars.station.c_str() ); strcat( &dum[0], tpars.station.c_str() );
else if ( strcmp ( tag, "@AP" ) == 0 ) else if ( strcmp ( tag, "@AP" ) == 0 )
strcat( &dum[0], tpars.airport.c_str() ); strcat( &dum[0], tpars.airport.c_str() );
else if ( strcmp ( tag, "@CS" ) == 0 ) else if ( strcmp ( tag, "@CS" ) == 0 )
strcat( &dum[0], tpars.callsign.c_str() ); strcat( &dum[0], tpars.callsign.c_str() );
else if ( strcmp ( tag, "@TD" ) == 0 ) { else if ( strcmp ( tag, "@TD" ) == 0 ) {
if ( tpars.tdir == 1 ) { if ( tpars.tdir == 1 ) {
char buf[] = "left"; char buf[] = "left";
strcat( &dum[0], &buf[0] ); strcat( &dum[0], &buf[0] );
} }
else { else {
char buf[] = "right"; char buf[] = "right";
strcat( &dum[0], &buf[0] ); strcat( &dum[0], &buf[0] );
} }
} }
else if ( strcmp ( tag, "@HE" ) == 0 ) { else if ( strcmp ( tag, "@HE" ) == 0 ) {
char buf[10]; char buf[10];
sprintf( buf, "%i", (int)(tpars.heading) ); sprintf( buf, "%i", (int)(tpars.heading) );
strcat( &dum[0], &buf[0] ); strcat( &dum[0], &buf[0] );
} }
else if ( strcmp ( tag, "@VD" ) == 0 ) { else if ( strcmp ( tag, "@VD" ) == 0 ) {
if ( tpars.VDir == 1 ) { if ( tpars.VDir == 1 ) {
char buf[] = "Descent and maintain"; char buf[] = "Descent and maintain";
strcat( &dum[0], &buf[0] ); strcat( &dum[0], &buf[0] );
} }
else if ( tpars.VDir == 2 ) { else if ( tpars.VDir == 2 ) {
char buf[] = "Maintain"; char buf[] = "Maintain";
strcat( &dum[0], &buf[0] ); strcat( &dum[0], &buf[0] );
} }
else if ( tpars.VDir == 3 ) { else if ( tpars.VDir == 3 ) {
char buf[] = "Climb and maintain"; char buf[] = "Climb and maintain";
strcat( &dum[0], &buf[0] ); strcat( &dum[0], &buf[0] );
} }
} }
else if ( strcmp ( tag, "@AL" ) == 0 ) { else if ( strcmp ( tag, "@AL" ) == 0 ) {
char buf[10]; char buf[10];
sprintf( buf, "%i", (int)(tpars.alt) ); sprintf( buf, "%i", (int)(tpars.alt) );
strcat( &dum[0], &buf[0] ); strcat( &dum[0], &buf[0] );
} }
else if ( strcmp ( tag, "@MI" ) == 0 ) { else if ( strcmp ( tag, "@MI" ) == 0 ) {
char buf[10]; char buf[10];
sprintf( buf, "%3.1f", tpars.miles ); sprintf( buf, "%3.1f", tpars.miles );
strcat( &dum[0], &buf[0] ); strcat( &dum[0], &buf[0] );
} }
else if ( strcmp ( tag, "@FR" ) == 0 ) { else if ( strcmp ( tag, "@FR" ) == 0 ) {
char buf[10]; char buf[10];
sprintf( buf, "%6.2f", tpars.freq ); sprintf( buf, "%6.2f", tpars.freq );
strcat( &dum[0], &buf[0] ); strcat( &dum[0], &buf[0] );
} }
else if ( strcmp ( tag, "@RW" ) == 0 ) else if ( strcmp ( tag, "@RW" ) == 0 )
strcat( &dum[0], tpars.runway.c_str() ); strcat( &dum[0], tpars.runway.c_str() );
else { else {
cout << "Tag " << tag << " not found" << endl; cout << "Tag " << tag << " not found" << endl;
break; break;
} }
strcat( &dum[0], &mes[len+3] ); strcat( &dum[0], &mes[len+3] );
strcpy( &mes[0], &dum[0] ); strcpy( &mes[0], &dum[0] );
} }
//cout << mes << endl; //cout << mes << endl;
break; break;
} }
} }
if ( mes != "" ) return mes; if ( mes != "" ) return mes;
else return "No transmission found"; else return "No transmission found";
} }

View file

@ -1,80 +1,80 @@
// transmissionlist.hxx -- transmission management class // transmissionlist.hxx -- transmission management class
// //
// Written by Alexander Kappes, started March 2002. // Written by Alexander Kappes, started March 2002.
// Based on navlist.hxx by Curtis Olson, started April 2000. // Based on navlist.hxx by Curtis Olson, started April 2000.
// //
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org // Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
// //
// This program is free software; you can redistribute it and/or // This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the // published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, but // This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
// //
#ifndef _FG_TRANSMISSIONLIST_HXX #ifndef _FG_TRANSMISSIONLIST_HXX
#define _FG_TRANSMISSIONLIST_HXX #define _FG_TRANSMISSIONLIST_HXX
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <simgear/misc/sg_path.hxx> #include <simgear/misc/sg_path.hxx>
#include <map> #include <map>
#include <vector> #include <vector>
#include <plib/pu.h> #include <plib/pu.h>
#include "transmission.hxx" #include "transmission.hxx"
SG_USING_STD(map); SG_USING_STD(map);
SG_USING_STD(vector); SG_USING_STD(vector);
class FGTransmissionList { class FGTransmissionList {
// convenience types // convenience types
typedef vector < FGTransmission > transmission_list_type; typedef vector < FGTransmission > transmission_list_type;
typedef transmission_list_type::iterator transmission_list_iterator; typedef transmission_list_type::iterator transmission_list_iterator;
typedef transmission_list_type::const_iterator transmission_list_const_iterator; typedef transmission_list_type::const_iterator transmission_list_const_iterator;
// typedef map < int, transmission_list_type, less<int> > transmission_map_type; // typedef map < int, transmission_list_type, less<int> > transmission_map_type;
typedef map < int, transmission_list_type > transmission_map_type; typedef map < int, transmission_list_type > transmission_map_type;
typedef transmission_map_type::iterator transmission_map_iterator; typedef transmission_map_type::iterator transmission_map_iterator;
typedef transmission_map_type::const_iterator transmission_map_const_iterator; typedef transmission_map_type::const_iterator transmission_map_const_iterator;
transmission_map_type transmissionlist_station; transmission_map_type transmissionlist_station;
public: public:
FGTransmissionList(); FGTransmissionList();
~FGTransmissionList(); ~FGTransmissionList();
// load the transmission data and build the map // load the transmission data and build the map
bool init( SGPath path ); bool init( SGPath path );
// query the database for the specified code, // query the database for the specified code,
bool query_station( const int &station, FGTransmission *a, int max_trans, int &num_trans ); bool query_station( const int &station, FGTransmission *a, int max_trans, int &num_trans );
// generate the transmission text given the code of the message // generate the transmission text given the code of the message
// and the parameters // and the parameters
string gen_text(const int &station, const TransCode code, string gen_text(const int &station, const TransCode code,
const TransPar &tpars, const bool ttext); const TransPar &tpars, const bool ttext);
}; };
void mkATCMenuInit (void); void mkATCMenuInit (void);
void mkATCMenu (void); void mkATCMenu (void);
extern FGTransmissionList *current_transmissionlist; extern FGTransmissionList *current_transmissionlist;
#endif // _FG_TRANSMISSIONLIST_HXX #endif // _FG_TRANSMISSIONLIST_HXX