JSBSim Flight Dynamics Model  1.1.11 (13 Feb 2022)
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
11  Software Foundation; either version 2 of the License, or (at your option) any
12  later 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
20  with this program; if not, write to the Free Software Foundation, Inc., 59
21  Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 
23  Further information about the GNU Lesser General Public License can also be
24  found on 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 
42 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 FORWARD DECLARATIONS
44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
45 
46 namespace JSBSim {
47 
48 class FGFCS;
49 class Element;
50 
51 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52 CLASS DOCUMENTATION
53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
54 
123 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
124 CLASS DECLARATION
125 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
126 
127 class FGSensor : public FGFCSComponent
128 {
129 public:
130  FGSensor(FGFCS* fcs, Element* element);
131  virtual ~FGSensor();
132 
133  void SetFailLow(double val) {if (val > 0.0) fail_low = true; else fail_low = false;}
134  void SetFailHigh(double val) {if (val > 0.0) fail_high = true; else fail_high = false;}
135  void SetFailStuck(double val) {if (val > 0.0) fail_stuck = true; else fail_stuck = false;}
136 
137  double GetFailLow(void) const {if (fail_low) return 1.0; else return 0.0;}
138  double GetFailHigh(void) const {if (fail_high) return 1.0; else return 0.0;}
139  double GetFailStuck(void) const {if (fail_stuck) return 1.0; else return 0.0;}
140  int GetQuantized(void) const {return quantized;}
141 
142  bool Run (void) override;
143  void ResetPastStates(void) override;
144 
145 protected:
146  enum eNoiseType {ePercent=0, eAbsolute} NoiseType;
147  enum eDistributionType {eUniform=0, eGaussian} DistributionType;
148  double min, max;
149  double span;
150  double bias;
151  double gain;
152  double drift_rate;
153  double drift;
154  double noise_variance;
155  double lag;
156  double granularity;
157  double ca;
158  double cb;
160  double PreviousInput;
161  int noise_type;
162  int bits;
163  int quantized;
164  int divisions;
165  bool fail_low;
166  bool fail_high;
167  bool fail_stuck;
168  std::string quant_property;
169 
170  void ProcessSensorSignal(void);
171  void Noise(void);
172  void Bias(void);
173  void Drift(void);
174  void Quantize(void);
175  void Lag(void);
176  void Gain(void);
177 
178  void bind(Element* el) override;
179 
180 private:
181  void Debug(int from) override;
182 };
183 }
184 #endif
JSBSim::FGSensor::PreviousOutput
double PreviousOutput
lag filter coefficient "b"
Definition: FGSensor.h:159
JSBSim::FGFCSComponent
Base class for JSBSim Flight Control System Components.
Definition: FGFCSComponent.h:84
JSBSim::FGSensor
Encapsulates a Sensor component for the flight control system.
Definition: FGSensor.h:127
JSBSim::FGFCS
Encapsulates the Flight Control System (FCS) functionality.
Definition: FGFCS.h:187
JSBSim::Element
Definition: FGXMLElement.h:143
JSBSim::FGSensor::cb
double cb
lag filter coefficient "a"
Definition: FGSensor.h:158