]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/flight_control/FGFilter.h
Sync. with JSBSim CVS
[flightgear.git] / src / FDM / JSBSim / models / flight_control / FGFilter.h
index 694018e136855d2b7f0c2f5e5b9c71229e2b0af3..efb03541cef6cd4f63575456105a6a01ec68aa73 100644 (file)
@@ -4,23 +4,23 @@
  Author:       Jon S. Berndt
  Date started: 4/2000
 
- ------------- Copyright (C)  -------------
+ ------------- Copyright (C) 2000 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 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.
 
 HISTORY
@@ -38,13 +38,12 @@ INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #include "FGFCSComponent.h"
-#include <input_output/FGXMLElement.h>
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_FILTER "$Id$"
+#define ID_FILTER "$Id: FGFilter.h,v 1.12 2009/10/24 22:59:30 jberndt Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -52,120 +51,172 @@ FORWARD DECLARATIONS
 
 namespace JSBSim {
 
+class Element;
+class FGPropertyManager;
+class FGFCS;
+
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS DOCUMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 /** Encapsulates a filter for the flight control system.
-The filter component can simulate any filter up to second order. The
+The filter component can simulate any first or second order filter. The
 Tustin substitution is used to take filter definitions from LaPlace space to the
 time domain. The general format for a filter specification is:
 
-<pre>
-\<component name="name" type="type">
-  \<input> property \</input>
-  \<c1> value \<c/1>
-  [\<c2> value \<c/2>]
-  [\<c3> value \<c/3>]
-  [\<c4> value \<c/4>]
-  [\<c5> value \<c/5>]
-  [\<c6> value \<c/6>]
-  [\<output> property \<output>]
-\</component>
-</pre>
+@code
+<typename name="name">
+  <input> property </input>
+  <c1> value|property </c1>
+  [<c2> value|property </c2>]
+  [<c3> value|property </c3>]
+  [<c4> value|property </c4>]
+  [<c5> value|property </c5>]
+  [<c6> value|property </c6>]
+  [<clipto>
+    <min> {[-]property name | value} </min>
+    <max> {[-]property name | value} </max>
+  </clipto>]
+  [<output> property </output>]
+</typename>
+@endcode
 
 For a lag filter of the form,
-<pre>
+
+@code
   C1
 ------
 s + C1
-</pre>
+@endcode
+
 the corresponding filter definition is:
-<pre>
-\<component name="name" type="LAG_FILTER">
-  \<input> property \</input>
-  \<c1> value \<c/1>
-  [\<output> property \<output>]
-\</component>
-</pre>
+
+@code
+<lag_filter name="name">
+  <input> property </input>
+  <c1> value|property </c1>
+  [<clipto>
+    <min> {[-]property name | value} </min>
+    <max> {[-]property name | value} </max>
+  </clipto>]
+  [<output> property <output>]
+</lag_filter>
+@endcode
+
 As an example, for the specific filter:
-<pre>
+
+@code
   600
 ------
 s + 600
-</pre>
+@endcode
+
 the corresponding filter definition could be:
-<pre>
-\<component name="Heading Roll Error Lag" type="LAG_FILTER">
-  \<input> fcs/heading-command \</input>
-  \<c1> 600 \</c1>
-\</component>
-</pre>
+
+@code
+<lag_filter name="Heading Roll Error Lag">
+  <input> fcs/heading-command </input>
+  <c1> 600 </c1>
+</lag_filter>
+@endcode
+
 For a lead-lag filter of the form:
-<pre>
+
+@code
 C1*s + C2
 ---------
 C3*s + C4
-</pre>
+@endcode
+
 The corresponding filter definition is:
-<pre>
-\<component name="name" type="LEAD_LAG_FILTER">
-  \<input> property \</input>
-  \<c1> value \<c/1>
-  \<c2> value \<c/2>
-  \<c3> value \<c/3>
-  \<c4> value \<c/4>
-  [\<output> property \<output>]
-\</component>
-</pre>
+
+@code
+<lead_lag_filter name="name">
+  <input> property </input>
+  <c1> value|property <c/1>
+  <c2> value|property <c/2>
+  <c3> value|property <c/3>
+  <c4> value|property <c/4>
+  [<clipto>
+    <min> {[-]property name | value} </min>
+    <max> {[-]property name | value} </max>
+  </clipto>]
+  [<output> property </output>]
+</lead_lag_filter>
+@endcode
+
 For a washout filter of the form:
-<pre>
+
+@code
   s
 ------
 s + C1
-</pre>
+@endcode
+
 The corresponding filter definition is:
-<pre>
-\<component name="name" type="WASHOUT_FILTER">
-  \<input> property \</input>
-  \<c1> value \</c1>
-  [\<output> property \<output>]
-\</component>
-</pre>
+
+@code
+<washout_filter name="name">
+  <input> property </input>
+  <c1> value </c1>
+  [<clipto>
+    <min> {[-]property name | value} </min>
+    <max> {[-]property name | value} </max>
+  </clipto>]
+  [<output> property </output>]
+</washout_filter>
+@endcode
+
 For a second order filter of the form:
-<pre>
+
+@code
 C1*s^2 + C2*s + C3
 ------------------
 C4*s^2 + C5*s + C6
-</pre>
+@endcode
+
 The corresponding filter definition is:
-<pre>
-\<component name="name" type="SECOND_ORDER_FILTER">
-  \<input> property \</input>
-  \<c1> value \<c/1>
-  \<c2> value \<c/2>
-  \<c3> value \<c/3>
-  \<c4> value \<c/4>
-  \<c5> value \<c/5>
-  \<c6> value \<c/6>
-  [\<output> property \<output>]
-\</component>
-</pre>
+
+@code
+<second_order_filter name="name">
+  <input> property </input>
+  <c1> value|property </c1>
+  <c2> value|property </c2>
+  <c3> value|property </c3>
+  <c4> value|property </c4>
+  <c5> value|property </c5>
+  <c6> value|property </c6>
+  [<clipto>
+    <min> {[-]property name | value} </min>
+    <max> {[-]property name | value} </max>
+  </clipto>]
+  [<output> property </output>]
+</second_order_filter>
+@endcode
+
 For an integrator of the form:
-<pre>
+
+@code
  C1
  ---
   s
-</pre>
+@endcode
+
 The corresponding filter definition is:
-<pre>
-\<component name="name" type="INTEGRATOR">
-  \<input> property \</input>
-  \<c1> value \<c/1>
-  [\<trigger> property \</trigger>]
-  [\<output> property \<output>]
-\</component>
-</pre>
+
+@code
+<integrator name="name">
+  <input> property </input>
+  <c1> value|property </c1>
+  [<trigger> property </trigger>]
+  [<clipto>
+    <min> {[-]property name | value} </min>
+    <max> {[-]property name | value} </max>
+  </clipto>]
+  [<output> property </output>]
+</integrator>
+@endcode
+
 For the integrator, the trigger features the following behavior. If the trigger
 property value is:
   - 0: no action is taken - the output is calculated normally
@@ -177,7 +228,8 @@ is so that the last component in a "string" can copy its value to the appropriat
 output, such as the elevator, or speedbrake, etc.
 
 @author Jon S. Berndt
-@version $Id$
+@version $Revision: 1.12 $
+
 */
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -195,27 +247,27 @@ public:
   /** When true, causes previous values to be set to current values. This
       is particularly useful for first pass. */
   bool Initialize;
-
+  void ResetPastStates(void) {Input = 0.0; Initialize = true;}
+  
   enum {eLag, eLeadLag, eOrder2, eWashout, eIntegrator, eUnknown} FilterType;
 
 private:
-  double dt;
   double ca;
   double cb;
   double cc;
   double cd;
   double ce;
-  double C1;
-  double C2;
-  double C3;
-  double C4;
-  double C5;
-  double C6;
+  double C[7]; // There are 6 coefficients, indexing is "1" based.
+  double PropertySign[7];
   double PreviousInput1;
   double PreviousInput2;
   double PreviousOutput1;
   double PreviousOutput2;
   FGPropertyManager* Trigger;
+  FGPropertyManager* PropertyNode[7];
+  void CalculateDynamicFilters(void);
+  void ReadFilterCoefficients(Element* el, int index);
+  bool DynamicFilter;
   void Debug(int from);
 };
 }