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