]> git.mxchange.org Git - flightgear.git/blobdiff - src/Instrumentation/turn_indicator.cxx
Begin a rewrite of the magnetic compass code. So far, only northerly
[flightgear.git] / src / Instrumentation / turn_indicator.cxx
index 84bfdbdf81661fcb0434bb3cd44a3c79fee7d7e0..6eab60a491000987514f2894e9e1de3fccd5b0ba 100644 (file)
 
 // Use a bigger number to be more responsive, or a smaller number
 // to be more sluggish.
-#define RESPONSIVENESS 1.0
+#define RESPONSIVENESS 0.5
 
 
+TurnIndicator::TurnIndicator ( SGPropertyNode *node) :
+    _last_rate(0),
+    name("turn-indicator"),
+    num(0)
+{
+    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 turn-indicator config logic" );
+            if ( name.length() ) {
+                SG_LOG( SG_INSTR, SG_WARN, "Section = " << name );
+            }
+        }
+    }
+}
+
 TurnIndicator::TurnIndicator () :
     _last_rate(0)
 {
@@ -25,28 +48,40 @@ TurnIndicator::~TurnIndicator ()
 void
 TurnIndicator::init ()
 {
+    string branch;
+    branch = "/instrumentation/" + name;
+
+    SGPropertyNode *node = fgGetNode(branch.c_str(), num, true );
     _roll_rate_node = fgGetNode("/orientation/roll-rate-degps", true);
     _yaw_rate_node = fgGetNode("/orientation/yaw-rate-degps", true);
     _electric_current_node = 
         fgGetNode("/systems/electrical/outputs/turn-coordinator", true);
-    _rate_out_node = 
-        fgGetNode("/instrumentation/turn-indicator/indicated-turn-rate", true);
+    _rate_out_node = node->getChild("indicated-turn-rate", 0, true);
+
+    //_serviceable_node->setBoolValue(true);
+    
 }
 
 void
 TurnIndicator::bind ()
 {
-    fgTie("/instrumentation/turn-indicator/serviceable",
+    string branch;
+    branch = "/instrumentation/" + name + "/serviceable";
+    fgTie(branch.c_str(),
           &_gyro, &Gyro::is_serviceable, &Gyro::set_serviceable);
-    fgTie("/instrumentation/turn-indicator/spin",
+    branch = "/instrumentation/" + name + "/spin";
+    fgTie(branch.c_str(),
           &_gyro, &Gyro::get_spin_norm, &Gyro::set_spin_norm);
 }
 
 void
 TurnIndicator::unbind ()
 {
-    fgUntie("/instrumentation/turn-indicator/serviceable");
-    fgUntie("/instrumentation/turn-indicator/spin");
+    string branch;
+    branch = "/instrumentation/" + name + "/serviceable";
+    fgUntie(branch.c_str());
+    branch = "/instrumentation/" + name + "/spin";
+    fgUntie(branch.c_str());
 }
 
 void