FlightGear next
FGSensor.h
Go to the documentation of this file.
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
26HISTORY
27--------------------------------------------------------------------------------
28
29%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
30SENTRY
31%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
32
33#ifndef FGSENSOR_H
34#define FGSENSOR_H
35
36/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37INCLUDES
38%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
39
40#include "FGFCSComponent.h"
41
42/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43FORWARD DECLARATIONS
44%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
45
46namespace JSBSim {
47
48class FGFCS;
49class Element;
50
51/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52CLASS DOCUMENTATION
53%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
54
122
123/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
124CLASS DECLARATION
125%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
126
128{
129public:
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
145protected:
148 double min, max;
149 double span;
150 double bias;
151 double gain;
153 double drift;
155 double lag;
157 double ca;
158 double cb;
162 int bits;
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
180private:
181 void Debug(int from) override;
182};
183}
184#endif
FGFCSComponent(FGFCS *fcs, Element *el)
Constructor.
double PreviousInput
Definition FGSensor.h:160
std::string quant_property
Definition FGSensor.h:168
double GetFailLow(void) const
Definition FGSensor.h:137
virtual ~FGSensor()
Definition FGSensor.cpp:125
double drift_rate
Definition FGSensor.h:152
double cb
lag filter coefficient "a"
Definition FGSensor.h:158
void Noise(void)
Definition FGSensor.cpp:180
double granularity
Definition FGSensor.h:156
bool Run(void) override
Definition FGSensor.cpp:141
void Quantize(void)
Definition FGSensor.cpp:225
void bind(Element *el) override
Definition FGSensor.cpp:247
void SetFailStuck(double val)
Definition FGSensor.h:135
enum JSBSim::FGSensor::eDistributionType DistributionType
void SetFailLow(double val)
Definition FGSensor.h:133
double noise_variance
Definition FGSensor.h:154
double GetFailHigh(void) const
Definition FGSensor.h:138
enum JSBSim::FGSensor::eNoiseType NoiseType
double PreviousOutput
lag filter coefficient "b"
Definition FGSensor.h:159
FGSensor(FGFCS *fcs, Element *element)
Definition FGSensor.cpp:52
int GetQuantized(void) const
Definition FGSensor.h:140
double GetFailStuck(void) const
Definition FGSensor.h:139
void Gain(void)
Definition FGSensor.cpp:210
void Lag(void)
Definition FGSensor.cpp:236
void ResetPastStates(void) override
Definition FGSensor.cpp:132
void ProcessSensorSignal(void)
Definition FGSensor.cpp:154
void Bias(void)
Definition FGSensor.cpp:203
void SetFailHigh(double val)
Definition FGSensor.h:134
void Drift(void)
Definition FGSensor.cpp:217