Various tweaks and fixes to navcom radios.
Oops, taking the address of a temporary in main.cxx: 3dcloud rendering.
This commit is contained in:
parent
5eef7d7ad1
commit
29e72b0b90
7 changed files with 507 additions and 508 deletions
|
@ -70,18 +70,20 @@ FGNavCom::FGNavCom() :
|
||||||
lon_node(fgGetNode("/position/longitude-deg", true)),
|
lon_node(fgGetNode("/position/longitude-deg", true)),
|
||||||
lat_node(fgGetNode("/position/latitude-deg", true)),
|
lat_node(fgGetNode("/position/latitude-deg", true)),
|
||||||
alt_node(fgGetNode("/position/altitude-ft", true)),
|
alt_node(fgGetNode("/position/altitude-ft", true)),
|
||||||
last_nav_ident(""),
|
last_nav_id(""),
|
||||||
last_nav_vor(false),
|
last_nav_vor(false),
|
||||||
nav_play_count(0),
|
nav_play_count(0),
|
||||||
nav_last_time(0),
|
nav_last_time(0),
|
||||||
need_update(true),
|
need_update(true),
|
||||||
|
power_btn(true),
|
||||||
comm_freq(0.0),
|
comm_freq(0.0),
|
||||||
comm_alt_freq(0.0),
|
comm_alt_freq(0.0),
|
||||||
comm_vol_btn(0.0),
|
comm_vol_btn(0.0),
|
||||||
nav_freq(0.0),
|
nav_freq(0.0),
|
||||||
nav_alt_freq(0.0),
|
nav_alt_freq(0.0),
|
||||||
nav_radial(0.0),
|
nav_radial(0.0),
|
||||||
nav_vol_btn(0.0)
|
nav_vol_btn(0.0),
|
||||||
|
nav_ident_btn(true)
|
||||||
{
|
{
|
||||||
SGPath path( globals->get_fg_root() );
|
SGPath path( globals->get_fg_root() );
|
||||||
SGPath term = path;
|
SGPath term = path;
|
||||||
|
@ -124,6 +126,11 @@ FGNavCom::bind ()
|
||||||
char propname[256];
|
char propname[256];
|
||||||
|
|
||||||
// User inputs
|
// User inputs
|
||||||
|
sprintf( propname, "/radios/comm[%d]/inputs/power-btn", index );
|
||||||
|
fgTie( propname, this,
|
||||||
|
&FGNavCom::get_power_btn, &FGNavCom::set_power_btn );
|
||||||
|
fgSetArchivable( propname );
|
||||||
|
|
||||||
sprintf( propname, "/radios/comm[%d]/frequencies/selected-mhz", index );
|
sprintf( propname, "/radios/comm[%d]/frequencies/selected-mhz", index );
|
||||||
fgTie( propname, this, &FGNavCom::get_comm_freq, &FGNavCom::set_comm_freq );
|
fgTie( propname, this, &FGNavCom::get_comm_freq, &FGNavCom::set_comm_freq );
|
||||||
fgSetArchivable( propname );
|
fgSetArchivable( propname );
|
||||||
|
@ -138,11 +145,6 @@ FGNavCom::bind ()
|
||||||
&FGNavCom::get_comm_vol_btn, &FGNavCom::set_comm_vol_btn );
|
&FGNavCom::get_comm_vol_btn, &FGNavCom::set_comm_vol_btn );
|
||||||
fgSetArchivable( propname );
|
fgSetArchivable( propname );
|
||||||
|
|
||||||
sprintf( propname, "/radios/comm[%d]/ident", index );
|
|
||||||
fgTie( propname, this,
|
|
||||||
&FGNavCom::get_comm_ident_btn, &FGNavCom::set_comm_ident_btn );
|
|
||||||
fgSetArchivable( propname );
|
|
||||||
|
|
||||||
sprintf( propname, "/radios/nav[%d]/frequencies/selected-mhz", index );
|
sprintf( propname, "/radios/nav[%d]/frequencies/selected-mhz", index );
|
||||||
fgTie( propname, this,
|
fgTie( propname, this,
|
||||||
&FGNavCom::get_nav_freq, &FGNavCom::set_nav_freq );
|
&FGNavCom::get_nav_freq, &FGNavCom::set_nav_freq );
|
||||||
|
@ -194,14 +196,12 @@ FGNavCom::unbind ()
|
||||||
{
|
{
|
||||||
char propname[256];
|
char propname[256];
|
||||||
|
|
||||||
|
sprintf( propname, "/radios/comm[%d]/inputs/power-btn", index );
|
||||||
|
fgUntie( propname );
|
||||||
sprintf( propname, "/radios/comm[%d]/frequencies/selected-mhz", index );
|
sprintf( propname, "/radios/comm[%d]/frequencies/selected-mhz", index );
|
||||||
fgUntie( propname );
|
fgUntie( propname );
|
||||||
sprintf( propname, "/radios/comm[%d]/frequencies/standby-mhz", index );
|
sprintf( propname, "/radios/comm[%d]/frequencies/standby-mhz", index );
|
||||||
fgUntie( propname );
|
fgUntie( propname );
|
||||||
sprintf( propname, "/radios/comm[%d]/on", index );
|
|
||||||
fgUntie( propname );
|
|
||||||
sprintf( propname, "/radios/comm[%d]/ident", index );
|
|
||||||
fgUntie( propname );
|
|
||||||
|
|
||||||
sprintf( propname, "/radios/nav[%d]/frequencies/selected-mhz", index );
|
sprintf( propname, "/radios/nav[%d]/frequencies/selected-mhz", index );
|
||||||
fgUntie( propname );
|
fgUntie( propname );
|
||||||
|
@ -211,8 +211,6 @@ FGNavCom::unbind ()
|
||||||
fgUntie( propname );
|
fgUntie( propname );
|
||||||
sprintf( propname, "/radios/nav[%d]/radials/selected-deg", index );
|
sprintf( propname, "/radios/nav[%d]/radials/selected-deg", index );
|
||||||
fgUntie( propname );
|
fgUntie( propname );
|
||||||
sprintf( propname, "/radios/nav[%d]/on", index );
|
|
||||||
fgUntie( propname );
|
|
||||||
sprintf( propname, "/radios/nav[%d]/ident", index );
|
sprintf( propname, "/radios/nav[%d]/ident", index );
|
||||||
fgUntie( propname );
|
fgUntie( propname );
|
||||||
sprintf( propname, "/radios/nav[%d]/to-flag", index );
|
sprintf( propname, "/radios/nav[%d]/to-flag", index );
|
||||||
|
@ -308,7 +306,7 @@ FGNavCom::update(double dt)
|
||||||
// Nav.
|
// Nav.
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
if ( nav_valid ) {
|
if ( nav_valid && power_btn ) {
|
||||||
station = Point3D( nav_x, nav_y, nav_z );
|
station = Point3D( nav_x, nav_y, nav_z );
|
||||||
nav_loc_dist = aircraft.distance3D( station );
|
nav_loc_dist = aircraft.distance3D( station );
|
||||||
|
|
||||||
|
@ -363,7 +361,7 @@ FGNavCom::update(double dt)
|
||||||
if ( nav_valid && nav_inrange ) {
|
if ( nav_valid && nav_inrange ) {
|
||||||
// play station ident via audio system if on + ident,
|
// play station ident via audio system if on + ident,
|
||||||
// otherwise turn it off
|
// otherwise turn it off
|
||||||
if ( nav_vol_btn > 0.1 && nav_ident_btn ) {
|
if ( power_btn && nav_ident_btn ) {
|
||||||
FGSimpleSound *sound;
|
FGSimpleSound *sound;
|
||||||
sound = globals->get_soundmgr()->find( nav_fx_name );
|
sound = globals->get_soundmgr()->find( nav_fx_name );
|
||||||
if ( sound != NULL ) {
|
if ( sound != NULL ) {
|
||||||
|
@ -429,11 +427,11 @@ void FGNavCom::search()
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
if ( current_ilslist->query( lon, lat, elev, nav_freq, &ils ) ) {
|
if ( current_ilslist->query( lon, lat, elev, nav_freq, &ils ) ) {
|
||||||
nav_ident = ils.get_locident();
|
nav_id = ils.get_locident();
|
||||||
nav_valid = true;
|
nav_valid = true;
|
||||||
if ( last_nav_ident != nav_ident || last_nav_vor ) {
|
if ( last_nav_id != nav_id || last_nav_vor ) {
|
||||||
nav_trans_ident = ils.get_trans_ident();
|
nav_trans_ident = ils.get_trans_ident();
|
||||||
last_nav_ident = nav_ident;
|
last_nav_id = nav_id;
|
||||||
last_nav_vor = false;
|
last_nav_vor = false;
|
||||||
nav_loc = true;
|
nav_loc = true;
|
||||||
nav_has_dme = ils.get_has_dme();
|
nav_has_dme = ils.get_has_dme();
|
||||||
|
@ -489,10 +487,10 @@ void FGNavCom::search()
|
||||||
// cout << " id = " << ils.get_locident() << endl;
|
// cout << " id = " << ils.get_locident() << endl;
|
||||||
}
|
}
|
||||||
} else if ( current_navlist->query( lon, lat, elev, nav_freq, &nav ) ) {
|
} else if ( current_navlist->query( lon, lat, elev, nav_freq, &nav ) ) {
|
||||||
nav_ident = nav.get_ident();
|
nav_id = nav.get_ident();
|
||||||
nav_valid = true;
|
nav_valid = true;
|
||||||
if ( last_nav_ident != nav_ident || !last_nav_vor ) {
|
if ( last_nav_id != nav_id || !last_nav_vor ) {
|
||||||
last_nav_ident = nav_ident;
|
last_nav_id = nav_id;
|
||||||
last_nav_vor = true;
|
last_nav_vor = true;
|
||||||
nav_trans_ident = nav.get_trans_ident();
|
nav_trans_ident = nav.get_trans_ident();
|
||||||
nav_loc = false;
|
nav_loc = false;
|
||||||
|
@ -545,10 +543,10 @@ void FGNavCom::search()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nav_valid = false;
|
nav_valid = false;
|
||||||
nav_ident = "";
|
nav_id = "";
|
||||||
nav_radial = 0;
|
nav_radial = 0;
|
||||||
nav_trans_ident = "";
|
nav_trans_ident = "";
|
||||||
last_nav_ident = "";
|
last_nav_id = "";
|
||||||
#ifdef ENABLE_AUDIO_SUPPORT
|
#ifdef ENABLE_AUDIO_SUPPORT
|
||||||
if ( ! globals->get_soundmgr()->remove( nav_fx_name ) ) {
|
if ( ! globals->get_soundmgr()->remove( nav_fx_name ) ) {
|
||||||
cout << "Failed to remove nav-vor-ident sound" << endl;
|
cout << "Failed to remove nav-vor-ident sound" << endl;
|
||||||
|
|
|
@ -51,7 +51,7 @@ class FGNavCom : public FGSubsystem
|
||||||
SGPropertyNode *lat_node;
|
SGPropertyNode *lat_node;
|
||||||
SGPropertyNode *alt_node;
|
SGPropertyNode *alt_node;
|
||||||
|
|
||||||
string last_nav_ident;
|
string last_nav_id;
|
||||||
bool last_nav_vor;
|
bool last_nav_vor;
|
||||||
int nav_play_count;
|
int nav_play_count;
|
||||||
time_t nav_last_time;
|
time_t nav_last_time;
|
||||||
|
@ -62,7 +62,8 @@ class FGNavCom : public FGSubsystem
|
||||||
|
|
||||||
bool need_update;
|
bool need_update;
|
||||||
|
|
||||||
string comm_ident;
|
bool power_btn;
|
||||||
|
|
||||||
bool comm_valid;
|
bool comm_valid;
|
||||||
bool comm_inrange;
|
bool comm_inrange;
|
||||||
double comm_freq;
|
double comm_freq;
|
||||||
|
@ -77,7 +78,7 @@ class FGNavCom : public FGSubsystem
|
||||||
double comm_range;
|
double comm_range;
|
||||||
double comm_effective_range;
|
double comm_effective_range;
|
||||||
|
|
||||||
string nav_ident;
|
string nav_id;
|
||||||
string nav_trans_ident;
|
string nav_trans_ident;
|
||||||
bool nav_valid;
|
bool nav_valid;
|
||||||
bool nav_inrange;
|
bool nav_inrange;
|
||||||
|
@ -138,6 +139,12 @@ public:
|
||||||
sprintf( dme_fx_name, "dme%d-vor-ident", index );
|
sprintf( dme_fx_name, "dme%d-vor-ident", index );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NavCom Setters
|
||||||
|
inline void set_power_btn( bool val ) {
|
||||||
|
power_btn = val;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// COMM Setters
|
// COMM Setters
|
||||||
inline void set_comm_freq( double freq ) {
|
inline void set_comm_freq( double freq ) {
|
||||||
comm_freq = freq; need_update = true;
|
comm_freq = freq; need_update = true;
|
||||||
|
@ -165,6 +172,9 @@ public:
|
||||||
}
|
}
|
||||||
inline void set_nav_ident_btn( bool val ) { nav_ident_btn = val; }
|
inline void set_nav_ident_btn( bool val ) { nav_ident_btn = val; }
|
||||||
|
|
||||||
|
// NavCom Accessors
|
||||||
|
inline bool get_power_btn() const { return power_btn; }
|
||||||
|
|
||||||
// COMM Accessors
|
// COMM Accessors
|
||||||
inline double get_comm_freq () const { return comm_freq; }
|
inline double get_comm_freq () const { return comm_freq; }
|
||||||
inline double get_comm_alt_freq () const { return comm_alt_freq; }
|
inline double get_comm_alt_freq () const { return comm_alt_freq; }
|
||||||
|
|
|
@ -205,68 +205,6 @@ FGRadioStack::unbind ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// model standard VOR/DME/TACAN service volumes as per AIM 1-1-8
|
|
||||||
double FGRadioStack::adjustNavRange( double stationElev, double aircraftElev,
|
|
||||||
double nominalRange )
|
|
||||||
{
|
|
||||||
// extend out actual usable range to be 1.3x the published safe range
|
|
||||||
const double usability_factor = 1.3;
|
|
||||||
|
|
||||||
// assumptions we model the standard service volume, plus
|
|
||||||
// ... rather than specifying a cylinder, we model a cone that
|
|
||||||
// contains the cylinder. Then we put an upside down cone on top
|
|
||||||
// to model diminishing returns at too-high altitudes.
|
|
||||||
|
|
||||||
// altitude difference
|
|
||||||
double alt = ( aircraftElev * SG_METER_TO_FEET - stationElev );
|
|
||||||
// cout << "aircraft elev = " << aircraftElev * SG_METER_TO_FEET
|
|
||||||
// << " station elev = " << stationElev << endl;
|
|
||||||
|
|
||||||
if ( nominalRange < 25.0 + SG_EPSILON ) {
|
|
||||||
// Standard Terminal Service Volume
|
|
||||||
return term_tbl->interpolate( alt ) * usability_factor;
|
|
||||||
} else if ( nominalRange < 50.0 + SG_EPSILON ) {
|
|
||||||
// Standard Low Altitude Service Volume
|
|
||||||
// table is based on range of 40, scale to actual range
|
|
||||||
return low_tbl->interpolate( alt ) * nominalRange / 40.0
|
|
||||||
* usability_factor;
|
|
||||||
} else {
|
|
||||||
// Standard High Altitude Service Volume
|
|
||||||
// table is based on range of 130, scale to actual range
|
|
||||||
return high_tbl->interpolate( alt ) * nominalRange / 130.0
|
|
||||||
* usability_factor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// model standard ILS service volumes as per AIM 1-1-9
|
|
||||||
double FGRadioStack::adjustILSRange( double stationElev, double aircraftElev,
|
|
||||||
double offsetDegrees, double distance )
|
|
||||||
{
|
|
||||||
// assumptions we model the standard service volume, plus
|
|
||||||
|
|
||||||
// altitude difference
|
|
||||||
// double alt = ( aircraftElev * SG_METER_TO_FEET - stationElev );
|
|
||||||
double offset = fabs( offsetDegrees );
|
|
||||||
|
|
||||||
if ( offset < 10 ) {
|
|
||||||
return FG_ILS_DEFAULT_RANGE;
|
|
||||||
} else if ( offset < 35 ) {
|
|
||||||
return 10 + (35 - offset) * (FG_ILS_DEFAULT_RANGE - 10) / 25;
|
|
||||||
} else if ( offset < 45 ) {
|
|
||||||
return (45 - offset);
|
|
||||||
} else if ( offset > 170 ) {
|
|
||||||
return FG_ILS_DEFAULT_RANGE;
|
|
||||||
} else if ( offset > 145 ) {
|
|
||||||
return 10 + (offset - 145) * (FG_ILS_DEFAULT_RANGE - 10) / 25;
|
|
||||||
} else if ( offset > 135 ) {
|
|
||||||
return (offset - 135);
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Update the various nav values based on position and valid tuned in navs
|
// Update the various nav values based on position and valid tuned in navs
|
||||||
void
|
void
|
||||||
FGRadioStack::update(double dt)
|
FGRadioStack::update(double dt)
|
||||||
|
@ -327,6 +265,8 @@ FGRadioStack::update(double dt)
|
||||||
dme_inrange = false;
|
dme_inrange = false;
|
||||||
dme_dist = 0.0;
|
dme_dist = 0.0;
|
||||||
dme_prev_dist = 0.0;
|
dme_prev_dist = 0.0;
|
||||||
|
dme_spd = 0.0;
|
||||||
|
dme_ete = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// marker beacon blinking
|
// marker beacon blinking
|
||||||
|
@ -380,19 +320,19 @@ void FGRadioStack::search()
|
||||||
// don't worry about overhead for now,
|
// don't worry about overhead for now,
|
||||||
// since this is handled only periodically
|
// since this is handled only periodically
|
||||||
int dme_switch_pos = fgGetInt("/radios/dme/switch-position");
|
int dme_switch_pos = fgGetInt("/radios/dme/switch-position");
|
||||||
if (dme_switch_pos == 0) {
|
if ( dme_switch_pos == 1 && navcom1.get_power_btn() ) {
|
||||||
dme_freq = 0;
|
|
||||||
dme_inrange = false;
|
|
||||||
} else if (dme_switch_pos == 1) {
|
|
||||||
if ( dme_freq != navcom1.get_nav_freq() ) {
|
if ( dme_freq != navcom1.get_nav_freq() ) {
|
||||||
dme_freq = navcom1.get_nav_freq();
|
dme_freq = navcom1.get_nav_freq();
|
||||||
need_update = true;
|
need_update = true;
|
||||||
}
|
}
|
||||||
} else if (dme_switch_pos == 3) {
|
} else if ( dme_switch_pos == 3 && navcom2.get_power_btn() ) {
|
||||||
if ( dme_freq != navcom2.get_nav_freq() ) {
|
if ( dme_freq != navcom2.get_nav_freq() ) {
|
||||||
dme_freq = navcom2.get_nav_freq();
|
dme_freq = navcom2.get_nav_freq();
|
||||||
need_update = true;
|
need_update = true;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
dme_freq = 0;
|
||||||
|
dme_inrange = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FGILS ils;
|
FGILS ils;
|
||||||
|
|
|
@ -88,14 +88,6 @@ class FGRadioStack : public FGSubsystem
|
||||||
FGNavCom navcom1;
|
FGNavCom navcom1;
|
||||||
FGNavCom navcom2;
|
FGNavCom navcom2;
|
||||||
|
|
||||||
// model standard VOR/DME/TACAN service volumes as per AIM 1-1-8
|
|
||||||
double adjustNavRange( double stationElev, double aircraftElev,
|
|
||||||
double nominalRange );
|
|
||||||
|
|
||||||
// model standard ILS service volumes as per AIM 1-1-9
|
|
||||||
double adjustILSRange( double stationElev, double aircraftElev,
|
|
||||||
double offsetDegrees, double distance );
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FGRadioStack();
|
FGRadioStack();
|
||||||
|
|
|
@ -499,8 +499,8 @@ void fgRenderFrame() {
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA ) ;
|
glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA ) ;
|
||||||
if ( _bcloud_orig ) {
|
if ( _bcloud_orig ) {
|
||||||
sgClouds3d->Set_Cloud_Orig( &(globals->get_scenery()->
|
Point3D c = globals->get_scenery()->get_center();
|
||||||
get_center()) );
|
sgClouds3d->Set_Cloud_Orig( &c );
|
||||||
_bcloud_orig = false;
|
_bcloud_orig = false;
|
||||||
}
|
}
|
||||||
sgClouds3d->Update( current__view->get_absolute_view_pos() );
|
sgClouds3d->Update( current__view->get_absolute_view_pos() );
|
||||||
|
|
|
@ -398,9 +398,13 @@ bool FGATC610x::open() {
|
||||||
dme_kt = fgGetNode( "/radios/dme/speed-kt", true );
|
dme_kt = fgGetNode( "/radios/dme/speed-kt", true );
|
||||||
dme_nm = fgGetNode( "/radios/dme/distance-nm", true );
|
dme_nm = fgGetNode( "/radios/dme/distance-nm", true );
|
||||||
|
|
||||||
|
navcom1_power = fgGetNode( "/radios/comm[0]/inputs/power-btn", true );
|
||||||
|
navcom2_power = fgGetNode( "/radios/comm[1]/inputs/power-btn", true );
|
||||||
|
|
||||||
com1_freq = fgGetNode( "/radios/comm[0]/frequencies/selected-mhz", true );
|
com1_freq = fgGetNode( "/radios/comm[0]/frequencies/selected-mhz", true );
|
||||||
com1_stby_freq
|
com1_stby_freq
|
||||||
= fgGetNode( "/radios/comm[0]/frequencies/standby-mhz", true );
|
= fgGetNode( "/radios/comm[0]/frequencies/standby-mhz", true );
|
||||||
|
|
||||||
com2_freq = fgGetNode( "/radios/comm[1]/frequencies/selected-mhz", true );
|
com2_freq = fgGetNode( "/radios/comm[1]/frequencies/selected-mhz", true );
|
||||||
com2_stby_freq
|
com2_stby_freq
|
||||||
= fgGetNode( "/radios/comm[1]/frequencies/standby-mhz", true );
|
= fgGetNode( "/radios/comm[1]/frequencies/standby-mhz", true );
|
||||||
|
@ -666,10 +670,11 @@ bool FGATC610x::do_radio_switches() {
|
||||||
fgSetInt( "/radios/dme/switch-position", 3 );
|
fgSetInt( "/radios/dme/switch-position", 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Com1 Power
|
// NavCom1 Power
|
||||||
fgSetBool( "/radios/comm[0]/inputs/power-btn",
|
fgSetBool( "/radios/comm[0]/inputs/power-btn",
|
||||||
radio_switch_data[7] & 0x01 );
|
radio_switch_data[7] & 0x01 );
|
||||||
|
|
||||||
|
if ( navcom1_power->getBoolValue() ) {
|
||||||
// Com1 Swap
|
// Com1 Swap
|
||||||
int com1_swap = !((radio_switch_data[7] >> 1) & 0x01);
|
int com1_swap = !((radio_switch_data[7] >> 1) & 0x01);
|
||||||
static int last_com1_swap;
|
static int last_com1_swap;
|
||||||
|
@ -680,11 +685,13 @@ bool FGATC610x::do_radio_switches() {
|
||||||
fgSetFloat( "/radios/comm[0]/frequencies/standby-mhz", tmp );
|
fgSetFloat( "/radios/comm[0]/frequencies/standby-mhz", tmp );
|
||||||
}
|
}
|
||||||
last_com1_swap = com1_swap;
|
last_com1_swap = com1_swap;
|
||||||
|
}
|
||||||
|
|
||||||
// Com2 Power
|
// NavCom2 Power
|
||||||
fgSetBool( "/radios/comm[1]/inputs/power-btn",
|
fgSetBool( "/radios/comm[1]/inputs/power-btn",
|
||||||
radio_switch_data[15] & 0x01 );
|
radio_switch_data[15] & 0x01 );
|
||||||
|
|
||||||
|
if ( navcom2_power->getBoolValue() ) {
|
||||||
// Com2 Swap
|
// Com2 Swap
|
||||||
int com2_swap = !((radio_switch_data[15] >> 1) & 0x01);
|
int com2_swap = !((radio_switch_data[15] >> 1) & 0x01);
|
||||||
static int last_com2_swap;
|
static int last_com2_swap;
|
||||||
|
@ -695,7 +702,9 @@ bool FGATC610x::do_radio_switches() {
|
||||||
fgSetFloat( "/radios/comm[1]/frequencies/standby-mhz", tmp );
|
fgSetFloat( "/radios/comm[1]/frequencies/standby-mhz", tmp );
|
||||||
}
|
}
|
||||||
last_com2_swap = com2_swap;
|
last_com2_swap = com2_swap;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( navcom1_power->getBoolValue() ) {
|
||||||
// Nav1 Swap
|
// Nav1 Swap
|
||||||
int nav1_swap = radio_switch_data[11] & 0x01;
|
int nav1_swap = radio_switch_data[11] & 0x01;
|
||||||
static int last_nav1_swap;
|
static int last_nav1_swap;
|
||||||
|
@ -706,7 +715,9 @@ bool FGATC610x::do_radio_switches() {
|
||||||
fgSetFloat( "/radios/nav[0]/frequencies/standby-mhz", tmp );
|
fgSetFloat( "/radios/nav[0]/frequencies/standby-mhz", tmp );
|
||||||
}
|
}
|
||||||
last_nav1_swap = nav1_swap;
|
last_nav1_swap = nav1_swap;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( navcom2_power->getBoolValue() ) {
|
||||||
// Nav2 Swap
|
// Nav2 Swap
|
||||||
int nav2_swap = !(radio_switch_data[19] & 0x01);
|
int nav2_swap = !(radio_switch_data[19] & 0x01);
|
||||||
static int last_nav2_swap;
|
static int last_nav2_swap;
|
||||||
|
@ -717,7 +728,9 @@ bool FGATC610x::do_radio_switches() {
|
||||||
fgSetFloat( "/radios/nav[1]/frequencies/standby-mhz", tmp );
|
fgSetFloat( "/radios/nav[1]/frequencies/standby-mhz", tmp );
|
||||||
}
|
}
|
||||||
last_nav2_swap = nav2_swap;
|
last_nav2_swap = nav2_swap;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( navcom1_power->getBoolValue() ) {
|
||||||
// Com1 Tuner
|
// Com1 Tuner
|
||||||
int com1_tuner_fine = ((radio_switch_data[5] >> 4) & 0x0f) - 1;
|
int com1_tuner_fine = ((radio_switch_data[5] >> 4) & 0x0f) - 1;
|
||||||
int com1_tuner_coarse = (radio_switch_data[5] & 0x0f) - 1;
|
int com1_tuner_coarse = (radio_switch_data[5] & 0x0f) - 1;
|
||||||
|
@ -767,7 +780,9 @@ bool FGATC610x::do_radio_switches() {
|
||||||
|
|
||||||
fgSetFloat( "/radios/comm[0]/frequencies/standby-mhz",
|
fgSetFloat( "/radios/comm[0]/frequencies/standby-mhz",
|
||||||
coarse_freq + fine_freq / 40.0 );
|
coarse_freq + fine_freq / 40.0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( navcom2_power->getBoolValue() ) {
|
||||||
// Com2 Tuner
|
// Com2 Tuner
|
||||||
int com2_tuner_fine = ((radio_switch_data[13] >> 4) & 0x0f) - 1;
|
int com2_tuner_fine = ((radio_switch_data[13] >> 4) & 0x0f) - 1;
|
||||||
int com2_tuner_coarse = (radio_switch_data[13] & 0x0f) - 1;
|
int com2_tuner_coarse = (radio_switch_data[13] & 0x0f) - 1;
|
||||||
|
@ -817,7 +832,9 @@ bool FGATC610x::do_radio_switches() {
|
||||||
|
|
||||||
fgSetFloat( "/radios/comm[1]/frequencies/standby-mhz",
|
fgSetFloat( "/radios/comm[1]/frequencies/standby-mhz",
|
||||||
coarse_freq + fine_freq / 40.0 );
|
coarse_freq + fine_freq / 40.0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( navcom1_power->getBoolValue() ) {
|
||||||
// Nav1 Tuner
|
// Nav1 Tuner
|
||||||
int nav1_tuner_fine = ((radio_switch_data[9] >> 4) & 0x0f) - 1;
|
int nav1_tuner_fine = ((radio_switch_data[9] >> 4) & 0x0f) - 1;
|
||||||
int nav1_tuner_coarse = (radio_switch_data[9] & 0x0f) - 1;
|
int nav1_tuner_coarse = (radio_switch_data[9] & 0x0f) - 1;
|
||||||
|
@ -867,7 +884,9 @@ bool FGATC610x::do_radio_switches() {
|
||||||
|
|
||||||
fgSetFloat( "/radios/nav[0]/frequencies/standby-mhz",
|
fgSetFloat( "/radios/nav[0]/frequencies/standby-mhz",
|
||||||
coarse_freq + fine_freq / 20.0 );
|
coarse_freq + fine_freq / 20.0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( navcom2_power->getBoolValue() ) {
|
||||||
// Nav2 Tuner
|
// Nav2 Tuner
|
||||||
int nav2_tuner_fine = ((radio_switch_data[17] >> 4) & 0x0f) - 1;
|
int nav2_tuner_fine = ((radio_switch_data[17] >> 4) & 0x0f) - 1;
|
||||||
int nav2_tuner_coarse = (radio_switch_data[17] & 0x0f) - 1;
|
int nav2_tuner_coarse = (radio_switch_data[17] & 0x0f) - 1;
|
||||||
|
@ -917,7 +936,9 @@ bool FGATC610x::do_radio_switches() {
|
||||||
|
|
||||||
fgSetFloat( "/radios/nav[1]/frequencies/standby-mhz",
|
fgSetFloat( "/radios/nav[1]/frequencies/standby-mhz",
|
||||||
coarse_freq + fine_freq / 20.0);
|
coarse_freq + fine_freq / 20.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( adf_power->getBoolValue() ) {
|
||||||
// ADF Tuner
|
// ADF Tuner
|
||||||
int adf_tuner_fine = ((radio_switch_data[21] >> 4) & 0x0f) - 1;
|
int adf_tuner_fine = ((radio_switch_data[21] >> 4) & 0x0f) - 1;
|
||||||
int adf_tuner_coarse = (radio_switch_data[21] & 0x0f) - 1;
|
int adf_tuner_coarse = (radio_switch_data[21] & 0x0f) - 1;
|
||||||
|
@ -990,6 +1011,7 @@ bool FGATC610x::do_radio_switches() {
|
||||||
fgSetFloat( "/radios/kr-87/outputs/standby-khz", value );
|
fgSetFloat( "/radios/kr-87/outputs/standby-khz", value );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ADF buttons
|
// ADF buttons
|
||||||
fgSetInt( "/radios/kr-87/inputs/adf-btn",
|
fgSetInt( "/radios/kr-87/inputs/adf-btn",
|
||||||
|
@ -1130,6 +1152,7 @@ bool FGATC610x::do_radio_display() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( navcom1_power->getBoolValue() ) {
|
||||||
// Com1 standby frequency
|
// Com1 standby frequency
|
||||||
float com1_stby = com1_stby_freq->getFloatValue();
|
float com1_stby = com1_stby_freq->getFloatValue();
|
||||||
if ( fabs(com1_stby) > 999.99 ) {
|
if ( fabs(com1_stby) > 999.99 ) {
|
||||||
|
@ -1157,7 +1180,16 @@ bool FGATC610x::do_radio_display() {
|
||||||
radio_display_data[11] = 0x00 | digits[0];
|
radio_display_data[11] = 0x00 | digits[0];
|
||||||
// the 0x00 in the upper nibble of the 6th byte of each display
|
// the 0x00 in the upper nibble of the 6th byte of each display
|
||||||
// turns on the decimal point
|
// turns on the decimal point
|
||||||
|
} else {
|
||||||
|
radio_display_data[6] = 0xff;
|
||||||
|
radio_display_data[7] = 0xff;
|
||||||
|
radio_display_data[8] = 0xff;
|
||||||
|
radio_display_data[9] = 0xff;
|
||||||
|
radio_display_data[10] = 0xff;
|
||||||
|
radio_display_data[11] = 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( navcom2_power->getBoolValue() ) {
|
||||||
// Com2 standby frequency
|
// Com2 standby frequency
|
||||||
float com2_stby = com2_stby_freq->getFloatValue();
|
float com2_stby = com2_stby_freq->getFloatValue();
|
||||||
if ( fabs(com2_stby) > 999.99 ) {
|
if ( fabs(com2_stby) > 999.99 ) {
|
||||||
|
@ -1185,7 +1217,16 @@ bool FGATC610x::do_radio_display() {
|
||||||
radio_display_data[23] = 0x00 | digits[0];
|
radio_display_data[23] = 0x00 | digits[0];
|
||||||
// the 0x00 in the upper nibble of the 6th byte of each display
|
// the 0x00 in the upper nibble of the 6th byte of each display
|
||||||
// turns on the decimal point
|
// turns on the decimal point
|
||||||
|
} else {
|
||||||
|
radio_display_data[18] = 0xff;
|
||||||
|
radio_display_data[19] = 0xff;
|
||||||
|
radio_display_data[20] = 0xff;
|
||||||
|
radio_display_data[21] = 0xff;
|
||||||
|
radio_display_data[22] = 0xff;
|
||||||
|
radio_display_data[23] = 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( navcom1_power->getBoolValue() ) {
|
||||||
// Nav1 standby frequency
|
// Nav1 standby frequency
|
||||||
float nav1_stby = nav1_stby_freq->getFloatValue();
|
float nav1_stby = nav1_stby_freq->getFloatValue();
|
||||||
if ( fabs(nav1_stby) > 999.99 ) {
|
if ( fabs(nav1_stby) > 999.99 ) {
|
||||||
|
@ -1213,7 +1254,16 @@ bool FGATC610x::do_radio_display() {
|
||||||
radio_display_data[17] = 0x00 | digits[0];
|
radio_display_data[17] = 0x00 | digits[0];
|
||||||
// the 0x00 in the upper nibble of the 6th byte of each display
|
// the 0x00 in the upper nibble of the 6th byte of each display
|
||||||
// turns on the decimal point
|
// turns on the decimal point
|
||||||
|
} else {
|
||||||
|
radio_display_data[12] = 0xff;
|
||||||
|
radio_display_data[13] = 0xff;
|
||||||
|
radio_display_data[14] = 0xff;
|
||||||
|
radio_display_data[15] = 0xff;
|
||||||
|
radio_display_data[16] = 0xff;
|
||||||
|
radio_display_data[17] = 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( navcom2_power->getBoolValue() ) {
|
||||||
// Nav2 standby frequency
|
// Nav2 standby frequency
|
||||||
float nav2_stby = nav2_stby_freq->getFloatValue();
|
float nav2_stby = nav2_stby_freq->getFloatValue();
|
||||||
if ( fabs(nav2_stby) > 999.99 ) {
|
if ( fabs(nav2_stby) > 999.99 ) {
|
||||||
|
@ -1241,6 +1291,14 @@ bool FGATC610x::do_radio_display() {
|
||||||
radio_display_data[29] = 0x00 | digits[0];
|
radio_display_data[29] = 0x00 | digits[0];
|
||||||
// the 0x00 in the upper nibble of the 6th byte of each display
|
// the 0x00 in the upper nibble of the 6th byte of each display
|
||||||
// turns on the decimal point
|
// turns on the decimal point
|
||||||
|
} else {
|
||||||
|
radio_display_data[24] = 0xff;
|
||||||
|
radio_display_data[25] = 0xff;
|
||||||
|
radio_display_data[26] = 0xff;
|
||||||
|
radio_display_data[27] = 0xff;
|
||||||
|
radio_display_data[28] = 0xff;
|
||||||
|
radio_display_data[29] = 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
// ADF standby frequency / timer
|
// ADF standby frequency / timer
|
||||||
if ( adf_power->getBoolValue() ) {
|
if ( adf_power->getBoolValue() ) {
|
||||||
|
|
|
@ -73,6 +73,7 @@ class FGATC610x : public FGProtocol {
|
||||||
|
|
||||||
SGPropertyNode *mag_compass;
|
SGPropertyNode *mag_compass;
|
||||||
SGPropertyNode *dme_min, *dme_kt, *dme_nm;
|
SGPropertyNode *dme_min, *dme_kt, *dme_nm;
|
||||||
|
SGPropertyNode *navcom1_power, *navcom2_power;
|
||||||
SGPropertyNode *com1_freq, *com1_stby_freq;
|
SGPropertyNode *com1_freq, *com1_stby_freq;
|
||||||
SGPropertyNode *com2_freq, *com2_stby_freq;
|
SGPropertyNode *com2_freq, *com2_stby_freq;
|
||||||
SGPropertyNode *nav1_freq, *nav1_stby_freq;
|
SGPropertyNode *nav1_freq, *nav1_stby_freq;
|
||||||
|
|
Loading…
Add table
Reference in a new issue