JSBSim Flight Dynamics Model 1.0 (23 February 2013)
An Open Source Flight Dynamics and Control Software Library in C++

FGSensor.h

00001 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00002 
00003  Header:       FGSensor.h
00004  Author:       Jon Berndt
00005  Date started: 9 July 2005
00006 
00007  ------------- Copyright (C) 2005 -------------
00008 
00009  This program is free software; you can redistribute it and/or modify it under
00010  the terms of the GNU Lesser General Public License as published by the Free Software
00011  Foundation; either version 2 of the License, or (at your option) any later
00012  version.
00013 
00014  This program is distributed in the hope that it will be useful, but WITHOUT
00015  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00016  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00017  details.
00018 
00019  You should have received a copy of the GNU Lesser General Public License along with
00020  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021  Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00023  Further information about the GNU Lesser General Public License can also be found on
00024  the world wide web at http://www.gnu.org.
00025 
00026 HISTORY
00027 --------------------------------------------------------------------------------
00028 
00029 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00030 SENTRY
00031 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
00032 
00033 #ifndef FGSENSOR_H
00034 #define FGSENSOR_H
00035 
00036 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00037 INCLUDES
00038 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
00039 
00040 #include "FGFCSComponent.h"
00041 #include <string>
00042 
00043 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00044 DEFINITIONS
00045 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
00046 
00047 #define ID_SENSOR "$Id: FGSensor.h,v 1.21 2012/01/08 12:39:14 bcoconni Exp $"
00048 
00049 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00050 FORWARD DECLARATIONS
00051 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
00052 
00053 namespace JSBSim {
00054 
00055 class FGFCS;
00056 class Element;
00057 
00058 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00059 CLASS DOCUMENTATION
00060 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
00061 
00130 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00131 CLASS DECLARATION
00132 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
00133 
00134 class FGSensor  : public FGFCSComponent
00135 {
00136 public:
00137   FGSensor(FGFCS* fcs, Element* element);
00138   virtual ~FGSensor();
00139 
00140   void SetFailLow(double val) {if (val > 0.0) fail_low = true; else fail_low = false;}
00141   void SetFailHigh(double val) {if (val > 0.0) fail_high = true; else fail_high = false;}
00142   void SetFailStuck(double val) {if (val > 0.0) fail_stuck = true; else fail_stuck = false;}
00143 
00144   double GetFailLow(void) const {if (fail_low) return 1.0; else return 0.0;}
00145   double GetFailHigh(void) const {if (fail_high) return 1.0; else return 0.0;}
00146   double GetFailStuck(void) const {if (fail_stuck) return 1.0; else return 0.0;}
00147   int    GetQuantized(void) const {return quantized;}
00148 
00149   virtual bool Run (void);
00150 
00151 protected:
00152   enum eNoiseType {ePercent=0, eAbsolute} NoiseType;
00153   enum eDistributionType {eUniform=0, eGaussian} DistributionType;
00154   double min, max;
00155   double span;
00156   double bias;
00157   double gain;
00158   double drift_rate;
00159   double drift;
00160   double noise_variance;
00161   double lag;
00162   double granularity;
00163   double ca; 
00164   double cb; 
00165   double PreviousOutput;
00166   double PreviousInput;
00167   int noise_type;
00168   int bits;
00169   int quantized;
00170   int divisions;
00171   bool fail_low;
00172   bool fail_high;
00173   bool fail_stuck;
00174   std::string quant_property;
00175 
00176   void ProcessSensorSignal(void);
00177   void Noise(void);
00178   void Bias(void);
00179   void Drift(void);
00180   void Quantize(void);
00181   void Lag(void);
00182   void Gain(void);
00183 
00184   void bind(void);
00185 
00186 private:
00187   void Debug(int from);
00188 };
00189 }
00190 #endif