1
0
Fork 0

Vivian Meazza:

This adds a TACAN instrument to the inventory. Range and bearing are calculated
to the TACAN or VORTAC beacon selected by means of the Channel Selector in the E
quipment/Radio pull-down menu.

A TACAN beacon has also been added to the aircraft carrier Nimitz (channel #029Y
).
This commit is contained in:
ehofman 2005-10-01 09:56:53 +00:00
parent 5555809250
commit 1c3e2d4942
15 changed files with 261 additions and 35 deletions

View file

@ -301,18 +301,13 @@ void FGAICarrier::bind() {
SGRawValuePointer<double>(&rel_wind_speed_kts));
props->tie("controls/flols/wave-off-lights",
SGRawValuePointer<bool>(&wave_off_lights));
props->tie("instrumentation/TACAN/bearing-true-deg",
SGRawValuePointer<double>(&bearing));
props->tie("instrumentation/TACAN/range-nm",
SGRawValuePointer<double>(&range));
props->setBoolValue("controls/flols/cut-lights", false);
props->setBoolValue("controls/flols/wave-off-lights", false);
props->setBoolValue("controls/flols/cond-datum-lights", true);
props->setBoolValue("controls/crew", false);
props->setStringValue("instrumentation/TACAN/channel-ID", TACAN_channel_id.c_str());
props->setStringValue("navaids/tacan/channel-ID", TACAN_channel_id.c_str());
props->setStringValue("sign", sign.c_str());
}
@ -331,9 +326,7 @@ void FGAICarrier::unbind() {
props->untie("environment/rel-wind-from-degs");
props->untie("environment/rel-wind-speed-kts");
props->untie("controls/flols/wave-off-lights");
props->untie("instrumentation/TACAN/bearing-true-deg");
props->untie("instrumentation/TACAN/range-nm");
props->untie("instrumentation/TACAN/channel-ID");
}
bool FGAICarrier::getParkPosition(const string& id, Point3D& geodPos,
@ -756,7 +749,7 @@ void FGAICarrier::UpdateWind( double dt) {
wave_off_lights = true;
}
cout << "rel wind: " << rel_wind << endl;
// cout << "rel wind: " << rel_wind << endl;
}// end update wind
@ -800,7 +793,7 @@ void FGAICarrier::ReturnToBox(){
distance *= SG_METER_TO_NM;
cout << "return course: " << course << " distance: " << distance << endl;
//cout << "return course: " << course << " distance: " << distance << endl;
//turn the carrier
FGAIShip::TurnTo(course);
FGAIShip::AccelTo(base_speed);

View file

@ -99,8 +99,8 @@ FGAIScenario::FGAIScenario(const string &filename)
en->cd = entry_node->getDoubleValue("cd", 0.029);
en->mass = entry_node->getDoubleValue("mass", 0.007);
en->radius = entry_node->getDoubleValue("turn-radius-ft", 2000);
en->TACAN_channel_ID= entry_node->getStringValue("TACAN-channel-ID", "017X");
en->name = entry_node->getStringValue("name", "");
en->TACAN_channel_ID= entry_node->getStringValue("TACAN-channel-ID", "029Y");
en->name = entry_node->getStringValue("name", "Nimitz");
en->pennant_number = entry_node->getStringValue("pennant-number", "");
en->wire_objects = getAllStringNodeVals("wire", entry_node);
en->catapult_objects = getAllStringNodeVals("catapult", entry_node);

View file

@ -174,8 +174,8 @@ void FGAIShip::Run(double dt) {
//low pass filter
roll = (raw_roll * roll_constant) + (roll * (1 - roll_constant));
cout << " rudder: " << rudder << " raw roll: "<< raw_roll<<" roll: " << roll ;
cout << " hdg: " << hdg << endl ;
/*cout << " rudder: " << rudder << " raw roll: "<< raw_roll<<" roll: " << roll ;
cout << " hdg: " << hdg << endl ;*/
// adjust target rudder angle if heading lock engaged
if (hdg_lock) {

View file

@ -15,7 +15,7 @@ AirportList::AirportList (int x, int y, int width, int height)
_nAirports = _airports->size();
_content = new char *[_nAirports+1];
for (unsigned int i = 0; i < _nAirports; i++) {
for (int i = 0; i < _nAirports; i++) {
const FGAirport *airport = _airports->getAirport(i);
snprintf(buf, 1023, "%s %s",
airport->getId().c_str(),
@ -33,7 +33,7 @@ AirportList::AirportList (int x, int y, int width, int height)
AirportList::~AirportList ()
{
for (unsigned int i = 0; i < _nAirports; i++) {
for (int i = 0; i < _nAirports; i++) {
delete _content[i];
_content[i] = 0;
}

View file

@ -22,6 +22,7 @@ libInstrumentation_a_SOURCES = \
transponder.cxx transponder.hxx \
turn_indicator.cxx turn_indicator.hxx \
vertical_speed_indicator.cxx vertical_speed_indicator.hxx \
inst_vertical_speed_indicator.cxx inst_vertical_speed_indicator.hxx
inst_vertical_speed_indicator.cxx inst_vertical_speed_indicator.hxx \
tacan.cxx tacan.hxx
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src

View file

@ -36,6 +36,7 @@
#include "turn_indicator.hxx"
#include "vertical_speed_indicator.hxx"
#include "inst_vertical_speed_indicator.hxx" // (TJ)
#include "tacan.hxx"
FGInstrumentMgr::FGInstrumentMgr ()
@ -92,6 +93,7 @@ bool FGInstrumentMgr::build ()
for ( i = 0; i < count; ++i ) {
node = config_props->getChild(i);
string name = node->getName();
cout<< "instrument name: " << name << endl;
std::ostringstream temp;
temp << i;
if ( name == "adf" ) {
@ -151,6 +153,10 @@ bool FGInstrumentMgr::build ()
} else if ( name == "inst-vertical-speed-indicator" ) { // (TJ)
set_subsystem( "instrument" + temp.str(),
new InstVerticalSpeedIndicator( node ) );
} else if ( name == "tacan" ) {
set_subsystem( "instrument" + temp.str(),
new TACAN( node ) );
} else {
SG_LOG( SG_ALL, SG_ALERT, "Unknown top level section: "
<< name );

View file

@ -1096,14 +1096,20 @@ fgInitNav ()
FGNavList *gslist = new FGNavList;
FGNavList *dmelist = new FGNavList;
FGNavList *mkrlist = new FGNavList;
FGNavList *tacanlist = new FGNavList;
FGNavList *carrierlist = new FGNavList;
FGTACANList *channellist = new FGTACANList;
globals->set_navlist( navlist );
globals->set_loclist( loclist );
globals->set_gslist( gslist );
globals->set_dmelist( dmelist );
globals->set_mkrlist( mkrlist );
globals->set_tacanlist( tacanlist );
globals->set_carrierlist( carrierlist );
globals->set_channellist( channellist );
if ( !fgNavDBInit(airports, navlist, loclist, gslist, dmelist, mkrlist) ) {
if ( !fgNavDBInit(airports, navlist, loclist, gslist, dmelist, mkrlist, tacanlist, carrierlist, channellist) ) {
SG_LOG( SG_GENERAL, SG_ALERT,
"Problems loading one or more navigational database" );
}

View file

@ -82,6 +82,8 @@ FGGlobals::FGGlobals() :
gslist( NULL ),
dmelist( NULL ),
mkrlist( NULL ),
tacanlist( NULL ),
carrierlist( NULL ),
fixlist( NULL )
{
}

View file

@ -73,6 +73,7 @@ class FGControls;
class FGFlightPlanDispatcher;
class FGIO;
class FGNavList;
class FGTACANList;
class FGFixList;
class FGLight;
class FGModelMgr;
@ -205,8 +206,12 @@ private:
FGNavList *gslist;
FGNavList *dmelist;
FGNavList *mkrlist;
FGNavList *tacanlist;
FGNavList *carrierlist;
FGTACANList *channellist;
FGFixList *fixlist;
#ifdef FG_MPLAYER_AS
//Mulitplayer managers
FGMultiplayTxMgr *multiplayer_tx_mgr;
@ -371,11 +376,16 @@ public:
inline void set_gslist( FGNavList *n ) { gslist = n; }
inline FGNavList *get_dmelist() const { return dmelist; }
inline void set_dmelist( FGNavList *n ) { dmelist = n; }
inline FGNavList *get_tacanlist() const { return tacanlist; }
inline void set_tacanlist( FGNavList *n ) { tacanlist = n; }
inline FGNavList *get_carrierlist() const { return carrierlist; }
inline void set_carrierlist( FGNavList *n ) { carrierlist = n; }
inline FGNavList *get_mkrlist() const { return mkrlist; }
inline void set_mkrlist( FGNavList *n ) { mkrlist = n; }
inline FGFixList *get_fixlist() const { return fixlist; }
inline void set_fixlist( FGFixList *f ) { fixlist = f; }
inline FGTACANList *get_channellist() const { return channellist; }
inline void set_channellist( FGTACANList *c ) { channellist = c; }
/**
* Save the current state as the initial state.

View file

@ -244,7 +244,13 @@ FGRenderer::update( bool refresh_camera_settings ) {
SGAnimation::set_sim_time_sec( 0.0 );
return;
}
// return;
// TODO:TEST only, don't commit that !!
// sgFXperFrameInit();
extern void sgShaderFrameInit(double delta_time_sec);
sgShaderFrameInit(delta_time_sec);
bool draw_otw = fgGetBool("/sim/rendering/draw-otw");
bool skyblend = fgGetBool("/sim/rendering/skyblend");

View file

@ -40,7 +40,9 @@ SG_USING_STD( string );
// load and initialize the navigational databases
bool fgNavDBInit( FGAirportList *airports,
FGNavList *navlist, FGNavList *loclist, FGNavList *gslist,
FGNavList *dmelist, FGNavList *mkrlist )
FGNavList *dmelist, FGNavList *mkrlist,
FGNavList *tacanlist, FGNavList *carrierlist,
FGTACANList *channellist)
{
SG_LOG(SG_GENERAL, SG_INFO, "Loading Navaid Databases");
// SG_LOG(SG_GENERAL, SG_INFO, " VOR/NDB");
@ -83,13 +85,14 @@ bool fgNavDBInit( FGAirportList *airports,
break;
}
/* cout << "id = " << n.get_ident() << endl;
cout << " type = " << n.get_type() << endl;
cout << " lon = " << n.get_lon() << endl;
cout << " lat = " << n.get_lat() << endl;
cout << " elev = " << n.get_elev() << endl;
cout << " freq = " << n.get_freq() << endl;
cout << " range = " << n.get_range() << endl << endl; */
/*cout << "id = " << r->get_ident() << endl;
cout << " type = " << r->get_type() << endl;
cout << " lon = " << r->get_lon() << endl;
cout << " lat = " << r->get_lat() << endl;
cout << " elev = " <<r->get_elev_ft() << endl;
cout << " freq = " << r->get_freq() << endl;
cout << " range = " << r->get_range() << endl;
cout << " name = " << r->get_name() << endl << endl; */
// fudge elevation to the field elevation if it's not specified
if ( fabs(r->get_elev_ft()) < 0.01 && r->get_apt_id().length() ) {
@ -118,14 +121,105 @@ bool fgNavDBInit( FGAirportList *airports,
mkrlist->add( r );
} else if ( r->get_type() == 12 ) {
// DME=12
string str1( r->get_name() );
unsigned int loc1= str1.find( "TACAN", 0 );
unsigned int loc2 = str1.find( "VORTAC", 0 );
if( loc1 != string::npos || loc2 != string::npos ){
//cout << " name = " << r->get_name() ;
//cout << " freq = " << r->get_freq() ;
tacanlist->add( r );
}
dmelist->add( r );
}
in >> skipcomment;
}
// cout << "min freq = " << min << endl;
// cout << "max freq = " << max << endl;
// load the carrier navaids file
string file, name;
path = "";
path = globals->get_fg_root() ;
path.append( "Navaids/carrier_nav.dat" );
file = path.str();
SG_LOG( SG_GENERAL, SG_ALERT, "opening file: " << path.str() );
sg_gzifstream incarrier( path.str() );
if ( !incarrier.is_open() ) {
SG_LOG( SG_GENERAL, SG_ALERT, "Cannot open file: " << path.str() );
exit(-1);
}
// skip first two lines
//incarrier >> skipeol;
//incarrier >> skipeol;
#ifdef __MWERKS__
char c = 0;
while ( incarrier.get(c) && c != '\0' ) {
incarrier.putback(c);
#else
while ( ! incarrier.eof() ) {
#endif
FGNavRecord *r = new FGNavRecord;
incarrier >> (*r);
carrierlist->add ( r );
/*cout << " carrier lon: "<< r->get_lon() ;
cout << " carrier lat: "<< r->get_lat() ;
cout << " freq: " << r->get_freq() ;
cout << " carrier name: "<< r->get_name() << endl;*/
//if ( r->get_type() > 95 ) {
// break;}
} // end while
// end loading the carrier navaids file
// load the channel/freqency file
string channel, freq;
path="";
path = globals->get_fg_root();
path.append( "Navaids/TACAN_freq.dat" );
file = path.str();
cout << file << endl;
//
sg_gzifstream inchannel( path.str() );
if ( !inchannel.is_open() ) {
SG_LOG( SG_GENERAL, SG_ALERT, "Cannot open file: " << path.str() );
exit(-1);
}
// skip first two lines
inchannel >> skipeol;
inchannel >> skipeol;
#ifdef __MWERKS__
char c = 0;
while ( inchannel.get(c) && c != '\0' ) {
in.putback(c);
#else
while ( ! inchannel.eof() ) {
#endif
FGTACANRecord *r = new FGTACANRecord;
inchannel >> (*r);
channellist->add ( r );
//cout << "channel = " << r->get_channel() ;
//cout << " freq = " << r->get_freq() << endl;
} // end while
// end ReadChanFile
return true;
}
@ -219,3 +313,4 @@ void fgNavDBAlignLOCwithRunway( FGRunwayList *runways, FGNavList *loclist,
++freq;
}
}

View file

@ -43,8 +43,9 @@
// load and initialize the navigational databases
bool fgNavDBInit( FGAirportList *airports,
FGNavList *navlist, FGNavList *loclist, FGNavList *gslist,
FGNavList *dmelist, FGNavList *mkrbeacons );
FGNavList *dmelist, FGNavList *mkrbeacons,
FGNavList *tacanlist, FGNavList *carrierlist,
FGTACANList *channellist );
// This routines traverses the localizer list and attempts to match
// each entry with it's corresponding runway. When it is successful,
@ -54,5 +55,4 @@ bool fgNavDBInit( FGAirportList *airports,
void fgNavDBAlignLOCwithRunway( FGRunwayList *runways, FGNavList *loclist,
double threshold );
#endif // _FG_NAVDB_HXX

View file

@ -36,11 +36,16 @@
FGNavList::FGNavList( void ) {
}
FGTACANList::FGTACANList( void ){
}
// Destructor
FGNavList::~FGNavList( void ) {
}
FGTACANList::~FGTACANList( void ){
}
// load the navaids and build the map
bool FGNavList::init() {
@ -53,6 +58,10 @@ bool FGNavList::init() {
return true;
}
bool FGTACANList::init() {
return true;
}
// real add a marker beacon
static void real_add( nav_map_type &navmap, const int master_index,
@ -128,6 +137,11 @@ bool FGNavList::add( FGNavRecord *n ) {
return true;
}
// add an entry to the lists
bool FGTACANList::add( FGTACANRecord *c ) {
ident_channels[c->get_channel()].push_back(c);
return true;
}
// Query the database for the specified frequency. It is assumed that
// there will be multiple stations with matching frequencies so a
@ -137,6 +151,7 @@ FGNavRecord *FGNavList::findByFreq( double freq, double lon, double lat, double
{
nav_list_type stations = navaids[(int)(freq*100.0 + 0.5)];
Point3D aircraft = sgGeodToCart( Point3D(lon, lat, elev) );
SG_LOG( SG_INSTR, SG_DEBUG, "findbyFreq " << freq << " size " << stations.size() );
return findNavFromList( aircraft, stations );
}
@ -157,7 +172,7 @@ FGNavRecord *FGNavList::findByIdent( const char* ident,
FGNavRecord *FGNavList::findByIdentAndFreq( const char* ident, const double freq )
{
nav_list_type stations = ident_navaids[ident];
SG_LOG( SG_INSTR, SG_DEBUG, "findByIdent " << ident<< " size " << stations.size() );
if ( freq > 0.0 ) {
// sometimes there can be duplicated idents. If a freq is
// specified, use it to refine the search.
@ -321,3 +336,28 @@ FGNavRecord *FGNavList::findClosest( double lon_rad, double lat_rad,
return result;
}
// Given a TACAN Channel return the first matching frequency
FGTACANRecord *FGTACANList::findByChannel( string channel )
{
tacan_list_type stations = ident_channels[channel];
SG_LOG( SG_INSTR, SG_DEBUG, "findByChannel " << channel<< " size " << stations.size() );
if (stations.size()) {
return stations[0];
}
return NULL;
}
// Given a frequency, return the first matching station.
FGNavRecord *FGNavList::findStationByFreq( double freq )
{
nav_list_type stations = navaids[(int)(freq*100.0 + 0.5)];
SG_LOG( SG_INSTR, SG_DEBUG, "findStationByFreq " << freq << " size " << stations.size() );
if (stations.size()) {
return stations[0];
}
return NULL;
}

View file

@ -41,19 +41,22 @@ SG_USING_STD(string);
// convenience types
typedef vector < FGNavRecord* > nav_list_type;
typedef vector < FGTACANRecord* > tacan_list_type;
typedef nav_list_type::iterator nav_list_iterator;
typedef nav_list_type::const_iterator nav_list_const_iterator;
typedef map < int, nav_list_type > nav_map_type;
typedef map < int, tacan_list_type > tacan_map_type;
typedef nav_map_type::iterator nav_map_iterator;
typedef nav_map_type::const_iterator nav_map_const_iterator;
typedef map < string, nav_list_type > nav_ident_map_type;
typedef map < string, tacan_list_type > tacan_ident_map_type;
class FGNavList {
nav_list_type navlist;
nav_list_type carrierlist;
nav_map_type navaids;
nav_map_type navaids_by_tile;
nav_ident_map_type ident_navaids;
@ -73,6 +76,7 @@ public:
// add an entry
bool add( FGNavRecord *n );
//bool add( FGTACANRecord *r );
// Query the database for the specified frequency. It is assumed
// that there will be multiple stations with matching frequencies
@ -97,8 +101,40 @@ public:
// returns the closest entry to the give lon/lat/elev
FGNavRecord *findClosest( double lon_rad, double lat_rad, double elev_m );
// given a frequency returns the first matching entry
FGNavRecord *findStationByFreq( double frequency );
inline nav_map_type get_navaids() const { return navaids; }
};
class FGTACANList {
tacan_list_type channellist;
//nav_list_type carrierlist;
tacan_map_type channels;
//nav_map_type navaids_by_tile;
tacan_ident_map_type ident_channels;
// Given a point and a list of stations, return the closest one to
// the specified point.
/*FGNavRecord *findNavFromList( const Point3D &aircraft,
const nav_list_type &stations );*/
public:
FGTACANList();
~FGTACANList();
// initialize the TACAN list
bool init();
// add an entry
bool add( FGTACANRecord *r );
// Given a TACAN Channel, return the appropriate frequency.
FGTACANRecord *findByChannel( string channel );
};
#endif // _FG_NAVLIST_HXX

View file

@ -172,5 +172,36 @@ operator >> ( istream& in, FGNavRecord& n )
return in;
}
class FGTACANRecord {
string channel;
int freq;
public:
inline FGTACANRecord(void);
inline ~FGTACANRecord(void) {}
inline string get_channel() { return channel; }
inline int get_freq() const { return freq; }
friend istream& operator>> ( istream&, FGTACANRecord& );
};
inline
FGTACANRecord::FGTACANRecord(void) :
channel(""),
freq(0)
{
}
inline istream&
operator >> ( istream& in, FGTACANRecord& n )
{
in >> n.channel >> n.freq ;
//getline( in, n.name );
return in;
}
#endif // _FG_NAVRECORD_HXX