]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/flight_control/FGPID.cpp
Andreas Gaeb: fix #222 (JSBSIm reset problems)
[flightgear.git] / src / FDM / JSBSim / models / flight_control / FGPID.cpp
index e2395e3a114fad6949ae7bf556452219738a9b3d..ac265b8ff991275b7cff7e2561a3dc5ce99b44dc 100755 (executable)
@@ -4,7 +4,7 @@
  Author:       Jon S. Berndt
  Date started: 6/17/2006
 
- ------------- Copyright (C) 2006 Jon S. Berndt (jsb@hal-pc.org) -------------
+ ------------- Copyright (C) 2006 Jon S. Berndt (jon@jsbsim.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
  the terms of the GNU Lesser General Public License as published by the Free Software
@@ -36,10 +36,15 @@ INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #include "FGPID.h"
+#include "input_output/FGXMLElement.h"
+#include <string>
+#include <iostream>
+
+using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id$";
+static const char *IdSrc = "$Id: FGPID.cpp,v 1.16 2009/10/24 22:59:30 jberndt Exp $";
 static const char *IdHdr = ID_PID;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -49,7 +54,6 @@ CLASS IMPLEMENTATION
 FGPID::FGPID(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
 {
   string kp_string, ki_string, kd_string;
-  dt = fcs->GetState()->Getdt();
 
   Kp = Ki = Kd = 0.0;
   KpPropertyNode = 0;
@@ -64,7 +68,7 @@ FGPID::FGPID(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
 
   if ( element->FindElement("kp") ) {
     kp_string = element->FindElementValue("kp");
-    if (kp_string.find_first_not_of("+-.0123456789Ee") != string::npos) { // property
+    if (!is_number(kp_string)) { // property
       if (kp_string[0] == '-') {
        KpPropertySign = -1.0;
        kp_string.erase(0,1);
@@ -77,7 +81,7 @@ FGPID::FGPID(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
 
   if ( element->FindElement("ki") ) {
     ki_string = element->FindElementValue("ki");
-    if (ki_string.find_first_not_of("+-.0123456789Ee") != string::npos) { // property
+    if (!is_number(ki_string)) { // property
       if (ki_string[0] == '-') {
        KiPropertySign = -1.0;
        ki_string.erase(0,1);
@@ -90,7 +94,7 @@ FGPID::FGPID(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
 
   if ( element->FindElement("kd") ) {
     kd_string = element->FindElementValue("kd");
-    if (kd_string.find_first_not_of("+-.0123456789Ee") != string::npos) { // property
+    if (!is_number(kd_string)) { // property
       if (kd_string[0] == '-') {
        KdPropertySign = -1.0;
        kd_string.erase(0,1);
@@ -101,9 +105,6 @@ FGPID::FGPID(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
     }
   }
 
-  //if (element->FindElement("kp")) Kp = element->FindElementValueAsNumber("kp");
-  //if (element->FindElement("ki")) Ki = element->FindElementValueAsNumber("ki");
-  //if (element->FindElement("kd")) Kd = element->FindElementValueAsNumber("kd");
   if (element->FindElement("trigger")) {
     Trigger =  PropertyManager->GetNode(element->FindElementValue("trigger"));
   }
@@ -192,7 +193,10 @@ void FGPID::Debug(int from)
       else
         cout << "      INPUT: " << InputNodes[0]->getName() << 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