]> git.mxchange.org Git - flightgear.git/blobdiff - src/Instrumentation/inst_vertical_speed_indicator.cxx
Make voiceplayer independent
[flightgear.git] / src / Instrumentation / inst_vertical_speed_indicator.cxx
index 81c746306e367ab26b56a9f77378fd6fa6bafb72..0237a6ded883c7a98a68a1e5fba518c0aee8a2fe 100644 (file)
 //
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 
+#include <limits>
 #include <simgear/math/interpolater.hxx>
 
 #include "inst_vertical_speed_indicator.hxx"
@@ -131,34 +132,20 @@ static double altitude_data[][2] = {
 
 
 InstVerticalSpeedIndicator::InstVerticalSpeedIndicator ( SGPropertyNode *node ) :
+                            _name(node->getStringValue("name", "inst-vertical-speed-indicator")),
+                            _num(node->getIntValue("number", 0)),
                             _internal_pressure_inhg( SEA_LEVEL_INHG ),
-                           _internal_sea_inhg( SEA_LEVEL_INHG ),
-                           _pressure_table(new SGInterpTable),
-                            _altitude_table(new SGInterpTable),
-                           _speed_ft_per_s( 0 )
+                            _internal_sea_inhg( SEA_LEVEL_INHG ),
+                            _speed_ft_per_s( 0 ),
+                            _pressure_table(new SGInterpTable),
+                            _altitude_table(new SGInterpTable)
 {
-    for (int i = 0; pressure_data[i][0] != -1; i++)
+    int i;
+    for ( i = 0; pressure_data[i][0] != -1; i++)
         _pressure_table->addEntry( pressure_data[i][0], pressure_data[i][1] );
 
-    for (int i = 0; altitude_data[i][0] != -1; i++)
+    for ( i = 0; altitude_data[i][0] != -1; i++)
         _altitude_table->addEntry( altitude_data[i][0], altitude_data[i][1] );
-
-    int i;
-    for ( i = 0; i < node->nChildren(); ++i ) {
-        SGPropertyNode *child = node->getChild(i);
-        string cname = child->getName();
-        string cval = child->getStringValue();
-        if ( cname == "name" ) {
-            name = cval;
-        } else if ( cname == "number" ) {
-            num = child->getIntValue();
-        } else {
-            SG_LOG( SG_INSTR, SG_WARN, "Error in inst-vertical-speed-indicator config logic" );
-            if ( name.length() ) {
-                SG_LOG( SG_INSTR, SG_WARN, "Section = " << name );
-            }
-        }
-    }
 }
 
 
@@ -171,8 +158,10 @@ InstVerticalSpeedIndicator::~InstVerticalSpeedIndicator ()
 
 void InstVerticalSpeedIndicator::init ()
 {
+    SGPropertyNode *node = fgGetNode("/instrumentation", true)->getChild(_name, _num, true);
+
     _serviceable_node =
-        fgGetNode("/instrumentation/inst-vertical-speed-indicator/serviceable", true);
+        node->getNode("serviceable", true);
     _freeze_node =
         fgGetNode("/sim/freeze/master", true);
 
@@ -189,11 +178,9 @@ void InstVerticalSpeedIndicator::init ()
     _speed_up_node =
         fgGetNode("/sim/speed-up", true);
     _speed_node =
-        fgGetNode("/instrumentation/inst-vertical-speed-indicator/indicated-speed-fps",
-                  true);
+        node->getNode("indicated-speed-fps", true);
     _speed_min_node =
-        fgGetNode("/instrumentation/inst-vertical-speed-indicator/indicated-speed-fpm",
-                  true);
+        node->getNode("indicated-speed-fpm", true);
 
     // Initialize at ambient pressure
     _internal_pressure_inhg = _pressure_node->getDoubleValue();
@@ -205,7 +192,7 @@ void InstVerticalSpeedIndicator::update (double dt)
     if (_serviceable_node->getBoolValue())
     {
        // avoids hang, when freeze
-        if( !_freeze_node->getBoolValue() )
+        if( !_freeze_node->getBoolValue() && std::numeric_limits<double>::min() < fabs(dt))
        {
            double pressure_inhg = _pressure_node->getDoubleValue();
            double sea_inhg = _sea_node->getDoubleValue();