]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGAircraft.cpp
Oct 2, 2000 JSBSim sync.
[flightgear.git] / src / FDM / JSBSim / FGAircraft.cpp
1 /*******************************************************************************
2  
3  Module:       FGAircraft.cpp
4  Author:       Jon S. Berndt
5  Date started: 12/12/98                                   
6  Purpose:      Encapsulates an aircraft
7  Called by:    FGFDMExec
8  
9  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
10  
11  This program is free software; you can redistribute it and/or modify it under
12  the terms of the GNU General Public License as published by the Free Software
13  Foundation; either version 2 of the License, or (at your option) any later
14  version.
15  
16  This program is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
19  details.
20  
21  You should have received a copy of the GNU General Public License along with
22  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
23  Place - Suite 330, Boston, MA  02111-1307, USA.
24  
25  Further information about the GNU General Public License can also be found on
26  the world wide web at http://www.gnu.org.
27  
28 FUNCTIONAL DESCRIPTION
29 --------------------------------------------------------------------------------
30 Models the aircraft reactions and forces. This class is instantiated by the
31 FGFDMExec class and scheduled as an FDM entry. LoadAircraft() is supplied with a
32 name of a valid, registered aircraft, and the data file is parsed.
33  
34 HISTORY
35 --------------------------------------------------------------------------------
36 12/12/98   JSB   Created
37 04/03/99   JSB   Changed Aero() method to correct body axis force calculation
38                  from wind vector. Fix provided by Tony Peden.
39 05/03/99   JSB   Changed (for the better?) the way configurations are read in.
40 9/17/99     TP   Combined force and moment functions. Added aero reference 
41                  point to config file. Added calculations for moments due to 
42                  difference in cg and aero reference point
43  
44 ********************************************************************************
45 COMMENTS, REFERENCES,  and NOTES
46 ********************************************************************************
47 [1] Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
48       Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420  Naval Postgraduate
49       School, January 1994
50 [2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
51       JSC 12960, July 1977
52 [3] Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
53       NASA-Ames", NASA CR-2497, January 1975
54 [4] Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
55       Wiley & Sons, 1979 ISBN 0-471-03032-5
56 [5] Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
57       1982 ISBN 0-471-08936-2
58  
59 The aerodynamic coefficients used in this model are:
60  
61 Longitudinal
62   CL0 - Reference lift at zero alpha
63   CD0 - Reference drag at zero alpha
64   CDM - Drag due to Mach
65   CLa - Lift curve slope (w.r.t. alpha)
66   CDa - Drag curve slope (w.r.t. alpha)
67   CLq - Lift due to pitch rate
68   CLM - Lift due to Mach
69   CLadt - Lift due to alpha rate
70  
71   Cmadt - Pitching Moment due to alpha rate
72   Cm0 - Reference Pitching moment at zero alpha
73   Cma - Pitching moment slope (w.r.t. alpha)
74   Cmq - Pitch damping (pitch moment due to pitch rate)
75   CmM - Pitch Moment due to Mach
76  
77 Lateral
78   Cyb - Side force due to sideslip
79   Cyr - Side force due to yaw rate
80  
81   Clb - Dihedral effect (roll moment due to sideslip)
82   Clp - Roll damping (roll moment due to roll rate)
83   Clr - Roll moment due to yaw rate
84   Cnb - Weathercocking stability (yaw moment due to sideslip)
85   Cnp - Rudder adverse yaw (yaw moment due to roll rate)
86   Cnr - Yaw damping (yaw moment due to yaw rate)
87  
88 Control
89   CLDe - Lift due to elevator
90   CDDe - Drag due to elevator
91   CyDr - Side force due to rudder
92   CyDa - Side force due to aileron
93  
94   CmDe - Pitch moment due to elevator
95   ClDa - Roll moment due to aileron
96   ClDr - Roll moment due to rudder
97   CnDr - Yaw moment due to rudder
98   CnDa - Yaw moment due to aileron
99  
100 ********************************************************************************
101 INCLUDES
102 *******************************************************************************/
103
104 #include <sys/stat.h>
105 #include <sys/types.h>
106
107 #ifdef FGFS
108 #  ifndef __BORLANDC__
109 #    include <simgear/compiler.h>
110 #  endif
111 #  ifdef FG_HAVE_STD_INCLUDES
112 #    include <cmath>
113 #  else
114 #    include <math.h>
115 #  endif
116 #else
117 #  include <cmath>
118 #endif
119
120 #include "FGAircraft.h"
121 #include "FGTranslation.h"
122 #include "FGRotation.h"
123 #include "FGAtmosphere.h"
124 #include "FGState.h"
125 #include "FGFDMExec.h"
126 #include "FGFCS.h"
127 #include "FGPosition.h"
128 #include "FGAuxiliary.h"
129 #include "FGOutput.h"
130
131 /*******************************************************************************
132 ************************************ CODE **************************************
133 *******************************************************************************/
134
135 FGAircraft::FGAircraft(FGFDMExec* fdmex) : FGModel(fdmex),
136     vMoments(3),
137     vForces(3),
138     vFs(3),
139     vXYZrp(3),
140     vbaseXYZcg(3),
141     vXYZcg(3),
142     vXYZep(3),
143     vEuler(3)
144     
145 {
146   Name = "FGAircraft";
147
148   AxisIdx["DRAG"]  = 0;
149   AxisIdx["SIDE"]  = 1;
150   AxisIdx["LIFT"]  = 2;
151   AxisIdx["ROLL"]  = 3;
152   AxisIdx["PITCH"] = 4;
153   AxisIdx["YAW"]   = 5;
154   
155   Coeff = new CoeffArray[6];
156
157   GearUp = false;
158   
159   alphaclmin = alphaclmax = 0;
160
161   numTanks = numEngines = numSelectedFuelTanks = numSelectedOxiTanks = 0;
162 }
163
164
165 /******************************************************************************/
166
167
168 FGAircraft::~FGAircraft(void) { 
169   unsigned int i,j;
170   cout << " ~FGAircraft" << endl;
171   if(Engine != NULL) {
172     for(i=0;i<numEngines; i++) 
173       delete Engine[i];
174   }    
175   cout << "  Engine" << endl;
176   if(Tank != NULL) {
177     for(i=0;i<numTanks; i++) 
178       delete Tank[i];
179   }    
180   cout << "  Tank" << endl;
181   cout << "  NumAxes: " << 6 << endl;
182   for(i=0;i<6;i++) {
183     cout << "  NumCoeffs: " << Coeff[i].size() << "  " << &Coeff[i] << endl;
184     for(j=0;j<Coeff[i].size();j++) {
185       
186       cout << "  Coeff[" << i << "][" << j << "]: " << Coeff[i][j] << endl;
187       delete Coeff[i][j];
188     }
189   } 
190   delete[] Coeff;
191   cout << "  Coeffs" << endl;
192   for(i=0;i<lGear.size();i++) {
193       delete lGear[i];
194   }  
195 }
196
197 /******************************************************************************/
198
199 bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string fname) {
200   string path;
201   string filename;
202   string aircraftCfgFileName;
203   string token;
204
205   AircraftPath = aircraft_path;
206   EnginePath = engine_path;
207
208 # ifndef macintosh
209   aircraftCfgFileName = AircraftPath + "/" + fname + "/" + fname + ".xml";
210 # else  
211   aircraftCfgFileName = AircraftPath + ";" + fname + ";" + fname + ".xml";
212 # endif
213
214   FGConfigFile AC_cfg(aircraftCfgFileName);
215   if (!AC_cfg.IsOpen()) return false;
216
217   ReadPrologue(&AC_cfg);
218
219   while ((AC_cfg.GetNextConfigLine() != "EOF") &&
220          (token = AC_cfg.GetValue()) != "/FDM_CONFIG") {
221     if (token == "METRICS") {
222       cout << "  Reading Metrics" << endl;
223       ReadMetrics(&AC_cfg);
224     } else if (token == "AERODYNAMICS") {
225       cout << "  Reading Aerodynamics" << endl;
226       ReadAerodynamics(&AC_cfg);
227     } else if (token == "UNDERCARRIAGE") {
228       cout << "  Reading Landing Gear" << endl;
229       ReadUndercarriage(&AC_cfg);
230     } else if (token == "PROPULSION") {
231       cout << "  Reading Propulsion" << endl;
232       ReadPropulsion(&AC_cfg);
233     } else if (token == "FLIGHT_CONTROL") {
234       cout << "  Reading Flight Control" << endl;
235       ReadFlightControls(&AC_cfg);
236     } else if (token == "OUTPUT") {
237       ReadOutput(&AC_cfg);
238     }
239   }
240
241   return true;
242 }
243
244 /******************************************************************************/
245
246 bool FGAircraft::Run(void) {
247   if (!FGModel::Run()) {                 // if false then execute this Run()
248     GetState();
249
250     for (int i = 1; i <= 3; i++)  vForces(i) = vMoments(i) = 0.0;
251
252     MassChange();
253     FMProp();
254     FMAero();
255     FMGear();
256     FMMass();
257
258     nlf = 0;
259     if (fabs(Position->GetGamma()) < 1.57) {
260         nlf = vFs(eZ)/(Weight*cos(Position->GetGamma()));
261     }    
262         
263   } else {                               // skip Run() execution this time
264   }
265
266
267   return false;
268 }
269
270 /******************************************************************************/
271
272 void FGAircraft::MassChange() {
273   static FGColumnVector vXYZtank(3);
274   float Tw;
275   float IXXt, IYYt, IZZt, IXZt;
276   unsigned int t;
277   unsigned int axis_ctr;
278
279   for (axis_ctr=1; axis_ctr<=3; axis_ctr++) vXYZtank(axis_ctr) = 0.0;
280
281   // UPDATE TANK CONTENTS
282   //
283   // For each engine, cycle through the tanks and draw an equal amount of
284   // fuel (or oxidizer) from each active tank. The needed amount of fuel is
285   // determined by the engine in the FGEngine class. If more fuel is needed
286   // than is available in the tank, then that amount is considered a shortage,
287   // and will be drawn from the next tank. If the engine cannot be fed what it
288   // needs, it will be considered to be starved, and will shut down.
289
290   float Oshortage, Fshortage;
291
292   for (unsigned int e=0; e<numEngines; e++) {
293     Fshortage = Oshortage = 0.0;
294     for (t=0; t<numTanks; t++) {
295       switch(Engine[e]->GetType()) {
296       case FGEngine::etRocket:
297
298         switch(Tank[t]->GetType()) {
299         case FGTank::ttFUEL:
300           if (Tank[t]->GetSelected()) {
301             Fshortage = Tank[t]->Reduce((Engine[e]->CalcFuelNeed()/
302                                          numSelectedFuelTanks)*(dt*rate) + Fshortage);
303           }
304           break;
305         case FGTank::ttOXIDIZER:
306           if (Tank[t]->GetSelected()) {
307             Oshortage = Tank[t]->Reduce((Engine[e]->CalcOxidizerNeed()/
308                                          numSelectedOxiTanks)*(dt*rate) + Oshortage);
309           }
310           break;
311         }
312         break;
313
314       case FGEngine::etPiston:
315       case FGEngine::etTurboJet:
316       case FGEngine::etTurboProp:
317
318         if (Tank[t]->GetSelected()) {
319           Fshortage = Tank[t]->Reduce((Engine[e]->CalcFuelNeed()/
320                                        numSelectedFuelTanks)*(dt*rate) + Fshortage);
321         }
322         break;
323       }
324     }
325     if ((Fshortage <= 0.0) || (Oshortage <= 0.0)) Engine[e]->SetStarved();
326     else Engine[e]->SetStarved(false);
327   }
328
329   Weight = EmptyWeight;
330   for (t=0; t<numTanks; t++)
331     Weight += Tank[t]->GetContents();
332
333   Mass = Weight / GRAVITY;
334   // Calculate new CG here.
335
336   Tw = 0;
337   for (t=0; t<numTanks; t++) {
338     vXYZtank(eX) += Tank[t]->GetX()*Tank[t]->GetContents();
339     vXYZtank(eY) += Tank[t]->GetY()*Tank[t]->GetContents();
340     vXYZtank(eZ) += Tank[t]->GetZ()*Tank[t]->GetContents();
341
342     Tw += Tank[t]->GetContents();
343   }
344
345   vXYZcg = (vXYZtank + EmptyWeight*vbaseXYZcg) / (Tw + EmptyWeight);
346
347   // Calculate new moments of inertia here
348
349   IXXt = IYYt = IZZt = IXZt = 0.0;
350   for (t=0; t<numTanks; t++) {
351     IXXt += ((Tank[t]->GetX()-vXYZcg(eX))/12.0)*((Tank[t]->GetX() - vXYZcg(eX))/12.0)*Tank[t]->GetContents()/GRAVITY;
352     IYYt += ((Tank[t]->GetY()-vXYZcg(eY))/12.0)*((Tank[t]->GetY() - vXYZcg(eY))/12.0)*Tank[t]->GetContents()/GRAVITY;
353     IZZt += ((Tank[t]->GetZ()-vXYZcg(eZ))/12.0)*((Tank[t]->GetZ() - vXYZcg(eZ))/12.0)*Tank[t]->GetContents()/GRAVITY;
354     IXZt += ((Tank[t]->GetX()-vXYZcg(eX))/12.0)*((Tank[t]->GetZ() - vXYZcg(eZ))/12.0)*Tank[t]->GetContents()/GRAVITY;
355   }
356
357   Ixx = baseIxx + IXXt;
358   Iyy = baseIyy + IYYt;
359   Izz = baseIzz + IZZt;
360   Ixz = baseIxz + IXZt;
361
362 }
363
364 /******************************************************************************/
365
366 void FGAircraft::FMAero(void) {
367   static FGColumnVector vDXYZcg(3);
368   static FGColumnVector vAeroBodyForces(3);
369   unsigned int axis_ctr,ctr;
370
371   for (axis_ctr=1; axis_ctr<=3; axis_ctr++) vFs(axis_ctr) = 0.0;
372
373   for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
374     for (ctr=0; ctr < Coeff[axis_ctr].size(); ctr++) {
375       vFs(axis_ctr+1) += Coeff[axis_ctr][ctr]->TotalValue();
376     }
377   }
378
379   vAeroBodyForces = State->GetTs2b(alpha, beta)*vFs;
380   vForces += vAeroBodyForces;
381
382   // The d*cg distances below, given in inches, are the distances FROM the c.g.
383   // TO the reference point. Since the c.g. and ref point are given in inches in
384   // the structural system (X positive rearwards) and the body coordinate system
385   // is given with X positive out the nose, the dxcg and dzcg values are
386   // *rotated* 180 degrees about the Y axis.
387
388   vDXYZcg(eX) = -(vXYZrp(eX) - vXYZcg(eX))/12.0;  //cg and rp values are in inches
389   vDXYZcg(eY) =  (vXYZrp(eY) - vXYZcg(eY))/12.0;
390   vDXYZcg(eZ) = -(vXYZrp(eZ) - vXYZcg(eZ))/12.0;
391
392   vMoments(eL) += vAeroBodyForces(eZ)*vDXYZcg(eY) - vAeroBodyForces(eY)*vDXYZcg(eZ); // rolling moment
393   vMoments(eM) += vAeroBodyForces(eX)*vDXYZcg(eZ) - vAeroBodyForces(eZ)*vDXYZcg(eX); // pitching moment
394   vMoments(eN) += vAeroBodyForces(eY)*vDXYZcg(eX) - vAeroBodyForces(eX)*vDXYZcg(eY); // yawing moment
395   
396   for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
397     for (ctr = 0; ctr < Coeff[axis_ctr+3].size(); ctr++) {
398       vMoments(axis_ctr+1) += Coeff[axis_ctr+3][ctr]->TotalValue();
399     }
400   }
401 }
402
403 /******************************************************************************/
404
405 void FGAircraft::FMGear(void) {
406
407   if (GearUp) {
408     // crash routine
409   } else {
410     for (unsigned int i=0;i<lGear.size();i++) {
411       vForces  += lGear[i]->Force();
412       vMoments += lGear[i]->Moment();
413     }
414   }
415 }
416
417 /******************************************************************************/
418
419 void FGAircraft::FMMass(void) {
420   vForces(eX) += -GRAVITY*sin(vEuler(eTht)) * Mass;
421   vForces(eY) +=  GRAVITY*sin(vEuler(ePhi))*cos(vEuler(eTht)) * Mass;
422   vForces(eZ) +=  GRAVITY*cos(vEuler(ePhi))*cos(vEuler(eTht)) * Mass;
423 }
424
425 /******************************************************************************/
426
427 void FGAircraft::FMProp(void) {
428   for (unsigned int i=0;i<numEngines;i++) {
429
430     // Changes required here for new engine placement parameters (i.e. location and direction)
431
432     vForces(eX) += Engine[i]->CalcThrust();
433   }
434   
435 }
436
437 /******************************************************************************/
438
439 void FGAircraft::GetState(void) {
440   dt = State->Getdt();
441
442   alpha = Translation->Getalpha();
443   beta = Translation->Getbeta();
444   vEuler = Rotation->GetEuler();
445 }
446
447 /******************************************************************************/
448
449 void FGAircraft::ReadMetrics(FGConfigFile* AC_cfg) {
450   string token = "";
451   string parameter;
452
453   AC_cfg->GetNextConfigLine();
454
455   while ((token = AC_cfg->GetValue()) != "/METRICS") {
456     *AC_cfg >> parameter;
457     if (parameter == "AC_WINGAREA") {
458         *AC_cfg >> WingArea;
459         cout << "    WingArea: " << WingArea  << endl; 
460     } else if (parameter == "AC_WINGSPAN") {
461         *AC_cfg >> WingSpan;
462         cout << "    WingSpan: " << WingSpan  << endl;
463     } else if (parameter == "AC_CHORD") {
464         *AC_cfg >> cbar;
465         cout << "    Chord: " << cbar << endl;
466     } else if (parameter == "AC_IXX") {
467         *AC_cfg >> baseIxx;
468         cout << "    baseIxx: " << baseIxx << endl;
469     } else if (parameter == "AC_IYY") {
470         *AC_cfg >> baseIyy;
471         cout << "    baseIyy: " << baseIyy << endl;
472     } else if (parameter == "AC_IZZ") { 
473         *AC_cfg >> baseIzz;
474         cout << "    baseIzz: " << baseIzz << endl;
475     } else if (parameter == "AC_IXZ") { 
476         *AC_cfg >> baseIxz;
477         cout << "    baseIxz: " << baseIxz  << endl;
478     } else if (parameter == "AC_EMPTYWT") {
479         *AC_cfg >> EmptyWeight;
480         cout << "    EmptyWeight: " << EmptyWeight  << endl;
481     } else if (parameter == "AC_CGLOC") {
482         *AC_cfg >> vbaseXYZcg(eX) >> vbaseXYZcg(eY) >> vbaseXYZcg(eZ);
483         cout << "    CG (x, y, z): " << vbaseXYZcg << endl;
484     } else if (parameter == "AC_EYEPTLOC") {
485         *AC_cfg >> vXYZep(eX) >> vXYZep(eY) >> vXYZep(eZ);
486         cout << "    Eyepoint (x, y, z): " << vXYZep << endl;
487     } else if (parameter == "AC_AERORP") {
488         *AC_cfg >> vXYZrp(eX) >> vXYZrp(eY) >> vXYZrp(eZ);
489         cout << "    Ref Pt (x, y, z): " << vXYZrp << endl;
490     } else if (parameter == "AC_ALPHALIMITS") {
491         *AC_cfg >> alphaclmin >> alphaclmax;
492         cout << "    Maximum Alpha: " << alphaclmax
493              << "    Minimum Alpha: " << alphaclmin 
494              << endl;
495     }         
496   }
497 }
498
499 /******************************************************************************/
500
501 void FGAircraft::ReadPropulsion(FGConfigFile* AC_cfg) {
502   string token;
503   string engine_name;
504   string parameter;
505
506   AC_cfg->GetNextConfigLine();
507
508   while ((token = AC_cfg->GetValue()) != "/PROPULSION") {
509     *AC_cfg >> parameter;
510
511     if (parameter == "AC_ENGINE") {
512
513       *AC_cfg >> engine_name;
514       Engine[numEngines] = new FGEngine(FDMExec, EnginePath, engine_name, numEngines);
515       numEngines++;
516
517     } else if (parameter == "AC_TANK") {
518
519       Tank[numTanks] = new FGTank(AC_cfg);
520       switch(Tank[numTanks]->GetType()) {
521       case FGTank::ttFUEL:
522         numSelectedFuelTanks++;
523         break;
524       case FGTank::ttOXIDIZER:
525         numSelectedOxiTanks++;
526         break;
527       }
528       numTanks++;
529     }
530   }
531 }
532
533 /******************************************************************************/
534
535 void FGAircraft::ReadFlightControls(FGConfigFile* AC_cfg) {
536   string token;
537
538   FCS->LoadFCS(AC_cfg);
539 }
540
541 /******************************************************************************/
542
543 void FGAircraft::ReadAerodynamics(FGConfigFile* AC_cfg) {
544   string token, axis;
545
546   AC_cfg->GetNextConfigLine();
547   
548   while ((token = AC_cfg->GetValue()) != "/AERODYNAMICS") {
549     if (token == "AXIS") {
550       CoeffArray ca;
551       axis = AC_cfg->GetValue("NAME");
552       AC_cfg->GetNextConfigLine();
553       while ((token = AC_cfg->GetValue()) != "/AXIS") {
554         ca.push_back(new FGCoefficient(FDMExec, AC_cfg));
555         DisplayCoeffFactors(ca.back()->Getmultipliers());
556       }
557       Coeff[AxisIdx[axis]]=ca;
558       AC_cfg->GetNextConfigLine();
559     }
560   }
561 }
562
563 /******************************************************************************/
564
565 void FGAircraft::ReadUndercarriage(FGConfigFile* AC_cfg) {
566   string token;
567
568   AC_cfg->GetNextConfigLine();
569
570   while ((token = AC_cfg->GetValue()) != "/UNDERCARRIAGE") {
571     lGear.push_back(new FGLGear(AC_cfg, FDMExec));
572   }
573 }
574
575 /******************************************************************************/
576
577 void FGAircraft::ReadOutput(FGConfigFile* AC_cfg) {
578   string token, parameter;
579   int OutRate = 0;
580   int subsystems = 0;
581
582   token = AC_cfg->GetValue("NAME");
583   Output->SetFilename(token);
584   token = AC_cfg->GetValue("TYPE");
585   Output->SetType(token);
586   AC_cfg->GetNextConfigLine();
587
588   while ((token = AC_cfg->GetValue()) != "/OUTPUT") {
589     *AC_cfg >> parameter;
590     if (parameter == "RATE_IN_HZ") *AC_cfg >> OutRate;
591     if (parameter == "SIMULATION") {
592       *AC_cfg >> parameter;
593       if (parameter == "ON") subsystems += ssSimulation;
594     }
595     if (parameter == "AEROSURFACES") {
596       *AC_cfg >> parameter;
597       if (parameter == "ON") subsystems += ssAerosurfaces;
598     }
599     if (parameter == "RATES") {
600       *AC_cfg >> parameter;
601       if (parameter == "ON") subsystems += ssRates;
602     }
603     if (parameter == "VELOCITIES") {
604       *AC_cfg >> parameter;
605       if (parameter == "ON") subsystems += ssVelocities;
606     }
607     if (parameter == "FORCES") {
608       *AC_cfg >> parameter;
609       if (parameter == "ON") subsystems += ssForces;
610     }
611     if (parameter == "MOMENTS") {
612       *AC_cfg >> parameter;
613       if (parameter == "ON") subsystems += ssMoments;
614     }
615     if (parameter == "ATMOSPHERE") {
616       *AC_cfg >> parameter;
617       if (parameter == "ON") subsystems += ssAtmosphere;
618     }
619     if (parameter == "MASSPROPS") {
620       *AC_cfg >> parameter;
621       if (parameter == "ON") subsystems += ssMassProps;
622     }
623     if (parameter == "POSITION") {
624       *AC_cfg >> parameter;
625       if (parameter == "ON") subsystems += ssPosition;
626     }
627     if (parameter == "COEFFICIENTS") {
628       *AC_cfg >> parameter;
629       if (parameter == "ON") subsystems += ssCoefficients;
630     }
631     if (parameter == "GROUND_REACTIONS") {
632       *AC_cfg >> parameter;
633       if (parameter == "ON") subsystems += ssGroundReactions;
634     }
635   }
636
637   Output->SetSubsystems(subsystems);
638
639   OutRate = OutRate>120?120:(OutRate<0?0:OutRate);
640   Output->SetRate( (int)(0.5 + 1.0/(State->Getdt()*OutRate)) );
641 }
642
643 /******************************************************************************/
644
645 void FGAircraft::ReadPrologue(FGConfigFile* AC_cfg) {
646   string token = AC_cfg->GetValue();
647   string scratch;
648   AircraftName = AC_cfg->GetValue("NAME");
649   cout << "Reading Aircraft Configuration File: " << AircraftName << endl;
650   scratch=AC_cfg->GetValue("VERSION").c_str();
651
652   CFGVersion = AC_cfg->GetValue("VERSION");
653   cout << "                            Version: " << CFGVersion << endl;
654   if (CFGVersion != NEEDED_CFG_VERSION) {
655     cout << endl << "YOU HAVE AN INCOMPATIBLE CFG FILE FOR THIS AIRCRAFT."
656     " RESULTS WILL BE UNPREDICTABLE !!" << endl;
657     cout << "Current version needed is: " << NEEDED_CFG_VERSION << endl;
658     cout << "         You have version: " << CFGVersion << endl << endl;
659     //exit(-1);
660   }
661
662
663 }
664
665 /******************************************************************************/
666
667 void FGAircraft::DisplayCoeffFactors(vector <eParam> multipliers) {
668   cout << "   Non-Dimensionalized by: ";
669
670   for (unsigned int i=0; i<multipliers.size();i++)
671     cout << State->paramdef[multipliers[i]];
672
673   cout << endl;
674 }
675
676 /******************************************************************************/
677
678 string FGAircraft::GetCoefficientStrings(void) {
679   string CoeffStrings = "";
680   bool firstime = true;
681
682   for (unsigned int axis = 0; axis < 6; axis++) {
683     for (unsigned int sd = 0; sd < Coeff[axis].size(); sd++) {
684       if (firstime) {
685         firstime = false;
686       } else {
687         CoeffStrings += ", ";
688       }
689       CoeffStrings += Coeff[axis][sd]->Getname();
690     }
691   }
692
693   return CoeffStrings;
694 }
695
696 /******************************************************************************/
697
698 string FGAircraft::GetCoefficientValues(void) {
699   string SDValues = "";
700   char buffer[10];
701   bool firstime = true;
702
703   for (unsigned int axis = 0; axis < 6; axis++) {
704     for (unsigned int sd = 0; sd < Coeff[axis].size(); sd++) {
705       if (firstime) {
706         firstime = false;
707       } else {
708         SDValues += ", ";
709       }
710       sprintf(buffer, "%9.6f", Coeff[axis][sd]->GetSD());
711       SDValues += string(buffer);
712     }
713   }
714
715   return SDValues;
716   ;
717 }
718
719 /******************************************************************************/
720
721 string FGAircraft::GetGroundReactionStrings(void) {
722   string GroundReactionStrings = "";
723   bool firstime = true;
724
725   for (unsigned int i=0;i<lGear.size();i++) {
726     if (!firstime) GroundReactionStrings += ", ";
727     GroundReactionStrings += (lGear[i]->GetName() + "_WOW, ");
728     GroundReactionStrings += (lGear[i]->GetName() + "_compressLength, ");
729     GroundReactionStrings += (lGear[i]->GetName() + "_compressSpeed, ");
730     GroundReactionStrings += (lGear[i]->GetName() + "_Force");
731
732     firstime = false;
733   }
734
735   return GroundReactionStrings;
736 }
737
738 /******************************************************************************/
739
740 string FGAircraft::GetGroundReactionValues(void) {
741   char buff[20];
742   string GroundReactionValues = "";
743
744   bool firstime = true;
745
746   for (unsigned int i=0;i<lGear.size();i++) {
747     if (!firstime) GroundReactionValues += ", ";
748     GroundReactionValues += string( lGear[i]->GetWOW()?"1":"0" ) + ", ";
749     GroundReactionValues += (string(gcvt(lGear[i]->GetCompLen(),    5, buff)) + ", ");
750     GroundReactionValues += (string(gcvt(lGear[i]->GetCompVel(),    6, buff)) + ", ");
751     GroundReactionValues += (string(gcvt(lGear[i]->GetCompForce(), 10, buff)));
752
753     firstime = false;
754   }
755
756   return GroundReactionValues;
757 }
758