]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/flight_control/FGDeadBand.cpp
Sync. with JSBSim (CVS) again
[flightgear.git] / src / FDM / JSBSim / models / flight_control / FGDeadBand.cpp
index bbd8f68f0c00137d2909941a66e0256d831aad06..745f8ad281d5804fa14fa14ae82b0c2009ea7c35 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 2000 -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
  Foundation; either version 2 of the License, or (at your option) any later
  version.
 
  This program is distributed in the hope that it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
  Place - Suite 330, Boston, MA  02111-1307, USA.
 
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 FUNCTIONAL DESCRIPTION
@@ -52,11 +52,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 +93,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) {
@@ -121,10 +138,12 @@ 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;
+      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;
     }
   }