]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/flight_control/FGSensor.h
Sync. with JSBSim (CVS) again
[flightgear.git] / src / FDM / JSBSim / models / flight_control / FGSensor.h
index fddede8577e180ce547aaed5a06368c632dd9ca5..1e8701c90c5e1491a165c60ffee9e8036e5c0503 100755 (executable)
@@ -39,6 +39,7 @@ INCLUDES
 
 #include "FGFCSComponent.h"
 #include <input_output/FGXMLElement.h>
+#include <vector>
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
@@ -52,6 +53,7 @@ FORWARD DECLARATIONS
 
 namespace JSBSim {
 
+using std::vector;
 class FGFCS;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -74,6 +76,7 @@ Syntax:
   </quantization>
   <drift_rate> number </drift_rate>
   <bias> number </bias>
+  <delay> number < /delay>
 </sensor>
 @endcode
 
@@ -101,7 +104,8 @@ 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$
@@ -115,25 +119,27 @@ 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;}
-  inline int    GetQuantized(void) const {return quantized;}
+  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;
+  enum eDistributionType {eUniform=0, eGaussian} DistributionType;
   double dt;
   double min, max;
   double span;
   double bias;
+  double gain;
   double drift_rate;
   double drift;
   double noise_variance;
@@ -147,19 +153,25 @@ private:
   int bits;
   int quantized;
   int divisions;
+  int delay;
+  int index;
   bool fail_low;
   bool fail_high;
   bool fail_stuck;
   string quant_property;
+  vector <double> output_array;
 
   void Noise(void);
   void Bias(void);
   void Drift(void);
   void Quantize(void);
   void Lag(void);
+  void Delay(void);
+  void Gain(void);
 
   void bind(void);
 
+private:
   void Debug(int from);
 };
 }