]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/flight_control/FGDeadBand.cpp
Merge branch 'next' of git://gitorious.org/fg/flightgear into next
[flightgear.git] / src / FDM / JSBSim / models / flight_control / FGDeadBand.cpp
index 4bdb8108eb151e0b1592e3274ff3993404e3b282..361afb66a1bf48848f3d4f3536cee60e9189ea5f 100644 (file)
@@ -38,10 +38,15 @@ INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #include "FGDeadBand.h"
+#include "input_output/FGXMLElement.h"
+#include "input_output/FGPropertyManager.h"
+#include <iostream>
+
+using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id$";
+static const char *IdSrc = "$Id: FGDeadBand.cpp,v 1.9 2009/10/24 22:59:30 jberndt Exp $";
 static const char *IdHdr = ID_DEADBAND;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -52,11 +57,24 @@ CLASS IMPLEMENTATION
 
 FGDeadBand::FGDeadBand(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
 {
+  string width_string;
+
+  WidthPropertyNode = 0;
+  WidthPropertySign = 1.0;
   gain = 1.0;
   width = 0.0;
 
-  if (element->FindElement("width")) {
-    width = element->FindElementValueAsNumber("width");
+  if ( element->FindElement("width") ) {
+    width_string = element->FindElementValue("width");
+    if (!is_number(width_string)) { // property
+      if (width_string[0] == '-') {
+       WidthPropertySign = -1.0;
+       width_string.erase(0,1);
+      }
+      WidthPropertyNode = PropertyManager->GetNode(width_string);
+    } else {
+      width = element->FindElementValueAsNumber("width");
+    }
   }
 
   if (element->FindElement("gain")) {
@@ -80,6 +98,10 @@ bool FGDeadBand::Run(void )
 {
   Input = InputNodes[0]->getDoubleValue() * InputSigns[0];
 
+  if (WidthPropertyNode != 0) {
+    width = WidthPropertyNode->getDoubleValue() * WidthPropertySign;
+  }
+
   if (Input < -width/2.0) {
     Output = (Input + width/2.0)*gain;
   } else if (Input > width/2.0) {
@@ -120,12 +142,17 @@ void FGDeadBand::Debug(int from)
 
   if (debug_lvl & 1) { // Standard console startup message output
     if (from == 0) { // Constructor
-      cout << "      INPUT: " << InputNodes[0]->getName() << endl;
-      cout << "      DEADBAND WIDTH: " << width << endl;
+      cout << "      INPUT: " << InputNodes[0]->GetName() << endl;
+      if (WidthPropertyNode != 0) {
+        cout << "      DEADBAND WIDTH: " << WidthPropertyNode->GetName() << endl;
+      } else {
+        cout << "      DEADBAND WIDTH: " << width << endl;
+      }
       cout << "      GAIN: " << gain << endl;
-      if (clip) cout << "      CLIPTO: " << clipmin
-                                  << ", " << clipmax << endl;
-      if (IsOutput) cout << "      OUTPUT: " << OutputNode->getName() << endl;
+      if (IsOutput) {
+        for (unsigned int i=0; i<OutputNodes.size(); i++)
+          cout << "      OUTPUT: " << OutputNodes[i]->getName() << endl;
+      }
     }
   }
   if (debug_lvl & 2 ) { // Instantiation/Destruction notification