1
0
Fork 0

Prepare and implement reinit methods for instruments

to clear error conditions, drifts, offsets etc
This commit is contained in:
ThorstenB 2012-09-17 00:12:29 +02:00
parent 65a5f6744f
commit 043128c7c0
44 changed files with 238 additions and 62 deletions

View file

@ -80,6 +80,12 @@ AirspeedIndicator::init ()
_environmentManager = (FGEnvironmentMgr*) globals->get_subsystem("environment");
}
void
AirspeedIndicator::reinit ()
{
_speed_node->setDoubleValue(0.0);
}
#ifndef FPSTOKTS
# define FPSTOKTS 0.592484
#endif

View file

@ -40,6 +40,7 @@ public:
virtual ~AirspeedIndicator ();
virtual void init ();
virtual void reinit ();
virtual void update (double dt);
private:

View file

@ -75,13 +75,20 @@ Altimeter::setSettingHPa( double value )
void
Altimeter::init ()
{
raw_PA = 0.0;
_kollsman = 0.0;
_pressure_node = fgGetNode(_static_pressure.c_str(), true);
_serviceable_node = _rootNode->getChild("serviceable", 0, true);
_press_alt_node = _rootNode->getChild("pressure-alt-ft", 0, true);
_mode_c_node = _rootNode->getChild("mode-c-alt-ft", 0, true);
_altitude_node = _rootNode->getChild("indicated-altitude-ft", 0, true);
reinit();
}
void
Altimeter::reinit ()
{
_raw_PA = 0.0;
_kollsman = 0.0;
}
void
@ -105,13 +112,13 @@ Altimeter::update (double dt)
double pressure = _pressure_node->getDoubleValue();
double press_alt = _press_alt_node->getDoubleValue();
// The mechanism settles slowly toward new pressure altitude:
raw_PA = fgGetLowPass(raw_PA, _altimeter.press_alt_ft(pressure), trat);
_mode_c_node->setDoubleValue(100 * SGMiscd::round(raw_PA/100));
_raw_PA = fgGetLowPass(_raw_PA, _altimeter.press_alt_ft(pressure), trat);
_mode_c_node->setDoubleValue(100 * SGMiscd::round(_raw_PA/100));
_kollsman = fgGetLowPass(_kollsman, _altimeter.kollsman_ft(_settingInHg), trat);
if (_quantum)
press_alt = _quantum * SGMiscd::round(raw_PA/_quantum);
press_alt = _quantum * SGMiscd::round(_raw_PA/_quantum);
else
press_alt = raw_PA;
press_alt = _raw_PA;
_press_alt_node->setDoubleValue(press_alt);
_altitude_node->setDoubleValue(press_alt - _kollsman);
}

View file

@ -36,6 +36,7 @@ public:
virtual ~Altimeter ();
virtual void init ();
virtual void reinit ();
virtual void update (double dt);
virtual void bind();
virtual void unbind();
@ -51,7 +52,7 @@ private:
double _tau;
double _quantum;
double _kollsman;
double raw_PA;
double _raw_PA;
double _settingInHg;
SGPropertyNode_ptr _serviceable_node;

View file

@ -65,6 +65,16 @@ AttitudeIndicator::init ()
_roll_int_node = node->getChild("internal-roll-deg", 0, true);
_pitch_out_node = node->getChild("indicated-pitch-deg", 0, true);
_roll_out_node = node->getChild("indicated-roll-deg", 0, true);
reinit();
}
void
AttitudeIndicator::reinit ()
{
_roll_int_node->setDoubleValue(0.0);
_pitch_int_node->setDoubleValue(0.0);
_gyro.reinit();
}
void

View file

@ -45,6 +45,7 @@ public:
virtual ~AttitudeIndicator ();
virtual void init ();
virtual void reinit ();
virtual void bind ();
virtual void unbind ();
virtual void update (double dt);

View file

@ -88,6 +88,14 @@ DME::init ()
if( NULL == _audioIdent )
_audioIdent = new DMEAudioIdent( temp.str() );
_audioIdent->init();
reinit();
}
void
DME::reinit ()
{
_time_before_search_sec = 0;
}
void

View file

@ -39,6 +39,7 @@ public:
virtual ~DME ();
virtual void init ();
virtual void reinit ();
virtual void update (double delta_time_sec);
private:

View file

@ -328,7 +328,11 @@ GPS::init ()
// last thing, add the deprecated prop watcher
new DeprecatedPropListener(_gpsNode);
}
void
GPS::reinit ()
{
clearOutput();
}

View file

@ -84,6 +84,7 @@ public:
// SGSubsystem interface
virtual void init ();
virtual void reinit ();
virtual void update (double delta_time_sec);
virtual void bind();

View file

@ -13,6 +13,12 @@ Gyro::~Gyro ()
{
}
void Gyro::reinit(void)
{
_power_norm = 0.0;
_spin_norm = 0.0;
}
void
Gyro::update (double delta_time_sec)
{

View file

@ -18,12 +18,15 @@ public:
*/
Gyro ();
/**
* Destructor.
*/
virtual ~Gyro ();
/**
* Reset the gyro.
*/
void reinit(void);
/**
* Update the gyro.

View file

@ -48,8 +48,16 @@ HeadingIndicator::init ()
_heading_out_node = node->getChild("indicated-heading-deg", 0, true);
_heading_bug_error_node = node->getChild("heading-bug-error-deg", 0, true);
_heading_bug_node = node->getChild("heading-bug-deg", 0, true);
reinit();
}
void
HeadingIndicator::reinit ()
{
_last_heading_deg = (_heading_in_node->getDoubleValue() +
_offset_node->getDoubleValue());
_gyro.reinit();
}
void

View file

@ -42,6 +42,7 @@ public:
virtual ~HeadingIndicator ();
virtual void init ();
virtual void reinit ();
virtual void bind ();
virtual void unbind ();
virtual void update (double dt);

View file

@ -61,25 +61,20 @@ HeadingIndicatorDG::init ()
_heading_in_node = fgGetNode("/orientation/heading-deg", true);
_yaw_rate_node = fgGetNode("/orientation/yaw-rate-degps", true);
_g_node = fgGetNode("/accelerations/pilot-g", true);
_g_node = fgGetNode("/accelerations/pilot-g", true);
SGPropertyNode *node = fgGetNode(branch.c_str(), num, true );
_offset_node = node->getChild("offset-deg", 0, true);
_serviceable_node = node->getChild("serviceable", 0, true);
SGPropertyNode *node = fgGetNode(branch.c_str(), num, true );
_offset_node = node->getChild("offset-deg", 0, true);
_serviceable_node = node->getChild("serviceable", 0, true);
_heading_bug_error_node = node->getChild("heading-bug-error-deg", 0, true);
_error_node = node->getChild("error-deg", 0, true);
_nav1_error_node = node->getChild("nav1-course-error-deg", 0, true);
_heading_out_node = node->getChild("indicated-heading-deg", 0, true);
_align_node = node->getChild("align-deg", 0, true);
_error_node = node->getChild("error-deg", 0, true);
_nav1_error_node = node->getChild("nav1-course-error-deg", 0, true);
_heading_out_node = node->getChild("indicated-heading-deg", 0, true);
_align_node = node->getChild("align-deg", 0, true);
_electrical_node = fgGetNode("/systems/electrical/outputs/DG", true);
_align_node->setDoubleValue(0);
_error_node->setDoubleValue(0);
_last_heading_deg = (_heading_in_node->getDoubleValue() +
_offset_node->getDoubleValue() + _align_node->getDoubleValue());
reinit();
}
void
@ -108,6 +103,20 @@ HeadingIndicatorDG::unbind ()
fgUntie((branch + "/spin").c_str());
}
void
HeadingIndicatorDG::reinit (void)
{
// reset errors/drift values
_align_node->setDoubleValue(0.0);
_error_node->setDoubleValue(0.0);
_offset_node->setDoubleValue(0.0);
_last_heading_deg = (_heading_in_node->getDoubleValue() +
_offset_node->getDoubleValue() + _align_node->getDoubleValue());
_gyro.reinit();
}
void
HeadingIndicatorDG::update (double dt)
{
@ -162,7 +171,7 @@ HeadingIndicatorDG::update (double dt)
_heading_out_node->setDoubleValue(heading);
// calculate the difference between the indicacted heading
// calculate the difference between the indicated heading
// and the selected heading for use with an autopilot
static SGPropertyNode *bnode
= fgGetNode( "/autopilot/settings/heading-bug-deg", false );

View file

@ -40,6 +40,7 @@ public:
virtual ~HeadingIndicatorDG ();
virtual void init ();
virtual void reinit ();
virtual void bind ();
virtual void unbind ();
virtual void update (double dt);
@ -51,7 +52,6 @@ private:
std::string name;
int num;
//string vacuum_system;
SGPropertyNode_ptr _offset_node;
SGPropertyNode_ptr _heading_in_node;

View file

@ -61,7 +61,7 @@ HeadingIndicatorFG::init ()
string branch;
branch = "/instrumentation/" + name;
_heading_in_node = fgGetNode("/orientation/heading-deg", true);
_heading_in_node = fgGetNode("/orientation/heading-deg", true);
SGPropertyNode *node = fgGetNode(branch.c_str(), num, true );
if( NULL == (_offset_node = node->getChild("offset-deg", 0, false)) ) {
@ -69,14 +69,22 @@ HeadingIndicatorFG::init ()
_offset_node->setDoubleValue( -globals->get_mag()->get_magvar() * SGD_RADIANS_TO_DEGREES );
}
_serviceable_node = node->getChild("serviceable", 0, true);
_error_node = node->getChild("heading-bug-error-deg", 0, true);
_nav1_error_node = node->getChild("nav1-course-error-deg", 0, true);
_error_node = node->getChild("heading-bug-error-deg", 0, true);
_nav1_error_node = node->getChild("nav1-course-error-deg", 0, true);
_heading_out_node = node->getChild("indicated-heading-deg", 0, true);
_off_node = node->getChild("off-flag", 0, true);
_electrical_node = fgGetNode("/systems/electrical/outputs/DG", true);
reinit();
}
void
HeadingIndicatorFG::reinit ()
{
_last_heading_deg = (_heading_in_node->getDoubleValue() +
_offset_node->getDoubleValue());
_electrical_node = fgGetNode("/systems/electrical/outputs/DG", true);
_gyro.reinit();
}
void
@ -91,7 +99,6 @@ HeadingIndicatorFG::bind ()
&_gyro, &Gyro::is_serviceable, &Gyro::set_serviceable);
fgTie((branch + "/spin").c_str(),
&_gyro, &Gyro::get_spin_norm, &Gyro::set_spin_norm);
}
void

View file

@ -42,6 +42,7 @@ public:
virtual ~HeadingIndicatorFG ();
virtual void init ();
virtual void reinit ();
virtual void bind ();
virtual void unbind ();
virtual void update (double dt);

View file

@ -185,9 +185,14 @@ void InstVerticalSpeedIndicator::init ()
node->getNode("indicated-speed-fps", true);
_speed_min_node =
node->getNode("indicated-speed-fpm", true);
}
void InstVerticalSpeedIndicator::reinit ()
{
// Initialize at ambient pressure
_internal_pressure_inhg = _pressure_node->getDoubleValue();
_speed_ft_per_s = 0.0;
_internal_sea_inhg = _sea_node->getDoubleValue();
}

View file

@ -58,6 +58,7 @@ public:
virtual ~InstVerticalSpeedIndicator ();
virtual void init ();
virtual void reinit ();
virtual void update (double dt);
private:

View file

@ -118,6 +118,9 @@ void FGKR_87::init () {
_sgr->tie_to_listener();
}
void FGKR_87::reinit () {
_time_before_search_sec = 0;
}
void FGKR_87::bind () {
_tiedProperties.setRoot(fgGetNode("/instrumentation/kr-87", true));

View file

@ -109,6 +109,7 @@ public:
~FGKR_87();
void init ();
void reinit ();
void bind ();
void unbind ();
void update (double dt_sec);

View file

@ -48,8 +48,16 @@ MagCompass::init ()
_y_accel_node = fgGetNode("/accelerations/pilot/y-accel-fps_sec", true);
_z_accel_node = fgGetNode("/accelerations/pilot/z-accel-fps_sec", true);
_out_node = node->getChild("indicated-heading-deg", 0, true);
reinit();
}
void
MagCompass::reinit ()
{
_error_deg = 0.0;
_rate_degps = 0.0;
}
void
MagCompass::update (double delta_time_sec)

View file

@ -44,6 +44,7 @@ public:
virtual ~MagCompass ();
virtual void init ();
virtual void reinit ();
virtual void update (double dt);
private:

View file

@ -43,7 +43,6 @@ using std::string;
// Constructor
FGMarkerBeacon::FGMarkerBeacon(SGPropertyNode *node) :
audio_vol(NULL),
need_update(true),
outer_blink(false),
middle_blink(false),
inner_blink(false),
@ -121,11 +120,16 @@ FGMarkerBeacon::init ()
_sgr = smgr->find("avionics", true);
_sgr->tie_to_listener();
blink.stamp();
outer_marker = middle_marker = inner_marker = false;
reinit();
}
void
FGMarkerBeacon::reinit ()
{
blink.stamp();
outer_marker = middle_marker = inner_marker = false;
_time_before_search_sec = 0.0;
}
void
FGMarkerBeacon::bind ()
@ -160,8 +164,6 @@ FGMarkerBeacon::unbind ()
void
FGMarkerBeacon::update(double dt)
{
need_update = false;
// On timeout, scan again, this needs to run every iteration no
// matter what the power or serviceable state. If power is turned
// off or the unit becomes unserviceable while a beacon sound is

View file

@ -51,8 +51,6 @@ class FGMarkerBeacon : public SGSubsystem
SGPropertyNode_ptr serviceable;
SGPropertyNode_ptr sound_working;
bool need_update;
bool outer_marker;
bool middle_marker;
bool inner_marker;
@ -83,6 +81,7 @@ public:
~FGMarkerBeacon();
void init ();
void reinit ();
void bind ();
void unbind ();
void update (double dt);

View file

@ -41,19 +41,6 @@ MasterReferenceGyro::~MasterReferenceGyro ()
void
MasterReferenceGyro::init ()
{
_last_hdg = 0;
_last_roll = 0;
_last_pitch = 0;
_indicated_hdg = 0;
_indicated_roll = 0;
_indicated_pitch = 0;
_indicated_hdg_rate = 0;
_indicated_roll_rate = 0;
_indicated_pitch_rate = 0;
_erect_time = 180;
_last_g = 1;
_g_error = 10;
string branch;
branch = "/instrumentation/" + _name;
@ -83,12 +70,32 @@ MasterReferenceGyro::init ()
_hdg_input_source_node = node->getChild("heading-source", 0, true);
_fast_erect_node = node->getChild("fast-erect", 0, true);
reinit();
}
void
MasterReferenceGyro::reinit ()
{
_last_hdg = 0;
_last_roll = 0;
_last_pitch = 0;
_indicated_hdg = 0;
_indicated_roll = 0;
_indicated_pitch = 0;
_indicated_hdg_rate = 0;
_indicated_roll_rate = 0;
_indicated_pitch_rate = 0;
_erect_time = 180;
_last_g = 1;
_g_error = 10;
_electrical_node->setDoubleValue(0);
_responsiveness_node->setDoubleValue(0.75);
_off_node->setBoolValue(false);
_hdg_input_source_node->setBoolValue(false);
_fast_erect_node->setBoolValue(false);
_g_in_node->setDoubleValue(1);
_gyro.reinit();
}
void

View file

@ -43,6 +43,7 @@ public:
virtual ~MasterReferenceGyro ();
virtual void init ();
virtual void reinit ();
virtual void bind ();
virtual void unbind ();
virtual void update (double dt);

View file

@ -267,6 +267,12 @@ FGNavRadio::init ()
node->getNode( "dme-in-range", true )->alias( fgGetNode("/instrumentation/dme[0]/in-range", true ) );
}
void
FGNavRadio::reinit ()
{
_time_before_search_sec = -1.0;
}
void
FGNavRadio::bind ()
{

View file

@ -190,6 +190,7 @@ public:
~FGNavRadio();
void init ();
void reinit ();
void bind ();
void unbind ();
void update (double dt);

View file

@ -36,6 +36,14 @@ SlipSkidBall::init ()
_z_accel_node = fgGetNode("/accelerations/pilot/z-accel-fps_sec", true);
_out_node = node->getChild("indicated-slip-skid", 0, true);
_override_node = node->getChild("override", 0, true);
reinit();
}
void
SlipSkidBall::reinit ()
{
_out_node->setDoubleValue(0.0);
}
void

View file

@ -37,6 +37,7 @@ public:
virtual ~SlipSkidBall ();
virtual void init ();
virtual void reinit ();
virtual void update (double dt);
private:

View file

@ -124,6 +124,12 @@ TACAN::init ()
_electrical_node = fgGetNode("/systems/electrical/outputs/tacan", true);
}
void
TACAN::reinit ()
{
_time_before_search_sec = 0;
}
void
TACAN::update (double delta_time_sec)
{

View file

@ -40,6 +40,7 @@ public:
virtual ~TACAN ();
virtual void init ();
virtual void reinit ();
virtual void update (double delta_time_sec);
private:

View file

@ -377,6 +377,12 @@ TCAS::AdvisoryCoordinator::AdvisoryCoordinator(TCAS* _tcas) :
void
TCAS::AdvisoryCoordinator::init(void)
{
reinit();
}
void
TCAS::AdvisoryCoordinator::reinit(void)
{
clear();
previous = current;
@ -1181,6 +1187,13 @@ TCAS::init(void)
threatDetector.init();
}
void
TCAS::reinit(void)
{
nextUpdateTime = 0;
advisoryCoordinator.reinit();
}
void
TCAS::bind(void)
{

View file

@ -238,6 +238,7 @@ class TCAS : public SGSubsystem
void bind (SGPropertyNode* node);
void init (void);
void reinit (void);
void update (int mode);
void clear (void);
@ -385,6 +386,7 @@ public:
virtual void bind (void);
virtual void unbind (void);
virtual void init (void);
virtual void reinit (void);
virtual void update (double dt);
};

View file

@ -46,6 +46,15 @@ TurnIndicator::init ()
_electric_current_node =
fgGetNode("/systems/electrical/outputs/turn-coordinator", true);
_rate_out_node = node->getChild("indicated-turn-rate", 0, true);
reinit();
}
void
TurnIndicator::reinit ()
{
_last_rate = 0;
_gyro.reinit();
}
void

View file

@ -44,6 +44,7 @@ public:
virtual ~TurnIndicator ();
virtual void init ();
virtual void reinit ();
virtual void bind ();
virtual void unbind ();
virtual void update (double dt);

View file

@ -39,7 +39,13 @@ VerticalSpeedIndicator::init ()
_speed_node = node->getChild("indicated-speed-fpm", 0, true);
_speed_up_node = fgGetNode("/sim/speed-up", true);
// Initialize at ambient pressure
reinit();
}
void
VerticalSpeedIndicator::reinit ()
{
// Initialize at ambient pressure
_internal_pressure_inhg = _pressure_node->getDoubleValue();
}

View file

@ -36,6 +36,7 @@ public:
virtual ~VerticalSpeedIndicator ();
virtual void init ();
virtual void reinit ();
virtual void update (double dt);
private:

View file

@ -37,6 +37,15 @@ StaticSystem::init ()
_serviceable_node = node->getChild("serviceable", 0, true);
_pressure_in_node = fgGetNode("/environment/pressure-inhg", true);
_pressure_out_node = node->getChild("pressure-inhg", 0, true);
reinit();
}
void
StaticSystem::reinit ()
{
// start with settled static pressure
_pressure_out_node->setDoubleValue(_pressure_in_node->getDoubleValue());
}
void
@ -56,7 +65,6 @@ StaticSystem::update (double dt)
double trat = _tau ? dt/_tau : 100;
double target = _pressure_in_node->getDoubleValue();
double current = _pressure_out_node->getDoubleValue();
// double delta = target - current;
_pressure_out_node->setDoubleValue(fgGetLowPass(current, target, trat));
}
}

View file

@ -40,6 +40,7 @@ public:
virtual ~StaticSystem ();
virtual void init ();
virtual void reinit ();
virtual void bind ();
virtual void unbind ();
virtual void update (double dt);

View file

@ -46,6 +46,14 @@ VacuumSystem::init()
}
_pressure_node = fgGetNode("/environment/pressure-inhg", true);
_suction_node = node->getChild("suction-inhg", 0, true);
reinit();
}
void
VacuumSystem::reinit()
{
_suction_node->setDoubleValue(0.0);
}
void
@ -69,14 +77,14 @@ VacuumSystem::update (double dt)
if (!_serviceable_node->getBoolValue()) {
suction = 0.0;
} else {
// select the source with the max rpm
// select the source with the max rpm
double rpm = 0.0;
for ( i = 0; i < _rpm_nodes.size(); i++ ) {
double tmp = _rpm_nodes[i]->getDoubleValue() * _scale;
if ( tmp > rpm ) {
rpm = tmp;
}
}
for ( i = 0; i < _rpm_nodes.size(); i++ ) {
double tmp = _rpm_nodes[i]->getDoubleValue() * _scale;
if ( tmp > rpm ) {
rpm = tmp;
}
}
double pressure = _pressure_node->getDoubleValue();
// This magic formula yields about 4 inhg at 700 rpm
suction = pressure * rpm / (rpm + 4875.0);

View file

@ -43,6 +43,7 @@ public:
virtual ~VacuumSystem ();
virtual void init ();
virtual void reinit ();
virtual void bind ();
virtual void unbind ();
virtual void update (double dt);