From: ThorstenB Date: Sun, 16 Sep 2012 22:12:29 +0000 (+0200) Subject: Prepare and implement reinit methods for instruments X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=043128c7c093c99125ba0ece4c0bcc0b697d2a63;p=flightgear.git Prepare and implement reinit methods for instruments to clear error conditions, drifts, offsets etc --- diff --git a/src/Instrumentation/airspeed_indicator.cxx b/src/Instrumentation/airspeed_indicator.cxx index d31fd7672..a3ff2df4e 100644 --- a/src/Instrumentation/airspeed_indicator.cxx +++ b/src/Instrumentation/airspeed_indicator.cxx @@ -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 diff --git a/src/Instrumentation/airspeed_indicator.hxx b/src/Instrumentation/airspeed_indicator.hxx index 26dd15a52..1222b492f 100644 --- a/src/Instrumentation/airspeed_indicator.hxx +++ b/src/Instrumentation/airspeed_indicator.hxx @@ -40,6 +40,7 @@ public: virtual ~AirspeedIndicator (); virtual void init (); + virtual void reinit (); virtual void update (double dt); private: diff --git a/src/Instrumentation/altimeter.cxx b/src/Instrumentation/altimeter.cxx index 3924ed7c9..3ef204687 100644 --- a/src/Instrumentation/altimeter.cxx +++ b/src/Instrumentation/altimeter.cxx @@ -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); } diff --git a/src/Instrumentation/altimeter.hxx b/src/Instrumentation/altimeter.hxx index f57c1ad37..121cafa7c 100644 --- a/src/Instrumentation/altimeter.hxx +++ b/src/Instrumentation/altimeter.hxx @@ -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; diff --git a/src/Instrumentation/attitude_indicator.cxx b/src/Instrumentation/attitude_indicator.cxx index 19f6d4c70..de79e811d 100644 --- a/src/Instrumentation/attitude_indicator.cxx +++ b/src/Instrumentation/attitude_indicator.cxx @@ -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 diff --git a/src/Instrumentation/attitude_indicator.hxx b/src/Instrumentation/attitude_indicator.hxx index 4bdc48b90..14453511d 100644 --- a/src/Instrumentation/attitude_indicator.hxx +++ b/src/Instrumentation/attitude_indicator.hxx @@ -45,6 +45,7 @@ public: virtual ~AttitudeIndicator (); virtual void init (); + virtual void reinit (); virtual void bind (); virtual void unbind (); virtual void update (double dt); diff --git a/src/Instrumentation/dme.cxx b/src/Instrumentation/dme.cxx index bcea965d8..ae1ce11e9 100644 --- a/src/Instrumentation/dme.cxx +++ b/src/Instrumentation/dme.cxx @@ -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 diff --git a/src/Instrumentation/dme.hxx b/src/Instrumentation/dme.hxx index 084fd8207..376e1ce9c 100644 --- a/src/Instrumentation/dme.hxx +++ b/src/Instrumentation/dme.hxx @@ -39,6 +39,7 @@ public: virtual ~DME (); virtual void init (); + virtual void reinit (); virtual void update (double delta_time_sec); private: diff --git a/src/Instrumentation/gps.cxx b/src/Instrumentation/gps.cxx index 3d15e8e57..729ad0526 100644 --- a/src/Instrumentation/gps.cxx +++ b/src/Instrumentation/gps.cxx @@ -328,7 +328,11 @@ GPS::init () // last thing, add the deprecated prop watcher new DeprecatedPropListener(_gpsNode); - +} + +void +GPS::reinit () +{ clearOutput(); } diff --git a/src/Instrumentation/gps.hxx b/src/Instrumentation/gps.hxx index 21cd46166..f1e191d1f 100644 --- a/src/Instrumentation/gps.hxx +++ b/src/Instrumentation/gps.hxx @@ -84,6 +84,7 @@ public: // SGSubsystem interface virtual void init (); + virtual void reinit (); virtual void update (double delta_time_sec); virtual void bind(); diff --git a/src/Instrumentation/gyro.cxx b/src/Instrumentation/gyro.cxx index 93fee30be..6de938e9a 100644 --- a/src/Instrumentation/gyro.cxx +++ b/src/Instrumentation/gyro.cxx @@ -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) { diff --git a/src/Instrumentation/gyro.hxx b/src/Instrumentation/gyro.hxx index eee834cb6..53a71c69f 100644 --- a/src/Instrumentation/gyro.hxx +++ b/src/Instrumentation/gyro.hxx @@ -18,12 +18,15 @@ public: */ Gyro (); - /** * Destructor. */ virtual ~Gyro (); + /** + * Reset the gyro. + */ + void reinit(void); /** * Update the gyro. diff --git a/src/Instrumentation/heading_indicator.cxx b/src/Instrumentation/heading_indicator.cxx index d026be3e0..12daafb8a 100644 --- a/src/Instrumentation/heading_indicator.cxx +++ b/src/Instrumentation/heading_indicator.cxx @@ -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 diff --git a/src/Instrumentation/heading_indicator.hxx b/src/Instrumentation/heading_indicator.hxx index ecd06fb18..f340c05dd 100644 --- a/src/Instrumentation/heading_indicator.hxx +++ b/src/Instrumentation/heading_indicator.hxx @@ -42,6 +42,7 @@ public: virtual ~HeadingIndicator (); virtual void init (); + virtual void reinit (); virtual void bind (); virtual void unbind (); virtual void update (double dt); diff --git a/src/Instrumentation/heading_indicator_dg.cxx b/src/Instrumentation/heading_indicator_dg.cxx index 287938983..3f64a0c82 100644 --- a/src/Instrumentation/heading_indicator_dg.cxx +++ b/src/Instrumentation/heading_indicator_dg.cxx @@ -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 ); diff --git a/src/Instrumentation/heading_indicator_dg.hxx b/src/Instrumentation/heading_indicator_dg.hxx index f5035b159..d4f2fb759 100644 --- a/src/Instrumentation/heading_indicator_dg.hxx +++ b/src/Instrumentation/heading_indicator_dg.hxx @@ -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; diff --git a/src/Instrumentation/heading_indicator_fg.cxx b/src/Instrumentation/heading_indicator_fg.cxx index 406300f12..eeeaf1bd4 100644 --- a/src/Instrumentation/heading_indicator_fg.cxx +++ b/src/Instrumentation/heading_indicator_fg.cxx @@ -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 diff --git a/src/Instrumentation/heading_indicator_fg.hxx b/src/Instrumentation/heading_indicator_fg.hxx index cb31470d9..9ed2bce0b 100644 --- a/src/Instrumentation/heading_indicator_fg.hxx +++ b/src/Instrumentation/heading_indicator_fg.hxx @@ -41,8 +41,9 @@ public: HeadingIndicatorFG (); virtual ~HeadingIndicatorFG (); - virtual void init (); - virtual void bind (); + virtual void init (); + virtual void reinit (); + virtual void bind (); virtual void unbind (); virtual void update (double dt); diff --git a/src/Instrumentation/inst_vertical_speed_indicator.cxx b/src/Instrumentation/inst_vertical_speed_indicator.cxx index 8730901c9..639b95025 100644 --- a/src/Instrumentation/inst_vertical_speed_indicator.cxx +++ b/src/Instrumentation/inst_vertical_speed_indicator.cxx @@ -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(); } diff --git a/src/Instrumentation/inst_vertical_speed_indicator.hxx b/src/Instrumentation/inst_vertical_speed_indicator.hxx index 18e818604..10c9f00c1 100644 --- a/src/Instrumentation/inst_vertical_speed_indicator.hxx +++ b/src/Instrumentation/inst_vertical_speed_indicator.hxx @@ -58,6 +58,7 @@ public: virtual ~InstVerticalSpeedIndicator (); virtual void init (); + virtual void reinit (); virtual void update (double dt); private: diff --git a/src/Instrumentation/kr_87.cxx b/src/Instrumentation/kr_87.cxx index 22694f7cf..8b968c73a 100644 --- a/src/Instrumentation/kr_87.cxx +++ b/src/Instrumentation/kr_87.cxx @@ -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)); diff --git a/src/Instrumentation/kr_87.hxx b/src/Instrumentation/kr_87.hxx index cd10cf445..626b50283 100644 --- a/src/Instrumentation/kr_87.hxx +++ b/src/Instrumentation/kr_87.hxx @@ -109,6 +109,7 @@ public: ~FGKR_87(); void init (); + void reinit (); void bind (); void unbind (); void update (double dt_sec); diff --git a/src/Instrumentation/mag_compass.cxx b/src/Instrumentation/mag_compass.cxx index cf8ee8c89..74252b1ed 100644 --- a/src/Instrumentation/mag_compass.cxx +++ b/src/Instrumentation/mag_compass.cxx @@ -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) diff --git a/src/Instrumentation/mag_compass.hxx b/src/Instrumentation/mag_compass.hxx index 474babdaf..91af5c056 100644 --- a/src/Instrumentation/mag_compass.hxx +++ b/src/Instrumentation/mag_compass.hxx @@ -44,6 +44,7 @@ public: virtual ~MagCompass (); virtual void init (); + virtual void reinit (); virtual void update (double dt); private: diff --git a/src/Instrumentation/marker_beacon.cxx b/src/Instrumentation/marker_beacon.cxx index 5fa56fade..41b981536 100644 --- a/src/Instrumentation/marker_beacon.cxx +++ b/src/Instrumentation/marker_beacon.cxx @@ -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,12 +120,17 @@ FGMarkerBeacon::init () _sgr = smgr->find("avionics", true); _sgr->tie_to_listener(); - blink.stamp(); + 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 diff --git a/src/Instrumentation/marker_beacon.hxx b/src/Instrumentation/marker_beacon.hxx index 52259b6a2..5836f92ea 100644 --- a/src/Instrumentation/marker_beacon.hxx +++ b/src/Instrumentation/marker_beacon.hxx @@ -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); diff --git a/src/Instrumentation/mrg.cxx b/src/Instrumentation/mrg.cxx index 2b1280340..1eb1f2394 100644 --- a/src/Instrumentation/mrg.cxx +++ b/src/Instrumentation/mrg.cxx @@ -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 diff --git a/src/Instrumentation/mrg.hxx b/src/Instrumentation/mrg.hxx index 25be4d8e6..7f8f97742 100644 --- a/src/Instrumentation/mrg.hxx +++ b/src/Instrumentation/mrg.hxx @@ -43,6 +43,7 @@ public: virtual ~MasterReferenceGyro (); virtual void init (); + virtual void reinit (); virtual void bind (); virtual void unbind (); virtual void update (double dt); diff --git a/src/Instrumentation/navradio.cxx b/src/Instrumentation/navradio.cxx index 4c054ff9c..d908e7490 100644 --- a/src/Instrumentation/navradio.cxx +++ b/src/Instrumentation/navradio.cxx @@ -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 () { diff --git a/src/Instrumentation/navradio.hxx b/src/Instrumentation/navradio.hxx index 1c33f5eb6..0debf55dd 100644 --- a/src/Instrumentation/navradio.hxx +++ b/src/Instrumentation/navradio.hxx @@ -190,6 +190,7 @@ public: ~FGNavRadio(); void init (); + void reinit (); void bind (); void unbind (); void update (double dt); diff --git a/src/Instrumentation/slip_skid_ball.cxx b/src/Instrumentation/slip_skid_ball.cxx index b5a439158..4bb1f916b 100644 --- a/src/Instrumentation/slip_skid_ball.cxx +++ b/src/Instrumentation/slip_skid_ball.cxx @@ -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 diff --git a/src/Instrumentation/slip_skid_ball.hxx b/src/Instrumentation/slip_skid_ball.hxx index 1dc1c8916..728717b22 100644 --- a/src/Instrumentation/slip_skid_ball.hxx +++ b/src/Instrumentation/slip_skid_ball.hxx @@ -37,6 +37,7 @@ public: virtual ~SlipSkidBall (); virtual void init (); + virtual void reinit (); virtual void update (double dt); private: diff --git a/src/Instrumentation/tacan.cxx b/src/Instrumentation/tacan.cxx index 21fc2f493..dfdab58fd 100644 --- a/src/Instrumentation/tacan.cxx +++ b/src/Instrumentation/tacan.cxx @@ -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) { diff --git a/src/Instrumentation/tacan.hxx b/src/Instrumentation/tacan.hxx index 083efa665..fd26b22c2 100644 --- a/src/Instrumentation/tacan.hxx +++ b/src/Instrumentation/tacan.hxx @@ -40,6 +40,7 @@ public: virtual ~TACAN (); virtual void init (); + virtual void reinit (); virtual void update (double delta_time_sec); private: diff --git a/src/Instrumentation/tcas.cxx b/src/Instrumentation/tcas.cxx index 32cd6f637..95a4dda5f 100644 --- a/src/Instrumentation/tcas.cxx +++ b/src/Instrumentation/tcas.cxx @@ -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) { diff --git a/src/Instrumentation/tcas.hxx b/src/Instrumentation/tcas.hxx index f44faf398..9f9f0964e 100644 --- a/src/Instrumentation/tcas.hxx +++ b/src/Instrumentation/tcas.hxx @@ -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); }; diff --git a/src/Instrumentation/turn_indicator.cxx b/src/Instrumentation/turn_indicator.cxx index 6b91cae37..06fd868e2 100644 --- a/src/Instrumentation/turn_indicator.cxx +++ b/src/Instrumentation/turn_indicator.cxx @@ -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 diff --git a/src/Instrumentation/turn_indicator.hxx b/src/Instrumentation/turn_indicator.hxx index 04a8e6fcb..096e8fcd6 100644 --- a/src/Instrumentation/turn_indicator.hxx +++ b/src/Instrumentation/turn_indicator.hxx @@ -44,6 +44,7 @@ public: virtual ~TurnIndicator (); virtual void init (); + virtual void reinit (); virtual void bind (); virtual void unbind (); virtual void update (double dt); diff --git a/src/Instrumentation/vertical_speed_indicator.cxx b/src/Instrumentation/vertical_speed_indicator.cxx index f59912651..55d3a77ed 100644 --- a/src/Instrumentation/vertical_speed_indicator.cxx +++ b/src/Instrumentation/vertical_speed_indicator.cxx @@ -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(); } diff --git a/src/Instrumentation/vertical_speed_indicator.hxx b/src/Instrumentation/vertical_speed_indicator.hxx index 56b4f0e18..8c9b31ac6 100644 --- a/src/Instrumentation/vertical_speed_indicator.hxx +++ b/src/Instrumentation/vertical_speed_indicator.hxx @@ -36,6 +36,7 @@ public: virtual ~VerticalSpeedIndicator (); virtual void init (); + virtual void reinit (); virtual void update (double dt); private: diff --git a/src/Systems/static.cxx b/src/Systems/static.cxx index e8447121c..f58d1ce3c 100644 --- a/src/Systems/static.cxx +++ b/src/Systems/static.cxx @@ -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)); } } diff --git a/src/Systems/static.hxx b/src/Systems/static.hxx index b4853d1ea..b50d32c5a 100644 --- a/src/Systems/static.hxx +++ b/src/Systems/static.hxx @@ -40,6 +40,7 @@ public: virtual ~StaticSystem (); virtual void init (); + virtual void reinit (); virtual void bind (); virtual void unbind (); virtual void update (double dt); diff --git a/src/Systems/vacuum.cxx b/src/Systems/vacuum.cxx index b7f91e0ec..9bf84e284 100644 --- a/src/Systems/vacuum.cxx +++ b/src/Systems/vacuum.cxx @@ -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); diff --git a/src/Systems/vacuum.hxx b/src/Systems/vacuum.hxx index 3b4713269..c9507c816 100644 --- a/src/Systems/vacuum.hxx +++ b/src/Systems/vacuum.hxx @@ -43,6 +43,7 @@ public: virtual ~VacuumSystem (); virtual void init (); + virtual void reinit (); virtual void bind (); virtual void unbind (); virtual void update (double dt);