]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/flight_control/FGSensor.h
Merge branch 'next' of git://gitorious.org/fg/flightgear into next
[flightgear.git] / src / FDM / JSBSim / models / flight_control / FGSensor.h
old mode 100755 (executable)
new mode 100644 (file)
index 37205ba..bcc18db
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 2005 -------------
 
  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,13 @@ INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #include "FGFCSComponent.h"
-#include <input_output/FGXMLElement.h>
+#include <string>
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_SENSOR "$Id$"
+#define ID_SENSOR "$Id: FGSensor.h,v 1.19 2009/10/24 22:59:30 jberndt Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -53,6 +53,7 @@ FORWARD DECLARATIONS
 namespace JSBSim {
 
 class FGFCS;
+class Element;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS DOCUMENTATION
@@ -62,10 +63,11 @@ CLASS DOCUMENTATION
 
 Syntax:
 
-<sensor name=\94name\94 rate_group=\94name\94>
+@code
+<sensor name="name">
   <input> property </input>
   <lag> number </lag>
-  <noise variation=\94PERCENT|ABSOLUTE\94> number </noise>
+  <noise variation="PERCENT|ABSOLUTE"> number </noise>
   <quantization name="name">
     <bits> number </bits>
     <min> number </min>
@@ -73,14 +75,17 @@ Syntax:
   </quantization>
   <drift_rate> number </drift_rate>
   <bias> number </bias>
+  <delay> number < /delay>
 </sensor>
+@endcode
 
 Example:
 
-<sensor name=\94aero/sensor/qbar\94 rate_group=\94HFCS\94>
+@code
+<sensor name="aero/sensor/qbar">
   <input> aero/qbar </input>
   <lag> 0.5 </lag>
-  <noise variation=\94PERCENT\94> 2 </noise>
+  <noise variation="PERCENT"> 2 </noise>
   <quantization name="aero/sensor/quantized/qbar">
     <bits> 12 </bits>
     <min> 0 </min>
@@ -88,6 +93,7 @@ Example:
   </quantization>
   <bias> 0.5 </bias>
 </sensor>
+@endcode
 
 The only required element in the sensor definition is the input element. In that
 case, no degradation would be modeled, and the output would simply be the input.
@@ -97,11 +103,12 @@ percentage variance. That is, if the number given is 0.05, the the variance is
 understood to be +/-0.05 percent maximum variance. So, the actual value for the sensor
 will be *anywhere* from 0.95 to 1.05 of the actual "perfect" value at any time -
 even varying all the way from 0.95 to 1.05 in adjacent frames - whatever the delta
-time.
+time. The delay element can specify a frame delay. The integer number provided is
+the number of frames to delay the output signal.
 
 @author Jon S. Berndt
-@version $Revision$
-  */
+@version $Revision: 1.19 $
+*/
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS DECLARATION
@@ -111,24 +118,26 @@ class FGSensor  : public FGFCSComponent
 {
 public:
   FGSensor(FGFCS* fcs, Element* element);
-  ~FGSensor();
+  virtual ~FGSensor();
 
-  inline void SetFailLow(double val) {if (val > 0.0) fail_low = true; else fail_low = false;}
-  inline void SetFailHigh(double val) {if (val > 0.0) fail_high = true; else fail_high = false;}
-  inline void SetFailStuck(double val) {if (val > 0.0) fail_stuck = true; else fail_stuck = false;}
+  void SetFailLow(double val) {if (val > 0.0) fail_low = true; else fail_low = false;}
+  void SetFailHigh(double val) {if (val > 0.0) fail_high = true; else fail_high = false;}
+  void SetFailStuck(double val) {if (val > 0.0) fail_stuck = true; else fail_stuck = false;}
 
-  inline double GetFailLow(void) const {if (fail_low) return 1.0; else return 0.0;}
-  inline double GetFailHigh(void) const {if (fail_high) return 1.0; else return 0.0;}
-  inline double GetFailStuck(void) const {if (fail_stuck) return 1.0; else return 0.0;}
+  double GetFailLow(void) const {if (fail_low) return 1.0; else return 0.0;}
+  double GetFailHigh(void) const {if (fail_high) return 1.0; else return 0.0;}
+  double GetFailStuck(void) const {if (fail_stuck) return 1.0; else return 0.0;}
+  int    GetQuantized(void) const {return quantized;}
 
-  bool Run (void);
+  virtual bool Run (void);
 
-private:
+protected:
   enum eNoiseType {ePercent=0, eAbsolute} NoiseType;
-  double dt;
+  enum eDistributionType {eUniform=0, eGaussian} DistributionType;
   double min, max;
   double span;
   double bias;
+  double gain;
   double drift_rate;
   double drift;
   double noise_variance;
@@ -145,15 +154,19 @@ private:
   bool fail_low;
   bool fail_high;
   bool fail_stuck;
+  std::string quant_property;
 
+  void ProcessSensorSignal(void);
   void Noise(void);
   void Bias(void);
   void Drift(void);
   void Quantize(void);
   void Lag(void);
+  void Gain(void);
 
   void bind(void);
 
+private:
   void Debug(int from);
 };
 }