Beginning work on integrating radiostack model into fgfs.
This commit is contained in:
parent
9a3b25e4fa
commit
b23f930aa6
6 changed files with 48 additions and 18 deletions
|
@ -27,6 +27,9 @@
|
||||||
#include "radiostack.hxx"
|
#include "radiostack.hxx"
|
||||||
|
|
||||||
|
|
||||||
|
FGRadioStack *current_radiostack;
|
||||||
|
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
FGRadioStack::FGRadioStack() {
|
FGRadioStack::FGRadioStack() {
|
||||||
need_update = true;
|
need_update = true;
|
||||||
|
@ -42,17 +45,16 @@ FGRadioStack::~FGRadioStack() {
|
||||||
void FGRadioStack::update( double lon, double lat, double elev ) {
|
void FGRadioStack::update( double lon, double lat, double elev ) {
|
||||||
need_update = false;
|
need_update = false;
|
||||||
|
|
||||||
FGNav n;
|
|
||||||
|
|
||||||
// nav1
|
// nav1
|
||||||
if ( current_navlist->query( lon, lat, elev, nav1_freq,
|
FGILS ils;
|
||||||
&n, &nav1_heading, &nav1_dist) ) {
|
if ( current_ilslist->query( lon, lat, elev, nav1_freq,
|
||||||
|
&ils, &nav1_heading, &nav1_dist) ) {
|
||||||
nav1_inrange = true;
|
nav1_inrange = true;
|
||||||
nav1_lon = n.get_lon();
|
nav1_lon = ils.get_loclon();
|
||||||
nav1_lat = n.get_lat();
|
nav1_lat = ils.get_loclat();
|
||||||
nav1_elev = n.get_elev();
|
nav1_elev = ils.get_gselev();
|
||||||
cout << "Found a vor station in range" << endl;
|
cout << "Found a vor station in range" << endl;
|
||||||
cout << " id = " << n.get_ident() << endl;
|
cout << " id = " << ils.get_locident() << endl;
|
||||||
cout << " heading = " << nav1_heading
|
cout << " heading = " << nav1_heading
|
||||||
<< " dist = " << nav1_dist << endl;
|
<< " dist = " << nav1_dist << endl;
|
||||||
} else {
|
} else {
|
||||||
|
@ -61,14 +63,15 @@ void FGRadioStack::update( double lon, double lat, double elev ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// nav1
|
// nav1
|
||||||
|
FGNav nav;
|
||||||
if ( current_navlist->query( lon, lat, elev, nav2_freq,
|
if ( current_navlist->query( lon, lat, elev, nav2_freq,
|
||||||
&n, &nav2_heading, &nav2_dist) ) {
|
&nav, &nav2_heading, &nav2_dist) ) {
|
||||||
nav2_inrange = true;
|
nav2_inrange = true;
|
||||||
nav2_lon = n.get_lon();
|
nav2_lon = nav.get_lon();
|
||||||
nav2_lat = n.get_lat();
|
nav2_lat = nav.get_lat();
|
||||||
nav2_elev = n.get_elev();
|
nav2_elev = nav.get_elev();
|
||||||
cout << "Found a vor station in range" << endl;
|
cout << "Found a vor station in range" << endl;
|
||||||
cout << " id = " << n.get_ident() << endl;
|
cout << " id = " << nav.get_ident() << endl;
|
||||||
cout << " heading = " << nav2_heading
|
cout << " heading = " << nav2_heading
|
||||||
<< " dist = " << nav2_dist << endl;
|
<< " dist = " << nav2_dist << endl;
|
||||||
} else {
|
} else {
|
||||||
|
@ -79,13 +82,13 @@ void FGRadioStack::update( double lon, double lat, double elev ) {
|
||||||
// adf
|
// adf
|
||||||
double junk;
|
double junk;
|
||||||
if ( current_navlist->query( lon, lat, elev, adf_freq,
|
if ( current_navlist->query( lon, lat, elev, adf_freq,
|
||||||
&n, &adf_heading, &junk) ) {
|
&nav, &adf_heading, &junk) ) {
|
||||||
adf_inrange = true;
|
adf_inrange = true;
|
||||||
adf_lon = n.get_lon();
|
adf_lon = nav.get_lon();
|
||||||
adf_lat = n.get_lat();
|
adf_lat = nav.get_lat();
|
||||||
adf_elev = n.get_elev();
|
adf_elev = nav.get_elev();
|
||||||
cout << "Found an adf station in range" << endl;
|
cout << "Found an adf station in range" << endl;
|
||||||
cout << " id = " << n.get_ident() << endl;
|
cout << " id = " << nav.get_ident() << endl;
|
||||||
cout << " heading = " << adf_heading
|
cout << " heading = " << adf_heading
|
||||||
<< " dist = " << junk << endl;
|
<< " dist = " << junk << endl;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -109,4 +109,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
extern FGRadioStack *current_radiostack;
|
||||||
|
|
||||||
|
|
||||||
#endif // _FG_RADIOSTACK_HXX
|
#endif // _FG_RADIOSTACK_HXX
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
|
|
||||||
FG_USING_NAMESPACE(std);
|
FG_USING_NAMESPACE(std);
|
||||||
|
|
||||||
|
#include "radiostack.hxx"
|
||||||
#include "steam.hxx"
|
#include "steam.hxx"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@
|
||||||
#include <Airports/simple.hxx>
|
#include <Airports/simple.hxx>
|
||||||
#include <Autopilot/autopilot.hxx>
|
#include <Autopilot/autopilot.hxx>
|
||||||
#include <Cockpit/cockpit.hxx>
|
#include <Cockpit/cockpit.hxx>
|
||||||
|
#include <Cockpit/radiostack.hxx>
|
||||||
#include <FDM/Balloon.h>
|
#include <FDM/Balloon.h>
|
||||||
#include <FDM/External.hxx>
|
#include <FDM/External.hxx>
|
||||||
#include <FDM/JSBsim.hxx>
|
#include <FDM/JSBsim.hxx>
|
||||||
|
@ -469,6 +470,21 @@ bool fgInitSubsystems( void ) {
|
||||||
p_fix.append( "Navaids/default.fix" );
|
p_fix.append( "Navaids/default.fix" );
|
||||||
current_fixlist->init( p_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
|
// Initialize the Cockpit subsystem
|
||||||
if( fgCockpitInit( ¤t_aircraft )) {
|
if( fgCockpitInit( ¤t_aircraft )) {
|
||||||
// Cockpit initialized ok.
|
// Cockpit initialized ok.
|
||||||
|
|
|
@ -78,6 +78,7 @@
|
||||||
|
|
||||||
#include <Autopilot/autopilot.hxx>
|
#include <Autopilot/autopilot.hxx>
|
||||||
#include <Cockpit/cockpit.hxx>
|
#include <Cockpit/cockpit.hxx>
|
||||||
|
#include <Cockpit/radiostack.hxx>
|
||||||
#include <Cockpit/steam.hxx>
|
#include <Cockpit/steam.hxx>
|
||||||
#include <FDM/UIUCModel/uiuc_aircraft.h>
|
#include <FDM/UIUCModel/uiuc_aircraft.h>
|
||||||
#include <FDM/UIUCModel/uiuc_aircraftdir.h>
|
#include <FDM/UIUCModel/uiuc_aircraftdir.h>
|
||||||
|
@ -742,6 +743,11 @@ void fgUpdateTimeDepCalcs(int multi_loop, int remainder) {
|
||||||
|
|
||||||
// Update solar system
|
// Update solar system
|
||||||
ephem->update( t, cur_fdm_state->get_Latitude() );
|
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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,7 @@ public:
|
||||||
inline double get_locheading() const { return locheading; }
|
inline double get_locheading() const { return locheading; }
|
||||||
inline double get_loclat() const { return loclat; }
|
inline double get_loclat() const { return loclat; }
|
||||||
inline double get_loclon() const { return loclon; }
|
inline double get_loclon() const { return loclon; }
|
||||||
|
inline double get_gselev() const { return gselev; }
|
||||||
inline double get_gsangle() const { return gsangle; }
|
inline double get_gsangle() const { return gsangle; }
|
||||||
inline double get_gslat() const { return gslat; }
|
inline double get_gslat() const { return gslat; }
|
||||||
inline double get_gslon() const { return gslon; }
|
inline double get_gslon() const { return gslon; }
|
||||||
|
|
Loading…
Reference in a new issue