Navradio: constructor cleanup, tie/untie helper, and a new 'operable' property to make it clear when the radio is functioning.
This commit is contained in:
parent
45d0e14cad
commit
38e76a175e
2 changed files with 32 additions and 59 deletions
|
@ -94,56 +94,6 @@ FGNavRadio::FGNavRadio(SGPropertyNode *node) :
|
||||||
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)),
|
||||||
is_valid_node(NULL),
|
|
||||||
power_btn_node(NULL),
|
|
||||||
freq_node(NULL),
|
|
||||||
alt_freq_node(NULL),
|
|
||||||
sel_radial_node(NULL),
|
|
||||||
vol_btn_node(NULL),
|
|
||||||
ident_btn_node(NULL),
|
|
||||||
audio_btn_node(NULL),
|
|
||||||
backcourse_node(NULL),
|
|
||||||
nav_serviceable_node(NULL),
|
|
||||||
cdi_serviceable_node(NULL),
|
|
||||||
gs_serviceable_node(NULL),
|
|
||||||
tofrom_serviceable_node(NULL),
|
|
||||||
dme_serviceable_node(NULL),
|
|
||||||
fmt_freq_node(NULL),
|
|
||||||
fmt_alt_freq_node(NULL),
|
|
||||||
heading_node(NULL),
|
|
||||||
radial_node(NULL),
|
|
||||||
recip_radial_node(NULL),
|
|
||||||
target_radial_true_node(NULL),
|
|
||||||
target_auto_hdg_node(NULL),
|
|
||||||
time_to_intercept(NULL),
|
|
||||||
to_flag_node(NULL),
|
|
||||||
from_flag_node(NULL),
|
|
||||||
inrange_node(NULL),
|
|
||||||
signal_quality_norm_node(NULL),
|
|
||||||
cdi_deflection_node(NULL),
|
|
||||||
cdi_deflection_norm_node(NULL),
|
|
||||||
cdi_xtrack_error_node(NULL),
|
|
||||||
cdi_xtrack_hdg_err_node(NULL),
|
|
||||||
has_gs_node(NULL),
|
|
||||||
loc_node(NULL),
|
|
||||||
loc_dist_node(NULL),
|
|
||||||
gs_deflection_node(NULL),
|
|
||||||
gs_deflection_deg_node(NULL),
|
|
||||||
gs_deflection_norm_node(NULL),
|
|
||||||
gs_rate_of_climb_node(NULL),
|
|
||||||
gs_dist_node(NULL),
|
|
||||||
gs_inrange_node(NULL),
|
|
||||||
nav_id_node(NULL),
|
|
||||||
id_c1_node(NULL),
|
|
||||||
id_c2_node(NULL),
|
|
||||||
id_c3_node(NULL),
|
|
||||||
id_c4_node(NULL),
|
|
||||||
nav_slaved_to_gps_node(NULL),
|
|
||||||
gps_cdi_deflection_node(NULL),
|
|
||||||
gps_to_flag_node(NULL),
|
|
||||||
gps_from_flag_node(NULL),
|
|
||||||
gps_has_gs_node(NULL),
|
|
||||||
gps_xtrack_error_nm_node(NULL),
|
|
||||||
play_count(0),
|
play_count(0),
|
||||||
last_time(0),
|
last_time(0),
|
||||||
target_radial(0.0),
|
target_radial(0.0),
|
||||||
|
@ -169,6 +119,10 @@ FGNavRadio::FGNavRadio(SGPropertyNode *node) :
|
||||||
term_tbl = new SGInterpTable( term.str() );
|
term_tbl = new SGInterpTable( term.str() );
|
||||||
low_tbl = new SGInterpTable( low.str() );
|
low_tbl = new SGInterpTable( low.str() );
|
||||||
high_tbl = new SGInterpTable( high.str() );
|
high_tbl = new SGInterpTable( high.str() );
|
||||||
|
|
||||||
|
|
||||||
|
string branch("/instrumentation/" + _name);
|
||||||
|
_radio_node = fgGetNode(branch.c_str(), _num, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -190,11 +144,7 @@ FGNavRadio::init ()
|
||||||
|
|
||||||
morse.init();
|
morse.init();
|
||||||
|
|
||||||
string branch;
|
SGPropertyNode* node = _radio_node.get();
|
||||||
branch = "/instrumentation/" + _name;
|
|
||||||
|
|
||||||
SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true );
|
|
||||||
|
|
||||||
bus_power_node =
|
bus_power_node =
|
||||||
fgGetNode(("/systems/electrical/outputs/" + _name).c_str(), true);
|
fgGetNode(("/systems/electrical/outputs/" + _name).c_str(), true);
|
||||||
|
|
||||||
|
@ -267,8 +217,6 @@ FGNavRadio::init ()
|
||||||
id_c3_node = node->getChild("nav-id_asc3", 0, true);
|
id_c3_node = node->getChild("nav-id_asc3", 0, true);
|
||||||
id_c4_node = node->getChild("nav-id_asc4", 0, true);
|
id_c4_node = node->getChild("nav-id_asc4", 0, true);
|
||||||
|
|
||||||
node->tie("dme-in-range", SGRawValuePointer<bool>(&_dmeInRange));
|
|
||||||
|
|
||||||
// gps slaving support
|
// gps slaving support
|
||||||
nav_slaved_to_gps_node = node->getChild("slaved-to-gps", 0, true);
|
nav_slaved_to_gps_node = node->getChild("slaved-to-gps", 0, true);
|
||||||
gps_cdi_deflection_node = fgGetNode("/instrumentation/gps/cdi-deflection", true);
|
gps_cdi_deflection_node = fgGetNode("/instrumentation/gps/cdi-deflection", true);
|
||||||
|
@ -289,13 +237,18 @@ FGNavRadio::init ()
|
||||||
void
|
void
|
||||||
FGNavRadio::bind ()
|
FGNavRadio::bind ()
|
||||||
{
|
{
|
||||||
|
tie("dme-in-range", SGRawValuePointer<bool>(&_dmeInRange));
|
||||||
|
tie("operable", SGRawValueMethods<FGNavRadio, bool>(*this, &FGNavRadio::isOperable, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FGNavRadio::unbind ()
|
FGNavRadio::unbind ()
|
||||||
{
|
{
|
||||||
|
for (unsigned int t=0; t<_tiedNodes.size(); ++t) {
|
||||||
|
_tiedNodes[t]->untie();
|
||||||
|
}
|
||||||
|
_tiedNodes.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -388,6 +341,7 @@ FGNavRadio::update(double dt)
|
||||||
&& (bus_power_node->getDoubleValue() > 1.0)
|
&& (bus_power_node->getDoubleValue() > 1.0)
|
||||||
&& nav_serviceable_node->getBoolValue() )
|
&& nav_serviceable_node->getBoolValue() )
|
||||||
{
|
{
|
||||||
|
_operable = true;
|
||||||
if (nav_slaved_to_gps_node->getBoolValue()) {
|
if (nav_slaved_to_gps_node->getBoolValue()) {
|
||||||
updateGPSSlaved();
|
updateGPSSlaved();
|
||||||
} else {
|
} else {
|
||||||
|
@ -419,6 +373,7 @@ void FGNavRadio::clearOutputs()
|
||||||
from_flag_node->setBoolValue( false );
|
from_flag_node->setBoolValue( false );
|
||||||
|
|
||||||
_dmeInRange = false;
|
_dmeInRange = false;
|
||||||
|
_operable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGNavRadio::updateReceiver(double dt)
|
void FGNavRadio::updateReceiver(double dt)
|
||||||
|
|
|
@ -47,6 +47,7 @@ class FGNavRadio : public SGSubsystem
|
||||||
SGInterpTable *low_tbl;
|
SGInterpTable *low_tbl;
|
||||||
SGInterpTable *high_tbl;
|
SGInterpTable *high_tbl;
|
||||||
|
|
||||||
|
SGPropertyNode_ptr _radio_node;
|
||||||
SGPropertyNode_ptr lon_node;
|
SGPropertyNode_ptr lon_node;
|
||||||
SGPropertyNode_ptr lat_node;
|
SGPropertyNode_ptr lat_node;
|
||||||
SGPropertyNode_ptr alt_node;
|
SGPropertyNode_ptr alt_node;
|
||||||
|
@ -125,6 +126,7 @@ class FGNavRadio : public SGSubsystem
|
||||||
|
|
||||||
// internal (private) values
|
// internal (private) values
|
||||||
|
|
||||||
|
bool _operable; ///< is the unit serviceable, on, powered, etc
|
||||||
int play_count;
|
int play_count;
|
||||||
time_t last_time;
|
time_t last_time;
|
||||||
FGNavRecordPtr _navaid;
|
FGNavRecordPtr _navaid;
|
||||||
|
@ -165,6 +167,7 @@ class FGNavRadio : public SGSubsystem
|
||||||
double _gsNeedleDeflectionNorm;
|
double _gsNeedleDeflectionNorm;
|
||||||
|
|
||||||
SGSharedPtr<SGSampleGroup> _sgr;
|
SGSharedPtr<SGSampleGroup> _sgr;
|
||||||
|
std::vector<SGPropertyNode*> _tiedNodes;
|
||||||
|
|
||||||
bool updateWithPower(double aDt);
|
bool updateWithPower(double aDt);
|
||||||
|
|
||||||
|
@ -193,6 +196,21 @@ class FGNavRadio : public SGSubsystem
|
||||||
*/
|
*/
|
||||||
double localizerWidth(FGNavRecord* aLOC);
|
double localizerWidth(FGNavRecord* aLOC);
|
||||||
FGNavRecord* findPrimaryNavaid(const SGGeod& aPos, double aFreqMHz);
|
FGNavRecord* findPrimaryNavaid(const SGGeod& aPos, double aFreqMHz);
|
||||||
|
|
||||||
|
/// accessor for tied, read-only 'operable' property
|
||||||
|
bool isOperable() const
|
||||||
|
{ return _operable; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tied-properties helper, record nodes which are tied for easy un-tie-ing
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
void tie(const char* aRelPath, const SGRawValue<T>& aRawValue)
|
||||||
|
{
|
||||||
|
SGPropertyNode* nd = _radio_node->getNode(aRelPath, true);
|
||||||
|
_tiedNodes.push_back(nd);
|
||||||
|
nd->tie(aRawValue);
|
||||||
|
}
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FGNavRadio(SGPropertyNode *node);
|
FGNavRadio(SGPropertyNode *node);
|
||||||
|
|
Loading…
Reference in a new issue