JSBSim Flight Dynamics Model  1.0 (02 March 2017)
An Open Source Flight Dynamics and Control Software Library in C++
FGSensor.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 
3  Header: FGSensor.h
4  Author: Jon Berndt
5  Date started: 9 July 2005
6 
7  ------------- Copyright (C) 2005 -------------
8 
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13 
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
17  details.
18 
19  You should have received a copy of the GNU Lesser General Public License along with
20  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21  Place - Suite 330, Boston, MA 02111-1307, USA.
22 
23  Further information about the GNU Lesser General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25 
26 HISTORY
27 --------------------------------------------------------------------------------
28 
29 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
30 SENTRY
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
32 
33 #ifndef FGSENSOR_H
34 #define FGSENSOR_H
35 
36 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37 INCLUDES
38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
39 
40 #include "FGFCSComponent.h"
41 #include <string>
42 
43 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44 DEFINITIONS
45 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
46 
47 #define ID_SENSOR "$Id: FGSensor.h,v 1.24 2014/01/02 21:58:42 bcoconni Exp $"
48 
49 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50 FORWARD DECLARATIONS
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
52 
53 namespace JSBSim {
54 
55 class FGFCS;
56 class Element;
57 
58 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 CLASS DOCUMENTATION
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
61 
130 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
131 CLASS DECLARATION
132 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
133 
134 class FGSensor : public FGFCSComponent
135 {
136 public:
137  FGSensor(FGFCS* fcs, Element* element);
138  virtual ~FGSensor();
139 
140  void SetFailLow(double val) {if (val > 0.0) fail_low = true; else fail_low = false;}
141  void SetFailHigh(double val) {if (val > 0.0) fail_high = true; else fail_high = false;}
142  void SetFailStuck(double val) {if (val > 0.0) fail_stuck = true; else fail_stuck = false;}
143 
144  double GetFailLow(void) const {if (fail_low) return 1.0; else return 0.0;}
145  double GetFailHigh(void) const {if (fail_high) return 1.0; else return 0.0;}
146  double GetFailStuck(void) const {if (fail_stuck) return 1.0; else return 0.0;}
147  int GetQuantized(void) const {return quantized;}
148 
149  virtual bool Run (void);
150  void ResetPastStates(void);
151 
152 protected:
153  enum eNoiseType {ePercent=0, eAbsolute} NoiseType;
154  enum eDistributionType {eUniform=0, eGaussian} DistributionType;
155  double min, max;
156  double span;
157  double bias;
158  double gain;
159  double drift_rate;
160  double drift;
161  double noise_variance;
162  double lag;
163  double granularity;
164  double ca;
165  double cb;
167  double PreviousInput;
168  int noise_type;
169  int bits;
170  int quantized;
171  int divisions;
172  bool fail_low;
173  bool fail_high;
174  bool fail_stuck;
175  std::string quant_property;
176 
177  void ProcessSensorSignal(void);
178  void Noise(void);
179  void Bias(void);
180  void Drift(void);
181  void Quantize(void);
182  void Lag(void);
183  void Gain(void);
184 
185  void bind(void);
186 
187 private:
188  void Debug(int from);
189 };
190 }
191 #endif
Encapsulates a Sensor component for the flight control system.
Definition: FGSensor.h:134
double cb
lag filter coefficient "a"
Definition: FGSensor.h:165
Encapsulates the Flight Control System (FCS) functionality.
Definition: FGFCS.h:193
Base class for JSBSim Flight Control System Components.
double PreviousOutput
lag filter coefficient "b"
Definition: FGSensor.h:166