]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/propulsion/FGTransmission.h
Better fix for a compilation problem with MSVC 2012
[flightgear.git] / src / FDM / JSBSim / models / propulsion / FGTransmission.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  JSBSim
4  Author:       Jon S. Berndt
5  Date started: 08/24/00
6  ------------- Copyright (C) 2000  Jon S. Berndt (jon@jsbsim.org) -------------
7
8  Header:       FGTransmission.h
9  Author:       T.Kreitler
10  Date started: 02/05/12
11
12  ------------- Copyright (C) 2012  T. Kreitler (t.kreitler@web.de) -------------
13
14  This program is free software; you can redistribute it and/or modify it under
15  the terms of the GNU Lesser General Public License as published by the Free Software
16  Foundation; either version 2 of the License, or (at your option) any later
17  version.
18
19  This program is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
21  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
22  details.
23
24  You should have received a copy of the GNU Lesser General Public License along with
25  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
26  Place - Suite 330, Boston, MA  02111-1307, USA.
27
28  Further information about the GNU Lesser General Public License can also be found on
29  the world wide web at http://www.gnu.org.
30
31 HISTORY
32 --------------------------------------------------------------------------------
33 02/05/12  T.Kreitler  Created
34
35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 SENTRY
37 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
38
39 #ifndef FGTRANSMISSION_H
40 #define FGTRANSMISSION_H
41
42 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 INCLUDES
44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
45
46 #include "FGJSBBase.h"
47 #include "FGFDMExec.h"
48 #include "input_output/FGPropertyManager.h"
49
50 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51 DEFINITIONS
52 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
53
54 #define ID_TRANSMISSION "$Id: FGTransmission.h,v 1.1 2012/02/25 14:37:02 jentron Exp $"
55
56 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 FORWARD DECLARATIONS
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
59
60 namespace JSBSim {
61
62 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
63 CLASS DOCUMENTATION
64 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
65
66 /** Utility class that handles power transmission in conjunction with FGRotor.
67
68   This class provides brake, clutch and free-wheel-unit (FWU) functionality
69   for the rotor model. Also it is responsible for the RPM calculations.
70
71   When the engine is off the brake could be used to slow/hold down a spinning
72   rotor. The maximum brake power is defined in the rotors' config file.
73   (Right now there is no checking if the input is in the [0..1] range.)
74
75   The clutch operation is based on a heuristic approach. In the intermediate
76   state the transfer is proportional to the clutch position. But equal RPM
77   values are enforced on the thruster and rotor sides when approaching the
78   closed state.
79
80   The FWU inhibits that the rotor is driving the engine. To do so, the code
81   just predicts the upcoming FWU state based on current torque conditions.
82
83   Some engines won't work properly when the clutch is open. To keep them
84   controllable some load must be provided on the engine side (EngineFriction,
85   aka gear-loss). See the notes under 'Engine issues' in FGRotor.
86
87 <h3>Property tree</h3>
88
89   The following properties are created (with x = your thruster number):
90   <pre>
91     propulsion/engine[x]/brake-ctrl-norm
92     propulsion/engine[x]/free-wheel-transmission
93     propulsion/engine[x]/clutch-ctrl-norm
94   </pre>
95
96 <h3>Notes</h3>
97
98   <ul>
99     <li> EngineFriction is assumed constant, so better orientate at low RPM
100          values, because piston and turboprop engines don't 'like' high
101          load at startup.</li>
102     <li> The model doesn't support backward operation.</li>
103     <li> And even worse, the torque calculations silently assume a minimal
104          RPM value of approx. 1.</li>
105   </ul>
106
107 */
108
109
110 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
111 CLASS DECLARATION
112 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
113
114 class FGTransmission : public FGJSBBase {
115
116 public:
117   /** Constructor for FGTransmission.
118       @param exec a pointer to the main executive object
119       @param num the number of the thruster that uses this object
120       @param dt simulation delta T */
121   FGTransmission(FGFDMExec *exec, int num, double dt);
122
123   /// Destructor for FGTransmission
124   ~FGTransmission();
125
126   void Calculate(double EnginePower, double ThrusterTorque, double dt);
127
128   void   SetMaxBrakePower(double x) {MaxBrakePower=x;}
129   double GetMaxBrakePower() const {return MaxBrakePower;}
130   void   SetEngineFriction(double x) {EngineFriction=x;}
131   double GetEngineFriction() const {return EngineFriction;}
132   void   SetEngineMoment(double x) {EngineMoment=x;}
133   double GetEngineMoment() const {return EngineMoment;}
134   void   SetThrusterMoment(double x) {ThrusterMoment=x;}
135   double GetThrusterMoment() const {return ThrusterMoment;}
136
137   double GetFreeWheelTransmission() const {return FreeWheelTransmission;}
138   void   SetEngineRPM(double x) {EngineRPM=x;}
139   double GetEngineRPM() {return EngineRPM;}
140   void   SetThrusterRPM(double x) {ThrusterRPM=x;}
141   double GetThrusterRPM() {return ThrusterRPM;}
142
143   double GetBrakeCtrlNorm() const {return BrakeCtrlNorm;}
144   void   SetBrakeCtrlNorm(double x) {BrakeCtrlNorm=x;}
145   double GetClutchCtrlNorm() const {return ClutchCtrlNorm;}
146   void   SetClutchCtrlNorm(double x) {ClutchCtrlNorm=x;}
147
148 private:
149   bool BindModel(int num);
150   void Debug(int from);
151
152   inline double omega_to_rpm(double w) {
153     return w * 9.54929658551372014613302580235; // omega/(2.0*PI) * 60.0
154   }
155   inline double rpm_to_omega(double r) {
156     return r * 0.104719755119659774615421446109; // (rpm/60.0)*2.0*PI
157   }
158
159   Filter FreeWheelLag;
160   double FreeWheelTransmission; // state, 0: free, 1:locked
161
162   double ThrusterMoment;
163   double EngineMoment;   // estimated MOI of gear and engine, influences acceleration
164   double EngineFriction; // estimated friction in gear and possibly engine
165
166   double ClutchCtrlNorm;
167   double BrakeCtrlNorm;
168   double MaxBrakePower;
169
170   double EngineRPM;
171   double ThrusterRPM;
172   FGPropertyManager* PropertyManager;
173
174 };
175
176 }
177 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
178 #endif
179