1
0
Fork 0

Beginning work on integrating radiostack model into fgfs.

This commit is contained in:
curt 2000-04-25 03:09:26 +00:00
parent 9a3b25e4fa
commit b23f930aa6
6 changed files with 48 additions and 18 deletions

View file

@ -27,6 +27,9 @@
#include "radiostack.hxx"
FGRadioStack *current_radiostack;
// Constructor
FGRadioStack::FGRadioStack() {
need_update = true;
@ -42,17 +45,16 @@ FGRadioStack::~FGRadioStack() {
void FGRadioStack::update( double lon, double lat, double elev ) {
need_update = false;
FGNav n;
// nav1
if ( current_navlist->query( lon, lat, elev, nav1_freq,
&n, &nav1_heading, &nav1_dist) ) {
FGILS ils;
if ( current_ilslist->query( lon, lat, elev, nav1_freq,
&ils, &nav1_heading, &nav1_dist) ) {
nav1_inrange = true;
nav1_lon = n.get_lon();
nav1_lat = n.get_lat();
nav1_elev = n.get_elev();
nav1_lon = ils.get_loclon();
nav1_lat = ils.get_loclat();
nav1_elev = ils.get_gselev();
cout << "Found a vor station in range" << endl;
cout << " id = " << n.get_ident() << endl;
cout << " id = " << ils.get_locident() << endl;
cout << " heading = " << nav1_heading
<< " dist = " << nav1_dist << endl;
} else {
@ -61,14 +63,15 @@ void FGRadioStack::update( double lon, double lat, double elev ) {
}
// nav1
FGNav nav;
if ( current_navlist->query( lon, lat, elev, nav2_freq,
&n, &nav2_heading, &nav2_dist) ) {
&nav, &nav2_heading, &nav2_dist) ) {
nav2_inrange = true;
nav2_lon = n.get_lon();
nav2_lat = n.get_lat();
nav2_elev = n.get_elev();
nav2_lon = nav.get_lon();
nav2_lat = nav.get_lat();
nav2_elev = nav.get_elev();
cout << "Found a vor station in range" << endl;
cout << " id = " << n.get_ident() << endl;
cout << " id = " << nav.get_ident() << endl;
cout << " heading = " << nav2_heading
<< " dist = " << nav2_dist << endl;
} else {
@ -79,13 +82,13 @@ void FGRadioStack::update( double lon, double lat, double elev ) {
// adf
double junk;
if ( current_navlist->query( lon, lat, elev, adf_freq,
&n, &adf_heading, &junk) ) {
&nav, &adf_heading, &junk) ) {
adf_inrange = true;
adf_lon = n.get_lon();
adf_lat = n.get_lat();
adf_elev = n.get_elev();
adf_lon = nav.get_lon();
adf_lat = nav.get_lat();
adf_elev = nav.get_elev();
cout << "Found an adf station in range" << endl;
cout << " id = " << n.get_ident() << endl;
cout << " id = " << nav.get_ident() << endl;
cout << " heading = " << adf_heading
<< " dist = " << junk << endl;
} else {

View file

@ -109,4 +109,7 @@ public:
};
extern FGRadioStack *current_radiostack;
#endif // _FG_RADIOSTACK_HXX

View file

@ -36,6 +36,7 @@
FG_USING_NAMESPACE(std);
#include "radiostack.hxx"
#include "steam.hxx"

View file

@ -59,6 +59,7 @@
#include <Airports/simple.hxx>
#include <Autopilot/autopilot.hxx>
#include <Cockpit/cockpit.hxx>
#include <Cockpit/radiostack.hxx>
#include <FDM/Balloon.h>
#include <FDM/External.hxx>
#include <FDM/JSBsim.hxx>
@ -469,6 +470,21 @@ bool fgInitSubsystems( void ) {
p_fix.append( "Navaids/default.fix" );
current_fixlist->init( p_fix );
// Initialize the underlying radio stack model
current_radiostack = new FGRadioStack;
current_radiostack->set_nav1_freq( 111.70 );
current_radiostack->set_nav1_radial( 280.0 );
current_radiostack->set_nav2_freq( 117.80 );
current_radiostack->set_nav2_radial( 068.0 );
current_radiostack->set_adf_freq( 210.0 );
current_radiostack->update( cur_fdm_state->get_Longitude(),
cur_fdm_state->get_Latitude(),
cur_fdm_state->get_Altitude() * FEET_TO_METER );
// Initialize the Cockpit subsystem
if( fgCockpitInit( &current_aircraft )) {
// Cockpit initialized ok.

View file

@ -78,6 +78,7 @@
#include <Autopilot/autopilot.hxx>
#include <Cockpit/cockpit.hxx>
#include <Cockpit/radiostack.hxx>
#include <Cockpit/steam.hxx>
#include <FDM/UIUCModel/uiuc_aircraft.h>
#include <FDM/UIUCModel/uiuc_aircraftdir.h>
@ -742,6 +743,11 @@ void fgUpdateTimeDepCalcs(int multi_loop, int remainder) {
// Update solar system
ephem->update( t, cur_fdm_state->get_Latitude() );
// Update radio stack model
current_radiostack->update( cur_fdm_state->get_Longitude(),
cur_fdm_state->get_Latitude(),
cur_fdm_state->get_Altitude() * FEET_TO_METER );
}

View file

@ -83,6 +83,7 @@ public:
inline double get_locheading() const { return locheading; }
inline double get_loclat() const { return loclat; }
inline double get_loclon() const { return loclon; }
inline double get_gselev() const { return gselev; }
inline double get_gsangle() const { return gsangle; }
inline double get_gslat() const { return gslat; }
inline double get_gslon() const { return gslon; }