A bunch of reorg and clean up of the KR 87 (adf) code including some
property renaming with corresponding changes to instruments in the base package.
This commit is contained in:
parent
24d14dd421
commit
2fec1506d3
5 changed files with 229 additions and 177 deletions
|
@ -75,8 +75,14 @@ FGKR_87::FGKR_87() :
|
||||||
alt_node(fgGetNode("/position/altitude-ft", true)),
|
alt_node(fgGetNode("/position/altitude-ft", true)),
|
||||||
need_update(true),
|
need_update(true),
|
||||||
valid(false),
|
valid(false),
|
||||||
freq(0.0),
|
inrange(false),
|
||||||
stby_freq(0.0),
|
goal_needle_deg(0.0),
|
||||||
|
et_flash_time(0.0),
|
||||||
|
ant_mode(0),
|
||||||
|
stby_mode(0),
|
||||||
|
timer_mode(0),
|
||||||
|
count_mode(0),
|
||||||
|
rotation(0),
|
||||||
on_off_vol_btn(0.5),
|
on_off_vol_btn(0.5),
|
||||||
adf_btn(true),
|
adf_btn(true),
|
||||||
bfo_btn(false),
|
bfo_btn(false),
|
||||||
|
@ -86,15 +92,12 @@ FGKR_87::FGKR_87() :
|
||||||
last_flt_et_btn(false),
|
last_flt_et_btn(false),
|
||||||
set_rst_btn(false),
|
set_rst_btn(false),
|
||||||
last_set_rst_btn(false),
|
last_set_rst_btn(false),
|
||||||
goal_needle_deg(0.0),
|
freq(0.0),
|
||||||
|
stby_freq(0.0),
|
||||||
needle_deg(0.0),
|
needle_deg(0.0),
|
||||||
flight_timer(0.0),
|
flight_timer(0.0),
|
||||||
elapsed_timer(0.0),
|
elapsed_timer(0.0),
|
||||||
tmp_timer(0.0),
|
tmp_timer(0.0)
|
||||||
ant_mode(0),
|
|
||||||
stby_mode(0),
|
|
||||||
timer_mode(0),
|
|
||||||
count_mode(0)
|
|
||||||
{
|
{
|
||||||
SGPath path( globals->get_fg_root() );
|
SGPath path( globals->get_fg_root() );
|
||||||
SGPath term = path;
|
SGPath term = path;
|
||||||
|
@ -130,83 +133,114 @@ FGKR_87::init ()
|
||||||
void
|
void
|
||||||
FGKR_87::bind ()
|
FGKR_87::bind ()
|
||||||
{
|
{
|
||||||
// User inputs
|
// internal values
|
||||||
fgTie("/radios/kr-87/frequencies/selected-khz", this,
|
fgTie("/radios/kr-87/internal/ident", this,
|
||||||
&FGKR_87::get_freq, &FGKR_87::set_freq);
|
|
||||||
fgSetArchivable("/radios/kr-87/frequencies/selected-khz");
|
|
||||||
fgTie("/radios/kr-87/frequencies/standby-khz", this,
|
|
||||||
&FGKR_87::get_stby_freq, &FGKR_87::set_stby_freq);
|
|
||||||
fgSetArchivable("/radios/kr-87/frequencies/standby-khz");
|
|
||||||
fgTie("/radios/kr-87/rotation-deg", this,
|
|
||||||
&FGKR_87::get_rotation, &FGKR_87::set_rotation);
|
|
||||||
fgSetArchivable("/radios/kr-87/rotation-deg");
|
|
||||||
fgTie("/radios/kr-87/needle-deg", this,
|
|
||||||
&FGKR_87::get_needle_deg);
|
|
||||||
fgTie("/radios/kr-87/on-off-volume", this,
|
|
||||||
&FGKR_87::get_on_off_vol_btn,
|
|
||||||
&FGKR_87::set_on_off_vol_btn);
|
|
||||||
fgSetArchivable("/radios/kr-87/on-off-volume");
|
|
||||||
fgTie("/radios/kr-87/adf-btn", this,
|
|
||||||
&FGKR_87::get_adf_btn,
|
|
||||||
&FGKR_87::set_adf_btn);
|
|
||||||
fgTie("/radios/kr-87/bfo-btn", this,
|
|
||||||
&FGKR_87::get_bfo_btn,
|
|
||||||
&FGKR_87::set_bfo_btn);
|
|
||||||
fgTie("/radios/kr-87/frq-btn", this,
|
|
||||||
&FGKR_87::get_frq_btn,
|
|
||||||
&FGKR_87::set_frq_btn);
|
|
||||||
fgTie("/radios/kr-87/flt-et-btn", this,
|
|
||||||
&FGKR_87::get_flt_et_btn,
|
|
||||||
&FGKR_87::set_flt_et_btn);
|
|
||||||
fgTie("/radios/kr-87/set-rst-btn", this,
|
|
||||||
&FGKR_87::get_set_rst_btn,
|
|
||||||
&FGKR_87::set_set_rst_btn);
|
|
||||||
fgTie("/radios/kr-87/stby-mode", this,
|
|
||||||
&FGKR_87::get_stby_mode);
|
|
||||||
fgTie("/radios/kr-87/timer-mode", this,
|
|
||||||
&FGKR_87::get_timer_mode);
|
|
||||||
fgTie("/radios/kr-87/count-mode", this,
|
|
||||||
&FGKR_87::get_count_mode);
|
|
||||||
fgTie("/radios/kr-87/ident", this,
|
|
||||||
&FGKR_87::get_ident_btn,
|
&FGKR_87::get_ident_btn,
|
||||||
&FGKR_87::set_ident_btn);
|
&FGKR_87::set_ident_btn);
|
||||||
fgSetArchivable("/radios/kr-87/ident");
|
fgSetArchivable("/radios/kr-87/internal/ident");
|
||||||
|
fgTie("/radios/kr-87/internal/inrange", this, &FGKR_87::get_inrange);
|
||||||
|
fgTie("/radios/kr-87/internal/heading", this, &FGKR_87::get_heading);
|
||||||
|
|
||||||
// calculated values
|
// modes
|
||||||
fgTie("/radios/kr-87/inrange", this, &FGKR_87::get_inrange);
|
fgTie("/radios/kr-87/modes/ant", this,
|
||||||
fgTie("/radios/kr-87/heading", this, &FGKR_87::get_heading);
|
&FGKR_87::get_ant_mode);
|
||||||
fgTie("/radios/kr-87/flight-timer", this, &FGKR_87::get_flight_timer);
|
fgTie("/radios/kr-87/modes/stby", this,
|
||||||
fgTie("/radios/kr-87/elapsed-timer", this,
|
&FGKR_87::get_stby_mode);
|
||||||
|
fgTie("/radios/kr-87/modes/timer", this,
|
||||||
|
&FGKR_87::get_timer_mode);
|
||||||
|
fgTie("/radios/kr-87/modes/count", this,
|
||||||
|
&FGKR_87::get_count_mode);
|
||||||
|
|
||||||
|
// input and buttons
|
||||||
|
fgTie("/radios/kr-87/inputs/rotation-deg", this,
|
||||||
|
&FGKR_87::get_rotation, &FGKR_87::set_rotation);
|
||||||
|
fgSetArchivable("/radios/kr-87/inputs/rotation-deg");
|
||||||
|
fgTie("/radios/kr-87/inputs/on-off-volume", this,
|
||||||
|
&FGKR_87::get_on_off_vol_btn,
|
||||||
|
&FGKR_87::set_on_off_vol_btn);
|
||||||
|
fgSetArchivable("/radios/kr-87/inputs/on-off-volume");
|
||||||
|
fgTie("/radios/kr-87/inputs/adf-btn", this,
|
||||||
|
&FGKR_87::get_adf_btn,
|
||||||
|
&FGKR_87::set_adf_btn);
|
||||||
|
fgTie("/radios/kr-87/inputs/bfo-btn", this,
|
||||||
|
&FGKR_87::get_bfo_btn,
|
||||||
|
&FGKR_87::set_bfo_btn);
|
||||||
|
fgTie("/radios/kr-87/inputs/frq-btn", this,
|
||||||
|
&FGKR_87::get_frq_btn,
|
||||||
|
&FGKR_87::set_frq_btn);
|
||||||
|
fgTie("/radios/kr-87/inputs/flt-et-btn", this,
|
||||||
|
&FGKR_87::get_flt_et_btn,
|
||||||
|
&FGKR_87::set_flt_et_btn);
|
||||||
|
fgTie("/radios/kr-87/inputs/set-rst-btn", this,
|
||||||
|
&FGKR_87::get_set_rst_btn,
|
||||||
|
&FGKR_87::set_set_rst_btn);
|
||||||
|
|
||||||
|
// outputs
|
||||||
|
fgTie("/radios/kr-87/outputs/selected-khz", this,
|
||||||
|
&FGKR_87::get_freq, &FGKR_87::set_freq);
|
||||||
|
fgSetArchivable("/radios/kr-87/outputs/selected-khz");
|
||||||
|
fgTie("/radios/kr-87/outputs/standby-khz", this,
|
||||||
|
&FGKR_87::get_stby_freq, &FGKR_87::set_stby_freq);
|
||||||
|
fgSetArchivable("/radios/kr-87/outputs/standby-khz");
|
||||||
|
fgTie("/radios/kr-87/outputs/needle-deg", this,
|
||||||
|
&FGKR_87::get_needle_deg);
|
||||||
|
fgTie("/radios/kr-87/outputs/flight-timer", this, &FGKR_87::get_flight_timer);
|
||||||
|
fgTie("/radios/kr-87/outputs/elapsed-timer", this,
|
||||||
&FGKR_87::get_elapsed_timer,
|
&FGKR_87::get_elapsed_timer,
|
||||||
&FGKR_87::set_elapsed_timer);
|
&FGKR_87::set_elapsed_timer);
|
||||||
|
|
||||||
|
// annunciators
|
||||||
|
fgTie("/radios/kr-87/annunciators/ant", this, &FGKR_87::get_ant_ann );
|
||||||
|
fgTie("/radios/kr-87/annunciators/adf", this, &FGKR_87::get_adf_ann );
|
||||||
|
fgTie("/radios/kr-87/annunciators/bfo", this, &FGKR_87::get_bfo_ann );
|
||||||
|
fgTie("/radios/kr-87/annunciators/frq", this, &FGKR_87::get_frq_ann );
|
||||||
|
fgTie("/radios/kr-87/annunciators/flt", this, &FGKR_87::get_flt_ann );
|
||||||
|
fgTie("/radios/kr-87/annunciators/et", this, &FGKR_87::get_et_ann );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGKR_87::unbind ()
|
FGKR_87::unbind ()
|
||||||
{
|
{
|
||||||
fgUntie("/radios/kr-87/frequencies/selected-khz");
|
// internal values
|
||||||
fgUntie("/radios/kr-87/frequencies/standby-khz");
|
fgUntie("/radios/kr-87/internal/ident");
|
||||||
fgUntie("/radios/kr-87/rotation-deg");
|
fgUntie("/radios/kr-87/internal/inrange");
|
||||||
fgUntie("/radios/kr-87/needle-deg");
|
fgUntie("/radios/kr-87/internal/heading");
|
||||||
fgUntie("/radios/kr-87/on-off-volume");
|
|
||||||
fgUntie("/radios/kr-87/adf-btn");
|
// modes
|
||||||
fgUntie("/radios/kr-87/bfo-btn");
|
fgUntie("/radios/kr-87/modes/ant");
|
||||||
fgUntie("/radios/kr-87/frq-btn");
|
fgUntie("/radios/kr-87/modes/stby");
|
||||||
fgUntie("/radios/kr-87/flt-et-btn");
|
fgUntie("/radios/kr-87/modes/timer");
|
||||||
fgUntie("/radios/kr-87/set-rst-btn");
|
fgUntie("/radios/kr-87/modes/count");
|
||||||
fgUntie("/radios/kr-87/timer-mode");
|
|
||||||
fgUntie("/radios/kr-87/count-mode");
|
// input and buttons
|
||||||
fgUntie("/radios/kr-87/ident");
|
fgUntie("/radios/kr-87/inputs/rotation-deg");
|
||||||
fgUntie("/radios/kr-87/inrange");
|
fgUntie("/radios/kr-87/inputs/on-off-volume");
|
||||||
fgUntie("/radios/kr-87/heading");
|
fgUntie("/radios/kr-87/inputs/adf-btn");
|
||||||
fgUntie("/radios/kr-87/flight-timer");
|
fgUntie("/radios/kr-87/inputs/bfo-btn");
|
||||||
fgUntie("/radios/kr-87/elapsed-timer");
|
fgUntie("/radios/kr-87/inputs/frq-btn");
|
||||||
|
fgUntie("/radios/kr-87/inputs/flt-et-btn");
|
||||||
|
fgUntie("/radios/kr-87/inputs/set-rst-btn");
|
||||||
|
|
||||||
|
// outputs
|
||||||
|
fgUntie("/radios/kr-87/outputs/selected-khz");
|
||||||
|
fgUntie("/radios/kr-87/outputs/standby-khz");
|
||||||
|
fgUntie("/radios/kr-87/outputs/needle-deg");
|
||||||
|
fgUntie("/radios/kr-87/outputs/flight-timer");
|
||||||
|
fgUntie("/radios/kr-87/outputs/elapsed-timer");
|
||||||
|
|
||||||
|
// annunciators
|
||||||
|
fgUntie("/radios/kr-87/annunciators/ant");
|
||||||
|
fgUntie("/radios/kr-87/annunciators/adf");
|
||||||
|
fgUntie("/radios/kr-87/annunciators/bfo");
|
||||||
|
fgUntie("/radios/kr-87/annunciators/frq");
|
||||||
|
fgUntie("/radios/kr-87/annunciators/flt");
|
||||||
|
fgUntie("/radios/kr-87/annunciators/et");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 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
|
||||||
FGKR_87::update(double dt)
|
FGKR_87::update( double dt )
|
||||||
{
|
{
|
||||||
double acft_lon = lon_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
|
double acft_lon = lon_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
|
||||||
double acft_lat = lat_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
|
double acft_lat = lat_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
|
||||||
|
@ -296,6 +330,25 @@ FGKR_87::update(double dt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// annunciators
|
||||||
|
ant_ann = adf_btn;
|
||||||
|
adf_ann = !adf_btn;
|
||||||
|
bfo_ann = bfo_btn;
|
||||||
|
frq_ann = !stby_mode;
|
||||||
|
flt_ann = stby_mode && !timer_mode;
|
||||||
|
if ( count_mode < 2 ) {
|
||||||
|
et_ann = stby_mode && timer_mode;
|
||||||
|
} else {
|
||||||
|
et_flash_time += dt;
|
||||||
|
if ( et_ann && et_flash_time > 0.5 ) {
|
||||||
|
et_ann = false;
|
||||||
|
et_flash_time -= 0.5;
|
||||||
|
} else if ( !et_ann && et_flash_time > 0.2 ) {
|
||||||
|
et_ann = true;
|
||||||
|
et_flash_time -= 0.2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( valid ) {
|
if ( valid ) {
|
||||||
// staightline distance
|
// staightline distance
|
||||||
station = Point3D( x, y, z );
|
station = Point3D( x, y, z );
|
||||||
|
@ -334,9 +387,16 @@ FGKR_87::update(double dt)
|
||||||
goal_needle_deg = 90.0;
|
goal_needle_deg = 90.0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// unit turned off
|
||||||
goal_needle_deg = 0.0;
|
goal_needle_deg = 0.0;
|
||||||
flight_timer = 0.0;
|
flight_timer = 0.0;
|
||||||
elapsed_timer = 0.0;
|
elapsed_timer = 0.0;
|
||||||
|
ant_ann = false;
|
||||||
|
adf_ann = false;
|
||||||
|
bfo_ann = false;
|
||||||
|
frq_ann = false;
|
||||||
|
flt_ann = false;
|
||||||
|
et_ann = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -53,13 +53,11 @@ class FGKR_87 : public FGSubsystem
|
||||||
|
|
||||||
bool need_update;
|
bool need_update;
|
||||||
|
|
||||||
|
// internal values
|
||||||
string ident;
|
string ident;
|
||||||
string trans_ident;
|
string trans_ident;
|
||||||
bool valid;
|
bool valid;
|
||||||
bool inrange;
|
bool inrange;
|
||||||
double freq;
|
|
||||||
double stby_freq;
|
|
||||||
double rotation;
|
|
||||||
double stn_lon;
|
double stn_lon;
|
||||||
double stn_lat;
|
double stn_lat;
|
||||||
double stn_elev;
|
double stn_elev;
|
||||||
|
@ -70,7 +68,19 @@ class FGKR_87 : public FGSubsystem
|
||||||
double x;
|
double x;
|
||||||
double y;
|
double y;
|
||||||
double z;
|
double z;
|
||||||
|
double goal_needle_deg;
|
||||||
|
double et_flash_time;
|
||||||
|
|
||||||
|
// modes
|
||||||
|
int ant_mode; // 0 = ADF mode (needle active), 1 = ANT mode
|
||||||
|
// (needle turned to 90, improved audio rcpt)
|
||||||
|
int stby_mode; // 0 = show stby freq, 1 = show timer
|
||||||
|
int timer_mode; // 0 = flt, 1 = et
|
||||||
|
int count_mode; // 0 = count up, 1 = count down, 2 = set et
|
||||||
|
// count down
|
||||||
|
|
||||||
|
// input and buttons
|
||||||
|
double rotation; // compass faceplace rotation
|
||||||
double on_off_vol_btn;
|
double on_off_vol_btn;
|
||||||
bool adf_btn; // 0 = normal, 1 = depressed
|
bool adf_btn; // 0 = normal, 1 = depressed
|
||||||
bool bfo_btn; // 0 = normal, 1 = depressed
|
bool bfo_btn; // 0 = normal, 1 = depressed
|
||||||
|
@ -79,21 +89,24 @@ class FGKR_87 : public FGSubsystem
|
||||||
bool flt_et_btn; // 0 = normal, 1 = depressed
|
bool flt_et_btn; // 0 = normal, 1 = depressed
|
||||||
bool last_flt_et_btn;
|
bool last_flt_et_btn;
|
||||||
bool set_rst_btn; // 0 = normal, 1 = depressed
|
bool set_rst_btn; // 0 = normal, 1 = depressed
|
||||||
bool last_set_rst_btn; // 0 = normal, 1 = depressed
|
bool last_set_rst_btn; // 0 = normal, 1 = depressed
|
||||||
bool ident_btn; // ???
|
bool ident_btn; // ???
|
||||||
|
|
||||||
double goal_needle_deg;
|
// outputs
|
||||||
|
double freq;
|
||||||
|
double stby_freq;
|
||||||
double needle_deg;
|
double needle_deg;
|
||||||
double flight_timer;
|
double flight_timer;
|
||||||
double elapsed_timer;
|
double elapsed_timer;
|
||||||
double tmp_timer;
|
double tmp_timer;
|
||||||
|
|
||||||
int ant_mode; // 0 = ADF mode (needle active), 1 = ANT mode
|
// annunciators
|
||||||
// (needle turned to 90, improved audio rcpt)
|
bool ant_ann;
|
||||||
int stby_mode; // 0 = show stby freq, 1 = show timer
|
bool adf_ann;
|
||||||
int timer_mode; // 0 = flt, 1 = et
|
bool bfo_ann;
|
||||||
int count_mode; // 0 = count up, 1 = count down, 2 = set et
|
bool frq_ann;
|
||||||
// count down
|
bool flt_ann;
|
||||||
|
bool et_ann;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -108,50 +121,60 @@ public:
|
||||||
// Update nav/adf radios based on current postition
|
// Update nav/adf radios based on current postition
|
||||||
void search ();
|
void search ();
|
||||||
|
|
||||||
// ADF Setters
|
// internal values
|
||||||
inline void set_freq( double f ) {
|
inline bool get_inrange() const { return inrange; }
|
||||||
freq = f; need_update = true;
|
inline double get_stn_lon() const { return stn_lon; }
|
||||||
}
|
inline double get_stn_lat() const { return stn_lat; }
|
||||||
inline void set_stby_freq( double freq ) { stby_freq = freq; }
|
inline double get_heading() const { return heading; }
|
||||||
|
|
||||||
|
// modes
|
||||||
|
inline int get_ant_mode() const { return ant_mode; }
|
||||||
|
inline int get_stby_mode() const { return stby_mode; }
|
||||||
|
inline int get_timer_mode() const { return timer_mode; }
|
||||||
|
inline int get_count_mode() const { return count_mode; }
|
||||||
|
|
||||||
|
// input and buttons
|
||||||
|
inline double get_rotation () const { return rotation; }
|
||||||
inline void set_rotation( double rot ) { rotation = rot; }
|
inline void set_rotation( double rot ) { rotation = rot; }
|
||||||
|
inline double get_on_off_vol_btn() const { return on_off_vol_btn; }
|
||||||
inline void set_on_off_vol_btn( double val ) {
|
inline void set_on_off_vol_btn( double val ) {
|
||||||
if ( val < 0.0 ) val = 0.0;
|
if ( val < 0.0 ) val = 0.0;
|
||||||
if ( val > 1.0 ) val = 1.0;
|
if ( val > 1.0 ) val = 1.0;
|
||||||
on_off_vol_btn = val;
|
on_off_vol_btn = val;
|
||||||
}
|
}
|
||||||
inline void set_ident_btn( bool val ) { ident_btn = val; }
|
inline bool get_adf_btn() const { return adf_btn; }
|
||||||
inline void set_adf_btn( bool val ) { adf_btn = val; }
|
inline void set_adf_btn( bool val ) { adf_btn = val; }
|
||||||
|
inline bool get_bfo_btn() const { return bfo_btn; }
|
||||||
inline void set_bfo_btn( bool val ) { bfo_btn = val; }
|
inline void set_bfo_btn( bool val ) { bfo_btn = val; }
|
||||||
|
inline bool get_frq_btn() const { return frq_btn; }
|
||||||
inline void set_frq_btn( bool val ) { frq_btn = val; }
|
inline void set_frq_btn( bool val ) { frq_btn = val; }
|
||||||
|
inline bool get_flt_et_btn() const { return flt_et_btn; }
|
||||||
inline void set_flt_et_btn( bool val ) { flt_et_btn = val; }
|
inline void set_flt_et_btn( bool val ) { flt_et_btn = val; }
|
||||||
|
inline bool get_set_rst_btn() const { return set_rst_btn; }
|
||||||
inline void set_set_rst_btn( bool val ) { set_rst_btn = val; }
|
inline void set_set_rst_btn( bool val ) { set_rst_btn = val; }
|
||||||
inline void set_elapsed_timer( double val ) { elapsed_timer = val; }
|
inline bool get_ident_btn() const { return ident_btn; }
|
||||||
|
inline void set_ident_btn( bool val ) { ident_btn = val; }
|
||||||
|
|
||||||
// ADF Accessors
|
// outputs
|
||||||
inline double get_freq () const { return freq; }
|
inline double get_freq () const { return freq; }
|
||||||
|
inline void set_freq( double f ) {
|
||||||
|
freq = f;
|
||||||
|
need_update = true;
|
||||||
|
}
|
||||||
double get_stby_freq () const;
|
double get_stby_freq () const;
|
||||||
inline double get_rotation () const { return rotation; }
|
inline void set_stby_freq( double freq ) { stby_freq = freq; }
|
||||||
|
|
||||||
// Calculated values
|
|
||||||
inline bool get_inrange() const { return inrange; }
|
|
||||||
inline double get_stn_lon() const { return stn_lon; }
|
|
||||||
inline double get_stn_lat() const { return stn_lat; }
|
|
||||||
inline double get_heading() const { return heading; }
|
|
||||||
inline double get_needle_deg() const { return needle_deg; }
|
inline double get_needle_deg() const { return needle_deg; }
|
||||||
inline double get_flight_timer() const { return flight_timer; }
|
inline double get_flight_timer() const { return flight_timer; }
|
||||||
inline double get_elapsed_timer() const { return elapsed_timer; }
|
inline double get_elapsed_timer() const { return elapsed_timer; }
|
||||||
inline double get_on_off_vol_btn() const { return on_off_vol_btn; }
|
inline void set_elapsed_timer( double val ) { elapsed_timer = val; }
|
||||||
inline int get_stby_mode() const { return stby_mode; }
|
|
||||||
inline int get_timer_mode() const { return timer_mode; }
|
|
||||||
inline int get_count_mode() const { return count_mode; }
|
|
||||||
|
|
||||||
// physical inputs
|
// annunciators
|
||||||
inline bool get_ident_btn() const { return ident_btn; }
|
inline bool get_ant_ann() const { return ant_ann; }
|
||||||
inline bool get_adf_btn() const { return adf_btn; }
|
inline bool get_adf_ann() const { return adf_ann; }
|
||||||
inline bool get_bfo_btn() const { return bfo_btn; }
|
inline bool get_bfo_ann() const { return bfo_ann; }
|
||||||
inline bool get_frq_btn() const { return frq_btn; }
|
inline bool get_frq_ann() const { return frq_ann; }
|
||||||
inline bool get_flt_et_btn() const { return flt_et_btn; }
|
inline bool get_flt_ann() const { return flt_ann; }
|
||||||
inline bool get_set_rst_btn() const { return set_rst_btn; }
|
inline bool get_et_ann() const { return et_ann; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -396,16 +396,23 @@ bool FGATC610x::open() {
|
||||||
nav2_stby_freq
|
nav2_stby_freq
|
||||||
= fgGetNode( "/radios/nav[1]/frequencies/standby-mhz", true );
|
= fgGetNode( "/radios/nav[1]/frequencies/standby-mhz", true );
|
||||||
|
|
||||||
adf_on_off_vol = fgGetNode( "/radios/kr-87/on-off-volume", true );
|
adf_on_off_vol = fgGetNode( "/radios/kr-87/inputs/on-off-volume", true );
|
||||||
adf_adf_btn = fgGetNode( "/radios/kr-87/adf-btn", true );
|
adf_adf_btn = fgGetNode( "/radios/kr-87/inputs/adf-btn", true );
|
||||||
adf_bfo_btn = fgGetNode( "/radios/kr-87/bfo-btn", true );
|
adf_bfo_btn = fgGetNode( "/radios/kr-87/inputs/bfo-btn", true );
|
||||||
adf_freq = fgGetNode( "/radios/kr-87/frequencies/selected-khz", true );
|
adf_freq = fgGetNode( "/radios/kr-87/outputs/selected-khz", true );
|
||||||
adf_stby_freq = fgGetNode( "/radios/kr-87/frequencies/standby-khz", true );
|
adf_stby_freq = fgGetNode( "/radios/kr-87/outputs/standby-khz", true );
|
||||||
adf_stby_mode = fgGetNode( "/radios/kr-87/stby-mode", true );
|
adf_stby_mode = fgGetNode( "/radios/kr-87/modes/stby", true );
|
||||||
adf_timer_mode = fgGetNode( "/radios/kr-87/timer-mode", true );
|
adf_timer_mode = fgGetNode( "/radios/kr-87/modes/timer", true );
|
||||||
adf_count_mode = fgGetNode( "/radios/kr-87/count-mode", true );
|
adf_count_mode = fgGetNode( "/radios/kr-87/modes/count", true );
|
||||||
adf_flight_timer = fgGetNode( "/radios/kr-87/flight-timer", true );
|
adf_flight_timer = fgGetNode( "/radios/kr-87/outputs/flight-timer", true );
|
||||||
adf_elapsed_timer = fgGetNode( "/radios/kr-87/elapsed-timer", true );
|
adf_elapsed_timer = fgGetNode( "/radios/kr-87/outputs/elapsed-timer",
|
||||||
|
true );
|
||||||
|
adf_ant_ann = fgGetNode( "/radios/kr-87/annunciators/ant", true );
|
||||||
|
adf_adf_ann = fgGetNode( "/radios/kr-87/annunciators/adf", true );
|
||||||
|
adf_bfo_ann = fgGetNode( "/radios/kr-87/annunciators/bfo", true );
|
||||||
|
adf_frq_ann = fgGetNode( "/radios/kr-87/annunciators/frq", true );
|
||||||
|
adf_flt_ann = fgGetNode( "/radios/kr-87/annunciators/flt", true );
|
||||||
|
adf_et_ann = fgGetNode( "/radios/kr-87/annunciators/et", true );
|
||||||
|
|
||||||
inner = fgGetNode( "/radios/marker-beacon/inner", true );
|
inner = fgGetNode( "/radios/marker-beacon/inner", true );
|
||||||
middle = fgGetNode( "/radios/marker-beacon/middle", true );
|
middle = fgGetNode( "/radios/marker-beacon/middle", true );
|
||||||
|
@ -472,7 +479,7 @@ bool FGATC610x::do_analog_in() {
|
||||||
|
|
||||||
// adf volume
|
// adf volume
|
||||||
tmp = (float)analog_in_data[26] / 1024.0f;
|
tmp = (float)analog_in_data[26] / 1024.0f;
|
||||||
fgSetFloat( "/radios/kr-87/on-off-volume", tmp );
|
fgSetFloat( "/radios/kr-87/inputs/on-off-volume", tmp );
|
||||||
|
|
||||||
// nav2 obs tuner
|
// nav2 obs tuner
|
||||||
tmp = (float)analog_in_data[29] * 360.0f / 1024.0f;
|
tmp = (float)analog_in_data[29] * 360.0f / 1024.0f;
|
||||||
|
@ -491,7 +498,7 @@ bool FGATC610x::do_analog_in() {
|
||||||
// Write the lights
|
// Write the lights
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bool FGATC610x::do_lights( double dt ) {
|
bool FGATC610x::do_lights() {
|
||||||
|
|
||||||
// Marker beacons
|
// Marker beacons
|
||||||
ATC610xSetLamp( lamps_fd, 4, inner->getBoolValue() );
|
ATC610xSetLamp( lamps_fd, 4, inner->getBoolValue() );
|
||||||
|
@ -499,37 +506,12 @@ bool FGATC610x::do_lights( double dt ) {
|
||||||
ATC610xSetLamp( lamps_fd, 3, outer->getBoolValue() );
|
ATC610xSetLamp( lamps_fd, 3, outer->getBoolValue() );
|
||||||
|
|
||||||
// ADF annunciators
|
// ADF annunciators
|
||||||
if ( adf_on_off_vol->getDoubleValue() >= 0.01 ) {
|
ATC610xSetLamp( lamps_fd, 11, adf_ant_ann->getBoolValue() ); // ANT
|
||||||
ATC610xSetLamp( lamps_fd, 11, !adf_adf_btn->getBoolValue() ); // ANT
|
ATC610xSetLamp( lamps_fd, 12, adf_adf_ann->getBoolValue() ); // ADF
|
||||||
ATC610xSetLamp( lamps_fd, 12, adf_adf_btn->getBoolValue() ); // ADF
|
ATC610xSetLamp( lamps_fd, 13, adf_bfo_ann->getBoolValue() ); // BFO
|
||||||
ATC610xSetLamp( lamps_fd, 13, adf_bfo_btn->getBoolValue() ); // BFO
|
ATC610xSetLamp( lamps_fd, 14, adf_frq_ann->getBoolValue() ); // FRQ
|
||||||
ATC610xSetLamp( lamps_fd, 14, !adf_stby_mode->getBoolValue() ); // FRQ
|
ATC610xSetLamp( lamps_fd, 15, adf_flt_ann->getBoolValue() ); // FLT
|
||||||
ATC610xSetLamp( lamps_fd, 15, adf_stby_mode->getBoolValue() &&
|
ATC610xSetLamp( lamps_fd, 16, adf_et_ann->getBoolValue() ); // ET
|
||||||
!adf_timer_mode->getBoolValue() ); // FLT
|
|
||||||
|
|
||||||
// ET needs to blink when we are in ET set countdown time
|
|
||||||
if ( adf_count_mode->getIntValue() < 2 ) {
|
|
||||||
ATC610xSetLamp( lamps_fd, 16, adf_stby_mode->getBoolValue() &&
|
|
||||||
adf_timer_mode->getBoolValue() ); // ET
|
|
||||||
} else {
|
|
||||||
et_flash_time += dt;
|
|
||||||
if ( et_flash && et_flash_time > 0.5 ) {
|
|
||||||
et_flash = false;
|
|
||||||
et_flash_time -= 0.5;
|
|
||||||
} else if ( !et_flash && et_flash_time > 0.2 ) {
|
|
||||||
et_flash = true;
|
|
||||||
et_flash_time -= 0.2;
|
|
||||||
}
|
|
||||||
ATC610xSetLamp( lamps_fd, 16, et_flash ); // ET
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ATC610xSetLamp( lamps_fd, 11, false ); // ANT
|
|
||||||
ATC610xSetLamp( lamps_fd, 12, false ); // ADF
|
|
||||||
ATC610xSetLamp( lamps_fd, 13, false ); // BFO
|
|
||||||
ATC610xSetLamp( lamps_fd, 14, false ); // FRQ
|
|
||||||
ATC610xSetLamp( lamps_fd, 15, false ); // FLT
|
|
||||||
ATC610xSetLamp( lamps_fd, 16, false ); // ET
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -865,21 +847,21 @@ bool FGATC610x::do_radio_switches() {
|
||||||
last_adf_tuner_coarse = adf_tuner_coarse;
|
last_adf_tuner_coarse = adf_tuner_coarse;
|
||||||
|
|
||||||
if ( adf_count_mode->getIntValue() == 2 ) {
|
if ( adf_count_mode->getIntValue() == 2 ) {
|
||||||
fgSetFloat( "/radios/kr-87/elapsed-timer", value );
|
fgSetFloat( "/radios/kr-87/outputs/elapsed-timer", value );
|
||||||
} else {
|
} else {
|
||||||
if ( adf_stby_mode->getIntValue() == 1 ) {
|
if ( adf_stby_mode->getIntValue() == 1 ) {
|
||||||
fgSetFloat( "/radios/kr-87/frequencies/selected-khz", value );
|
fgSetFloat( "/radios/kr-87/outputs/selected-khz", value );
|
||||||
} else {
|
} else {
|
||||||
fgSetFloat( "/radios/kr-87/frequencies/standby-khz", value );
|
fgSetFloat( "/radios/kr-87/outputs/standby-khz", value );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ADF Modes
|
// ADF Modes
|
||||||
fgSetInt( "/radios/kr-87/adf-btn", !(radio_switch_data[23] & 0x01) );
|
fgSetInt( "/radios/kr-87/inputs/adf-btn", !(radio_switch_data[23] & 0x01) );
|
||||||
fgSetInt( "/radios/kr-87/bfo-btn", !(radio_switch_data[23] >> 1 & 0x01) );
|
fgSetInt( "/radios/kr-87/inputs/bfo-btn", !(radio_switch_data[23] >> 1 & 0x01) );
|
||||||
fgSetInt( "/radios/kr-87/frq-btn", !(radio_switch_data[23] >> 2 & 0x01) );
|
fgSetInt( "/radios/kr-87/inputs/frq-btn", !(radio_switch_data[23] >> 2 & 0x01) );
|
||||||
fgSetInt( "/radios/kr-87/flt-et-btn", !(radio_switch_data[23] >> 3 & 0x01) );
|
fgSetInt( "/radios/kr-87/inputs/flt-et-btn", !(radio_switch_data[23] >> 3 & 0x01) );
|
||||||
fgSetInt( "/radios/kr-87/set-rst-btn", !(radio_switch_data[23] >> 4 & 0x01) );
|
fgSetInt( "/radios/kr-87/inputs/set-rst-btn", !(radio_switch_data[23] >> 4 & 0x01) );
|
||||||
/* cout << "adf = " << !(radio_switch_data[23] & 0x01)
|
/* cout << "adf = " << !(radio_switch_data[23] & 0x01)
|
||||||
<< " bfo = " << !(radio_switch_data[23] >> 1 & 0x01)
|
<< " bfo = " << !(radio_switch_data[23] >> 1 & 0x01)
|
||||||
<< " stby = " << !(radio_switch_data[23] >> 2 & 0x01)
|
<< " stby = " << !(radio_switch_data[23] >> 2 & 0x01)
|
||||||
|
@ -1268,17 +1250,11 @@ bool FGATC610x::do_switches() {
|
||||||
|
|
||||||
|
|
||||||
bool FGATC610x::process() {
|
bool FGATC610x::process() {
|
||||||
SGTimeStamp current;
|
|
||||||
current.stamp();
|
|
||||||
|
|
||||||
double dt = (double)(current - last_time_stamp) / 1000000;
|
|
||||||
last_time_stamp.stamp();
|
|
||||||
|
|
||||||
// Lock the hardware, skip if it's not ready yet
|
// Lock the hardware, skip if it's not ready yet
|
||||||
if ( ATC610xLock( lock_fd ) > 0 ) {
|
if ( ATC610xLock( lock_fd ) > 0 ) {
|
||||||
|
|
||||||
do_analog_in();
|
do_analog_in();
|
||||||
do_lights( dt );
|
do_lights();
|
||||||
do_radio_switches();
|
do_radio_switches();
|
||||||
do_radio_display();
|
do_radio_display();
|
||||||
do_steppers();
|
do_steppers();
|
||||||
|
|
|
@ -30,8 +30,6 @@
|
||||||
|
|
||||||
#include <plib/netChat.h>
|
#include <plib/netChat.h>
|
||||||
|
|
||||||
#include <simgear/timing/timestamp.hxx>
|
|
||||||
|
|
||||||
#include <Main/fg_props.hxx>
|
#include <Main/fg_props.hxx>
|
||||||
|
|
||||||
#include "protocol.hxx"
|
#include "protocol.hxx"
|
||||||
|
@ -83,16 +81,14 @@ class FGATC610x : public FGProtocol {
|
||||||
SGPropertyNode *adf_freq, *adf_stby_freq;
|
SGPropertyNode *adf_freq, *adf_stby_freq;
|
||||||
SGPropertyNode *adf_stby_mode, *adf_timer_mode;
|
SGPropertyNode *adf_stby_mode, *adf_timer_mode;
|
||||||
SGPropertyNode *adf_count_mode, *adf_flight_timer, *adf_elapsed_timer;
|
SGPropertyNode *adf_count_mode, *adf_flight_timer, *adf_elapsed_timer;
|
||||||
|
SGPropertyNode *adf_ant_ann, *adf_adf_ann, *adf_bfo_ann, *adf_frq_ann;
|
||||||
|
SGPropertyNode *adf_flt_ann, *adf_et_ann;
|
||||||
SGPropertyNode *inner, *middle, *outer;
|
SGPropertyNode *inner, *middle, *outer;
|
||||||
|
|
||||||
int dme_switch;
|
int dme_switch;
|
||||||
|
|
||||||
SGTimeStamp last_time_stamp;
|
|
||||||
double et_flash_time;
|
|
||||||
bool et_flash;
|
|
||||||
|
|
||||||
bool do_analog_in();
|
bool do_analog_in();
|
||||||
bool do_lights( double dt );
|
bool do_lights();
|
||||||
bool do_radio_switches();
|
bool do_radio_switches();
|
||||||
bool do_radio_display();
|
bool do_radio_display();
|
||||||
bool do_steppers();
|
bool do_steppers();
|
||||||
|
@ -100,10 +96,7 @@ class FGATC610x : public FGProtocol {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FGATC610x():
|
FGATC610x() { }
|
||||||
et_flash_time(0.0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
~FGATC610x() { }
|
~FGATC610x() { }
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ bool FGAtlas::gen_message() {
|
||||||
// cout << "generating atlas message" << endl;
|
// cout << "generating atlas message" << endl;
|
||||||
|
|
||||||
static SGPropertyNode *adf_freq
|
static SGPropertyNode *adf_freq
|
||||||
= fgGetNode("/radios/kr-87/frequencies/selected-khz", true);
|
= fgGetNode("/radios/kr-87/outputs/selected-khz", true);
|
||||||
|
|
||||||
char rmc[256], gga[256], patla[256];
|
char rmc[256], gga[256], patla[256];
|
||||||
char rmc_sum[10], gga_sum[10], patla_sum[10];
|
char rmc_sum[10], gga_sum[10], patla_sum[10];
|
||||||
|
|
Loading…
Reference in a new issue