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());
}
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,
wave_off_lights = true;
}
- cout << "rel wind: " << rel_wind << endl;
+ // cout << "rel wind: " << rel_wind << endl;
}// end update wind
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);
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);
//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) {
_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(),
AirportList::~AirportList ()
{
- for (unsigned int i = 0; i < _nAirports; i++) {
+ for (int i = 0; i < _nAirports; i++) {
delete _content[i];
_content[i] = 0;
}
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
#include "turn_indicator.hxx"
#include "vertical_speed_indicator.hxx"
#include "inst_vertical_speed_indicator.hxx" // (TJ)
+#include "tacan.hxx"
FGInstrumentMgr::FGInstrumentMgr ()
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" ) {
} 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 );
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" );
}
gslist( NULL ),
dmelist( NULL ),
mkrlist( NULL ),
+ tacanlist( NULL ),
+ carrierlist( NULL ),
fixlist( NULL )
{
}
class FGFlightPlanDispatcher;
class FGIO;
class FGNavList;
+class FGTACANList;
class FGFixList;
class FGLight;
class FGModelMgr;
FGNavList *gslist;
FGNavList *dmelist;
FGNavList *mkrlist;
+ FGNavList *tacanlist;
+ FGNavList *carrierlist;
+ FGTACANList *channellist;
FGFixList *fixlist;
+
#ifdef FG_MPLAYER_AS
//Mulitplayer managers
FGMultiplayTxMgr *multiplayer_tx_mgr;
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.
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");
// 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");
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() ) {
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;
}
++freq;
}
}
+
// 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,
void fgNavDBAlignLOCwithRunway( FGRunwayList *runways, FGNavList *loclist,
double threshold );
-
#endif // _FG_NAVDB_HXX
FGNavList::FGNavList( void ) {
}
+FGTACANList::FGTACANList( void ){
+}
+
// Destructor
FGNavList::~FGNavList( void ) {
}
+FGTACANList::~FGTACANList( void ){
+}
// load the navaids and build the map
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,
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
{
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 );
}
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.
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;
+}
// 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;
// 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
// 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
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