Convert ADF and (old) NavRadio to use new base class
This enables separate power-supply for each installation.
This commit is contained in:
parent
9cd8ccae80
commit
40b96fef48
4 changed files with 23 additions and 43 deletions
|
@ -62,8 +62,6 @@ adjust_range (double transmitter_elevation_ft, double aircraft_altitude_ft,
|
|||
|
||||
ADF::ADF (SGPropertyNode *node )
|
||||
:
|
||||
_name(node->getStringValue("name", "adf")),
|
||||
_num(node->getIntValue("number", 0)),
|
||||
_time_before_search_sec(0),
|
||||
_last_frequency_khz(-1),
|
||||
_transmitter_valid(false),
|
||||
|
@ -75,6 +73,7 @@ ADF::ADF (SGPropertyNode *node )
|
|||
_last_volume(-1),
|
||||
_sgr(0)
|
||||
{
|
||||
readConfig(node, "adf");
|
||||
}
|
||||
|
||||
ADF::~ADF ()
|
||||
|
@ -84,10 +83,11 @@ ADF::~ADF ()
|
|||
void
|
||||
ADF::init ()
|
||||
{
|
||||
string branch;
|
||||
branch = "/instrumentation/" + _name;
|
||||
SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true );
|
||||
string branch = nodePath();
|
||||
SGPropertyNode *node = fgGetNode(branch.c_str(), true );
|
||||
|
||||
initServicePowerProperties(node);
|
||||
|
||||
// instrument properties
|
||||
_error_node = node->getChild("error-deg", 0, true);
|
||||
_mode_node = node->getChild("mode", 0, true);
|
||||
|
@ -96,7 +96,6 @@ ADF::init ()
|
|||
_bearing_node = node->getChild("indicated-bearing-deg", 0, true);
|
||||
_ident_node = node->getChild("ident", 0, true);
|
||||
_ident_audible_node = node->getChild("ident-audible", 0, true);
|
||||
_serviceable_node = node->getChild("serviceable", 0, true);
|
||||
_power_btn_node = node->getChild("power-btn", 0, true);
|
||||
_operable_node = node->getChild("operable", 0, true);
|
||||
|
||||
|
@ -105,7 +104,6 @@ ADF::init ()
|
|||
_frequency_node = fnode->getChild("selected-khz", 0, true);
|
||||
|
||||
// foreign simulator properties
|
||||
_electrical_node = fgGetNode("/systems/electrical/outputs/adf", true);
|
||||
_heading_node = fgGetNode("/orientation/heading-deg", true);
|
||||
|
||||
// backward compatibility check
|
||||
|
@ -118,17 +116,15 @@ ADF::init ()
|
|||
_sgr->tie_to_listener();
|
||||
|
||||
std::ostringstream temp;
|
||||
temp << _name << _num;
|
||||
temp << name() << number();
|
||||
_adf_ident = temp.str();
|
||||
}
|
||||
|
||||
void
|
||||
ADF::update (double delta_time_sec)
|
||||
{
|
||||
// If it's off, don't waste any time.
|
||||
if (_electrical_node->getDoubleValue() < 8.0
|
||||
|| !_serviceable_node->getBoolValue()
|
||||
|| !_power_btn_node->getBoolValue() ) {
|
||||
// If it's off, don't waste any time.
|
||||
if (!isServiceableAndPowered() || !_power_btn_node->getBoolValue()) {
|
||||
_in_range_node->setBoolValue(false);
|
||||
_operable_node->setBoolValue(false);
|
||||
_ident_node->setStringValue("");
|
||||
|
|
|
@ -7,15 +7,9 @@
|
|||
#ifndef __INSTRUMENTS_ADF_HXX
|
||||
#define __INSTRUMENTS_ADF_HXX 1
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error This library requires C++
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
#include <Instrumentation/AbstractInstrument.hxx>
|
||||
#include <simgear/math/SGMath.hxx>
|
||||
|
||||
class SGSampleGroup;
|
||||
|
@ -43,7 +37,7 @@ class SGSampleGroup;
|
|||
* /instrumentation/adf/indicated-bearing-deg
|
||||
* /instrumentation/adf/ident
|
||||
*/
|
||||
class ADF : public SGSubsystem
|
||||
class ADF : public AbstractInstrument
|
||||
{
|
||||
|
||||
public:
|
||||
|
@ -60,13 +54,8 @@ private:
|
|||
|
||||
void search (double frequency, const SGGeod& pos);
|
||||
|
||||
std::string _name;
|
||||
unsigned int _num;
|
||||
|
||||
SGPropertyNode_ptr _heading_node;
|
||||
SGPropertyNode_ptr _serviceable_node;
|
||||
SGPropertyNode_ptr _error_node;
|
||||
SGPropertyNode_ptr _electrical_node;
|
||||
SGPropertyNode_ptr _frequency_node;
|
||||
SGPropertyNode_ptr _mode_node;
|
||||
|
||||
|
|
|
@ -116,8 +116,6 @@ FGNavRadio::FGNavRadio(SGPropertyNode *node) :
|
|||
last_xtrack_error(0.0),
|
||||
xrate_ms(0.0),
|
||||
_localizerWidth(5.0),
|
||||
_name(node->getStringValue("name", "nav")),
|
||||
_num(node->getIntValue("number", 0)),
|
||||
_time_before_search_sec(-1.0),
|
||||
_gsCart(SGVec3d::zeros()),
|
||||
_gsAxis(SGVec3d::zeros()),
|
||||
|
@ -130,6 +128,8 @@ FGNavRadio::FGNavRadio(SGPropertyNode *node) :
|
|||
_gsNeedleDeflectionNorm(0.0),
|
||||
_audioIdent(NULL)
|
||||
{
|
||||
readConfig(node, "nav");
|
||||
|
||||
if (!static_terminalRangeInterp.get()) {
|
||||
// one-time interpolator init
|
||||
SGPath path( globals->get_fg_root() );
|
||||
|
@ -145,8 +145,8 @@ FGNavRadio::FGNavRadio(SGPropertyNode *node) :
|
|||
static_highRangeInterp.reset(new SGInterpTable(high));
|
||||
}
|
||||
|
||||
string branch("/instrumentation/" + _name);
|
||||
_radio_node = fgGetNode(branch.c_str(), _num, true);
|
||||
string branch = nodePath();
|
||||
_radio_node = fgGetNode(branch.c_str(), true);
|
||||
}
|
||||
|
||||
|
||||
|
@ -169,9 +169,9 @@ void
|
|||
FGNavRadio::init ()
|
||||
{
|
||||
SGPropertyNode* node = _radio_node.get();
|
||||
bus_power_node =
|
||||
fgGetNode(("/systems/electrical/outputs/" + _name).c_str(), true);
|
||||
|
||||
|
||||
initServicePowerProperties(node);
|
||||
|
||||
// inputs
|
||||
is_valid_node = node->getChild("data-is-valid", 0, true);
|
||||
power_btn_node = node->getChild("power-btn", 0, true);
|
||||
|
@ -261,7 +261,7 @@ FGNavRadio::init ()
|
|||
_magvarNode = fgGetNode("/environment/magnetic-variation-deg", true);
|
||||
|
||||
std::ostringstream temp;
|
||||
temp << _name << "-ident-" << _num;
|
||||
temp << name() << "-ident-" << number();
|
||||
if( NULL == _audioIdent )
|
||||
_audioIdent = new VORAudioIdent( temp.str() );
|
||||
_audioIdent->init();
|
||||
|
@ -379,9 +379,7 @@ FGNavRadio::update(double dt)
|
|||
return; // paused
|
||||
}
|
||||
|
||||
if (power_btn_node->getBoolValue()
|
||||
&& (bus_power_node->getDoubleValue() > 1.0)
|
||||
&& nav_serviceable_node->getBoolValue() )
|
||||
if (!isServiceableAndPowered() || !power_btn_node->getBoolValue())
|
||||
{
|
||||
_operable = true;
|
||||
updateReceiver(dt);
|
||||
|
@ -869,7 +867,7 @@ void FGNavRadio::updateAudio( double dt )
|
|||
// play station ident via audio system if on + ident,
|
||||
// otherwise turn it off
|
||||
if (!power_btn_node->getBoolValue()
|
||||
|| !(bus_power_node->getDoubleValue() > 1.0)
|
||||
|| !isServiceableAndPowered()
|
||||
|| !ident_btn_node->getBoolValue()
|
||||
|| !audio_btn_node->getBoolValue() ) {
|
||||
_audioIdent->setIdent("", 0.0 );
|
||||
|
|
|
@ -28,15 +28,15 @@
|
|||
#include <Main/fg_props.hxx>
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
#include <simgear/timing/timestamp.hxx>
|
||||
|
||||
#include <Instrumentation/AbstractInstrument.hxx>
|
||||
|
||||
class SGSampleGroup;
|
||||
|
||||
class FGNavRadio : public SGSubsystem, public SGPropertyChangeListener
|
||||
class FGNavRadio : public AbstractInstrument, public SGPropertyChangeListener
|
||||
{
|
||||
SGPropertyNode_ptr _radio_node;
|
||||
SGPropertyNode_ptr bus_power_node;
|
||||
|
||||
// property inputs
|
||||
SGPropertyNode_ptr is_valid_node; // is station data valid (may be way out
|
||||
|
@ -129,9 +129,6 @@ class FGNavRadio : public SGSubsystem, public SGPropertyChangeListener
|
|||
double last_xtrack_error;
|
||||
double xrate_ms;
|
||||
double _localizerWidth; // cached localizer width in degrees
|
||||
|
||||
std::string _name;
|
||||
int _num;
|
||||
|
||||
// internal periodic station search timer
|
||||
double _time_before_search_sec;
|
||||
|
|
Loading…
Add table
Reference in a new issue