]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/flight_control/FGActuator.cpp
Andreas Gaeb: fix #222 (JSBSIm reset problems)
[flightgear.git] / src / FDM / JSBSim / models / flight_control / FGActuator.cpp
old mode 100755 (executable)
new mode 100644 (file)
index 6db41de..4c58beb
@@ -4,7 +4,7 @@
  Author:       Jon Berndt
  Date started: 21 February 2006
 
- ------------- Copyright (C) 2007 Jon S. Berndt (jsb@hal-pc.org) -------------
+ ------------- Copyright (C) 2007 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
@@ -37,13 +37,13 @@ COMMENTS, REFERENCES,  and NOTES
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#include <algorithm>
-
 #include "FGActuator.h"
 
+using namespace std;
+
 namespace JSBSim {
 
-static const char *IdSrc = "$Id$";
+static const char *IdSrc = "$Id: FGActuator.cpp,v 1.14 2009/10/24 22:59:30 jberndt Exp $";
 static const char *IdHdr = ID_ACTUATOR;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -54,7 +54,6 @@ CLASS IMPLEMENTATION
 FGActuator::FGActuator(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
 {
   double denom;
-  dt = fcs->GetDt();
 
   // inputs are read from the base class constructor
 
@@ -103,13 +102,17 @@ FGActuator::~FGActuator()
 
 bool FGActuator::Run(void )
 {
-  dt = fcs->GetDt();
-
   Input = InputNodes[0]->getDoubleValue() * InputSigns[0];
-  Output = Input; // perfect actuator
 
   if (fail_zero) Input = 0;
-  if (fail_hardover) Input =  clipmax*fabs(Input)/Input;
+  if (fail_hardover) Input =  clipmax*sign(Input);
+
+  Output = Input; // Perfect actuator. At this point, if no failures are present
+                  // and no subsequent lag, limiting, etc. is done, the output
+                  // is simply the input. If any further processing is done
+                  // (below) such as lag, rate limiting, hysteresis, etc., then
+                  // the Input will be further processed and the eventual Output
+                  // will be overwritten from this perfect value.
 
   if (lag != 0.0)              Lag();        // models actuator lag
   if (rate_limit != 0)         RateLimit();  // limit the actuator rate
@@ -155,9 +158,9 @@ void FGActuator::Hysteresis(void)
   double input = Output;
   
   if (input > PreviousHystOutput) {
-    Output = std::max(PreviousHystOutput, input-0.5*hysteresis_width);
+    Output = max(PreviousHystOutput, input-0.5*hysteresis_width);
   } else if (input < PreviousHystOutput) {
-    Output = std::min(PreviousHystOutput, input+0.5*hysteresis_width);
+    Output = min(PreviousHystOutput, input+0.5*hysteresis_width);
   }
 
   PreviousHystOutput = Output;
@@ -190,7 +193,10 @@ void FGActuator::Deadband(void)
 
 void FGActuator::bind(void)
 {
-  string tmp = "fcs/" + PropertyManager->mkPropertyName(Name, true);
+  string tmp = Name;
+  if (Name.find("/") == string::npos) {
+    tmp = "fcs/" + PropertyManager->mkPropertyName(Name, true);
+  }
   const string tmp_zero = tmp + "/malfunction/fail_zero";
   const string tmp_hardover = tmp + "/malfunction/fail_hardover";
   const string tmp_stuck = tmp + "/malfunction/fail_stuck";
@@ -230,7 +236,10 @@ void FGActuator::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 (bias != 0.0) cout << "      Bias: " << bias << endl;
       if (rate_limit != 0) cout << "      Rate limit: " << rate_limit << endl;
       if (lag != 0) cout << "      Actuator lag: " << lag << endl;