From: jmt Date: Tue, 9 Mar 2010 11:11:07 +0000 (+0000) Subject: Syd Adams: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=45a446dfafe3bffa1e4fe51e8271efd97ea1bc34;p=flightgear.git Syd Adams: add ias-limit (brarber-pole) computation to airpseed-indicator expose selected DME frequency on the DME instrument --- diff --git a/src/Instrumentation/airspeed_indicator.cxx b/src/Instrumentation/airspeed_indicator.cxx index 0196ddbae..329d91a2e 100644 --- a/src/Instrumentation/airspeed_indicator.cxx +++ b/src/Instrumentation/airspeed_indicator.cxx @@ -20,7 +20,8 @@ AirspeedIndicator::AirspeedIndicator ( SGPropertyNode *node ) _name(node->getStringValue("name", "airspeed-indicator")), _num(node->getIntValue("number", 0)), _total_pressure(node->getStringValue("total-pressure", "/systems/pitot/total-pressure-inhg")), - _static_pressure(node->getStringValue("static-pressure", "/systems/static/pressure-inhg")) + _static_pressure(node->getStringValue("static-pressure", "/systems/static/pressure-inhg")), + _has_barber_pole(node->getBoolValue("has-barber-pole",false)) { } @@ -40,6 +41,17 @@ AirspeedIndicator::init () _static_pressure_node = fgGetNode(_static_pressure.c_str(), true); _density_node = fgGetNode("/environment/density-slugft3", true); _speed_node = node->getChild("indicated-speed-kt", 0, true); + + // barber-pole properties + _ias_limit_node = node->getNode("ias-limit",0, true); + _mach_limit_node = node->getNode("mach-limit",0, true); + _alt_threshold_node = node->getNode("alt-threshold",0, true); + _airspeed_limit = node->getChild("airspeed-limit-kt", 0, true); + + string paSource = node->getStringValue("pressure-alt-source", + "/instrumentation/altimeter/pressure-alt-ft"); + _pressure_alt = fgGetNode(paSource.c_str(), true); + _mach = fgGetNode("/velocities/mach", true); } #ifndef FPSTOKTS @@ -53,24 +65,39 @@ AirspeedIndicator::init () void AirspeedIndicator::update (double dt) { - if (_serviceable_node->getBoolValue()) { - double pt = _total_pressure_node->getDoubleValue() * INHGTOPSF; - double p = _static_pressure_node->getDoubleValue() * INHGTOPSF; - double r = _density_node->getDoubleValue(); - double q = ( pt - p ); // dynamic pressure - - // Now, reverse the equation (normalize dynamic pressure to - // avoid "nan" results from sqrt) - if ( q < 0 ) { q = 0.0; } - double v_fps = sqrt((2 * q) / r); - - // Publish the indicated airspeed - double last_speed_kt = _speed_node->getDoubleValue(); - double current_speed_kt = v_fps * FPSTOKTS; - _speed_node->setDoubleValue(fgGetLowPass(last_speed_kt, - current_speed_kt, - dt * RESPONSIVENESS)); + if (!_serviceable_node->getBoolValue()) { + return; } + + double pt = _total_pressure_node->getDoubleValue() * INHGTOPSF; + double p = _static_pressure_node->getDoubleValue() * INHGTOPSF; + double r = _density_node->getDoubleValue(); + double q = ( pt - p ); // dynamic pressure + + // Now, reverse the equation (normalize dynamic pressure to + // avoid "nan" results from sqrt) + if ( q < 0 ) { q = 0.0; } + double v_fps = sqrt((2 * q) / r); + + // Publish the indicated airspeed + double last_speed_kt = _speed_node->getDoubleValue(); + double current_speed_kt = v_fps * FPSTOKTS; + double filtered_speed = fgGetLowPass(last_speed_kt, + current_speed_kt, + dt * RESPONSIVENESS); + _speed_node->setDoubleValue(filtered_speed); + + if (!_has_barber_pole) { + return; + } + + double lmt = _ias_limit_node->getDoubleValue(); + if (_pressure_alt->getDoubleValue() > _alt_threshold_node->getDoubleValue()) { + double mmo = _mach_limit_node->getDoubleValue(); + lmt = (filtered_speed/_mach->getDoubleValue())* mmo; + } + + _airspeed_limit->setDoubleValue(lmt); } // end of airspeed_indicator.cxx diff --git a/src/Instrumentation/airspeed_indicator.hxx b/src/Instrumentation/airspeed_indicator.hxx index e4827081d..7948ed2f2 100644 --- a/src/Instrumentation/airspeed_indicator.hxx +++ b/src/Instrumentation/airspeed_indicator.hxx @@ -46,12 +46,18 @@ private: unsigned int _num; string _total_pressure; string _static_pressure; + bool _has_barber_pole; + SGPropertyNode_ptr _ias_limit_node; + SGPropertyNode_ptr _mach_limit_node; + SGPropertyNode_ptr _alt_threshold_node; SGPropertyNode_ptr _serviceable_node; SGPropertyNode_ptr _total_pressure_node; SGPropertyNode_ptr _static_pressure_node; SGPropertyNode_ptr _density_node; SGPropertyNode_ptr _speed_node; - + SGPropertyNode_ptr _airspeed_limit; + SGPropertyNode_ptr _pressure_alt; + SGPropertyNode_ptr _mach; }; #endif // __INSTRUMENTS_AIRSPEED_INDICATOR_HXX diff --git a/src/Instrumentation/dme.cxx b/src/Instrumentation/dme.cxx index 754008bd4..925681e0a 100644 --- a/src/Instrumentation/dme.cxx +++ b/src/Instrumentation/dme.cxx @@ -97,6 +97,7 @@ DME::update (double delta_time_sec) _time_before_search_sec = 0; _last_frequency_mhz = frequency_mhz; } + _frequency_node->setDoubleValue(frequency_mhz); // Get the aircraft position double longitude_rad =