]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGAircraft.cpp
Oct. 9, 2000 - synced with latest JSBsim code.
[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
171   cout << " ~FGAircraft" << endl;
172   if (Engine != NULL) {
173     for (i=0; i<numEngines; i++)
174       delete Engine[i];
175   }    
176   cout << "  Engine" << endl;
177
178   if (Tank != NULL) {
179     for (i=0; i<numTanks; i++)
180       delete Tank[i];
181   }    
182   cout << "  Tank" << endl;
183
184   cout << "  NumAxes: " << 6 << endl;
185   for (i=0; i<6; i++) {
186     cout << "  NumCoeffs: " << Coeff[i].size() << "  " << &Coeff[i] << endl;
187     for (j=0; j<Coeff[i].size(); j++) {
188       
189       cout << "  Coeff[" << i << "][" << j << "]: " << Coeff[i][j] << endl;
190       delete Coeff[i][j];
191     }
192   }
193
194   delete[] Coeff;
195   cout << "  Coeffs" << endl;
196
197   for (i=0; i<lGear.size(); i++) {
198       delete lGear[i];
199   }  
200 }
201
202 /******************************************************************************/
203
204 bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string fname) {
205   string path;
206   string filename;
207   string aircraftCfgFileName;
208   string token;
209
210   AircraftPath = aircraft_path;
211   EnginePath = engine_path;
212
213 # ifndef macintosh
214   aircraftCfgFileName = AircraftPath + "/" + fname + "/" + fname + ".xml";
215 # else  
216   aircraftCfgFileName = AircraftPath + ";" + fname + ";" + fname + ".xml";
217 # endif
218
219   FGConfigFile AC_cfg(aircraftCfgFileName);
220   if (!AC_cfg.IsOpen()) return false;
221
222   ReadPrologue(&AC_cfg);
223
224   while ((AC_cfg.GetNextConfigLine() != "EOF") &&
225          (token = AC_cfg.GetValue()) != "/FDM_CONFIG") {
226     if (token == "METRICS") {
227       cout << "  Reading Metrics" << endl;
228       ReadMetrics(&AC_cfg);
229     } else if (token == "AERODYNAMICS") {
230       cout << "  Reading Aerodynamics" << endl;
231       ReadAerodynamics(&AC_cfg);
232     } else if (token == "UNDERCARRIAGE") {
233       cout << "  Reading Landing Gear" << endl;
234       ReadUndercarriage(&AC_cfg);
235     } else if (token == "PROPULSION") {
236       cout << "  Reading Propulsion" << endl;
237       ReadPropulsion(&AC_cfg);
238     } else if (token == "FLIGHT_CONTROL") {
239       cout << "  Reading Flight Control" << endl;
240       ReadFlightControls(&AC_cfg);
241     } else if (token == "OUTPUT") {
242       ReadOutput(&AC_cfg);
243     }
244   }
245
246   return true;
247 }
248
249 /******************************************************************************/
250
251 bool FGAircraft::Run(void) {
252   if (!FGModel::Run()) {                 // if false then execute this Run()
253     GetState();
254
255     for (int i = 1; i <= 3; i++)  vForces(i) = vMoments(i) = 0.0;
256
257     MassChange();
258     FMProp();
259     FMAero();
260     FMGear();
261     FMMass();
262
263     nlf = 0;
264     if (fabs(Position->GetGamma()) < 1.57) {
265         nlf = vFs(eZ)/(Weight*cos(Position->GetGamma()));
266     }    
267         
268   } else {                               // skip Run() execution this time
269   }
270
271
272   return false;
273 }
274
275 /******************************************************************************/
276
277 void FGAircraft::MassChange() {
278   static FGColumnVector vXYZtank(3);
279   float Tw;
280   float IXXt, IYYt, IZZt, IXZt;
281   unsigned int t;
282   unsigned int axis_ctr;
283
284   for (axis_ctr=1; axis_ctr<=3; axis_ctr++) vXYZtank(axis_ctr) = 0.0;
285
286   // UPDATE TANK CONTENTS
287   //
288   // For each engine, cycle through the tanks and draw an equal amount of
289   // fuel (or oxidizer) from each active tank. The needed amount of fuel is
290   // determined by the engine in the FGEngine class. If more fuel is needed
291   // than is available in the tank, then that amount is considered a shortage,
292   // and will be drawn from the next tank. If the engine cannot be fed what it
293   // needs, it will be considered to be starved, and will shut down.
294
295   float Oshortage, Fshortage;
296
297   for (unsigned int e=0; e<numEngines; e++) {
298     Fshortage = Oshortage = 0.0;
299     for (t=0; t<numTanks; t++) {
300       switch(Engine[e]->GetType()) {
301       case FGEngine::etRocket:
302
303         switch(Tank[t]->GetType()) {
304         case FGTank::ttFUEL:
305           if (Tank[t]->GetSelected()) {
306             Fshortage = Tank[t]->Reduce((Engine[e]->CalcFuelNeed()/
307                                          numSelectedFuelTanks)*(dt*rate) + Fshortage);
308           }
309           break;
310         case FGTank::ttOXIDIZER:
311           if (Tank[t]->GetSelected()) {
312             Oshortage = Tank[t]->Reduce((Engine[e]->CalcOxidizerNeed()/
313                                          numSelectedOxiTanks)*(dt*rate) + Oshortage);
314           }
315           break;
316         }
317         break;
318
319       case FGEngine::etPiston:
320       case FGEngine::etTurboJet:
321       case FGEngine::etTurboProp:
322
323         if (Tank[t]->GetSelected()) {
324           Fshortage = Tank[t]->Reduce((Engine[e]->CalcFuelNeed()/
325                                        numSelectedFuelTanks)*(dt*rate) + Fshortage);
326         }
327         break;
328       }
329     }
330     if ((Fshortage <= 0.0) || (Oshortage <= 0.0)) Engine[e]->SetStarved();
331     else Engine[e]->SetStarved(false);
332   }
333
334   Weight = EmptyWeight;
335   for (t=0; t<numTanks; t++)
336     Weight += Tank[t]->GetContents();
337
338   Mass = Weight / GRAVITY;
339   // Calculate new CG here.
340
341   Tw = 0;
342   for (t=0; t<numTanks; t++) {
343     vXYZtank(eX) += Tank[t]->GetX()*Tank[t]->GetContents();
344     vXYZtank(eY) += Tank[t]->GetY()*Tank[t]->GetContents();
345     vXYZtank(eZ) += Tank[t]->GetZ()*Tank[t]->GetContents();
346
347     Tw += Tank[t]->GetContents();
348   }
349
350   vXYZcg = (vXYZtank + EmptyWeight*vbaseXYZcg) / (Tw + EmptyWeight);
351
352   // Calculate new moments of inertia here
353
354   IXXt = IYYt = IZZt = IXZt = 0.0;
355   for (t=0; t<numTanks; t++) {
356     IXXt += ((Tank[t]->GetX()-vXYZcg(eX))/12.0)*((Tank[t]->GetX() - vXYZcg(eX))/12.0)*Tank[t]->GetContents()/GRAVITY;
357     IYYt += ((Tank[t]->GetY()-vXYZcg(eY))/12.0)*((Tank[t]->GetY() - vXYZcg(eY))/12.0)*Tank[t]->GetContents()/GRAVITY;
358     IZZt += ((Tank[t]->GetZ()-vXYZcg(eZ))/12.0)*((Tank[t]->GetZ() - vXYZcg(eZ))/12.0)*Tank[t]->GetContents()/GRAVITY;
359     IXZt += ((Tank[t]->GetX()-vXYZcg(eX))/12.0)*((Tank[t]->GetZ() - vXYZcg(eZ))/12.0)*Tank[t]->GetContents()/GRAVITY;
360   }
361
362   Ixx = baseIxx + IXXt;
363   Iyy = baseIyy + IYYt;
364   Izz = baseIzz + IZZt;
365   Ixz = baseIxz + IXZt;
366
367 }
368
369 /******************************************************************************/
370
371 void FGAircraft::FMAero(void) {
372   static FGColumnVector vDXYZcg(3);
373   static FGColumnVector vAeroBodyForces(3);
374   unsigned int axis_ctr,ctr;
375
376   for (axis_ctr=1; axis_ctr<=3; axis_ctr++) vFs(axis_ctr) = 0.0;
377
378   for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
379     for (ctr=0; ctr < Coeff[axis_ctr].size(); ctr++) {
380       vFs(axis_ctr+1) += Coeff[axis_ctr][ctr]->TotalValue();
381     }
382   }
383
384   vAeroBodyForces = State->GetTs2b(alpha, beta)*vFs;
385   vForces += vAeroBodyForces;
386
387   // The d*cg distances below, given in inches, are the distances FROM the c.g.
388   // TO the reference point. Since the c.g. and ref point are given in inches in
389   // the structural system (X positive rearwards) and the body coordinate system
390   // is given with X positive out the nose, the dxcg and dzcg values are
391   // *rotated* 180 degrees about the Y axis.
392
393   vDXYZcg(eX) = -(vXYZrp(eX) - vXYZcg(eX))/12.0;  //cg and rp values are in inches
394   vDXYZcg(eY) =  (vXYZrp(eY) - vXYZcg(eY))/12.0;
395   vDXYZcg(eZ) = -(vXYZrp(eZ) - vXYZcg(eZ))/12.0;
396
397   vMoments(eL) += vAeroBodyForces(eZ)*vDXYZcg(eY) - vAeroBodyForces(eY)*vDXYZcg(eZ); // rolling moment
398   vMoments(eM) += vAeroBodyForces(eX)*vDXYZcg(eZ) - vAeroBodyForces(eZ)*vDXYZcg(eX); // pitching moment
399   vMoments(eN) += vAeroBodyForces(eY)*vDXYZcg(eX) - vAeroBodyForces(eX)*vDXYZcg(eY); // yawing moment
400   
401   for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
402     for (ctr = 0; ctr < Coeff[axis_ctr+3].size(); ctr++) {
403       vMoments(axis_ctr+1) += Coeff[axis_ctr+3][ctr]->TotalValue();
404     }
405   }
406 }
407
408 /******************************************************************************/
409
410 void FGAircraft::FMGear(void) {
411
412   if (GearUp) {
413     // crash routine
414   } else {
415
416 //  iGear = lGear.begin();
417 //  while (iGear != lGear.end()) {
418 //    vForces  += iGear->Force();
419 //    vMoments += iGear->Moment();
420 //    iGear++;
421 //  }
422
423     for (unsigned int i=0;i<lGear.size();i++) {
424       vForces  += lGear[i]->Force();
425       vMoments += lGear[i]->Moment();
426     }
427   }
428 }
429
430 /******************************************************************************/
431
432 void FGAircraft::FMMass(void) {
433   vForces(eX) += -GRAVITY*sin(vEuler(eTht)) * Mass;
434   vForces(eY) +=  GRAVITY*sin(vEuler(ePhi))*cos(vEuler(eTht)) * Mass;
435   vForces(eZ) +=  GRAVITY*cos(vEuler(ePhi))*cos(vEuler(eTht)) * Mass;
436 }
437
438 /******************************************************************************/
439
440 void FGAircraft::FMProp(void) {
441   for (unsigned int i=0;i<numEngines;i++) {
442
443     // Changes required here for new engine placement parameters (i.e. location and direction)
444
445     vForces(eX) += Engine[i]->CalcThrust();
446   }
447   
448 }
449
450 /******************************************************************************/
451
452 void FGAircraft::GetState(void) {
453   dt = State->Getdt();
454
455   alpha = Translation->Getalpha();
456   beta = Translation->Getbeta();
457   vEuler = Rotation->GetEuler();
458 }
459
460 /******************************************************************************/
461
462 void FGAircraft::ReadMetrics(FGConfigFile* AC_cfg) {
463   string token = "";
464   string parameter;
465
466   AC_cfg->GetNextConfigLine();
467
468   while ((token = AC_cfg->GetValue()) != "/METRICS") {
469     *AC_cfg >> parameter;
470     if (parameter == "AC_WINGAREA") {
471         *AC_cfg >> WingArea;
472         cout << "    WingArea: " << WingArea  << endl; 
473     } else if (parameter == "AC_WINGSPAN") {
474         *AC_cfg >> WingSpan;
475         cout << "    WingSpan: " << WingSpan  << endl;
476     } else if (parameter == "AC_CHORD") {
477         *AC_cfg >> cbar;
478         cout << "    Chord: " << cbar << endl;
479     } else if (parameter == "AC_IXX") {
480         *AC_cfg >> baseIxx;
481         cout << "    baseIxx: " << baseIxx << endl;
482     } else if (parameter == "AC_IYY") {
483         *AC_cfg >> baseIyy;
484         cout << "    baseIyy: " << baseIyy << endl;
485     } else if (parameter == "AC_IZZ") { 
486         *AC_cfg >> baseIzz;
487         cout << "    baseIzz: " << baseIzz << endl;
488     } else if (parameter == "AC_IXZ") { 
489         *AC_cfg >> baseIxz;
490         cout << "    baseIxz: " << baseIxz  << endl;
491     } else if (parameter == "AC_EMPTYWT") {
492         *AC_cfg >> EmptyWeight;
493         cout << "    EmptyWeight: " << EmptyWeight  << endl;
494     } else if (parameter == "AC_CGLOC") {
495         *AC_cfg >> vbaseXYZcg(eX) >> vbaseXYZcg(eY) >> vbaseXYZcg(eZ);
496         cout << "    CG (x, y, z): " << vbaseXYZcg << endl;
497     } else if (parameter == "AC_EYEPTLOC") {
498         *AC_cfg >> vXYZep(eX) >> vXYZep(eY) >> vXYZep(eZ);
499         cout << "    Eyepoint (x, y, z): " << vXYZep << endl;
500     } else if (parameter == "AC_AERORP") {
501         *AC_cfg >> vXYZrp(eX) >> vXYZrp(eY) >> vXYZrp(eZ);
502         cout << "    Ref Pt (x, y, z): " << vXYZrp << endl;
503     } else if (parameter == "AC_ALPHALIMITS") {
504         *AC_cfg >> alphaclmin >> alphaclmax;
505         cout << "    Maximum Alpha: " << alphaclmax
506              << "    Minimum Alpha: " << alphaclmin 
507              << endl;
508     }         
509   }
510 }
511
512 /******************************************************************************/
513
514 void FGAircraft::ReadPropulsion(FGConfigFile* AC_cfg) {
515   string token;
516   string engine_name;
517   string parameter;
518
519   AC_cfg->GetNextConfigLine();
520
521   while ((token = AC_cfg->GetValue()) != "/PROPULSION") {
522     *AC_cfg >> parameter;
523
524     if (parameter == "AC_ENGINE") {
525
526       *AC_cfg >> engine_name;
527       Engine[numEngines] = new FGEngine(FDMExec, EnginePath, engine_name, numEngines);
528       numEngines++;
529
530     } else if (parameter == "AC_TANK") {
531
532       Tank[numTanks] = new FGTank(AC_cfg);
533       switch(Tank[numTanks]->GetType()) {
534       case FGTank::ttFUEL:
535         numSelectedFuelTanks++;
536         break;
537       case FGTank::ttOXIDIZER:
538         numSelectedOxiTanks++;
539         break;
540       }
541       numTanks++;
542     }
543   }
544 }
545
546 /******************************************************************************/
547
548 void FGAircraft::ReadFlightControls(FGConfigFile* AC_cfg) {
549   string token;
550
551   FCS->LoadFCS(AC_cfg);
552 }
553
554 /******************************************************************************/
555
556 void FGAircraft::ReadAerodynamics(FGConfigFile* AC_cfg) {
557   string token, axis;
558
559   AC_cfg->GetNextConfigLine();
560   
561   while ((token = AC_cfg->GetValue()) != "/AERODYNAMICS") {
562     if (token == "AXIS") {
563       CoeffArray ca;
564       axis = AC_cfg->GetValue("NAME");
565       AC_cfg->GetNextConfigLine();
566       while ((token = AC_cfg->GetValue()) != "/AXIS") {
567         ca.push_back(new FGCoefficient(FDMExec, AC_cfg));
568         DisplayCoeffFactors(ca.back()->Getmultipliers());
569       }
570       Coeff[AxisIdx[axis]]=ca;
571       AC_cfg->GetNextConfigLine();
572     }
573   }
574 }
575
576 /******************************************************************************/
577
578 void FGAircraft::ReadUndercarriage(FGConfigFile* AC_cfg) {
579   string token;
580
581   AC_cfg->GetNextConfigLine();
582
583   while ((token = AC_cfg->GetValue()) != "/UNDERCARRIAGE") {
584     lGear.push_back(new FGLGear(AC_cfg, FDMExec));
585   }
586 }
587
588 /******************************************************************************/
589
590 void FGAircraft::ReadOutput(FGConfigFile* AC_cfg) {
591   string token, parameter;
592   int OutRate = 0;
593   int subsystems = 0;
594
595   token = AC_cfg->GetValue("NAME");
596   Output->SetFilename(token);
597   token = AC_cfg->GetValue("TYPE");
598   Output->SetType(token);
599   AC_cfg->GetNextConfigLine();
600
601   while ((token = AC_cfg->GetValue()) != "/OUTPUT") {
602     *AC_cfg >> parameter;
603     if (parameter == "RATE_IN_HZ") *AC_cfg >> OutRate;
604     if (parameter == "SIMULATION") {
605       *AC_cfg >> parameter;
606       if (parameter == "ON") subsystems += ssSimulation;
607     }
608     if (parameter == "AEROSURFACES") {
609       *AC_cfg >> parameter;
610       if (parameter == "ON") subsystems += ssAerosurfaces;
611     }
612     if (parameter == "RATES") {
613       *AC_cfg >> parameter;
614       if (parameter == "ON") subsystems += ssRates;
615     }
616     if (parameter == "VELOCITIES") {
617       *AC_cfg >> parameter;
618       if (parameter == "ON") subsystems += ssVelocities;
619     }
620     if (parameter == "FORCES") {
621       *AC_cfg >> parameter;
622       if (parameter == "ON") subsystems += ssForces;
623     }
624     if (parameter == "MOMENTS") {
625       *AC_cfg >> parameter;
626       if (parameter == "ON") subsystems += ssMoments;
627     }
628     if (parameter == "ATMOSPHERE") {
629       *AC_cfg >> parameter;
630       if (parameter == "ON") subsystems += ssAtmosphere;
631     }
632     if (parameter == "MASSPROPS") {
633       *AC_cfg >> parameter;
634       if (parameter == "ON") subsystems += ssMassProps;
635     }
636     if (parameter == "POSITION") {
637       *AC_cfg >> parameter;
638       if (parameter == "ON") subsystems += ssPosition;
639     }
640     if (parameter == "COEFFICIENTS") {
641       *AC_cfg >> parameter;
642       if (parameter == "ON") subsystems += ssCoefficients;
643     }
644     if (parameter == "GROUND_REACTIONS") {
645       *AC_cfg >> parameter;
646       if (parameter == "ON") subsystems += ssGroundReactions;
647     }
648   }
649
650   Output->SetSubsystems(subsystems);
651
652   OutRate = OutRate>120?120:(OutRate<0?0:OutRate);
653   Output->SetRate( (int)(0.5 + 1.0/(State->Getdt()*OutRate)) );
654 }
655
656 /******************************************************************************/
657
658 void FGAircraft::ReadPrologue(FGConfigFile* AC_cfg) {
659   string token = AC_cfg->GetValue();
660   string scratch;
661   AircraftName = AC_cfg->GetValue("NAME");
662   cout << "Reading Aircraft Configuration File: " << AircraftName << endl;
663   scratch=AC_cfg->GetValue("VERSION").c_str();
664
665   CFGVersion = AC_cfg->GetValue("VERSION");
666   cout << "                            Version: " << CFGVersion << endl;
667   if (CFGVersion != NEEDED_CFG_VERSION) {
668     cout << endl << "YOU HAVE AN INCOMPATIBLE CFG FILE FOR THIS AIRCRAFT."
669     " RESULTS WILL BE UNPREDICTABLE !!" << endl;
670     cout << "Current version needed is: " << NEEDED_CFG_VERSION << endl;
671     cout << "         You have version: " << CFGVersion << endl << endl;
672     //exit(-1);
673   }
674
675
676 }
677
678 /******************************************************************************/
679
680 void FGAircraft::DisplayCoeffFactors(vector <eParam> multipliers) {
681   cout << "   Non-Dimensionalized by: ";
682
683   for (unsigned int i=0; i<multipliers.size();i++)
684     cout << State->paramdef[multipliers[i]];
685
686   cout << endl;
687 }
688
689 /******************************************************************************/
690
691 string FGAircraft::GetCoefficientStrings(void) {
692   string CoeffStrings = "";
693   bool firstime = true;
694
695   for (unsigned int axis = 0; axis < 6; axis++) {
696     for (unsigned int sd = 0; sd < Coeff[axis].size(); sd++) {
697       if (firstime) {
698         firstime = false;
699       } else {
700         CoeffStrings += ", ";
701       }
702       CoeffStrings += Coeff[axis][sd]->Getname();
703     }
704   }
705
706   return CoeffStrings;
707 }
708
709 /******************************************************************************/
710
711 string FGAircraft::GetCoefficientValues(void) {
712   string SDValues = "";
713   char buffer[10];
714   bool firstime = true;
715
716   for (unsigned int axis = 0; axis < 6; axis++) {
717     for (unsigned int sd = 0; sd < Coeff[axis].size(); sd++) {
718       if (firstime) {
719         firstime = false;
720       } else {
721         SDValues += ", ";
722       }
723       sprintf(buffer, "%9.6f", Coeff[axis][sd]->GetSD());
724       SDValues += string(buffer);
725     }
726   }
727
728   return SDValues;
729   ;
730 }
731
732 /******************************************************************************/
733
734 string FGAircraft::GetGroundReactionStrings(void) {
735   string GroundReactionStrings = "";
736   bool firstime = true;
737
738   for (unsigned int i=0;i<lGear.size();i++) {
739     if (!firstime) GroundReactionStrings += ", ";
740     GroundReactionStrings += (lGear[i]->GetName() + "_WOW, ");
741     GroundReactionStrings += (lGear[i]->GetName() + "_compressLength, ");
742     GroundReactionStrings += (lGear[i]->GetName() + "_compressSpeed, ");
743     GroundReactionStrings += (lGear[i]->GetName() + "_Force");
744
745     firstime = false;
746   }
747
748   return GroundReactionStrings;
749 }
750
751 /******************************************************************************/
752
753 string FGAircraft::GetGroundReactionValues(void) {
754   char buff[20];
755   string GroundReactionValues = "";
756
757   bool firstime = true;
758
759   for (unsigned int i=0;i<lGear.size();i++) {
760     if (!firstime) GroundReactionValues += ", ";
761     GroundReactionValues += string( lGear[i]->GetWOW()?"1":"0" ) + ", ";
762     GroundReactionValues += (string(gcvt(lGear[i]->GetCompLen(),    5, buff)) + ", ");
763     GroundReactionValues += (string(gcvt(lGear[i]->GetCompVel(),    6, buff)) + ", ");
764     GroundReactionValues += (string(gcvt(lGear[i]->GetCompForce(), 10, buff)));
765
766     firstime = false;
767   }
768
769   return GroundReactionValues;
770 }
771