+
+ double lmt = _ias_limit_node->getDoubleValue();
+ if (_pressure_alt->getDoubleValue() > _alt_threshold_node->getDoubleValue()) {
+ double mmo = _mach_limit_node->getDoubleValue();
+ lmt = (filtered_speed/_mach_node->getDoubleValue())* mmo;
+ }
+
+ _airspeed_limit->setDoubleValue(lmt);
+}
+
+void
+AirspeedIndicator::computeMach()
+{
+ if (!_environmentManager) {
+ return;
+ }
+
+ FGEnvironment env(_environmentManager->getEnvironment());
+
+ double oatK = env.get_temperature_degc() + SG_T0_K - 15.0 ; // OAT in Kelvin
+ oatK = std::max( oatK , 0.001 ); // should never happen, but just in case someone flies into space...
+ double c = sqrt(SG_gamma * SG_R_m2_p_s2_p_K * oatK); // speed-of-sound in m/s at aircraft position
+ double pt = _total_pressure_node->getDoubleValue() * SG_INHG_TO_PA; // total pressure in Pa
+ double p = _static_pressure_node->getDoubleValue() * SG_INHG_TO_PA; // static pressure in Pa
+ p = std::max( p , 0.001 ); // should never happen, but just in case someone flies into space...
+ double rho = _density_node->getDoubleValue() * SG_SLUGFT3_TO_KGPM3; // air density in kg/m3
+ rho = std::max( rho , 0.001 ); // should never happen, but just in case someone flies into space...
+
+ // true airspeed in m/s
+ pt = std::max( pt , p );
+ double V_true = sqrt( 7 * p/rho * (pow( 1 + (pt-p)/p , 1/3.5 ) -1 ) );
+ // Mach number; _see notes in systems/pitot.cxx_
+ double mach = V_true / c;
+
+ // publish Mach and TAS
+ _mach_node->setDoubleValue(mach);
+ _tas_node->setDoubleValue(V_true * SG_MPS_TO_KT );