Begin interfacing the navcom's to the electrical model.
This commit is contained in:
parent
427505cf37
commit
4a28902197
3 changed files with 17 additions and 29 deletions
|
@ -41,29 +41,6 @@
|
|||
SG_USING_STD(string);
|
||||
|
||||
|
||||
/**
|
||||
* Boy, this is ugly! Make the VOR range vary by altitude difference.
|
||||
*/
|
||||
static double kludgeRange ( double stationElev, double aircraftElev,
|
||||
double nominalRange)
|
||||
{
|
||||
// Assume that the nominal range (usually 50nm) applies at a 5,000
|
||||
// ft difference. Just a wild guess!
|
||||
double factor = ((aircraftElev*SG_METER_TO_FEET) - stationElev) / 5000.0;
|
||||
double range = fabs(nominalRange * factor);
|
||||
|
||||
// Clamp the range to keep it sane; for now, never less than 25%
|
||||
// or more than 500% of nominal range.
|
||||
if (range < nominalRange/4.0) {
|
||||
range = nominalRange/4.0;
|
||||
} else if (range > nominalRange*5.0) {
|
||||
range = nominalRange*5.0;
|
||||
}
|
||||
|
||||
return range;
|
||||
}
|
||||
|
||||
|
||||
// Constructor
|
||||
FGNavCom::FGNavCom() :
|
||||
lon_node(fgGetNode("/position/longitude-deg", true)),
|
||||
|
@ -123,6 +100,13 @@ FGNavCom::bind ()
|
|||
{
|
||||
char propname[256];
|
||||
|
||||
// we know index is valid now so lets bind to the bus property
|
||||
// here.
|
||||
sprintf( propname, "/systems/electrical/outputs/navcomm[%d]", index );
|
||||
// default to true in case no electrical system defined.
|
||||
fgSetDouble( propname, 60.0 );
|
||||
bus_power = fgGetNode( propname, true );
|
||||
|
||||
// User inputs
|
||||
sprintf( propname, "/radios/comm[%d]/inputs/power-btn", index );
|
||||
fgTie( propname, this,
|
||||
|
@ -304,7 +288,7 @@ FGNavCom::update(double dt)
|
|||
// Nav.
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if ( nav_valid && power_btn ) {
|
||||
if ( nav_valid && power_btn && (bus_power->getDoubleValue() > 1.0) ) {
|
||||
station = Point3D( nav_x, nav_y, nav_z );
|
||||
nav_loc_dist = aircraft.distance3D( station );
|
||||
|
||||
|
@ -359,7 +343,9 @@ FGNavCom::update(double dt)
|
|||
if ( nav_valid && nav_inrange ) {
|
||||
// play station ident via audio system if on + ident,
|
||||
// otherwise turn it off
|
||||
if ( power_btn && nav_ident_btn ) {
|
||||
if ( power_btn && (bus_power->getDoubleValue() > 1.0)
|
||||
&& nav_ident_btn )
|
||||
{
|
||||
FGSimpleSound *sound;
|
||||
sound = globals->get_soundmgr()->find( nav_fx_name );
|
||||
if ( sound != NULL ) {
|
||||
|
|
|
@ -48,6 +48,7 @@ class FGNavCom : public FGSubsystem
|
|||
SGPropertyNode *lon_node;
|
||||
SGPropertyNode *lat_node;
|
||||
SGPropertyNode *alt_node;
|
||||
SGPropertyNode *bus_power;
|
||||
|
||||
string last_nav_id;
|
||||
bool last_nav_vor;
|
||||
|
@ -171,6 +172,9 @@ public:
|
|||
inline void set_nav_ident_btn( bool val ) { nav_ident_btn = val; }
|
||||
|
||||
// NavCom Accessors
|
||||
inline bool has_power() const {
|
||||
return power_btn && (bus_power->getDoubleValue() > 1.0);
|
||||
}
|
||||
inline bool get_power_btn() const { return power_btn; }
|
||||
|
||||
// COMM Accessors
|
||||
|
|
|
@ -320,12 +320,12 @@ void FGRadioStack::search()
|
|||
// don't worry about overhead for now,
|
||||
// since this is handled only periodically
|
||||
int dme_switch_pos = fgGetInt("/radios/dme/switch-position");
|
||||
if ( dme_switch_pos == 1 && navcom1.get_power_btn() ) {
|
||||
if ( dme_switch_pos == 1 && navcom1.has_power() ) {
|
||||
if ( dme_freq != navcom1.get_nav_freq() ) {
|
||||
dme_freq = navcom1.get_nav_freq();
|
||||
need_update = true;
|
||||
}
|
||||
} else if ( dme_switch_pos == 3 && navcom2.get_power_btn() ) {
|
||||
} else if ( dme_switch_pos == 3 && navcom2.has_power() ) {
|
||||
if ( dme_freq != navcom2.get_nav_freq() ) {
|
||||
dme_freq = navcom2.get_nav_freq();
|
||||
need_update = true;
|
||||
|
@ -440,8 +440,6 @@ void FGRadioStack::search()
|
|||
}
|
||||
last_beacon = beacon_type;
|
||||
|
||||
navcom1.search();
|
||||
navcom2.search();
|
||||
adf.search();
|
||||
xponder.search();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue