1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5 Date started: 09/12/2000
6 Purpose: This module models a Piston engine
8 ------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) --------------
10 This program is free software; you can redistribute it and/or modify it under
11 the terms of the GNU General Public License as published by the Free Software
12 Foundation; either version 2 of the License, or (at your option) any later
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
20 You should have received a copy of the GNU General Public License along with
21 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22 Place - Suite 330, Boston, MA 02111-1307, USA.
24 Further information about the GNU General Public License can also be found on
25 the world wide web at http://www.gnu.org.
27 FUNCTIONAL DESCRIPTION
28 --------------------------------------------------------------------------------
30 This class descends from the FGEngine class and models a Piston engine based on
31 parameters given in the engine config file for this class
34 --------------------------------------------------------------------------------
35 09/12/2000 JSB Created
37 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
43 static const char *IdSrc = "$Id$";
44 static const char *IdHdr = ID_PISTON;
46 extern short debug_lvl;
48 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
52 FGPiston::FGPiston(FGFDMExec* exec, FGConfigFile* Eng_cfg) : FGEngine(exec)
56 Name = Eng_cfg->GetValue("NAME");
57 cout << "\n Engine Name: " << Name << endl;
58 Eng_cfg->GetNextConfigLine();
59 while (Eng_cfg->GetValue() != "/FG_PISTON") {
61 if (token == "BRAKEHORSEPOWER") {
62 *Eng_cfg >> BrakeHorsePower;
63 cout << " BrakeHorsePower = " << BrakeHorsePower << endl;
64 } else if (token == "MAXTHROTTLE") {
65 *Eng_cfg >> MaxThrottle;
66 cout << " MaxThrottle = " << MaxThrottle << endl;
67 } else if (token == "MINTHROTTLE") {
68 *Eng_cfg >> MinThrottle;
69 cout << " MinThrottle = " << MinThrottle << endl;
70 } else if (token == "SLFUELFLOWMAX") {
71 *Eng_cfg >> SLFuelFlowMax;
72 cout << " SLFuelFlowMax = " << SLFuelFlowMax << endl;
73 } else if (token == "SPEEDSLOPE") {
74 *Eng_cfg >> SpeedSlope;
75 cout << " SpeedSlope = " << SpeedSlope << endl;
76 } else if (token == "SPEEDINTERCEPT") {
77 *Eng_cfg >> SpeedIntercept;
78 cout << " SpeedIntercept = " << SpeedIntercept << endl;
79 } else if (token == "ALTITUDESLOPE") {
80 *Eng_cfg >> AltitudeSlope;
81 cout << " AltitudeSlope = " << AltitudeSlope << endl;
83 cout << "Unhandled token in Engine config file: " << token << endl;
89 if (debug_lvl & 2) cout << "Instantiated: FGPiston" << endl;
92 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
96 if (debug_lvl & 2) cout << "Destroyed: FGPiston" << endl;
99 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
101 float FGPiston::Calculate(float PowerRequired)
103 float h,EngineMaxPower;
107 Throttle = FCS->GetThrottlePos(EngineNumber);
109 h = Position->Geth();
113 EngineMaxPower = (1 + AltitudeSlope*h)*BrakeHorsePower;
114 PowerAvailable = Throttle*EngineMaxPower*HPTOFTLBSSEC - PowerRequired;
116 return PowerAvailable;
119 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
121 void FGPiston::Debug(void)
123 //TODO: Add your source code here