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